Просмотр исходного кода

1.新增删除入库订单功能以
2.增加入库上下左右输入
3.解决出库产品删除不联动问题

huang_an 2 лет назад
Родитель
Сommit
e914768405

+ 3 - 2
src/api/warehouseManagement/outin.js

@@ -31,10 +31,11 @@ export default {
   },
   //删除
   delete: async (data) => {
-    const res = await request.delete('/wms/outin/delete', data);
+    const res = await request.delete('/wms/outin/delete', { data });
     if (res.data.code == 0) {
-      return res.data.data;
+      return res.data;
     }
+    return Promise.reject(new Error(res.data.message));
   },
   //出库实时库存
   getRealTimeInventory: async (params) => {

+ 9 - 2
src/views/warehouseManagement/components/AssetsDialog.vue

@@ -49,8 +49,7 @@
             <template>
               <el-select
                 style="width: 100%"
-                clearable
-                @change="changeDimension"
+                @change="changeDimensionHandler"
                 v-model="dimension"
                 placeholder="请选择"
               >
@@ -125,6 +124,8 @@
             :selectable="selectable"
           >
           </el-table-column>
+          <el-table-column label="序号" type="index" width="50">
+          </el-table-column>
           <el-table-column
             prop="assetCode"
             label="编码"
@@ -332,6 +333,12 @@
     },
     created() {},
     methods: {
+      changeDimensionHandler(e) {
+        // this.$refs.multipleTable.clearSelection();
+        // this.selectionList = [];
+        this.pages.pageNum = 1;
+        this.changeDimension(e);
+      },
       async changeDimension(e, is) {
         // await this.$refs.multipleTable.clearSelection();
         // this.selectionList = [];

+ 4 - 4
src/views/warehouseManagement/outgoingManagement/add.vue

@@ -1076,6 +1076,7 @@
       //出库明细删除
       listDel(row, index) {
         this.warehousingMaterialList.splice(index, 1);
+        console.log(this.warehousingMaterialList);
         if (this.warehousingMaterialList.length == 0) {
           this.formData.sourceBizNo = '';
           this.formData.extInfo.clientName = '';
@@ -1083,10 +1084,9 @@
           this.formData.extInfo.clientUserPhone = '';
         }
         // 从 this.batchDetailsVOList 中删除满足条件的对象
-        this.removeItemsFromArray(
-          this.batchDetailsVOList,
-          (item) => item.code.substr(0, 8) === row.code
-        );
+        this.removeItemsFromArray(this.batchDetailsVOList, (item) => {
+          return item.code.substr(0, 12) === row.code;
+        });
 
         // 从 this.materialCodeReqList 中删除满足条件的对象
         this.removeItemsFromArray(

+ 204 - 13
src/views/warehouseManagement/stockManagement/add.vue

@@ -441,13 +441,20 @@
                   <template v-else>{{ row[item.prop] }}</template>
                 </template>
               </el-table-column>
-              <el-table-column label="批号" width="100" prop="assetName">
+              <el-table-column label="批号" width="100" prop="manualBatchNo">
                 <template slot-scope="{ row, $index }">
                   <template v-if="row.isSave">
                     {{ row.manualBatchNo }}
                   </template>
                   <el-form-item v-else>
-                    <el-input v-model="row.manualBatchNo"> </el-input>
+                    <el-input
+                      :ref="'manualBatchNo' + $index"
+                      @keyup.native="
+                        moveFocus($event, $index, 'manualBatchNo', '产品', row)
+                      "
+                      v-model="row.manualBatchNo"
+                    >
+                    </el-input>
                   </el-form-item>
                 </template>
               </el-table-column>
@@ -489,6 +496,16 @@
                       required
                     >
                       <el-input
+                        :ref="'minPackingCount' + $index"
+                        @keyup.native="
+                          moveFocus(
+                            $event,
+                            $index,
+                            'minPackingCount',
+                            '产品',
+                            row
+                          )
+                        "
                         type="number"
                         v-model="row.minPackingCount"
                         @input="minPackingCountChange(row, $event)"
@@ -519,6 +536,10 @@
                     required
                   >
                     <el-input
+                      :ref="'outInNum' + $index"
+                      @keyup.native="
+                        moveFocus($event, $index, 'outInNum', '产品', row)
+                      "
                       v-model="row.outInNum"
                       @input="packNum(row, $event)"
                     >
@@ -657,6 +678,10 @@
                     :prop="`warehousingMaterialList.${$index}.univalence`"
                   >
                     <el-input
+                      :ref="'univalence' + $index"
+                      @keyup.native="
+                        moveFocus($event, $index, 'univalence', '产品', row)
+                      "
                       v-model="row.univalence"
                       placeholder="非必填"
                       @input="
@@ -878,33 +903,52 @@
               prop="measuringUnit"
             ></el-table-column>
             <el-table-column label="物料代号" prop="materielCode" width="130">
-              <template slot-scope="{ row }">
+              <template slot-scope="{ row, $index }">
                 <el-input
                   v-if="!row.isPack"
+                  :ref="'materielCode' + $index"
+                  @keyup.native="
+                    moveFocus($event, $index, 'materielCode', '包装', row)
+                  "
                   v-model="row.materielCode"
                 ></el-input>
                 <span v-else>{{ row.materielCode }}</span>
               </template>
             </el-table-column>
             <el-table-column label="客户代号" prop="clientCode">
-              <template slot-scope="{ row }">
+              <template slot-scope="{ row, $index }">
                 <el-input
                   v-if="!row.isPack"
+                  :ref="'clientCode' + $index"
+                  @keyup.native="
+                    moveFocus($event, $index, 'clientCode', '包装', row)
+                  "
                   v-model="row.clientCode"
                 ></el-input>
                 <span v-else> {{ row.clientCode }}</span>
               </template>
             </el-table-column>
             <el-table-column label="刻码" prop="engrave">
-              <template slot-scope="{ row }">
-                <el-input v-if="!row.isPack" v-model="row.engrave"></el-input>
+              <template slot-scope="{ row, $index }">
+                <el-input
+                  v-if="!row.isPack"
+                  :ref="'engrave' + $index"
+                  @keyup.native="
+                    moveFocus($event, $index, 'engrave', '包装', row)
+                  "
+                  v-model="row.engrave"
+                ></el-input>
                 <span v-else>{{ row.engrave }}</span>
               </template>
             </el-table-column>
             <el-table-column label="重量" prop="weight" width="100">
-              <template slot-scope="{ row }">
+              <template slot-scope="{ row, $index }">
                 <el-input
                   v-if="!row.isPack && row.measuringUnit != row.weightUtil"
+                  :ref="'weight' + $index"
+                  @keyup.native="
+                    moveFocus($event, $index, 'weight', '包装', row)
+                  "
                   v-model="row.weight"
                   @input="weightInput($event, row)"
                 ></el-input>
@@ -1065,33 +1109,52 @@
               prop="measuringUnit"
             ></el-table-column>
             <el-table-column label="物料代号" prop="materielCode" width="130">
-              <template slot-scope="{ row }">
+              <template slot-scope="{ row, $index }">
                 <el-input
                   v-if="!row.isPack"
+                  :ref="'materielCode' + $index"
+                  @keyup.native="
+                    moveFocus($event, $index, 'materielCode', '物料', row)
+                  "
                   v-model="row.materielCode"
                 ></el-input>
                 <span v-else>{{ row.materielCode }}</span>
               </template>
             </el-table-column>
             <el-table-column label="客户代号" prop="clientCode">
-              <template slot-scope="{ row }">
+              <template slot-scope="{ row, $index }">
                 <el-input
                   v-if="!row.isPack"
+                  :ref="'clientCode' + $index"
+                  @keyup.native="
+                    moveFocus($event, $index, 'clientCode', '物料', row)
+                  "
                   v-model="row.clientCode"
                 ></el-input>
                 <span v-else>{{ row.clientCode }}</span>
               </template>
             </el-table-column>
             <el-table-column label="刻码" prop="engrave">
-              <template slot-scope="{ row }">
-                <el-input v-if="!row.isPack" v-model="row.engrave"></el-input>
+              <template slot-scope="{ row, $index }">
+                <el-input
+                  v-if="!row.isPack"
+                  :ref="'engrave' + $index"
+                  @keyup.native="
+                    moveFocus($event, $index, 'engrave', '物料', row)
+                  "
+                  v-model="row.engrave"
+                ></el-input>
                 <span v-else>{{ row.engrave }}</span>
               </template>
             </el-table-column>
             <el-table-column label="重量" prop="weight" width="100">
-              <template slot-scope="{ row }">
+              <template slot-scope="{ row, $index }">
                 <el-input
                   v-if="!row.isPack && row.measuringUnit != row.weightUnit"
+                  :ref="'weight' + $index"
+                  @keyup.native="
+                    moveFocus($event, $index, 'weight', '物料', row)
+                  "
                   v-model="row.weight"
                 ></el-input>
                 <span v-else>{{ row.weight }}</span>
@@ -1323,10 +1386,138 @@
       this.initData();
     },
     methods: {
+      // 键盘移动
+      moveFocus(event, index, key, type, row) {
+        let keyfield = [];
+        let listLength = 0;
+        switch (type) {
+          case '产品':
+            listLength = this.warehousingMaterialList.length;
+            keyfield = [
+              'manualBatchNo',
+              'minPackingCount',
+              'outInNum',
+              'univalence'
+            ];
+            break;
+          case '包装':
+            listLength = this.materialCodeReqList.length;
+            if (row.measuringUnit != row.weightUtil) {
+              keyfield = ['materielCode', 'clientCode', 'engrave', 'weight'];
+            } else {
+              keyfield = ['materielCode', 'clientCode', 'engrave'];
+            }
+            break;
+          case '物料':
+            listLength = this.resultArray.length;
+            if (row.measuringUnit != row.weightUnit) {
+              keyfield = ['materielCode', 'clientCode', 'engrave', 'weight'];
+            } else {
+              keyfield = ['materielCode', 'clientCode', 'engrave'];
+            }
+            break;
+        }
+
+        if (event.keyCode === 13) {
+          // 回车
+          if (
+            index === listLength - 1 &&
+            key === keyfield[keyfield.length - 1]
+          ) {
+            // 最后一行最后一个
+            return;
+          }
+
+          this.$refs[key + index].blur();
+          if (key === keyfield[keyfield.length - 1]) {
+            // 当前行最后一个,跳转下一行第一个
+            this.$refs[keyfield[0] + (index + 1)].focus();
+          } else {
+            // 跳转下一个
+            const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
+            this.$nextTick(() => {
+              this.$refs[keyfield[nextkeyindex] + index].focus();
+            });
+          }
+        }
+
+        // 向上 =38
+        if (event.keyCode === 38) {
+          console.log('向上');
+          if (index === 0) {
+            // 第一行
+            console.log('第一行无法向上');
+            return;
+          }
+          this.$refs[key + index].blur();
+          this.$nextTick(() => {
+            this.$refs[key + (index - 1)].focus();
+          });
+        }
+
+        // 下 = 40
+        if (event.keyCode === 40) {
+          console.log('向下');
+          if (index === listLength - 1) {
+            // 最后一行
+            console.log('最后一行无法向下');
+            return;
+          }
+          this.$refs[key + index].blur();
+          this.$nextTick(() => {
+            this.$refs[key + (index + 1)].focus();
+          });
+        }
+
+        // 左 = 37
+        if (event.keyCode === 37) {
+          console.log('向左');
+          if (index === 0 && key === keyfield[0]) {
+            // 第一行第一个
+            console.log('第一行第一个无法向左');
+            return;
+          }
+          this.$refs[key + index].blur();
+          if (key === keyfield[0]) {
+            // 当前行第一个,跳转上一行最后一个
+            this.$refs[keyfield[keyfield.length - 1] + (index - 1)].focus();
+          } else {
+            // 跳转上一个
+            const prevkeyindex = keyfield.findIndex((k) => k === key) - 1;
+            this.$nextTick(() => {
+              this.$refs[keyfield[prevkeyindex] + index].focus();
+            });
+          }
+        }
+
+        // 右 = 39
+        if (event.keyCode === 39) {
+          console.log('向右');
+          if (
+            index === listLength - 1 &&
+            key === keyfield[keyfield.length - 1]
+          ) {
+            // 最后一行最后一个
+            console.log('最后一行最后一个无法向左');
+            return;
+          }
+          this.$refs[key + index].blur();
+          if (key === keyfield[keyfield.length - 1]) {
+            // 当前行最后一个,跳转下一行第一个
+            this.$refs[keyfield[0] + (index + 1)].focus();
+          } else {
+            // 跳转下一个
+            const nextkeyindex = keyfield.findIndex((k) => k === key) + 1;
+            this.$nextTick(() => {
+              this.$refs[keyfield[nextkeyindex] + index].focus();
+            });
+          }
+        }
+      },
       // 包装维度最小包装单元改变——>总重量
       minPackingCountChange(row, value) {
         if (value >= 0) {
-          row.minPackingCount = value;
+          row.minPackingCount = value.replace(/^[0]+/, '');
         } else {
           row.minPackingCount = 0;
         }

+ 7 - 3
src/views/warehouseManagement/stockManagement/index.vue

@@ -128,7 +128,7 @@
           >
             提交
           </el-link>
-          <el-link
+          <!-- <el-link
             type="warning"
             :underline="false"
             icon="el-icon-edit"
@@ -136,7 +136,7 @@
             @click="edit(row)"
           >
             修改
-          </el-link>
+          </el-link> -->
           <el-link
             type="primary"
             :underline="false"
@@ -345,7 +345,11 @@
           type: 'warning'
         })
           .then(async () => {
-            console.log('删除了');
+            const data = await outin.delete([row.id]);
+            if (data.code == '0') {
+              this.$message.success('删除成功!');
+              this.getList();
+            }
           })
           .catch(() => {});
       },