quwangxin 2 лет назад
Родитель
Сommit
4de7a190a2

+ 0 - 1
src/components/Dict/DictSelection.vue

@@ -1,7 +1,6 @@
 <template>
   <el-select
     v-model="selectVal"
-    size="small"
     style="width: 100%"
     v-bind="$attrs"
     v-on="$listeners"

+ 23 - 4
src/views/saleOrder/components/EquipmentDialog.vue

@@ -43,8 +43,10 @@
             :columns="columns"
             :datasource="datasource"
             :selection.sync="selection"
+            @select="handleSelect"
             cache-key="systemRoleTable"
             row-key="id"
+            height="50vh"
             @done="setSelect"
           >
           </ele-pro-table>
@@ -132,7 +134,7 @@
           pageNum: page,
           size: limit,
           categoryLevelId: this.categoryLevelId,
-		  isProduct:true
+          isProduct: true
         };
         const data = await getList(params);
         this.tableList = data.list;
@@ -161,7 +163,7 @@
       setSelect () {
         this.$nextTick(() => {
           this.tableList.forEach((row) => {
-            this.selectList.forEach((selected) => {
+            this.selectList.forEach((selected, index) => {
               if (selected.productCode === row.code) {
                 this.$refs.equiTable.toggleRowSelection(row, true);
               }
@@ -169,9 +171,26 @@
           });
         });
       },
+      // 取消选中
+      handleSelect (selection, row) {
+        if (!selection.find((i) => i.id === row.id)) {
+          const index = this.selectList.findIndex(
+            (itm) => row.code == itm.productCode
+          );
+          console.log(index);
+          if (index > -1) {
+            this.selectList.splice(index, 1);
+          }
+        }
+      },
       // 选择
       selected () {
-        this.$emit('choose', this.selection);
+        this.$emit('choose', [
+          ...this.selection,
+          ...this.selectList.filter(
+            (i) => !this.selection.find((p) => p.code === i.productCode)
+          )
+        ]);
         this.handleClose();
       }
     }
@@ -183,7 +202,7 @@
     border: 1px solid #eee;
     padding: 10px 0;
     box-sizing: border-box;
-    height: 530px;
+    max-height: 530px;
     overflow: auto;
   }
   .table_col {

+ 52 - 15
src/views/saleOrder/components/create-order.vue

@@ -83,7 +83,7 @@
           </el-form-item>
         </el-col>
       </el-row>
-      <el-table :data="form.productInfoList" border>
+      <el-table :data="form.productInfoList" border height="40vh">
         <el-table-column label="序号" align="center" width="60">
           <template slot-scope="scope">
             <span>{{ scope.$index + 1 }}</span>
@@ -154,7 +154,11 @@
     <EquipmentDialog
       ref="equipmentRefs"
       @choose="confirmChoose"
-      :selectList="form.productInfoList"
+      :selectList="
+        form.productInfoList.filter(
+          (i) => !disabledList.find((p) => p.productCode === i.productCode)
+        )
+      "
     >
     </EquipmentDialog>
   </ele-modal>
@@ -164,6 +168,7 @@
   import { getCode } from '@/api/codeManagement';
   import EquipmentDialog from '../components/EquipmentDialog.vue';
   import { createOrUpdate, getOrderDetail } from '@/api/saleOrder';
+  import { deepClone } from '@/utils';
   import dayjs from 'dayjs';
   export default {
     components: {
@@ -173,6 +178,7 @@
       return {
         visible: false,
         loading: false,
+        disabledList: [], //已保存数据不做删除
         form: {
           productInfoList: [],
           deliveryRequirements: 1,
@@ -204,6 +210,11 @@
         }
       };
     },
+    watch: {
+      disabledList () {
+        console.log(this.disabledList, 'disabledList');
+      }
+    },
     computed: {
       // 是否开启响应式布局
       styleResponsive () {
@@ -224,6 +235,7 @@
       },
       getDetail (code) {
         getOrderDetail(code).then((res) => {
+          this.disabledList = res.productInfoList;
           this.form = res;
         });
       },
@@ -288,19 +300,36 @@
       },
       // 确定选择
       confirmChoose (list) {
-        list = list.map((item, index) => {
-          return {
-            categoryId: item.id,
-            productCode: item.code,
-            productName: item.name,
-            productUnitWeight:
-              item.netWeightUnit == 'G'
-                ? (item.netWeight * 1000000) / 1000000000
-                : item.netWeight,
-            model: item.modelType,
-            brandNo: item.brandNum
-          };
-        });
+        console.log(
+          'this.form.productInfoList',
+          deepClone(this.form.productInfoList)
+        );
+        list = list
+          .filter(
+            (i) =>
+              !this.disabledList.find(
+                (p) => p.productCode == i.code || p.productCode == i.productCode
+              )
+          )
+          .map((item, index) => {
+            if (item.productCode) {
+              return item;
+            } else {
+              return {
+                categoryId: item.id,
+                productCode: item.code,
+                productName: item.name,
+                productUnitWeight:
+                  item.netWeightUnit == 'G'
+                    ? (item.netWeight * 1000000) / 1000000000
+                    : item.netWeight,
+                model: item.modelType,
+                brandNo: item.brandNum
+              };
+            }
+          })
+          .concat(this.disabledList);
+        console.log('list', list);
         // 取出在弹窗中选中并且不在表格中的数据
         const result = list.filter(
           (i) =>
@@ -308,19 +337,27 @@
               (p) => p.productCode === i.productCode
             ) === -1
         );
+        console.log('result', result);
         // 取出在表格中并且不在弹窗中选中的数据 即取消选中的数据
         const del = this.form.productInfoList.filter(
           (i) => list.findIndex((p) => p.productCode === i.productCode) === -1
         );
+        console.log('del', del);
         for (let i = this.form.productInfoList.length - 1; i >= 0; i--) {
           for (let j in del) {
+            console.log(
+              this.form.productInfoList[i].productCode,
+              del[j].productCode
+            );
             if (
               this.form.productInfoList[i].productCode === del[j].productCode
             ) {
               this.form.productInfoList.splice(i, 1);
+              break;
             }
           }
         }
+
         this.form.productInfoList = this.form.productInfoList.concat(result);
         this.changeLineNumber();
       },

+ 39 - 40
src/views/saleOrder/components/order-search.vue

@@ -62,7 +62,7 @@
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
         <el-form-item label="生产状态:">
-          <el-select v-model="where.proStu" placeholder="请选择">
+          <el-select v-model="where.proStu" placeholder="请选择" class="w100">
             <el-option
               v-if="activeName == 'first'"
               v-for="item in awaitProcuct"
@@ -84,15 +84,19 @@
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
         <el-form-item label="按单按库:">
-		   <el-select v-model="where.orderLibraryType" placeholder="请选择">
-		     <el-option
-		       v-for="item in orderTypeList"
-		       :key="item.value"
-		       :label="item.label"
-		       :value="item.value"
-		     >
-		     </el-option>
-		   </el-select>
+          <el-select
+            v-model="where.orderLibraryType"
+            placeholder="请选择"
+            class="w100"
+          >
+            <el-option
+              v-for="item in orderTypeList"
+              :key="item.value"
+              :label="item.label"
+              :value="item.value"
+            >
+            </el-option>
+          </el-select>
         </el-form-item>
       </el-col>
       <el-col v-bind="styleResponsive ? { lg: 6, md: 12 } : { span: 6 }">
@@ -124,15 +128,10 @@
             icon="el-icon-search"
             class="ele-btn-icon"
             @click="search"
-            size="small"
           >
             查询
           </el-button>
-          <el-button
-            @click="reset"
-            icon="el-icon-refresh-left"
-            size="small"
-            type="primary"
+          <el-button @click="reset" icon="el-icon-refresh-left" type="primary"
             >重置</el-button
           >
         </div>
@@ -184,7 +183,7 @@
   export default {
     props: {
       selection: Array,
-	  activeName:String
+      activeName: String
     },
     components: {
       ImportException,
@@ -209,7 +208,7 @@
       return {
         fileUrl,
         // 表单数据
-		defaultWhere,
+        defaultWhere,
         where: { ...defaultWhere },
         time: [],
         fileList: [],
@@ -223,11 +222,11 @@
           { value: 6, label: '已完成' },
           { value: 7, label: '已延期' }
         ],
-		orderTypeList:[
-			{ value: 0, label: '所有' },
-			{ value: 1, label: '按单' },
-			{ value: 2, label: '按库' },
-		]
+        orderTypeList: [
+          { value: 0, label: '所有' },
+          { value: 1, label: '按单' },
+          { value: 2, label: '按库' }
+        ]
       };
     },
     computed: {
@@ -236,18 +235,18 @@
         return this.$store.state.theme.styleResponsive;
       }
     },
-	watch: {
-	  activeName: {
-	    handler () {
-	      if (this.activeName=='first') {
-	         this.where.proStu = 1
-	      }else{
-			 this.where.proStu = 0
-		  }
-	    },
-	    immediate: true
-	  }
-	},
+    watch: {
+      activeName: {
+        handler () {
+          if (this.activeName == 'first') {
+            this.where.proStu = 1;
+          } else {
+            this.where.proStu = 0;
+          }
+        },
+        immediate: true
+      }
+    },
     created () {},
     methods: {
       /* 搜索 */
@@ -262,11 +261,11 @@
       reset () {
         this.time = [];
         this.where = { ...this.defaultWhere };
-		if (this.activeName=='first') {
-		   this.where.proStu = 1
-		}else{
-		   this.where.proStu = 0
-		}
+        if (this.activeName == 'first') {
+          this.where.proStu = 1;
+        } else {
+          this.where.proStu = 0;
+        }
         this.search();
       },
       toImport () {