2213980799@qq.com 1 жил өмнө
parent
commit
1c9990f862

+ 82 - 34
src/views/inspectionPlan/components/edit.vue

@@ -11,13 +11,23 @@
   >
     <el-form ref="form" :model="form" :rules="rules" label-width="120px">
       <el-row>
+        <el-col :span="8">
+          <el-form-item label="编码:" prop="code">
+            <el-input
+              clearable
+              v-model="form.code"
+              placeholder="请输入"
+              disabled
+            />
+          </el-form-item>
+        </el-col>
         <el-col :span="8">
           <el-form-item label="名称:" prop="name">
             <el-input
               clearable
               v-model="form.name"
               placeholder="请输入"
-              :disabled="type == 'detail'||type == 'issued'"
+              :disabled="type == 'detail' || type == 'issued'"
             />
           </el-form-item>
         </el-col>
@@ -28,8 +38,7 @@
               @change="planChange"
               v-model="form.type"
               clearable
-              :disabled="type == 'detail'||type == 'issued'"
-
+              :disabled="type == 'detail' || type == 'issued'"
             ></DictSelection>
           </el-form-item>
         </el-col>
@@ -47,8 +56,7 @@
               style="width: 100%"
               clearable
               @change="planSourceChange"
-              :disabled="type == 'detail'||type == 'issued'"
-
+              :disabled="type == 'detail' || type == 'issued'"
             >
               <el-option
                 :label="item.label"
@@ -70,8 +78,7 @@
               v-model="form.autoOrder"
               placeholder="请选择"
               style="width: 100%"
-              :disabled="type == 'detail'||type == 'issued'"
-
+              :disabled="type == 'detail' || type == 'issued'"
             >
               <el-option label="是" :value="1" />
               <el-option label="否" :value="0" />
@@ -83,7 +90,7 @@
             <el-input v-model="form.batchNo" disabled />
           </el-form-item>
         </el-col>
-        <el-col :span="8">
+        <!-- <el-col :span="8">
           <el-form-item label="产品名称:" prop="productName">
             <el-input
               v-model="form.productName"
@@ -93,8 +100,8 @@
 
             />
           </el-form-item>
-        </el-col>
-        <el-col :span="8">
+        </el-col> -->
+        <!-- <el-col :span="8">
           <el-form-item label="产品编码:" prop="productCode">
             <el-input v-model="form.productCode" disabled />
           </el-form-item>
@@ -117,7 +124,7 @@
 
             />
           </el-form-item>
-        </el-col>
+        </el-col> -->
         <el-col :span="8">
           <el-form-item
             label="执行部门"
@@ -185,7 +192,7 @@
           </el-form-item>
         </el-col>
       </el-row>
-      <!-- <el-table :data="form.productJson" border height="30vh">
+      <el-table :data="form.productList" border height="30vh">
         <el-table-column label="产品编码" align="center" prop="productCode">
         </el-table-column>
         <el-table-column label="产品名称" align="center" prop="productName">
@@ -195,9 +202,20 @@
         </el-table-column>
         <el-table-column label="牌号" align="center" prop="brandNo">
         </el-table-column>
-        <el-table-column label="数量" align="center" prop="total">
+        <el-table-column label="数量" align="center" prop="productNumber">
+          <template slot-scope="scope">
+            <el-input
+              v-model="scope.row.productNumber"
+              :disabled="type == 'detail' || type == 'issued'"
+            />
+          </template>
         </el-table-column>
-        <el-table-column label="操作" align="center" width="70">
+        <el-table-column
+          label="操作"
+          align="center"
+          width="70"
+          v-if="!form.planSourceCode"
+        >
           <template slot-scope="scope">
             <el-link
               type="danger"
@@ -208,11 +226,11 @@
             </el-link>
           </template>
         </el-table-column>
-      </el-table> -->
-      <!-- <div class="add-product" @click="addProduct">
+      </el-table>
+      <div class="add-product" @click="addProduct">
         <i class="el-icon-circle-plus-outline"></i>
-      </div> -->
-      <EquipmentDialog ref="equipmentRefs" @choose="choose" />
+      </div>
+      <EquipmentDialog ref="equipmentRefs" @choose="choose" :type="1" />
       <productionPlan ref="productionPlanRef" @choose="choose" />
       <workOrder ref="workOrderRef" @choose="choose" />
       <produceOrder ref="produceOrderRef" @choose="choose" />
@@ -276,14 +294,15 @@ export default {
         groupName: '',
         planStartTime: '',
         planEndTime: '',
-        productCode: '',
-        productName: '',
-        specification: '',
-        brandNo: '',
+        // productCode: '',
+        // productName: '',
+        // specification: '',
+        // brandNo: '',
+        // productNumber: '',
         executeName: '',
-        productNumber: '',
         planSource: '',
-        batchNo: ''
+        batchNo: '',
+        productList: []
       };
     };
     return {
@@ -293,8 +312,8 @@ export default {
       sourceList: [],
       // 表单验证规则
       rules: {
-        name: [{ required: true, message: '请输入', trigger: 'blur' }],
-        productName: [{ required: true, message: '请选择', trigger: 'blur' }]
+        name: [{ required: true, message: '请输入', trigger: 'blur' }]
+        // productName: [{ required: true, message: '请选择', trigger: 'blur' }]
       },
       visible: false,
       type: null,
@@ -342,6 +361,9 @@ export default {
     planSourceChange() {
       this.choose({});
     },
+    handleDeleteItem(index) {
+      this.form.productList.splice(index, 1);
+    },
     addProduct() {
       if (this.form.planSource == 1) {
         this.$refs.warehousingRef.open();
@@ -361,12 +383,18 @@ export default {
         if (!valid) {
           return false;
         }
+        if (this.form.productList.length == 0) {
+          this.$message.error('请选择产品!');
+
+          return;
+        }
         this.loading = true;
         if (this.type == 'add') {
           delete this.form.id;
         }
-        console.log(this.type)
-        let URL = this.type == 'add' ? save : this.type =='edit' ? update : planIssued;
+        console.log(this.type);
+        let URL =
+          this.type == 'add' ? save : this.type == 'edit' ? update : planIssued;
         URL(this.form)
           .then((msg) => {
             this.loading = false;
@@ -380,15 +408,35 @@ export default {
       });
     },
     choose(data) {
-      console.log(data);
+      let arr = [];
+      if (Array.isArray(data)) {
+        data.forEach((item) => {
+          arr.push({
+            productCode: item.code,
+            productName: item.name,
+            specification: item.specification,
+            brandNo: item.brandNum,
+            productNumber: ''
+          });
+        });
+      } else {
+        arr = data.productName
+          ? [
+              {
+                productCode: data.productCode,
+                productName: data.productName,
+                specification: data.model,
+                brandNo: data.brandNo,
+                productNumber: data.productNumber
+              }
+            ]
+          : [];
+      }
+
       this.form.planSourceId = data.id;
       this.form.planSourceCode = data.code;
-      this.form.productCode = data.productCode || data[0]?.code;
-      this.form.productName = data.productName || data[0]?.name;
-      this.form.specification = data.model || data[0]?.specification;
-      this.form.brandNo = data.brandNo || data[0]?.brandNum;
       this.form.batchNo = data.batchNo;
-      this.form.productNumber = data.productNumber;
+      this.form.productList = arr;
     },
 
     //选择部门(搜索)

+ 0 - 3
src/views/inspectionPlan/components/productionPlan.vue

@@ -195,10 +195,7 @@ export default {
       });
     },
     open(ids) {
-    
       this.equipmentdialog = true;
-
-    
     },
     onDone(){
       this.$nextTick(() => {

+ 21 - 21
src/views/inspectionPlan/index.vue

@@ -111,28 +111,28 @@ export default {
             return cellValue == 1 ? '是' :  '否';
           }
         },
-        {
-          prop: 'productName',
-          label: '产品名称',
-        },
-        {
-          prop: 'productCode',
-          label: '产品编码',
-        },
-        {
-          prop: 'specification',
-          label: '规格',
-        },
-        {
-          prop: 'brandNo',
-          label: '牌号',
-        },
+        // {
+        //   prop: 'productName',
+        //   label: '产品名称',
+        // },
+        // {
+        //   prop: 'productCode',
+        //   label: '产品编码',
+        // },
+        // {
+        //   prop: 'specification',
+        //   label: '规格',
+        // },
+        // {
+        //   prop: 'brandNo',
+        //   label: '牌号',
+        // },
 
-        {
-          prop: 'productNumber',
-          label: '数量',
-          width: 60
-        },
+        // {
+        //   prop: 'productNumber',
+        //   label: '数量',
+        //   width: 60
+        // },
       
         {
           label: '执行部门',

+ 35 - 5
src/views/inspectionPoint/components/EquipmentDialog.vue

@@ -18,7 +18,10 @@
             :current.sync="current"
             highlight-current-row
             cache-key="systemRoleTable3"
-            
+            @selection-change="selectionChange"
+            @select="select"
+
+
             row-key="id"
             height="50vh"
             @done="onDone"
@@ -106,8 +109,9 @@ export default {
       categoryLevelId: null,
       code: null,
       selection: [],
-      ids:[]
-    };
+      ids:[],
+      oldSelection:[],//存储selection
+    }
   },
 
   watch: {},
@@ -120,10 +124,29 @@ export default {
       });
     },
     open(ids) {
-    
       this.equipmentdialog = true;
       this.ids=ids
-    
+    },
+    selectionChange(selection){
+      // console.log(this.oldSelection)
+      // this.ids.push(row.id)
+      this.oldSelection.push(...selection)
+      
+    },
+    select(selection, row){
+      // alert(1)
+      console.log(selection)
+      console.log(row)
+      console.log(selection.find(item=>item.id==row.id))
+      if(!selection.find(item=>item.id==row.id)){
+        this.ids= this.ids.filter(item=>item!=row.id) 
+        console.log(this.ids)
+      }else{
+        this.ids.push(row.id)
+      }
+      
+     
+      // this.ids=this.oldSelection.map(item=>item.id)
     },
     onDone(){
       this.$nextTick(() => {
@@ -136,6 +159,13 @@ export default {
     },
     // 选择
     selected() {
+      
+      if(this.type==1){
+        let ids= [...new Set(this.ids)]
+        this.selection=ids.map(item=>this.oldSelection.find(val=>val.id==item))
+      }
+      // console.log(this.selection)
+      // return
       this.$emit('choose', this.type==1?JSON.parse(JSON.stringify(this.selection)):JSON.parse(JSON.stringify(this.current)));
       this.handleClose();
     }

+ 5 - 0
src/views/inspectionPoint/components/inspectionProjectList.vue

@@ -3,6 +3,11 @@
     <div class="title">质检项</div>
 
     <el-table :data="listPage" border height="30vh">
+      <el-table-column label="序号" align="center" prop="inspectionCode"  width="50">
+        <template slot-scope="scope">
+          <span>{{ scope.$index + 1 }}</span>
+        </template>
+      </el-table-column>
       <el-table-column label="编码" align="center" prop="inspectionCode">
       </el-table-column>
       <el-table-column label="质检项名称" align="center" prop="inspectionName">