695593266@qq.com пре 5 месеци
родитељ
комит
1b2c0f262d

+ 41 - 37
src/views/produce/components/workPlan/components/addSample.vue

@@ -133,9 +133,7 @@
       >
         <template v-slot:toolbar>
           累计请样数量:{{ workSampleQuantity
-          }}{{
-            form.conditionType == '1' ? tableList[0]?.measureUnit : form.unit
-          }}
+          }}{{ sampleList[0]?.measureUnit || form.measureUnit }}
         </template>
       </ele-pro-table>
       <header-title title="请样信息"> </header-title>
@@ -165,12 +163,6 @@
               >
               </el-option>
             </el-select>
-            <!-- <DictSelection
-              dictName="取样类型"
-              v-model="form.qualityMode"
-              @change="handleQualityModeChange"
-              :disabled="form.isFirstSampling != '1'"
-            ></DictSelection> -->
           </el-form-item>
         </el-col>
         <el-col :span="8">
@@ -213,7 +205,7 @@
         <el-col :span="16">
           <el-row>
             <el-col :span="6" v-if="form.conditionType == 2">
-              <el-form-item prop="quantity">
+              <el-form-item prop="quantity" label="数量">
                 <el-input
                   v-model="form.quantity"
                   placeholder="请输入"
@@ -232,7 +224,7 @@
               </el-form-item>
             </el-col>
             <el-col :span="8" v-if="form.conditionType == 2">
-              <el-form-item prop="portion" label="数">
+              <el-form-item prop="portion" label="数">
                 <el-input
                   v-model="form.portion"
                   placeholder="请输入"
@@ -320,7 +312,7 @@
         type="primary"
         @click="save('submit')"
         v-loading="loading"
-        v-if="type != 'view' && isProcess"
+        v-if="type != 'view' && isSamplingApproval == 1 && isProcess"
         >提交</el-button
       >
 
@@ -376,6 +368,7 @@
   import inspectionWorkDialog from './inspectionWorkDialog.vue';
   import { getCodeList, getCode } from '@/api/login';
   import { getByCode } from '@/api/system/dictionary-data';
+
   export default {
     components: { bpmDetail, inspectionWorkDialog, processSubmitDialog },
     props: {
@@ -630,6 +623,7 @@
         tableList: [],
         type: 'add',
         title: '',
+        isSamplingApproval: 0,
         qualityMode: [],
         isProcess: true
       };
@@ -644,9 +638,10 @@
       async open(type, row) {
         this.activeComp = 'main';
         this.visible = true;
+        this.type = type;
         await this.getQualityMethodCode();
         await this.getProcess();
-        this.type = type;
+        this.parameterGetByCode();
         this.title =
           type == 'add' ? '请样' : type == 'edit' ? '修改请样' : '详情';
         if (type == 'add') {
@@ -664,7 +659,27 @@
         });
       },
 
+      async getQualityMethodCode() {
+        let res = await getByCode('quality_method_code');
+        if (res?.code == 0) {
+          console.log(res);
+          let list = res.data.map((item) => {
+            let key = Object.keys(item)[0];
+            return { value: Number(key), label: item[key] };
+          });
+          this.qualityMode = list;
+        }
+      },
+
+      parameterGetByCode() {
+        parameterGetByCode({
+          code: 'sampling_approval'
+        }).then((res) => {
+          this.isSamplingApproval = res.value;
+        });
+      },
       async init(row) {
+        let isPackingUnit = false;
         let data = await samplingRecordsPage({
           qualityWorkOrderId: row.id
         });
@@ -679,10 +694,6 @@
         } else {
           row.sourceCode = row.qualityPlanCode || row.workOrderCode;
           this.form = JSON.parse(JSON.stringify(row));
-
-          console.log(this.qualityMode, 'this.qualityMode');
-          console.log(this.form, 'this.form');
-
           this.form.qualityWorkOrderId = row.id;
           this.form.qualityWorkOrderCode = row.code;
           this.form.qualityWorkOrderName = row.name;
@@ -690,28 +701,20 @@
 
           if (!list1?.length) {
             this.form.isFirstSampling = 1;
+            isPackingUnit = true;
+            if (this.form.conditionType == 1) {
+              this.$set(this.form, 'packingUnit', '111');
+            }
           } else {
             this.$set(this.form, 'unit', list1[0].unit);
+            this.$set(this.form, 'measureUnit', list1[0].measureUnit);
           }
-          await this.datasource(list1[0]?.unit);
+          await this.datasource(list1[0]?.unit, isPackingUnit);
           await this.queryQualityTempleContent(
             !list1.length && row.qualityMode == 1
           );
         }
       },
-
-      async getQualityMethodCode() {
-        let res = await getByCode('quality_method_code');
-        if (res?.code == 0) {
-          console.log(res);
-          let list = res.data.map((item) => {
-            let key = Object.keys(item)[0];
-            return { value: Number(key), label: item[key] };
-          });
-          this.qualityMode = list;
-        }
-      },
-
       getById(id) {
         getById(id).then((res) => {
           this.workSampleQuantity =
@@ -777,7 +780,7 @@
       changeParent(row) {
         this.init(row);
       },
-      async datasource(unit) {
+      async datasource(unit, isPackingUnit) {
         const res = await queryQualityInventory({
           qualityWorkerId: this.form.qualityWorkOrderId,
           pageNum: 1,
@@ -807,6 +810,9 @@
             listArr.find((item) => unit == item.conversionUnit)?.id
           );
         }
+        if (isPackingUnit) {
+          this.$set(this.form, 'unit', res.list[0]?.measureUnit);
+        }
         this.form.pleaseUnit = res.list[0]?.measureUnit;
         res.list.map((el) => {
           el.weightProportion = el.weight
@@ -1184,7 +1190,6 @@
       },
 
       handleQualityModeChange(val) {
-        console.log(val, '值');
         if (val == 1) {
           this.updatePackingList();
         } else {
@@ -1274,13 +1279,11 @@
               //取整样
               if (data.conditionType == 1) {
                 data.quantity = data.portion;
-
-                data.measureUnit = this.tableList[0].measureUnit;
               } else {
-                data.measureUnit = data.unit;
                 data.copies = data.portion;
               }
             }
+            data.measureUnit = this.sampleList[0].measureUnit;
             this.loading = true;
 
             api({
@@ -1314,7 +1317,8 @@
             variables: {
               businessCode: res.code,
               businessName: '请样',
-              businessType: res.conditionType == 1 ? '整样' : '小样'
+              businessType:
+                res.qualityWorkOrderVO.conditionType == 1 ? '整样' : '小样'
             }
           };
           this.$refs.processSubmitDialogRef.init(params);

+ 265 - 92
src/views/produceOrder/components/releaseDialog/index.vue

@@ -729,47 +729,60 @@
         );
       },
 
+      // chooseStationList(list, index) {
+      //   const process = this.processList?.[index];
+
+      //   if (!process) {
+      //     console.warn(`processList[${index}] 不存在`);
+      //     return;
+      //   }
+
+      //   const oldList = structuredClone(
+      //     Array.isArray(process.list) ? process.list : []
+      //   );
+
+      //   list.forEach((item) => {
+      //     item.isNew = 1;
+      //   });
+
+      //   const newList = structuredClone(Array.isArray(list) ? list : []);
+
+      //   this.$set(this.processList[index], 'list', [...oldList, ...newList]);
+      // },
+
       chooseStationList(list, index) {
-        const process = this.processList?.[index];
+        const process = this.processList[index];
+        if (!process) return;
 
-        if (!process) {
-          console.warn(`processList[${index}] 不存在`);
-          return;
-        }
+        const oldList = process.list || [];
 
-        const oldList = structuredClone(
-          Array.isArray(process.list) ? process.list : []
-        );
+        const existingIds = new Set(oldList.map((i) => i.id || i.__tempKey));
 
-        list.forEach((item) => {
-          item.isNew = 1;
-        });
+        const newList = list
+          .filter((item) => !existingIds.has(item.id || item.__tempKey))
+          .map((item) => ({
+            ...item,
+            isNew: 1,
+            __tempKey: item.id || `temp_${Date.now()}_${Math.random()}`,
+            disposalStatus: 0,
+            assetCode: item.extInfo?.assetCode,
+            assetId: item.extInfo?.assetId,
+            assetName: item.extInfo?.assetName
+            // status: { code: 0, desc: '未派单' }
+          }));
+
+        this.$set(process, 'list', [...oldList, ...newList]);
 
-        const newList = structuredClone(Array.isArray(list) ? list : []);
+        const newIds = newList.map((i) => i.id || i.__tempKey);
+        if (!process.selection) process.selection = [];
+        process.selection.push(...newIds);
 
-        this.$set(this.processList[index], 'list', [...oldList, ...newList]);
+        this.$nextTick(() => {
+          const tab = `tableRef${process.index}`;
+          this.$refs[tab]?.[0]?.setSelectedRowKeys(process.selection);
+        });
       },
 
-      // // 选择工作中心
-      // async changeWork(e) {
-      //   this.form.workCenterId = e;
-      //   // this.changeDispatch(); // 查询工序列表
-      //   let data = this.workCenterList.find((item) => item.id == e);
-      //   this.form.workCenterName = data.name;
-      //   this.teamList = data.teamList || [];
-      //   if (this.teamList.length > 0) {
-      //     this.form.teamId = this.teamList[0].id;
-      //     await this.changeGroups(this.teamList[0].id);
-      //   } else {
-      //     // 如果没有 班组数据 将人员数据清空 并且判断
-      //     this.crewList = [];
-      //     this.form.teamId = '';
-      //     let data = this.processList.find((item) => item.id == this.processId);
-      //     if (data.assignType == 2) {
-      //       this.$set(data, 'list', []);
-      //     }
-      //   }
-      // },
       // 选择工作中心
       async changeWork(e) {
         this.form.workCenterId = e;
@@ -899,48 +912,134 @@
         return isWithdraw;
       },
       // 派单
+      // dispatch(row, type) {
+      //   if (row.selection.length == 0) {
+      //     return this.$message.warning('请最少选择一条数据');
+      //   }
+
+      //   let isWithdraw = this.getWithdrawT(row, type);
+      //   if (isWithdraw.length) {
+      //     if (type == 1) {
+      //       this.$message.warning(
+      //         isWithdraw.toString() + ',状态为已派单,如需重新派单请先撤回!'
+      //       );
+      //     }
+      //     if (type == 2) {
+      //       this.$message.warning(
+      //         isWithdraw.toString() + '还未派单,无需撤回!'
+      //       );
+      //     }
+      //     return;
+      //   }
+
+      //   let assignees = [];
+      //   let changeIds = [];
+      //   let flag = true; // 是否填写 校验
+      //   // let digit = true; // 数字校验
+      //   row.selection.forEach((item) => {
+      //     if (!item.quantity || !item.startTime || !item.endTime) {
+      //       flag = false;
+      //       return;
+      //     }
+      //     // let Aobj = {
+      //     //   assigneeId: item.id,
+      //     //   quantity: item.quantity,
+      //     //   weight: item.weight,
+      //     //   startTime: item.startTime,
+      //     //   endTime: item.endTime,
+      //     //   assigneeType: row.assignType,
+      //     //   assigneeName: item.name,
+      //     //   measuringUnit: this.current.measuringUnit,
+      //     //   isNew: item.isNew ? item.isNew : '',
+      //     //   deviceId: item.extInfo.assetId ? item.extInfo.assetId : '',
+      //     //   deviceName: item.extInfo.assetName ? item.extInfo.assetName : ''
+      //     // };
+      //     let Aobj = {
+      //       assigneeId: item.id,
+      //       quantity: item.quantity,
+      //       weight: item.weight,
+      //       startTime: item.startTime,
+      //       endTime: item.endTime,
+      //       assigneeType: row.assignType,
+      //       assigneeName: item.name,
+      //       measuringUnit: this.current.measuringUnit,
+      //       isNew: item.isNew ? item.isNew : '',
+      //       deviceId:
+      //         item.extInfo && item.extInfo.assetId ? item.extInfo.assetId : '',
+      //       deviceName:
+      //         item.extInfo && item.extInfo.assetName
+      //           ? item.extInfo.assetName
+      //           : '',
+      //       workStationId: item.id,
+      //       workStationName: item.name
+      //     };
+      //     if (item.teamTimeIds) {
+      //       Aobj.teamTimeIds = item.teamTimeIds;
+      //     }
+      //     assignees.push(Aobj);
+      //     changeIds.push(item.changeId);
+      //   });
+      //   if (!flag) {
+      //     this.$message.warning(
+      //       '请将所选数据的 数量 ,开始时间,完成时间 填写完毕'
+      //     );
+      //     return;
+      //   }
+      //   let data = null;
+      //   this.toolbarLoading = true;
+      //   if (type == 2) {
+      //     data = changeIds;
+      //   } else {
+      //     data = {
+      //       dispatchMethod: 0,
+      //       dispatchType: this.dispatchType,
+      //       taskId: this.processId,
+      //       taskName: row.name,
+      //       taskCode: row.code,
+      //       teamName: this.form.teamName,
+      //       teamId: this.form.teamId,
+      //       workCenterId: this.form.workCenterId,
+      //       workCenterName: this.form.workCenterName,
+      //       workOrderId: this.current.apsWorkOrderId,
+      //       sourceType: 2,
+      //       mesWorkOrderId: this.current.id,
+      //       mesWorkOrderCode: this.current.code,
+      //       assignees
+      //     };
+      //   }
+      //   const api =
+      //     type == 1 ? taskAssignment : type == 2 ? taskRevoked : taskSave;
+      //   api(data)
+      //     .then((res) => {
+      //       this.toolbarLoading = false;
+      //       if (res) {
+      //         this.$message.success('操作成功');
+      //         // 更改当前表格数据
+      //         this.setCurrentTab(row);
+      //       }
+      //     })
+      //     .catch((err) => {
+      //       this.toolbarLoading = false;
+      //       this.$message.warning(err.message);
+      //     });
+      // },
+
       dispatch(row, type) {
-        if (row.selection.length == 0) {
+        if (!row.selection || row.selection.length === 0) {
           return this.$message.warning('请最少选择一条数据');
         }
 
-        let isWithdraw = this.getWithdrawT(row, type);
-        if (isWithdraw.length) {
-          if (type == 1) {
-            this.$message.warning(
-              isWithdraw.toString() + ',状态为已派单,如需重新派单请先撤回!'
-            );
-          }
-          if (type == 2) {
-            this.$message.warning(
-              isWithdraw.toString() + '还未派单,无需撤回!'
-            );
-          }
-          return;
-        }
-
+        // 获取选择行
         let assignees = [];
         let changeIds = [];
-        let flag = true; // 是否填写 校验
-        // let digit = true; // 数字校验
+        let flag = true;
+
         row.selection.forEach((item) => {
           if (!item.quantity || !item.startTime || !item.endTime) {
             flag = false;
             return;
           }
-          // let Aobj = {
-          //   assigneeId: item.id,
-          //   quantity: item.quantity,
-          //   weight: item.weight,
-          //   startTime: item.startTime,
-          //   endTime: item.endTime,
-          //   assigneeType: row.assignType,
-          //   assigneeName: item.name,
-          //   measuringUnit: this.current.measuringUnit,
-          //   isNew: item.isNew ? item.isNew : '',
-          //   deviceId: item.extInfo.assetId ? item.extInfo.assetId : '',
-          //   deviceName: item.extInfo.assetName ? item.extInfo.assetName : ''
-          // };
+
           let Aobj = {
             assigneeId: item.id,
             quantity: item.quantity,
@@ -951,31 +1050,31 @@
             assigneeName: item.name,
             measuringUnit: this.current.measuringUnit,
             isNew: item.isNew ? item.isNew : '',
-            deviceId:
-              item.extInfo && item.extInfo.assetId ? item.extInfo.assetId : '',
-            deviceName:
-              item.extInfo && item.extInfo.assetName
-                ? item.extInfo.assetName
-                : '',
+            deviceId: item.extInfo?.assetId || '',
+            deviceName: item.extInfo?.assetName || '',
             workStationId: item.id,
             workStationName: item.name
           };
+
           if (item.teamTimeIds) {
             Aobj.teamTimeIds = item.teamTimeIds;
           }
+
           assignees.push(Aobj);
           changeIds.push(item.changeId);
         });
+
         if (!flag) {
-          this.$message.warning(
-            '请将所选数据的 数量 ,开始时间,完成时间 填写完毕'
+          return this.$message.warning(
+            '请将所选数据的数量、开始时间、完成时间填写完毕'
           );
-          return;
         }
+
         let data = null;
         this.toolbarLoading = true;
-        if (type == 2) {
-          data = changeIds;
+
+        if (type === 2) {
+          data = changeIds; // 撤回
         } else {
           data = {
             dispatchMethod: 0,
@@ -994,15 +1093,29 @@
             assignees
           };
         }
+
         const api =
-          type == 1 ? taskAssignment : type == 2 ? taskRevoked : taskSave;
+          type === 1 ? taskAssignment : type === 2 ? taskRevoked : taskSave;
+
         api(data)
           .then((res) => {
             this.toolbarLoading = false;
             if (res) {
               this.$message.success('操作成功');
-              // 更改当前表格数据
+
+              // 更新表格数据,包括新增工位状态
               this.setCurrentTab(row);
+
+              row.list.forEach((item) => {
+                if (item.isNew === 1) {
+                  // item.disposalStatus =
+                  //   type === 1 ? 1 : item.disposalStatus || 0;
+                  item.status = {
+                    code: type === 1 ? 1 : 0,
+                    desc: type === 1 ? '已派单' : '已保存'
+                  };
+                }
+              });
             }
           })
           .catch((err) => {
@@ -1010,6 +1123,7 @@
             this.$message.warning(err.message);
           });
       },
+
       cancel() {
         this.$emit('update:dispatchVisible', false);
       },
@@ -1052,41 +1166,100 @@
         }
       },
       // 指派数据处理
-      async getAssignData(index, arr) {
-        let list = JSON.parse(JSON.stringify(arr));
-        let dataRow = this.processList[index];
+      // async getAssignData(index, arr) {
+      //   let list = JSON.parse(JSON.stringify(arr));
+      //   let dataRow = this.processList[index];
 
-        console.log('7777');
+      //   console.log('7777');
 
-        // return;
-        // 不存在 班组数据的话 就不调用这个方法
-        if (!this.form.teamId) {
-          return;
-        }
-        let params = {
+      //   // return;
+      //   // 不存在 班组数据的话 就不调用这个方法
+      //   if (!this.form.teamId) {
+      //     return;
+      //   }
+      //   let params = {
+      //     workOrderId: this.current.apsWorkOrderId,
+      //     workCenterId: this.form.workCenterId,
+      //     teamId: this.form.teamId,
+      //     taskId: this.processId
+      //   };
+      //   this.tabLoading = true;
+      //   try {
+      //     const res = await listAssign(params);
+      //     this.tabLoading = false;
+
+      //     console.log(res, '数据11445');
+      //     // 如果 res 没有数据 说明未对数据进行操作 直接赋值
+      //     if (res.length == 0) {
+      //       this.$set(dataRow, 'list', list);
+      //       return;
+      //     }
+      //     // 对有操作过的数据进行赋值
+      //     this.operationalData(index, res, list);
+      //   } catch (err) {
+      //     this.tabLoading = false;
+      //     this.$message.warning(err.message);
+      //   }
+      // },
+
+      async getAssignData(index, arr, type = 0) {
+        const dataRow = this.processList[index];
+
+        const localNewList = (dataRow.list || []).filter((i) => i.isNew === 1);
+
+        let list = JSON.parse(JSON.stringify(arr || []));
+
+        if (!this.form.teamId) return;
+
+        const params = {
           workOrderId: this.current.apsWorkOrderId,
           workCenterId: this.form.workCenterId,
           teamId: this.form.teamId,
           taskId: this.processId
         };
+
         this.tabLoading = true;
         try {
           const res = await listAssign(params);
           this.tabLoading = false;
 
-          console.log(res, '数据11445');
-          // 如果 res 没有数据 说明未对数据进行操作 直接赋值
-          if (res.length == 0) {
-            this.$set(dataRow, 'list', list);
+          if (!res || res.length === 0) {
+            // 没有后台数据,合并新增工位
+            const merged = [...list, ...localNewList];
+            this.$set(dataRow, 'list', merged);
             return;
           }
-          // 对有操作过的数据进行赋值
+
+          // 已操作过数据处理
           this.operationalData(index, res, list);
+
+          // 合并新增工位并去重
+          const existingIds = new Set(
+            (dataRow.list || []).map((i) => i.id || i.__tempKey)
+          );
+          const mergedList = [
+            ...dataRow.list,
+            ...localNewList.filter((i) => !existingIds.has(i.id || i.__tempKey))
+          ];
+
+          // 更新新增工位状态
+          mergedList.forEach((item) => {
+            if (item.isNew === 1) {
+              item.disposalStatus = type === 1 ? 1 : item.disposalStatus || 0;
+              item.status = item.status || {
+                code: type === 1 ? 1 : 0,
+                desc: type === 1 ? '已派单' : '已保存'
+              };
+            }
+          });
+
+          this.$set(dataRow, 'list', mergedList);
         } catch (err) {
           this.tabLoading = false;
           this.$message.warning(err.message);
         }
       },
+
       // 操作过的数据 赋值
       operationalData(index, res, list) {
         const dataRow = this.processList[index];