Browse Source

修改bug

695593266@qq.com 11 months ago
parent
commit
5ccad556b8

+ 2 - 1
package.json

@@ -48,6 +48,7 @@
     "vue": "^2.7.10",
     "vue-clipboard2": "^0.3.3",
     "vue-countup-v2": "^4.0.0",
+    "vue-direction-key": "^1.0.5",
     "vue-echarts": "^6.2.3",
     "vue-i18n": "^8.27.2",
     "vue-router": "^3.6.4",
@@ -89,4 +90,4 @@
   "license": "ISC",
   "description": "",
   "packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
-}
+}

+ 9 - 0
src/api/inspectionWork/index.js

@@ -135,3 +135,12 @@ export async function qualityWorkOrderCertificate(params) {
     return res.data.data;
   }
 }
+
+// 判断是否是报工人
+export async function verificationQualityInspector(id) {
+  const res = await request.post(
+    `/qms/quality_work_order/verificationQualityInspector/${id}`
+  );
+
+  return res.data.code;
+}

+ 2 - 3
src/main.js

@@ -13,22 +13,20 @@ import './styles/index.scss';
 import DictSelection from '@/components/Dict/DictSelection';
 import HeaderTitle from '@/components/header-title';
 import authSelection from '@/components/authSelection';
+import Direction from 'vue-direction-key';
 // 公共搜索文件
 
 import seekPage from '@/components/common/seekPage';
 
 Vue.component('seekPage', seekPage);
 
-
 Vue.component('authSelection', authSelection);
 Vue.component('HeaderTitle', HeaderTitle);
 
-
 import clickOnce from './utils/clickOnce.js';
 // 注册全局自定义指令
 Vue.directive('click-once', clickOnce);
 
-
 // bpmnProcessDesigner 需要引入
 import MyPD from '@/components/bpmnProcessDesigner/package/index.js';
 Vue.use(MyPD);
@@ -62,6 +60,7 @@ Vue.use(EleAdmin, {
 });
 Vue.use(permission);
 Vue.use(VueClipboard);
+Vue.use(Direction);
 let instance = null;
 
 function render(props = {}) {

+ 1 - 1
src/views/produce/components/feeding/components/batchProductsBom.vue

@@ -254,7 +254,7 @@
       async asyncgetQualityParam() {
         console.log(this.itemIndex, 'index');
         if (this.form.quantity) {
-          if (this.itemData.extInfo.sourceQuantity < this.form.quantity) {
+          if (this.itemData.extInfo.sourceQuantity <= this.form.quantity) {
             this.$message.warning('拆批数不能大于数量');
             return;
           }

+ 35 - 6
src/views/produce/components/feeding/components/outboundOrderDialog.vue

@@ -1,13 +1,42 @@
 <template>
-  
+  <ele-modal
+    :visible.sync="visible"
+    v-if="visible"
+    :before-close="handleClose"
+    :close-on-click-modal="true"
+    :close-on-press-escape="false"
+    :maxable="true"
+    append-to-body
+    width="90%"
+  ></ele-modal>
 </template>
 
 <script>
-export default {
+  export default {
+    name: 'outboundOrderDialog',
 
-}
-</script>
+    data() {
+      return {
+        visible: false
+      };
+    },
+
+    computed: {
+      cloums() {
+        return [];
+      }
+    },
 
-<style>
+    mehtods: {
+      handleClose() {
+        this.visible = false;
+      },
+
+      open() {
+        this.visible = true;
+      }
+    }
+  };
+</script>
 
-</style>
+<style></style>

+ 8 - 5
src/views/produce/components/feeding/index.vue

@@ -39,7 +39,9 @@
             <div class="name">工单信息 </div>
 
             <div class="rx-bc">
-              <el-button type="text" size="mini" @click="outboundOrder()">出库单</el-button>
+              <el-button type="text" size="mini" @click="outboundOrder()"
+                >出库单</el-button
+              >
               <el-button
                 type="text"
                 size="mini"
@@ -190,6 +192,7 @@
     <div v-else>
       <el-empty description="批量报工,不需要投料,直接去报工取样"></el-empty>
     </div>
+    <outboundOrderDialog ref="outboundOrderDialogRef"></outboundOrderDialog>
   </div>
 </template>
 
@@ -218,6 +221,7 @@
   import aridRegion from './components/aridRegion.vue';
   import palletBom from './components/palletBom.vue';
   import revolvingDiskBom from './components/revolvingDiskBom.vue';
+  import outboundOrderDialog from './components/outboundOrderDialog.vue';
   import { deepClone } from '@/utils';
   import { timestampToDateTime } from '@/utils/index.js';
   import { parameterGetByCode } from '@/api/system/dictionary-data';
@@ -237,7 +241,8 @@
       aridRegion,
       palletBom,
       revolvingDiskBom,
-      batchProductsBom
+      batchProductsBom,
+      outboundOrderDialog
     },
     props: {
       workListIds: {
@@ -417,9 +422,7 @@
         });
       },
 
-      outboundOrder() {
-        
-      },
+      outboundOrder() {},
 
       openPicking(id, item) {
         this.$refs.pickingListRef.open(id, item, '选择列表');

+ 9 - 8
src/views/produce/components/footBtn.vue

@@ -236,14 +236,15 @@
       },
       singleReportInspection: {
         handler(v) {
-          if (v == 1 || v == null) {
-            let index = this.btnList2.findIndex(
-              (obj) => obj.name == '取样质检'
-            );
-            if (index !== -1) {
-              this.btnList2.splice(0, 1);
-            }
-          } else if (v == 0 && this.clientEnvironmentId != 3) {
+          // if (v == 1 || v == null) {
+          //   let index = this.btnList2.findIndex(
+          //     (obj) => obj.name == '取样质检'
+          //   );
+          //   if (index !== -1) {
+          //     this.btnList2.splice(0, 1);
+          //   }
+          // } else
+          if (v == 0 && this.clientEnvironmentId == 2) {
             let arr = {
               name: '取样质检',
               type: 'inspection',

+ 10 - 10
src/views/produce/components/jobBooking/components/jobBom.vue

@@ -474,16 +474,16 @@
           if (res && res.length) {
             this.forValue = res[0];
 
-            const engrave = res.map((item, index) => {
-              if (!item.extInfo.engrave) {
-                item.extInfo.engrave = index + 1;
-              }
+            // const engrave = res.map((item, index) => {
+            //   if (!item.extInfo.engrave) {
+            //     item.extInfo.engrave = index + 1;
+            //   }
 
-              return item;
-            });
+            //   return item;
+            // });
 
-            this.list = engrave;
-            this.item.product = engrave;
+            // this.list = engrave;
+            // this.item.product = engrave;
 
             // res.map((v) => {
             //   v.selected = true;
@@ -506,8 +506,8 @@
             //     }
             //   ];
             // });
-            // this.list = res;
-            // this.item.product = res;
+            this.list = res;
+            this.item.product = res;
           }
         });
       },

+ 8 - 8
src/views/produce/components/jobBooking/components/jobDdBom.vue

@@ -322,16 +322,16 @@
             //   v.selected = true;
             // });
 
-            const engrave = res.map((item, index) => {
-              if (!item.extInfo.engrave) {
-                item.extInfo.engrave = index + 1;
-              }
+            // const engrave = res.map((item, index) => {
+            //   if (!item.extInfo.engrave) {
+            //     item.extInfo.engrave = index + 1;
+            //   }
 
-              return item;
-            });
+            //   return item;
+            // });
 
-            this.list = engrave;
-            this.item.semiProductList = engrave;
+            this.list = res;
+            this.item.semiProductList = res;
           }
         });
       },

+ 12 - 6
src/views/produce/components/jobBooking/components/semiProductJobBom.vue

@@ -1070,13 +1070,19 @@
         for (let i = 0; i < engraveNumber; i++) {
           if (this.list.length < i) return;
 
-          this.$set(
-            this.list[i].extInfo,
-            'engrave',
-            Number(this.form.minNumber) + i
-          );
+          if (this.list.length > i) {
+            this.$set(
+              this.list[i].extInfo,
+              'engrave',
+              Number(this.form.minNumber) + i
+            );
+          } else {
+            break;
+          }
         }
-        this.$forceUpdate();
+
+        console.log('222222222222222');
+
         this.dialogEngrave = false;
       },
 

+ 2 - 1
src/views/produce/components/jobBooking/index.vue

@@ -821,12 +821,13 @@
             }
           } else {
             if (this.List.length > 0) {
+              console.log(this.List);
               for (let i = 0; i < this.List[0].semiProductList.length; i++) {
                 // if (!this.List[0].semiProductList[i].extInfo.engrave) {
                 //   this.$message.warning('请输入刻码!');
                 //   return;
                 // }
-                if (!this.List[0].semiProductList[i].confirm == 1) {
+                if (this.List[0].semiProductList[i].confirm == 1) {
                   if (!this.List[0].semiProductList[i].extInfo.engrave) {
                     this.$message.warning('请输入刻码!');
                     return;

+ 48 - 50
src/views/produce/components/warehousing/index.vue

@@ -117,8 +117,11 @@
         <!-- 单独报工 -->
         <div
           v-else-if="
-            item.currentTaskDiagram.type == 4 ||
-            (item.currentTaskDiagram.type == 5 && item.singleReport == 1)
+            item.currentTaskDiagram.type == 5 &&
+            item.singleReport == 1 &&
+            clientEnvironmentId != 3 &&
+            clientEnvironmentId != 2 &&
+            item.semiProductList
           "
         >
           <!-- <div v-if="item.toWarehouseList && item.toWarehouseList.length > 0"> -->
@@ -222,7 +225,7 @@
         <div
           v-if="
             clientEnvironmentId != 2 &&
-            item &&
+            item.product &&
             item.currentTaskDiagram.type == 5 &&
             clientEnvironmentId != 3 &&
             item.singleReport !== 1
@@ -701,58 +704,13 @@
           });
 
           console.log(listData, 'listData');
-          // const data = this.List[0];
-          // if (!this.warehouseId) {
-          //   return this.$message.warning('请选择仓库');
-          // }
-          // let categoryId = '',
-          //   rootCategoryLevelId = '';
-          // if (data.product.length) {
-          //   categoryId = data.product[0].categoryId;
-          //   rootCategoryLevelId = data.product[0].rootCategoryLevelId;
-          // }
-
-          // let storageInfo = {
-          //   inWarehouseSpecType:
-          //     this.clientEnvironmentId !== 3 || this.clientEnvironmentId !== 2
-          //       ? Number(this.inWarehouseSpecType)
-          //       : '',
-          //   warehouseId: this.warehouseId,
-          //   inWarehouseType: this.inWarehouseType,
-          //   toWarehouseList: this.clientEnvironmentId == 3 ? this.tgList : []
-          // };
-
-          // let num = '';
-          // if (data.workReportInfo && data.workReportInfo?.formedNum) {
-          //   num = data.workReportInfo.formedNum;
-          // }
-
-          // storageInfo.packingReportList = [
-          //   {
-          //     code: data.productCode,
-          //     categoryId: categoryId,
-          //     workOrderId: data.workOrderId,
-          //     rootCategoryLevelId: rootCategoryLevelId,
-          //     totalQuantity: num,
-          //     quantity: num,
-          //     unit: data.unit,
-          //     packingNum: 1,
-          //     taskId: -1
-          //   }
-          // ];
-
-          // data.storageInfo = storageInfo;
-          // console.log(storageInfo, 'storageInfo');
-          // console.log(data, 'this.data');
-
-          // const data = this.List[0];
 
           jobSave(listData).then((res) => {
             console.log(res);
             this.$message.success('入库成功');
             this.getList(this.idsList);
           });
-        } else {
+        } else if (this.clientEnvironmentId == 3) {
           let _arr = [];
 
           console.log(this.List, 'this.List');
@@ -763,7 +721,6 @@
             }
           });
 
-          // _arr[0].warehouseId = this.warehouseId;
           _arr.forEach((item) => {
             item.warehouseId = this.warehouseId;
           });
@@ -795,6 +752,47 @@
             };
           });
 
+          jobSave(_arr2).then((res) => {
+            console.log(res);
+            this.$message.success('入库成功');
+            this.getList(this.idsList);
+          });
+        } else {
+          let _arr = [];
+
+          console.log(this.List, 'this.List');
+
+          this.List.forEach((item) => {
+            item.warehouseId = this.warehouseId;
+          });
+
+          console.log(_arr, '_arr121221');
+
+          let bol = true;
+          bol = this.List.every((e, i) => {
+            return e.warehouseId;
+          });
+
+          if (!bol) {
+            this.$message.warning(`仓库不能为空`);
+            return false;
+          }
+
+          let _arr2 = JSON.parse(JSON.stringify(this.List));
+
+          _arr2.map((m) => {
+            m.storageInfo = {
+              warehouseId: m.warehouseId,
+              toWarehouseList: m.toWarehouseList,
+              inWarehouseSpecType: this.inWarehouseSpecType
+            };
+            delete m.warehouseId;
+            delete m.toWarehouseList;
+            return {
+              ...m
+            };
+          });
+
           jobSave(_arr2).then((res) => {
             console.log(res);
             this.$message.success('入库成功');

+ 25 - 8
src/views/produce/components/workPlan/components/newQualityContentTabs.vue

@@ -465,6 +465,12 @@
           // console.log(newVal, 'schemeList');
         },
         deep: true
+      },
+      activeName: {
+        handler(newVal) {
+          this.activeNameKK = newVal;
+          // console.log(newVal);
+        }
       }
     },
     props: {
@@ -715,6 +721,8 @@
       },
       // 分页后的样品列表
       paginatedSampleList() {
+        console.log(this.sampleList);
+
         const { currentPage, pageSize } = this.samplePagination;
         const start = (currentPage - 1) * pageSize;
         const end = start + pageSize;
@@ -964,20 +972,29 @@
         this.$refs.inspectionTemplateRef.open(2);
       },
       async inspectionTemplateSuccess(select) {
+        console.log(select);
+
         let data = await getQualityTemplateByIds({
           templateIds: select.map((item) => item.id)
         });
-        // planTemplateList
-        console.log(data);
+
+        // 这里是选择方案后,数据新加,要改为覆盖
+        // this.templateList.push(...data);
+        // const strings = this.templateList.map((item) => JSON.stringify(item));
+        // const removeDupList = [...new Set(strings)];
+        // const result = removeDupList.map((item) => JSON.parse(item));
+
+        this.templateList = [];
         this.templateList.push(...data);
-        const strings = this.templateList.map((item) => JSON.stringify(item));
-        const removeDupList = [...new Set(strings)];
-        const result = removeDupList.map((item) => JSON.parse(item));
-        this.templateList = result.map((item) => {
+        this.templateList.forEach((item) => {
           item['qualityResults'] = 1;
-          return item;
         });
-        // console.log(this.templateList);
+
+        // this.templateList = result.map((item) => {
+        //   item['qualityResults'] = 1;
+        //   return item;
+        // });
+
         this.sampleList.forEach((item, index) => {
           this.$set(
             this.sampleList[index],

+ 343 - 181
src/views/produce/components/workPlan/edit.vue

@@ -1,6 +1,7 @@
 <template>
-  <el-dialog
+  <ele-modal
     :visible.sync="visible"
+    v-if="visible"
     :before-close="handleClose"
     :close-on-click-modal="true"
     :close-on-press-escape="false"
@@ -8,7 +9,7 @@
     append-to-body
     width="90%"
   >
-    <div class="ele-body" v-if="visible">
+    <div class="ele-body">
       <el-card shadow="never">
         <header-title title="基本信息">
           <el-button @click="cancel">返回</el-button>
@@ -47,6 +48,7 @@
           :scheme-list="schemeList"
           :loading="loading"
           :form="form"
+          :status="statusType"
           @handleSelectionChange="handleSelectionChange1"
           @batch-quality="batchQuality"
           @batch-dispose="batchDispose"
@@ -67,16 +69,22 @@
         @handleDispose="handleDispose"
       ></sampleListDialog>
       <sampleDisposeDialog
+        v-if="sampleDisposeVisble"
+        :sampleDisposeVisble.sync="sampleDisposeVisble"
         ref="disposeRef"
         @handleDisposeConfirm="handleDisposeConfirm"
+        :rowData="rowData"
+        @close="closeDispose"
+        @handleDispose="handleDispose"
       ></sampleDisposeDialog>
     </div>
-  </el-dialog>
+  </ele-modal>
 </template>
 
 <script>
   import baseInfo from './components/baseInfo.vue';
-  import QualityContentTabs from './components/QualityContentTabs.vue';
+  // import QualityContentTabs from './components/QualityContentTabs.vue';
+  import QualityContentTabs from './components/newQualityContentTabs.vue';
 
   import { getCode } from '@/api/login';
   import {
@@ -105,31 +113,6 @@
     },
     mixins: [dictMixins],
 
-    props: {
-      // workListIds: {
-      //   type: Array,
-      //   default() {
-      //     return [];
-      //   }
-      // },
-      // activeName: {
-      //   type: String
-      // },
-      // reportNeedFeed: {}
-      workListIds: {
-        type: Array,
-        default() {
-          return [];
-        }
-      },
-      taskId: {
-        type: String,
-        default() {
-          return null;
-        }
-      }
-    },
-
     data() {
       const defaultForm = function () {
         return {
@@ -167,7 +150,9 @@
         };
       };
       return {
+        rowData: null,
         defaultForm,
+        sampleDisposeVisble: false,
         // 表单数据
         form: { ...defaultForm() },
         voList: [],
@@ -179,12 +164,13 @@
         loading: false,
 
         tabTaskId: null,
-        visible: false,
         // activeName: '2',
 
         packingList: [],
+        // 样品清单,处置,批量处置,批量质检,质检的操作
         sampleList: [],
         schemeList: [],
+        inventoryList: [],
         activeName: '1',
 
         isValid: true,
@@ -193,12 +179,13 @@
         qualityTimeStart: '',
         isReportProcessProduce: false,
         addStatus: [],
-        dataWork: {},
-        inventoryList: []
+        statusType: false,
+        visible: false,
+        dataWork: {}
       };
     },
     // watch: {
-    //   workListIds: {
+    //   '$route.query.id': {
     //     handler(id) {
     //       if (id) {
     //         this.getDetail();
@@ -210,37 +197,26 @@
     // },
 
     created() {
-      // console.log(11111);
-      // console.log(this.workListIds);
       // this.open();
-      // if (this.workListIds[0]) {
+      // if (this.$route.query.id) {
       //   this.getDetail();
       // }
     },
     methods: {
       //切换检验方式
       changeModel(val, flag) {
+        console.log('切换检验方式');
+
         this.$refs.tabsRef.tableSelClear();
         this.sampleList = [];
         this.$refs.tabsRef.tabsChange('1');
         this.$refs.tabsRef.tabsConditionType(null);
-
         this.form.qualityMode = val;
         //检验方式 全检
         if (this.form.qualityMode == 1) {
           this.activeName = '2';
           this.form.sampleNumber = '';
-          const sData = this.$refs.tabsRef.$refs.sourceTable.getData();
-          if (sData.length == 0) {
-            for (let i = 0; i < sData.length; i++) {
-              this.$set(sData[i], 'qualityStatus', 2);
-            }
-          }
-          console.log(
-            this.$refs.tabsRef.$refs.sourceTable.getData(),
-            'packingList'
-          );
-          this.getProSamList(sData);
+          this.changeGetSampleList(this.inventoryList);
         } else {
           this.activeName = '1';
           if (!flag) {
@@ -248,37 +224,6 @@
           }
         }
       },
-
-      async open(req) {
-        this.visible = true;
-        this.dataWork = req.data;
-        this.getDetail(req.workOrderId);
-        this.type = req.data.type ? req.data.type : req.type;
-        this.qualityType = req.data.qualityType ? req.data.qualityType : '';
-
-        this.title =
-          this.type == 'add' ? '新增' : this.type == 'edit' ? '报工' : '详情';
-
-        if (this.type == 'add') {
-          const code = await getCode('quality_work_order_code');
-          this.form.code = code;
-        } else {
-          if (
-            req.data.qualityTimeStart != '' ||
-            req.data.qualityTimeStart != null ||
-            req.data.qualityTimeStart != undefined
-          ) {
-            this.qualityTimeStart = this.getNowTime();
-          }
-        }
-      },
-
-      handleClose() {
-        this.visible = false;
-        // this.$refs.equiTable.clearSelection();
-        this.$emit('close', false);
-      },
-
       //根据类型判断样品清单现实列表数据
       async getProSamList(list) {
         //生产检验
@@ -356,6 +301,133 @@
           this.sampleList = this.addStatus;
         }
       },
+      // 创建计量数量为1的样品清单函数,用于计数类型的
+      async createSampleList(list) {
+        if (this.form.qualityMode != null) {
+          console.log('sssssjijdiajdia');
+
+          this.$message('正在生成样品清单');
+          const ProductSampleList = [];
+          console.log(list, 'list');
+          for (const oldItem of list) {
+            const count = oldItem.measureQuantity;
+            const newMeasureQuantity = oldItem.measureQuantity / count;
+            const newWeight = parseFloat((oldItem.weight / count).toFixed(2));
+
+            console.log(typeof oldItem.qualitySampleTemplateList, 'ssssss');
+
+            // 遍历新数组设置 qualityResults 默认值
+            this.schemeList.forEach((item) => {
+              if (typeof item === 'object' && item !== null) {
+                item.qualityResults = 1; // 设置默认值
+              }
+              delete item.id;
+            });
+
+            console.log(oldItem, 'oldItem');
+            console.log(count, newMeasureQuantity, newWeight);
+            delete oldItem.id;
+
+            if (
+              oldItem.qualitySampleTemplateList == undefined ||
+              oldItem.qualitySampleTemplateList == null ||
+              oldItem.qualitySampleTemplateList.length == 0
+            ) {
+              oldItem.qualitySampleTemplateList = JSON.parse(
+                JSON.stringify(this.schemeList)
+              );
+              for (let i = 0; i < count; i++) {
+                ProductSampleList.push({
+                  ...oldItem,
+                  measureQuantity: newMeasureQuantity,
+                  weight: newWeight,
+                  sampleCode: await this.getSampleCode(),
+                  qualitySampleTemplateList: JSON.parse(
+                    JSON.stringify(this.schemeList)
+                  )
+                });
+              }
+              console.log(ProductSampleList, 'ProductSampleList');
+              this.sampleList = ProductSampleList;
+              const pNum = ProductSampleList.reduce((sum, item) => {
+                return sum + Number(item.weight || 0);
+              }, 0);
+              this.form.totalWeight = parseFloat(pNum.toFixed(2));
+            } else {
+              for (let i = 0; i < count; i++) {
+                ProductSampleList.push({
+                  ...oldItem,
+                  measureQuantity: newMeasureQuantity,
+                  weight: newWeight,
+                  sampleCode: await this.getSampleCode(),
+                  qualitySampleTemplateList: JSON.parse(
+                    JSON.stringify(oldItem.qualitySampleTemplateList)
+                  )
+                });
+              }
+              console.log(ProductSampleList, 'ProductSampleList');
+              this.sampleList = ProductSampleList;
+              const pNum = ProductSampleList.reduce((sum, item) => {
+                return sum + Number(item.weight || 0);
+              }, 0);
+              this.form.totalWeight = parseFloat(pNum.toFixed(2));
+            }
+          }
+        }
+      },
+      // 全检计量计重的样品清单函数
+      async updatePackingList(list, sampleCount) {
+        // for (let i = 0; i < list.length; i++) {
+        //   list[i].sampleCode = await this.getSampleCode();
+        // }
+
+        const dataList = [];
+        let currentNum = sampleCount - list.length;
+        let currentNum1 = sampleCount;
+        // console.log(this.selectedList);
+
+        for (const item of list) {
+          const qualitySampleTemplateList = item.qualitySampleTemplateList
+            ?.length
+            ? JSON.parse(JSON.stringify(item.qualitySampleTemplateList))
+            : JSON.parse(
+                JSON.stringify(
+                  this.schemeList.map((item) => {
+                    item['qualityResults'] = 1;
+                    return item;
+                  })
+                )
+              );
+
+          if (sampleCount >= list.length) {
+            dataList.push({
+              ...item,
+              measureQuantity: item.measureQuantity, //作为计量数量
+              sampleCode: await this.getSampleCode(),
+              qualitySampleTemplateList
+            });
+          }
+        }
+
+        this.sampleList = dataList;
+        this.sampleNumber = this.sampleList.length;
+      },
+      // 切换检验方式为全检后生成样品
+      changeGetSampleList(list) {
+        this.$message('正在生成样品清单');
+        console.log(list);
+        console.log(this.form.total);
+
+        // 计量类型1是数量,2是重量
+        if (this.form.inspectionStandards == 1) {
+          this.createSampleList(list);
+        }
+        if (this.form.inspectionStandards == 2) {
+          this.updatePackingList(list, this.form.total);
+          // this.handleWeightFullSample(this.form.total);
+        }
+      },
+
       //输入取样数量
       changeNumber(val) {
         if (this.form.qualityMode !== 2) {
@@ -459,32 +531,47 @@
         }
       },
 
-      // async open(req) {
-      //   this.equipmentdialog = true;
-      //   console.log('弹窗打开了.....');
-      //   console.log(req);
-      //   console.log(req[workOrderId]);
-      //   console.log(req.workOrderId);
-      //   // this.getDetail(req.workOrderId);
-      //   this.type = this.$route.query.type;
-      //   this.qualityType = this.$route.query.qualityType;
-
-      //   this.title =
-      //     this.type == 'add' ? '新增' : this.type == 'edit' ? '报工' : '详情';
-
-      //   if (this.type == 'add') {
-      //     const code = await getCode('quality_work_order_code');
-      //     this.form.code = code;
-      //   } else {
-      //     if (
-      //       this.$route.query.qualityTimeStart != '' ||
-      //       this.$route.query.qualityTimeStart != null ||
-      //       this.$route.query.qualityTimeStart != undefined
-      //     ) {
-      //       this.qualityTimeStart = this.getNowTime();
-      //     }
-      //   }
-      // },
+      async open(req) {
+        this.visible = true;
+        this.dataWork = req.data;
+        this.getDetail(req.workOrderId);
+        this.type = req.data.type ? req.data.type : req.type;
+        this.qualityType = req.data.qualityType ? req.data.qualityType : '';
+
+        this.title =
+          this.type == 'add' ? '新增' : this.type == 'edit' ? '报工' : '详情';
+
+        if (this.type == 'add') {
+          const code = await getCode('quality_work_order_code');
+          this.form.code = code;
+        } else {
+          if (
+            req.data.qualityTimeStart != '' ||
+            req.data.qualityTimeStart != null ||
+            req.data.qualityTimeStart != undefined
+          ) {
+            this.qualityTimeStart = this.getNowTime();
+          }
+        }
+        // this.type = this.$route.query.type;
+        // this.qualityType = this.$route.query.qualityType;
+
+        // this.title =
+        //   this.type == 'add' ? '新增' : this.type == 'edit' ? '报工' : '详情';
+
+        // if (this.type == 'add') {
+        //   const code = await getCode('quality_work_order_code');
+        //   this.form.code = code;
+        // } else {
+        //   if (
+        //     this.$route.query.qualityTimeStart != '' ||
+        //     this.$route.query.qualityTimeStart != null ||
+        //     this.$route.query.qualityTimeStart != undefined
+        //   ) {
+        //     this.qualityTimeStart = this.getNowTime();
+        //   }
+        // }
+      },
       getNowTime() {
         const nowDate = this.getNowDate();
         return (
@@ -506,38 +593,36 @@
         return nowDate.year + '-' + nowDate.month + '-' + nowDate.strDate;
       },
       async getDetail(id) {
-        getById(id)
-          .then((res) => {
-            if (!res.qualifiedNumber) {
-              res.qualifiedNumber = res.total;
-            }
-
-            this.form = res.data;
+        getById(id).then((res) => {
+          this.form = res.data;
+          this.statusType = this.form.status == 1 ? true : false;
 
-            this.isReportProcessProduce =
-              this.form.isReportProcessProduce == 1 ? true : false;
+          this.isReportProcessProduce =
+            this.form.isReportProcessProduce == 1 ? true : false;
 
-            this.tabTaskId =
-              this.categoryParamList[0] && this.categoryParamList[0].id;
+          this.tabTaskId =
+            this.categoryParamList[0] && this.categoryParamList[0].id;
 
-            if (this.form.groupId) {
-              this.$nextTick(() => {
-                this.$refs.baseInfoRefs?.getUserList({
-                  groupId: this.form.groupId
-                });
+          if (this.form.groupId) {
+            this.$nextTick(() => {
+              this.$refs.baseInfoRefs?.getUserList({
+                groupId: this.form.groupId
               });
-            }
-            if (this.form.produceRoutingId) {
-              this.$nextTick(() => {
-                this.$refs.baseInfoRefs?.getTaskList();
-              });
-            }
-          })
-          .catch((error) => console.error('Error fetching data:', error));
+            });
+          }
+          if (this.form.produceRoutingId) {
+            this.$nextTick(() => {
+              this.$refs.baseInfoRefs?.getTaskList();
+            });
+          }
+        });
 
         // await this.queryQualityInventory()
+        // 质检方案
         await this.queryQualityTempleContent();
+        // 样品清单
         await this.queryQualitySamplContent();
+        // 来源清单
         await this.getQueryQualityInventory();
       },
       // getNewData(val) {
@@ -662,14 +747,13 @@
         console.log(unit, '所选单位');
         console.log(sampleCount, '数量');
         try {
-          console.log(this.isStandard1OrWeightSample());
-          console.log(this.isWeightStandardFullSample());
           if (this.isStandard1OrWeightSample()) {
             //抽检计量整样小样或者抽检计重小样
             if (!this.validateMeasureQuantity(measureQ, unit, sampleCount))
               return; //取样数量验证
             if (unit === 'KG' && !this.validateWeight(measureQ, sampleCount))
               return; // 若计量单位为重量,还需验证总重量是否足够
+            console.log(1111111111111);
 
             await this.getNewFullSampleList(
               Math.ceil(sampleCount),
@@ -677,13 +761,14 @@
               unit
             );
           } else if (this.isWeightStandardFullSample()) {
-            console.log('1111111111111');
             //抽检取计重取整样
             if (!this.validateSampleCount(sampleCount)) return;
-            console.log('1111111111111');
+            console.log(222222222222222222);
             await this.handleWeightFullSample(sampleCount);
           }
           this.activeName = '2';
+
+          this.$refs.tabsRef.tabsChange('2');
         } catch (error) {
           console.error('取样处理失败:', error);
           this.$message.error('取样处理失败');
@@ -702,6 +787,8 @@
           return;
         }
         this.activeName = '2';
+        this.$refs.tabsRef.tabsChange('2');
+
         if (this.form.isUnpack == 1) {
           // 1 拆包 2 不拆
           let measureQuantity = 1;
@@ -806,12 +893,14 @@
 
       async queryQualitySamplContent() {
         const res = await queryQualitySamplContent({
-          qualityWorkerId: this.dataWork.id,
+          qualityWorkerId: this.$route.query.id,
           size: 1000
         });
         let addStatus = res.list.map((item) => {
           item.isValid = true;
-          item.disposeTime = item.disposeTime ? item.disposeTime : null;
+          // item.disposeTime = item.disposeTime
+          //   ? item.disposeTime.split(' ')[0]
+          //   : null;
           item.sampleDate = item.sampleDate
             ? item.sampleDate.split(' ')[0]
             : null;
@@ -829,12 +918,15 @@
       },
       async queryQualityTempleContent() {
         const res = await queryQualityTempleContent({
-          qualityWorkerId: this.dataWork.id
+          qualityWorkerId: this.$route.query.id
         });
         console.log(res, '质检方案');
         this.schemeList = res.list;
       },
+      // 取样
       getConditionType(val) {
+        console.log(val, '------取样的回调');
+
         this.form.conditionType = val;
       },
 
@@ -848,8 +940,6 @@
           if (!valid) {
             return false;
           }
-
-          // this.type = 'edit';
           // this.loading = true;
           let URL =
             this.type == 'add' ? save : this.type == 'edit' ? update : '';
@@ -858,20 +948,23 @@
 
           delete this.form['qualityTimeEnd'];
 
+          console.log(this.sampleList);
+
           let params = {
             ...this.form,
             sampleList: this.sampleList,
             planTemplateList: this.schemeList,
             templateList: this.schemeList,
+            // qualityInventoryList: this.$refs.tabsRef.$refs.sourceTable.getData()
             qualityInventoryList: this.inventoryList
           };
           console.log(params, 'params ----');
+
           URL(params)
             .then((msg) => {
               this.loading = false;
               this.$message.success(msg);
-              this.visible = false;
-              // this.cancel();
+              this.cancel();
               this.$emit('done');
             })
             .catch((e) => {
@@ -926,18 +1019,22 @@
         }, 0);
         this.form.totalWeight = parseFloat(pNum.toFixed(2));
       },
-      handleDispose(index, row, type) {
-        if (!this.sampleList[index]) {
-          return;
-        }
+      handleDispose(data) {
+        console.log(data);
+        // return
+        this.rowData = data;
+        this.sampleDisposeVisble = true;
+        // if (!this.sampleList[index]) {
+        //   return;
+        // }
 
-        this.sampleList[index].sampleDate = this.getNowTimes();
+        // this.sampleList[index].sampleDate = this.getNowTimes();
 
-        this.sampleList[index].disposeTime = this.getNowTimes();
+        // this.sampleList[index].disposeTime = this.getNowTimes();
 
-        console.log(index, row, type, this.qualityType);
+        // console.log(index, row, type, this.qualityType);
 
-        this.$refs.disposeRef.openDispose(index, row, type, this.qualityType);
+        // this.$refs.disposeRef.openDispose(index, row, type, this.qualityType);
       },
       // 报工
       handleReporting(index, row) {
@@ -974,34 +1071,32 @@
               return;
             }
           }
-          console.log();
+
+          // this.form.qualityTimeEnd = new Date(this.getNowTime());
+          // this.form.qualityTimeStart = new Date(this.qualityTimeStart);
 
           this.form.qualityTimeEnd = this.getNowTime();
           this.form.qualityTimeStart = this.qualityTimeStart;
 
+          console.log(this.form.qualityTimeStart, this.form.qualityTimeEnd);
+
           // if (this.form.qualityMode == 1) {
           //   this.form.qualityResults = '';
           // }
 
-          // if (this.schemeList.length == 0) {
-          //   this.$message.error('样品清单不能为空!');
-          //   return;
-          // }
-
           let params = {
             ...this.form,
             sampleList: this.sampleList,
             planTemplateList: this.schemeList,
-            qualityInventoryList: this.inventoryList
             // qualityInventoryList: this.$refs.tabsRef.$refs.sourceTable.getData()
+            qualityInventoryList: this.inventoryList
           };
           console.log(params, 'params');
+
           exeReportWork(params)
             .then((msg) => {
               this.loading = false;
               this.$message.success(msg);
-              this.visible = false;
-              // this.$emit('close', false);
               // this.cancel();
               this.$emit('done');
             })
@@ -1013,20 +1108,24 @@
       // 处理确认事件
       handleDisposeConfirm(data, index) {
         console.log(data, index, '确认处置事件');
+        console.log(this.sampleList);
 
-        if (index != null) {
-          this.$set(this.sampleList, index, data);
-        } else {
+        if (index == undefined) {
           this.sampleList.forEach((obj) => {
-            obj.disposalStatus = data.disposalStatus;
+            obj.disposeType = data.disposeType;
             obj.sampleDate = data.sampleDate;
-            obj.disposeTime = data.disposeTime;
             obj.sampleCondition = data.sampleCondition;
             obj.producerManufacturer = data.producerManufacturer;
             obj.samplePlace = data.samplePlace;
             obj.sampleRemark = data.sampleRemark;
+            obj.depotId = data.depotId;
+            obj.depotName = data.depotName;
           });
+        } else {
+          this.$set(this.sampleList, index, data);
         }
+
+        console.log(this.sampleList);
       },
       //确认质检
       handleConfirm(list, index) {
@@ -1103,12 +1202,18 @@
       },
       // 批量处置
       batchDispose() {
-        this.$refs.disposeRef.openDispose(
-          null,
-          null,
-          'dispose',
-          this.qualityType
-        );
+        if (this.sampleList && this.sampleList.length) {
+          this.sampleDisposeVisble = true;
+          return;
+        }
+        this.$message('当前没有样品清单可以处置');
+
+        // this.$refs.disposeRef.openDispose(
+        //   null,
+        //   null,
+        //   'dispose',
+        //   this.qualityType
+        // );
       },
 
       //全检,检验标准改变时,重新获取样品列表
@@ -1242,6 +1347,10 @@
           }
         }
         this.sampleList = result;
+        if (this.sampleList.length > sampleCount) {
+          this.sampleList = this.sampleList.splice(0, sampleCount);
+        }
+
         this.form.sampleNumber = this.sampleList.length;
       },
       validateWeight(measureQ, sampleCount) {
@@ -1324,10 +1433,21 @@
         );
       },
 
+      handleClose() {
+        this.visible = false;
+        this.$emit('close');
+      },
+
       validateSampleCount(sampleCount) {
-        const invalidItem = this.selectedList.find(
-          (item) => item.measureQuantity < sampleCount
-        );
+        const chooseNumber = this.selectedList.reduce((acc, pro) => {
+          return pro.measureQuantity ? acc + Number(pro.measureQuantity) : acc;
+        }, 0);
+
+        const invalidItem = chooseNumber < sampleCount;
+        // console.log(this.selectedList, 'this.selectedList');
+        // const invalidItem = this.selectedList.find(
+        //   (item) => item.measureQuantity < sampleCount
+        // );
         if (invalidItem) {
           this.$message.info('所选的条目计量数量小于取样计量数量');
           return false;
@@ -1336,22 +1456,59 @@
       },
 
       async handleWeightFullSample(sampleCount) {
+        console.log(sampleCount);
+
+        const dataList = [];
+        let currentNum = sampleCount - this.selectedList.length;
+        let currentNum1 = sampleCount;
+        console.log(this.selectedList);
+
         for (const item of this.selectedList) {
           const qualitySampleTemplateList = item.qualitySampleTemplateList
             ?.length
             ? JSON.parse(JSON.stringify(item.qualitySampleTemplateList))
-            : JSON.parse(JSON.stringify(this.schemeList));
-          console.log(
-            this.isStandard1OrWeightSample(),
-            'this.isStandard1OrWeightSample()'
-          );
-          this.sampleList.push({
-            ...item,
-            measureQuantity: sampleCount, //作为计量数量
-            sampleCode: await this.getSampleCode(),
-            qualitySampleTemplateList
+            : JSON.parse(
+                JSON.stringify(
+                  this.schemeList.map((item) => {
+                    item['qualityResults'] = 1;
+                    return item;
+                  })
+                )
+              );
+
+          if (sampleCount >= this.selectedList.length) {
+            dataList.push({
+              ...item,
+              measureQuantity: 1, //作为计量数量
+              sampleCode: await this.getSampleCode(),
+              qualitySampleTemplateList
+            });
+          } else {
+            if (dataList.length < sampleCount) {
+              dataList.push({
+                ...item,
+                measureQuantity: currentNum1 > 1 ? 1 : currentNum1, //作为计量数量
+                sampleCode: await this.getSampleCode(),
+                qualitySampleTemplateList
+              });
+              currentNum1 -= 1;
+            }
+          }
+        }
+        if (sampleCount > this.selectedList.length) {
+          dataList.forEach((item) => {
+            if (currentNum > 0) {
+              let data = this.selectedList.find((val) => val.id == item.id);
+              item['measureQuantity'] =
+                data.measureQuantity - 1 - currentNum > 0
+                  ? currentNum + 1
+                  : data.measureQuantity;
+              currentNum = currentNum - (data.measureQuantity - 1);
+            }
           });
         }
+
+        this.sampleList = dataList;
         this.sampleNumber = this.sampleList.length;
       },
 
@@ -1389,6 +1546,11 @@
           qualificationRate,
           noQualificationRate
         );
+      },
+      closeDispose() {
+        this.rowData = null;
+        this.sampleDisposeVisble = false;
+        // this.rowData = null;
       }
     }
   };

+ 19 - 5
src/views/produce/components/workPlan/index.vue

@@ -1,5 +1,5 @@
 <template>
-  <el-dialog
+  <ele-modal
     :visible.sync="visible"
     :before-close="handleClose"
     :close-on-click-modal="true"
@@ -134,9 +134,9 @@
         @closeModel="closeModel"
       />
 
-      <edit ref="editRef" />
+      <edit ref="editRef" @close="close" />
     </div>
-  </el-dialog>
+  </ele-modal>
 </template>
 <script>
   import Certificate from './components/Certificate.vue';
@@ -146,7 +146,8 @@
   import {
     getList,
     removeItem,
-    updateCertificateNumber
+    updateCertificateNumber,
+    verificationQualityInspector
   } from '@/api/inspectionWork';
   import dictMixins from '@/mixins/dictMixins';
   import { getFile } from '@/api/system/file';
@@ -495,7 +496,15 @@
         // });
       },
 
-      openEdit(type, row) {
+      async openEdit(type, row) {
+        if (type == 'edit') {
+          const code = await verificationQualityInspector(row.id);
+          if (code == '-1') {
+            console.log('不是报工人');
+            return;
+          }
+        }
+
         const req = {
           workOrderId: row.id,
           data: row,
@@ -567,6 +576,11 @@
         this.$emit('close', false);
       },
 
+      close() {
+        console.log('关闭报工界面');
+        this.done();
+      },
+
       async getTnspectionPlanType() {
         let res = await getByCode('inspection_plan_type');
         if (res?.code == 0) {

File diff suppressed because it is too large
+ 129 - 189
yarn.lock


Some files were not shown because too many files changed in this diff