Browse Source

仓库调拨

unknown 4 days ago
parent
commit
2a1edab3cc

+ 59 - 55
src/views/wms/inLibrary/components/AdjustmentDailog.vue

@@ -6,13 +6,8 @@
     width="1200px"
     append-to-body
   >
-
     <!-- 列表 -->
-    <el-table
-      v-loading="loading"
-      :data="currentRows"
-      border
-    >
+    <el-table v-loading="loading" :data="currentRows" border>
       <el-table-column
         label="物料批次"
         align="center"
@@ -83,7 +78,11 @@
             :ref="`area-${scope.$index}`"
             v-model="scope.row.wmsStoreAreaIdNew"
             filterable
-            @change="($event) => { areaChange($event, scope.$index) }"
+            @change="
+              ($event) => {
+                areaChange($event, scope.$index);
+              }
+            "
           />
         </template>
       </el-table-column>
@@ -94,38 +93,39 @@
         width="120"
       >
         <template slot-scope="scope">
-          <LocationSelect :ref="`location-${scope.$index}`" v-model="scope.row.storeIdNew" filterable />
+          <LocationSelect
+            :ref="`location-${scope.$index}`"
+            v-model="scope.row.storeIdNew"
+            filterable
+          />
         </template>
       </el-table-column>
       <el-table-column label="操作人" align="center" prop="creator" />
     </el-table>
     <div slot="footer" class="dialog-footer">
-      <el-button
-        type="primary"
-        @click="handleAdjustLocation"
-      > 完成</el-button>
+      <el-button type="primary" @click="handleAdjustLocation"> 完成</el-button>
     </div>
   </el-dialog>
 </template>
 
 <script>
-import { LocationAdjustment } from '@/api/wms/inLibrary/locationAdjustment'
-import StockSelect from '../../incoming/wareHousing/components/StockSelect.vue'
-import AreaSelect from '../../incoming/wareHousing/components/AreaSelect.vue'
-import LocationSelect from '../../incoming/wareHousing/components/LocationSelect.vue'
+import { LocationAdjustment } from "@/api/wms/inLibrary/locationAdjustment";
+import StockSelect from "../../incoming/wareHousing/components/StockSelect.vue";
+import AreaSelect from "../../incoming/wareHousing/components/AreaSelect.vue";
+import LocationSelect from "../../incoming/wareHousing/components/LocationSelect.vue";
 
 export default {
-  name: 'LocationAdjustment',
+  name: "LocationAdjustment",
   components: {
     StockSelect,
     AreaSelect,
-    LocationSelect
+    LocationSelect,
   },
   props: {
     currentRows: {
       type: Array,
-      default: () => []
-    }
+      default: () => [],
+    },
   },
   data() {
     return {
@@ -134,7 +134,7 @@ export default {
       // WMS库内业务-货位调整列表
       list: [],
       // 弹出层标题
-      title: '',
+      title: "",
       // 是否显示弹出层
       open: false,
       // 查询参数
@@ -150,15 +150,17 @@ export default {
         erpStockIdNew: null,
         storeIdNew: null,
         remark: null,
-        createTime: []
+        createTime: [],
       },
       // 表单参数
       form: {},
       // 表单校验
       rules: {
-        materialLots: [{ required: true, message: '物料批次不能为空', trigger: 'blur' }]
-      }
-    }
+        materialLots: [
+          { required: true, message: "物料批次不能为空", trigger: "blur" },
+        ],
+      },
+    };
   },
   watch: {
     open: {
@@ -166,20 +168,20 @@ export default {
         if (val) {
           this.$nextTick(() => {
             for (let x = 0; x < this.currentRows.length; x++) {
-              const { erpStockId } = this.currentRows[x]
-              this.currentRows[x].erpStockIdNew = erpStockId
-              this.stockChange({ id: erpStockId }, x)
+              const { erpStockId } = this.currentRows[x];
+              this.currentRows[x].erpStockIdNew = erpStockId;
+              this.stockChange({ id: erpStockId }, x);
             }
-          })
+          });
         }
-      }
-    }
+      },
+    },
   },
   methods: {
     /** 取消按钮 */
     cancel() {
-      this.open = false
-      this.reset()
+      this.open = false;
+      this.reset();
     },
     /** 表单重置 */
     reset() {
@@ -193,39 +195,41 @@ export default {
         storeId: undefined,
         erpStockIdNew: undefined,
         storeIdNew: undefined,
-        remark: undefined
-      }
-      this.resetForm('form')
+        remark: undefined,
+      };
+      this.resetForm("form");
     },
     stockChange(item, index) {
       if (item) {
-        const { id } = item
-        this.$refs[`area-${index}`].options = []
-        this.$refs[`area-${index}`].fetchAreaList(id)
+        const { id } = item;
+        this.$refs[`area-${index}`].options = [];
+        this.$refs[`area-${index}`].fetchAreaList(id);
       }
     },
     areaChange(item, index) {
       if (item) {
-        const { id } = item
-        this.$refs[`location-${index}`].options = []
-        this.$refs[`location-${index}`].fetchLocationList(id)
+        const { id } = item;
+        this.$refs[`location-${index}`].options = [];
+        this.$refs[`location-${index}`].fetchLocationList(id);
       }
     },
     // 调整货位
     handleAdjustLocation() {
-      console.log('this.currentRows', this.currentRows)
-      const isEmpty = this.currentRows.every(item => (item.erpStockIdNew && item.wmsStoreAreaIdNew && item.storeIdNew))
+      console.log("this.currentRows", this.currentRows);
+      const isEmpty = this.currentRows.every(
+        (item) =>
+          item.erpStockIdNew && item.wmsStoreAreaIdNew && item.storeIdNew
+      );
       if (!isEmpty) {
-        this.$modal.msgWarning('仓库/区域/货位不能为空')
-        return
+        this.$modal.msgWarning("仓库/区域/货位不能为空");
+        return;
       }
-      LocationAdjustment(this.currentRows).then(res => {
-        this.$modal.msgSuccess('调整货位成功')
-        this.open = false
-        this.$emit('complete')
-      })
-    }
-  }
-}
+      LocationAdjustment(this.currentRows).then((res) => {
+        this.$modal.msgSuccess("调整货位成功");
+        this.open = false;
+        this.$emit("complete");
+      });
+    },
+  },
+};
 </script>
-

+ 128 - 22
src/views/wms/inLibrary/components/StockDailog.vue

@@ -6,6 +6,74 @@
     width="1200px"
     append-to-body
   >
+    <el-form
+      ref="ruleForm"
+      :model="formData"
+      :rules="formRules"
+      label-width="150px"
+      class="form-container"
+    >
+      <el-row :gutter="20">
+        <el-col :span="12"
+          ><el-form-item label="调拨类型" prop="transferType">
+            <el-select
+              v-model="formData.transferType"
+              placeholder="请选择调拨类型"
+            >
+              <el-option
+                v-for="dict in getDictDatas('erp_move_out_type')"
+                :key="dict.value"
+                :label="dict.label"
+                :value="dict.value"
+              />
+            </el-select> </el-form-item
+        ></el-col>
+
+        <el-col :span="12">
+          <el-form-item label="调入仓库" prop="stockIdNew">
+            <StockSelect
+              :ref="`stock`"
+              v-model="formData.stockIdNew"
+              filterable
+              @change="
+                ($event) => {
+                  stockChange($event);
+                }
+              "
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="调入区域" prop="areaIdNew">
+            <AreaSelect
+              :ref="`area`"
+              v-model="formData.areaIdNew"
+              filterable
+              @change="
+                ($event) => {
+                  areaChange($event);
+                }
+              "
+            />
+          </el-form-item>
+        </el-col>
+        <el-col :span="12">
+          <el-form-item label="调入货位" prop="locationIdNew">
+            <LocationSelect
+              :ref="`location`"
+              v-model="formData.locationIdNew"
+              filterable
+              @change="
+                ($event) => {
+                  locationChange($event);
+                }
+              "
+            />
+          </el-form-item>
+        </el-col>
+      </el-row>
+    </el-form>
+
     <!-- 列表 -->
     <el-table v-loading="loading" :data="currentRows" border>
       <el-table-column
@@ -51,8 +119,8 @@
         width="120"
         show-overflow-tooltip
       />
-      <el-table-column
-        label="调整后仓库"
+      <!-- <el-table-column
+        label="调仓库"
         align="center"
         prop="stockIdNew"
         width="160"
@@ -71,7 +139,7 @@
         </template>
       </el-table-column>
       <el-table-column
-        label="调整后区域"
+        label="调区域"
         align="center"
         prop="areaIdNew"
         width="120"
@@ -90,7 +158,7 @@
         </template>
       </el-table-column>
       <el-table-column
-        label="调整后货位"
+        label="调货位"
         align="center"
         prop="locationIdNew"
         width="120"
@@ -107,7 +175,7 @@
             "
           />
         </template>
-      </el-table-column>
+      </el-table-column> -->
       <el-table-column label="操作人" align="center" prop="creator" />
     </el-table>
     <div slot="footer" class="dialog-footer">
@@ -143,6 +211,39 @@ export default {
   },
   data() {
     return {
+      formData: {
+        transferType: undefined,
+        stockIdNew: undefined,
+        areaIdNew: undefined,
+        locationIdNew: undefined,
+      },
+      // 表单校验
+      formRules: {
+        transferType: [
+          { required: true, message: "请选择调拨类型", trigger: "blur" },
+        ],
+        stockIdNew: [
+          {
+            required: true,
+            message: "请选择调入仓库",
+            trigger: "blur",
+          },
+        ],
+        areaIdNew: [
+          {
+            required: true,
+            message: "请选择调入区域",
+            trigger: "blur",
+          },
+        ],
+        locationIdNew: [
+          {
+            required: true,
+            message: "请选择调入货位",
+            trigger: "blur",
+          },
+        ],
+      },
       // 遮罩层
       loading: false,
       // WMS库内业务-货位调整列表
@@ -183,8 +284,8 @@ export default {
           this.$nextTick(async () => {
             for (let x = 0; x < this.currentRows.length; x++) {
               const { stockCode, stockIdOld } = this.currentRows[x];
-              await this.$refs[`stock-${x}`].fetchStockList();
-              this.stockChange({ id: Number(stockIdOld), code: stockCode }, x);
+              await this.$refs[`stock`].fetchStockList();
+              // this.stockChange({ id: Number(stockIdOld), code: stockCode }, x);
             }
           });
         }
@@ -216,34 +317,39 @@ export default {
     stockChange(item, index) {
       if (item) {
         const { id, code } = item;
-        this.$refs[`stock-${index}`].value = Number(id);
-        this.currentRows[index].stockCodeNew = code;
-        this.currentRows[index].stockIdNew = id;
+        this.$refs[`stock`].value = Number(id);
+        this.formData.stockCodeNew = code;
+        this.formData.stockIdNew = id;
 
-        this.$refs[`area-${index}`].value = "";
-        this.$refs[`area-${index}`].options = [];
-        this.$refs[`area-${index}`].fetchAreaList(id);
-        this.$refs[`location-${index}`].options = [];
-        this.$refs[`location-${index}`].value = "";
+        this.$refs[`area`].value = "";
+        this.$refs[`area`].options = [];
+        this.$refs[`area`].fetchAreaList(id);
+        this.$refs[`location`].options = [];
+        this.$refs[`location`].value = "";
       }
     },
     areaChange(item, index) {
       if (item) {
         const { id, code } = item;
-        this.currentRows[index].areaCodeNew = code;
-        this.$refs[`location-${index}`].options = [];
-        this.$refs[`location-${index}`].fetchLocationList(id);
+        this.formData.areaCodeNew = code;
+        this.$refs[`location`].options = [];
+        this.$refs[`location`].fetchLocationList(id);
       }
     },
     locationChange(item, index) {
       if (item) {
         const { code } = item;
-        this.currentRows[index].locationCodeNew = code;
+        this.formData.locationCodeNew = code;
       }
     },
     // 调整货位
-    handleAdjustLocation() {
-      const isEmpty = this.currentRows.every(
+    async handleAdjustLocation() {
+      // 校验主表
+      await this.$refs["ruleForm"].validate();
+      let data = this.currentRows.map((v) => {
+        return { ...v, ...this.formData };
+      });
+      const isEmpty = data.every(
         (item) => item.stockIdNew && item.areaIdNew && item.locationIdNew
       );
       if (!isEmpty) {
@@ -252,7 +358,7 @@ export default {
       }
 
       this.loading = true;
-      stockTransfer(this.currentRows)
+      stockTransfer(data)
         .then((res) => {
           this.$modal.msgSuccess("调拨成功");
           this.open = false;