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

Merge branch 'dev' of http://110.41.163.243:9980/kd-aiot/kd-aiot-frontend-mes into dev

lucw 1 год назад
Родитель
Сommit
44e152e61b

+ 8 - 1
src/api/produce/index.js

@@ -156,4 +156,11 @@ export async function isJuRen(data) {
   }
   return Promise.reject(new Error(res.data.message));
 }
-// http://localhost:8084/api/main/asset/pdaPage?categoryLevelId=9&keyWord=&pageNum=1&size=100&taskId=1894207928134549506
+
+export async function pleaseEntrustManagement(data) {
+  const res = await request.post(`/mes/please_entrust_management/add`, data);
+  if (res.data.code == 0) {
+    return res.data;
+  }
+  return Promise.reject(new Error(res.data.message));
+}

+ 7 - 1
src/config/setting.js

@@ -21,7 +21,13 @@ export const SYSTEM_NAME = 'mes';
 export const REPEATABLE_TABS = [];
 
 // 不需要登录的路由
-export const WHITE_LIST = ['/login', '/forget', '/singleLogin'];
+export const WHITE_LIST = [
+  '/login',
+  '/forget',
+  '/singleLogin',
+  '/printJuren',
+  '/printJuRenOne'
+];
 
 // 开启 KeepAlive 后仍然不需要缓存的路由地址
 export const KEEP_ALIVE_EXCLUDES = [];

+ 61 - 5
src/views/produce/components/feeding/components/batchProductsBom.vue

@@ -80,7 +80,7 @@
           <el-input v-model="form.batchNo"></el-input>
         </el-form-item>
         <el-form-item label="拆批数">
-          <el-input v-model="form.quantity"></el-input>
+          <el-input v-model="form.quantity" @input="batchInput"></el-input>
         </el-form-item>
       </el-form>
       <span slot="footer" class="dialog-footer">
@@ -270,6 +270,24 @@
         this.dialogVisible = true;
       },
 
+      batchInput(val) {
+        let newVal = val.replace(/[^\d.]/g, '');
+
+        if (newVal.startsWith('.')) {
+          newVal = '';
+        }
+
+        const firstDotIndex = newVal.indexOf('.');
+        if (firstDotIndex !== -1) {
+          newVal =
+            newVal.slice(0, firstDotIndex + 1) +
+            newVal.slice(firstDotIndex + 1).replace(/\./g, '');
+        }
+
+        const match = newVal.match(/^(\d+)(\.\d{0,4})?/);
+        this.form.quantity = match ? match[0] : '';
+      },
+
       async getQualityParam() {
         if (this.form.quantity && this.form.batchNo) {
           if (Number(this.itemData.feedQuantity) == 0) {
@@ -291,16 +309,22 @@
               dataList.push(this.deepCopy(item));
             });
 
-            this.refreshData(dataList);
+            if (dataList.length != 0) {
+              this.refreshData(dataList);
+            }
           });
         }
         this.dialogVisible = false;
       },
 
       refreshData(list) {
-        const number =
-          Number(this.list[this.itemIndex].feedQuantity) -
-          Number(this.form.quantity);
+        // const number =
+        //   Number(this.list[this.itemIndex].feedQuantity) -
+        //   Number(this.form.quantity);
+        const number = this.sub(
+          Number(this.list[this.itemIndex].feedQuantity),
+          Number(this.form.quantity)
+        );
         this.list[this.itemIndex].extInfo.sourceQuantity = number;
         this.list[this.itemIndex].feedQuantity = number;
         this.list[this.itemIndex].extInfo.newWeight =
@@ -324,6 +348,38 @@
         this.$set(this.itemObj, 'product', this.list);
       },
 
+      toInteger(num) {
+        const len = this.getDecimalLength(num);
+        return {
+          int: Math.round(num * Math.pow(10, len)),
+          factor: Math.pow(10, len)
+        };
+      },
+
+      add(a, b) {
+        const { int: aInt, factor: aFactor } = this.toInteger(a);
+        const { int: bInt, factor: bFactor } = this.toInteger(b);
+        const maxFactor = Math.max(aFactor, bFactor);
+        return (
+          (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
+          maxFactor
+        );
+      },
+
+      sub(a, b) {
+        const { int: aInt, factor: aFactor } = this.toInteger(a);
+        const { int: bInt, factor: bFactor } = this.toInteger(b);
+        const maxFactor = Math.max(aFactor, bFactor);
+        return (
+          (aInt * (maxFactor / aFactor) - bInt * (maxFactor / bFactor)) /
+          maxFactor
+        );
+      },
+
+      getDecimalLength(num) {
+        return (num.toString().split('.')[1] || '').length;
+      },
+
       deepCopy(obj, hash = new WeakMap()) {
         if (obj === null) return null;
         if (obj instanceof Date) return new Date(obj);

+ 119 - 39
src/views/produce/components/jobBooking/components/batchSemiProductJobBom.vue

@@ -12,7 +12,8 @@
             item.currentTaskDiagram.type == 4 &&
             this.printStyle != 'notExist'
           "
-          ><el-button type="text" size="mini" @click="pritJuRen()"
+        >
+          <el-button type="text" size="mini" @click="pritJuRen()"
             >打印条码</el-button
           >
         </div>
@@ -552,6 +553,7 @@
           <el-input
             v-model="batchForm.quantity"
             style="width: 220px"
+            @input="batchInput"
           ></el-input>
           {{ batchForm.unit }}
         </el-form-item>
@@ -596,7 +598,11 @@
             batchForm.notType != 8
           "
         >
-          <el-input v-model="batchForm.notReason" placeholder="原因" />
+          <el-input
+            v-model="batchForm.notReason"
+            placeholder="原因"
+            style="width: 220px"
+          />
         </el-form-item>
         <!--  <div
             v-if="![1, 2, 3, 4, 6, 9, 7].includes(Number(batchForm.notType))"
@@ -648,7 +654,11 @@
           <el-input v-model="lossForm.batchNo" style="width: 220px"></el-input>
         </el-form-item>
         <el-form-item label="损耗数">
-          <el-input v-model="lossForm.quantity" style="width: 220px"></el-input>
+          <el-input
+            v-model="lossForm.quantity"
+            style="width: 220px"
+            @input="lossInput"
+          ></el-input>
           {{ lossForm.unit }}
         </el-form-item>
       </el-form>
@@ -657,6 +667,9 @@
         <el-button type="primary" @click="getLossParam">确 定</el-button>
       </span>
     </el-dialog>
+
+    <juRenPackOne ref="juRenPackOneRef" />
+    <juRenPack ref="juRenPackRef" />
   </div>
 </template>
 
@@ -670,10 +683,13 @@
   import { parameterGetByCode } from '@/api/system/dictionary-data';
   import { splitBatch } from '@/api/produce/feeding';
   import { juRenPrint, isJuRen } from '@/api/produce';
+  import juRenPackOne from '../../juRenPackOne.vue';
+  import juRenPack from '../../juRenPack.vue';
 
   export default {
     name: 'semiProductJobBom',
     mixins: [tabMixins],
+    components: { juRenPackOne, juRenPack },
     props: {
       list: {
         type: Array,
@@ -1246,12 +1262,15 @@
       sumweight(arr) {
         let formedWeight = 0;
         let noFormedWeight = 0;
+        let lossWeight = 0;
         arr.map((s, i) => {
           if (s.extInfo.reportWeight) {
-            if (s.extInfo.isQualified == 1) {
+            if (s.extInfo.isQualified == 1 && !s.extInfo.isLoss) {
               formedWeight += s.extInfo.reportWeight * 1;
-            } else {
+            } else if (!s.extInfo.isLoss) {
               noFormedWeight += s.extInfo.reportWeight * 1;
+            } else if (s.extInfo.isLoss == 1) {
+              lossWeight += s.extInfo.reportWeight * 1;
             }
           } else {
             s.extInfo.reportWeight = null;
@@ -1265,12 +1284,17 @@
 
         if (this.item.workReportInfo) {
           this.item.workReportInfo.formedWeight = parseFloat(
-            formedWeight.toFixed(2)
+            formedWeight.toFixed(4)
           );
           this.item.workReportInfo.notFormedWeight = parseFloat(
-            noFormedWeight.toFixed(2)
+            noFormedWeight.toFixed(4)
+          );
+          this.item.workReportInfo.lossWeight = parseFloat(
+            lossWeight.toFixed(4)
           );
         }
+
+        console.log(this.item.workReportInfo, 'this.item.workReportInfo');
       },
 
       async getCodeData() {
@@ -1405,6 +1429,24 @@
         this.batchVisible = true;
       },
 
+      batchInput(val) {
+        let newVal = val.replace(/[^\d.]/g, '');
+
+        if (newVal.startsWith('.')) {
+          newVal = '';
+        }
+
+        const firstDotIndex = newVal.indexOf('.');
+        if (firstDotIndex !== -1) {
+          newVal =
+            newVal.slice(0, firstDotIndex + 1) +
+            newVal.slice(firstDotIndex + 1).replace(/\./g, '');
+        }
+
+        const match = newVal.match(/^(\d+)(\.\d{0,4})?/);
+        this.batchForm.quantity = match ? match[0] : '';
+      },
+
       async getQualityParam() {
         if (this.batchForm.quantity && this.batchForm.batchNo) {
           if (Number(this.itemData.feedQuantity) == 0) {
@@ -1445,9 +1487,13 @@
       },
 
       refreshData(list) {
-        const number =
-          Number(this.list[this.itemIndex].feedQuantity) -
-          Number(this.batchForm.quantity);
+        // const number =
+        //   Number(this.list[this.itemIndex].feedQuantity) -
+        //   Number(this.batchForm.quantity);
+        const number = this.sub(
+          Number(this.list[this.itemIndex].feedQuantity),
+          Number(this.batchForm.quantity)
+        );
         this.list[this.itemIndex].extInfo.sourceQuantity = number;
         this.list[this.itemIndex].feedQuantity = number;
         this.list[this.itemIndex].extInfo.newWeight =
@@ -1479,6 +1525,38 @@
         }, result);
       },
 
+      toInteger(num) {
+        const len = this.getDecimalLength(num);
+        return {
+          int: Math.round(num * Math.pow(10, len)),
+          factor: Math.pow(10, len)
+        };
+      },
+
+      add(a, b) {
+        const { int: aInt, factor: aFactor } = this.toInteger(a);
+        const { int: bInt, factor: bFactor } = this.toInteger(b);
+        const maxFactor = Math.max(aFactor, bFactor);
+        return (
+          (aInt * (maxFactor / aFactor) + bInt * (maxFactor / bFactor)) /
+          maxFactor
+        );
+      },
+
+      sub(a, b) {
+        const { int: aInt, factor: aFactor } = this.toInteger(a);
+        const { int: bInt, factor: bFactor } = this.toInteger(b);
+        const maxFactor = Math.max(aFactor, bFactor);
+        return (
+          (aInt * (maxFactor / aFactor) - bInt * (maxFactor / bFactor)) /
+          maxFactor
+        );
+      },
+
+      getDecimalLength(num) {
+        return (num.toString().split('.')[1] || '').length;
+      },
+
       openLoss(item, index) {
         this.lossForm.quantity = '';
         this.lossForm.unit = '';
@@ -1490,6 +1568,24 @@
         this.lossVisible = true;
       },
 
+      lossInput(val) {
+        let newVal = val.replace(/[^\d.]/g, '');
+
+        if (newVal.startsWith('.')) {
+          newVal = '';
+        }
+
+        const firstDotIndex = newVal.indexOf('.');
+        if (firstDotIndex !== -1) {
+          newVal =
+            newVal.slice(0, firstDotIndex + 1) +
+            newVal.slice(firstDotIndex + 1).replace(/\./g, '');
+        }
+
+        const match = newVal.match(/^(\d+)(\.\d{0,4})?/);
+        this.lossForm.quantity = match ? match[0] : '';
+      },
+
       async getLossParam() {
         if (this.lossForm.quantity && this.lossForm.batchNo) {
           if (
@@ -1519,9 +1615,13 @@
       },
 
       refreshLossData(list) {
-        const number =
-          Number(this.list[this.lossIndex].feedQuantity) -
-          Number(this.lossForm.quantity);
+        // const number =
+        //   Number(this.list[this.lossIndex].feedQuantity) -
+        //   Number(this.lossForm.quantity);
+        const number = this.sub(
+          Number(this.list[this.lossIndex].feedQuantity),
+          Number(this.lossForm.quantity)
+        );
         this.list[this.lossIndex].extInfo.sourceQuantity = number;
         this.list[this.lossIndex].feedQuantity = number;
         this.list[this.lossIndex].extInfo.newWeight =
@@ -1534,14 +1634,6 @@
         });
 
         const newList = this.list.filter((item) => item.feedQuantity != 0);
-        console.log(newList, 'newList新数据');
-
-        // this.$set(
-        //   this.item,
-        //   'product',
-        //   this.list.filter((item) => item.feedQuantity != 0)
-        // );
-
         let _arr = [...newList, ...list];
 
         this.$set(this.item, 'product', _arr);
@@ -1832,25 +1924,13 @@
       },
 
       pritJuRen() {
-        const {
-          batchNo,
-          createDate,
-          enforceStandards,
-          layBy,
-          level,
-          netWeight,
-          notice,
-          productName,
-          purchaseOrigins,
-          specification,
-          warrantyPeriod,
-          warrantyPeriodUnit,
-          weightUnit
-        } = this.printData;
-
         if (this.printStyle == 'juRen1') {
-          const query = `?batchNo=${batchNo}&createDate=${createDate}&enforceStandards=${enforceStandards}&layBy=${layBy}&level=${level}&netWeight=${netWeight}&notice=${notice}&productName=${productName}&purchaseOrigins=${purchaseOrigins}&specification=${specification}&warrantyPeriod=${warrantyPeriod}&warrantyPeriodUnit=${warrantyPeriodUnit}&weightUnit=${weightUnit}`;
-          window.open('/printJuren' + query, '_blank');
+          this.$refs.juRenPackOneRef.open(
+            this.printData,
+            this.item.workOrderId
+          );
+
+          // this.$refs.juRenPackRef.open(this.printData);
         }
       }
     },

+ 76 - 27
src/views/produce/components/jobBooking/components/jobBom.vue

@@ -45,7 +45,6 @@
                 v-model="item.workReportInfo.formedNum"
                 :disabled="isDetails"
                 placeholder="请输入合格品数量"
-                @input="blurNum"
               >
                 <template slot="append">{{ item.unit }}</template>
               </el-input>
@@ -78,7 +77,6 @@
                 v-model="item.workReportInfo.notFormedNum"
                 :disabled="isDetails"
                 placeholder="请输入不合格数量"
-                @input="changeNum"
               >
                 <template slot="append">{{ item.unit }}</template>
               </el-input>
@@ -110,6 +108,46 @@
           </div> -->
         </div>
 
+        <div class="item rx-sc">
+          <div class="rx ww40">
+            <div class="lable lable100 rx-cc">损耗数量</div>
+            <div class="content content_num rx-sc">
+              <el-input
+                size="mini"
+                v-model="item.workReportInfo.lossQuantity"
+                :disabled="isDetails"
+                placeholder=""
+              >
+                <template slot="append">{{ item.unit }}</template>
+              </el-input>
+            </div>
+          </div>
+
+          <div class="rx ww40">
+            <div class="lable rx-cc">重量</div>
+            <div class="content content_num rx-sc">
+              <el-input
+                size="mini"
+                v-model="item.workReportInfo.lossWeight"
+                :disabled="isDetails"
+                placeholder=""
+              >
+                <template slot="append">{{ item.weightUnit }}</template>
+              </el-input>
+            </div>
+          </div>
+
+          <!-- <div class="rw ww20 rx-cc">
+            <div class="penalize" v-if="!isDetails" :style="{ background: not.warehouseId ? '#FFA07A' : '' }"
+              @click="penalize">
+              处置</div>
+            <div class="penalize" v-if="isDetails" :style="{ background: not.warehouseId ? '#FFA07A' : '' }" @click="
+              handleView(isDetails ? not.warehouseName : item.warehouseName)
+              ">
+              查看</div>
+          </div> -->
+        </div>
+
         <!-- 报工备注 -->
         <div class="item rx-sc">
           <div
@@ -257,6 +295,7 @@
           if (newVal.product && newVal.product.length != 0) {
             let formedNum = 0;
             let notFormedNum = 0;
+            let lossNum = 0;
 
             newVal.product.forEach((item) => {
               if (
@@ -267,28 +306,28 @@
               ) {
                 // formedNum = formedNum + Number(item.feedQuantity);
                 formedNum = this.add(formedNum, Number(item.feedQuantity));
-              } else {
-                if (
-                  (item.extInfo.notType == 5 || item.extInfo.notType == 8) &&
-                  !item.extInfo.isLoss
-                ) {
+              } else if (!item.extInfo.isLoss) {
+                if (item.extInfo.notType == 5 || item.extInfo.notType == 8) {
                   // formedNum = formedNum + Number(item.feedQuantity);
 
                   formedNum = this.add(formedNum, Number(item.feedQuantity));
                 } else {
                   // notFormedNum = notFormedNum + Number(item.feedQuantity);
-                  if (!item.extInfo.isLoss) {
-                    notFormedNum = this.add(
-                      notFormedNum,
-                      Number(item.feedQuantity)
-                    );
-                  }
+                  // if (!item.extInfo.isLoss) {
+                  notFormedNum = this.add(
+                    notFormedNum,
+                    Number(item.feedQuantity)
+                  );
+                  // }
                 }
+              } else if (item.extInfo.isLoss == 1) {
+                lossNum = this.add(lossNum, Number(item.feedQuantity));
               }
             });
 
             this.$set(this.item.workReportInfo, 'formedNum', formedNum);
             this.$set(this.item.workReportInfo, 'notFormedNum', notFormedNum);
+            this.$set(this.item.workReportInfo, 'lossQuantity', lossNum);
           }
 
           // if (
@@ -386,6 +425,16 @@
         );
       },
 
+      sub(a, b) {
+        const { int: aInt, factor: aFactor } = this.toInteger(a);
+        const { int: bInt, factor: bFactor } = this.toInteger(b);
+        const maxFactor = Math.max(aFactor, bFactor);
+        return (
+          (aInt * (maxFactor / aFactor) - bInt * (maxFactor / bFactor)) /
+          maxFactor
+        );
+      },
+
       getDecimalLength(num) {
         return (num.toString().split('.')[1] || '').length;
       },
@@ -410,13 +459,13 @@
       },
 
       blurNum() {
-        let total =
-          Number(this.item.workReportInfo.formedNum) +
-          Number(this.item.workReportInfo.notFormedNum);
-        if (total > this.item.formingNum) {
-          this.item.workReportInfo.formedNum = 0;
-          this.$message.warning('合格品数量加不合格数量不能大于要求生产数量');
-        }
+        // let total =
+        //   Number(this.item.workReportInfo.formedNum) +
+        //   Number(this.item.workReportInfo.notFormedNum);
+        // if (total > this.item.formingNum) {
+        //   this.item.workReportInfo.formedNum = 0;
+        //   this.$message.warning('合格品数量加不合格数量不能大于要求生产数量');
+        // }
 
         // let total =
         //   Number(this.item.workReportInfo.formedNum) +
@@ -507,13 +556,13 @@
       },
 
       changeNum() {
-        let total =
-          Number(this.item.workReportInfo.formedNum) +
-          Number(this.item.workReportInfo.notFormedNum);
-        if (total > this.item.formingNum) {
-          this.item.workReportInfo.notFormedNum = 0;
-          this.$message.warning('合格品数量加不合格数量不能大于要求生产数量');
-        }
+        // let total =
+        //   Number(this.item.workReportInfo.formedNum) +
+        //   Number(this.item.workReportInfo.notFormedNum);
+        // if (total > this.item.formingNum) {
+        //   this.item.workReportInfo.notFormedNum = 0;
+        //   this.$message.warning('合格品数量加不合格数量不能大于要求生产数量');
+        // }
         // this.notForme();
         // this.blurNum()
       },

+ 2 - 2
src/views/produce/components/jobBooking/components/semiProductJobBom.vue

@@ -1033,10 +1033,10 @@
 
           if (this.item.workReportInfo) {
             this.item.workReportInfo.formedWeight = parseFloat(
-              formedWeight.toFixed(2)
+              formedWeight.toFixed(4)
             );
             this.item.workReportInfo.notFormedWeight = parseFloat(
-              noFormedWeight.toFixed(2)
+              noFormedWeight.toFixed(4)
             );
           }
         }

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

@@ -942,7 +942,9 @@
                   formedWeight: null,
                   taskId: this.taskObj.id,
                   notFormedNum: null,
-                  notFormedWeigh: null
+                  notFormedWeight: null,
+                  lossNum: null,
+                  lossWeight: null
                 };
 
                 obj.notFormedList = [

+ 147 - 94
src/views/produce/components/juRenPack.vue

@@ -1,35 +1,87 @@
 <template>
-  <div class="label-container">
-    <!-- 第一行信息 -->
-    <div class="label-title">
-      <div class="label-info-left">
-        <div>{{ productName ? productName : ' ' }}</div>
-        <div>{{ purchaseOrigins ? purchaseOrigins : ' ' }}</div>
-        <div>{{ batchNo ? batchNo : ' ' }}</div>
-        <div>{{ specification ? specification : ' ' }}</div>
-        <div>{{ createDate ? createDate : ' ' }}</div>
-        <div>{{ layBy ? layBy : ' ' }}</div>
-        <div>{{ notice ? notice : ' ' }}</div>
-        <div>{{ enforceStandards ? enforceStandards : ' ' }}</div>
-      </div>
-
-      <div class="label-info-right">
-        <div class="right-div">{{ level ? level : ' ' }}</div>
-        <div class="right-div"
-          >{{ netWeight ? netWeight : ' '
-          }}{{ weightUnit ? weightUnit : ' ' }}</div
-        >
-        <div class="right-div"
-          >{{ warrantyPeriod ? warrantyPeriod : ' '
-          }}{{ warrantyPeriodUnit ? warrantyPeriodUnit : ' ' }}</div
+  <ele-modal
+    title="打印条码"
+    :visible.sync="QRvisible"
+    v-if="QRvisible"
+    width="800px"
+    :maxable="true"
+  >
+    <div id="printSection">
+      <div
+        style="
+          width: 90mm;
+          height: 60mm;
+          box-sizing: border-box;
+          font-size: 10px;
+          color: green;
+          margin: 0 auto;
+          font-weight: 700;
+        "
+      >
+        <!-- 第一行信息 -->
+        <div
+          style="
+            display: flex;
+            flex-direction: row;
+            padding: 0 45px;
+            box-sizing: border-box;
+          "
         >
+          <div
+            style="
+              display: flex;
+              flex-direction: column;
+              flex-wrap: wrap;
+              margin: 54px 0 0 62px;
+            "
+          >
+            <div style="height: 17px">{{
+              productName ? productName : ' '
+            }}</div>
+            <div style="height: 17px">{{
+              purchaseOrigins ? purchaseOrigins : ' '
+            }}</div>
+            <div style="height: 17px">{{ batchNo ? batchNo : ' ' }}</div>
+            <div style="height: 17px">{{
+              specification ? specification : ' '
+            }}</div>
+            <div style="height: 17px">{{ createDate ? createDate : ' ' }}</div>
+            <div style="height: 17px">{{ layBy ? layBy : ' ' }}</div>
+            <div style="height: 17px">{{ notice ? notice : ' ' }}</div>
+            <div style="height: 17px">{{
+              enforceStandards ? enforceStandards : ' '
+            }}</div>
+          </div>
+
+          <div
+            style="
+              display: flex;
+              flex-direction: column;
+              justify-content: center;
+              margin: 37px 0 1px 30px;
+            "
+          >
+            <div style="height: 17px">{{ level ? level : ' ' }}</div>
+            <div style="height: 17px"
+              >{{ netWeight ? netWeight : ' '
+              }}{{ weightUnit ? weightUnit : ' ' }}</div
+            >
+            <div style="height: 17px"
+              >{{ warrantyPeriod ? warrantyPeriod : ' '
+              }}{{ warrantyPeriodUnit ? warrantyPeriodUnit : ' ' }}</div
+            >
+          </div>
+        </div>
       </div>
     </div>
-  </div>
+    <div slot="footer">
+      <el-button @click="print">打印预览</el-button>
+      <el-button @click="close">关闭</el-button>
+    </div>
+  </ele-modal>
 </template>
 
 <script>
-  // import JsBarcode from 'jsbarcode';
   export default {
     data() {
       return {
@@ -45,75 +97,83 @@
         specification: '',
         warrantyPeriod: '',
         warrantyPeriodUnit: '',
-        weightUnit: ''
+        weightUnit: '',
+        QRvisible: false
       };
     },
 
-    mounted() {
-      const {
-        batchNo,
-        createDate,
-        enforceStandards,
-        layBy,
-        level,
-        netWeight,
-        notice,
-        productName,
-        purchaseOrigins,
-        specification,
-        warrantyPeriod,
-        warrantyPeriodUnit,
-        weightUnit
-      } = this.$route.query;
-      this.productName = productName ? productName : '';
-      this.batchNo = batchNo ? batchNo : '';
-      this.createDate = createDate ? createDate : '';
-      this.enforceStandards = enforceStandards ? enforceStandards : '';
-      this.layBy = layBy ? layBy : '';
-      this.level = level ? level : '';
-      this.netWeight = netWeight ? netWeight : '';
-      this.notice = notice ? notice : '';
-      this.purchaseOrigins = purchaseOrigins ? purchaseOrigins : '';
-      this.specification = specification ? specification : '';
-      this.warrantyPeriod =
-        warrantyPeriod && !warrantyPeriod ? warrantyPeriod : '';
-      this.warrantyPeriodUnit = warrantyPeriodUnit ? warrantyPeriodUnit : '';
-      this.weightUnit = weightUnit ? weightUnit : '';
+    mounted() {},
 
-      if (this.warrantyPeriodUnit === '1') {
-        this.warrantyPeriodUnit = '分钟';
-      } else if (this.warrantyPeriodUnit === '2') {
-        this.warrantyPeriodUnit = '小时';
-      } else if (this.warrantyPeriodUnit === '3') {
-        this.warrantyPeriodUnit = '日';
-      } else if (this.warrantyPeriodUnit === '4') {
-        this.warrantyPeriodUnit = '月';
-      } else if (this.warrantyPeriodUnit === '5') {
-        this.warrantyPeriodUnit = '年';
-      } else {
-        this.warrantyPeriodUnit = '';
-      }
+    methods: {
+      open(item) {
+        this.QRvisible = true;
+        const {
+          batchNo,
+          createDate,
+          enforceStandards,
+          layBy,
+          level,
+          netWeight,
+          notice,
+          productName,
+          purchaseOrigins,
+          specification,
+          warrantyPeriod,
+          warrantyPeriodUnit,
+          weightUnit
+        } = item;
+
+        this.productName = productName ? productName : '';
+        this.batchNo = batchNo ? batchNo : '';
+        this.createDate = createDate ? createDate : '';
+        this.enforceStandards = enforceStandards ? enforceStandards : '';
+        this.layBy = layBy ? layBy : '';
+        this.level = level ? level : '';
+        this.netWeight = netWeight ? netWeight : '';
+        this.notice = notice ? notice : '';
+        this.purchaseOrigins = purchaseOrigins ? purchaseOrigins : '';
+        this.specification = specification ? specification : '';
+        this.warrantyPeriod =
+          warrantyPeriod && !warrantyPeriod ? warrantyPeriod : '';
+        this.warrantyPeriodUnit = warrantyPeriodUnit ? warrantyPeriodUnit : '';
+        this.weightUnit = weightUnit ? weightUnit : '';
 
-      this.$nextTick(() => {
-        window.print();
-      });
+        if (this.warrantyPeriodUnit === '1') {
+          this.warrantyPeriodUnit = '分钟';
+        } else if (this.warrantyPeriodUnit === '2') {
+          this.warrantyPeriodUnit = '小时';
+        } else if (this.warrantyPeriodUnit === '3') {
+          this.warrantyPeriodUnit = '日';
+        } else if (this.warrantyPeriodUnit === '4') {
+          this.warrantyPeriodUnit = '月';
+        } else if (this.warrantyPeriodUnit === '5') {
+          this.warrantyPeriodUnit = '年';
+        } else {
+          this.warrantyPeriodUnit = '';
+        }
+      },
 
-      // const { id, name, price } = this.$route.query;
-      // this.order = { id, name, price };
+      close() {
+        this.QRvisible = false;
+      },
 
-      // console.log('打印参数', this.$route.query);
-      // console.log('打印参数', this.$route.query);
-      // this.orderId = this.$route.query.orderId;
-      // this.type = this.$route.query.type;
-      // window.addEventListener('message', (event) => {
-      //   console.log('接收到的参数', event.data);
-      // });
-      // JsBarcode('#barCode', '123456789012', {
-      //   format: 'CODE128',
-      //   width: 4,
-      //   height: 40,
-      //   displayValue: true
-      // });
+      print() {
+        const printSection = document.getElementById('printSection');
+        // 创建打印任务
+        const printWindow = window.open('', '_blank');
+        printWindow.document.open();
+        printWindow.document.write('<html><head><title>打印预览</title>');
+        printWindow.document.write(
+          '<link rel="stylesheet" href="your-stylesheet-url.css" type="text/css" />'
+        );
+        printWindow.document.write('</head><body>');
+        printWindow.document.write(printSection.innerHTML);
+        printWindow.document.write('</body></html>');
+        printWindow.document.close();
+        printWindow.onload = function () {
+          printWindow.print();
+        };
+      }
     }
   };
 </script>
@@ -138,7 +198,6 @@
   }
   .label-info-left {
     display: flex;
-    // flex: 1;
     flex-direction: column;
     flex-wrap: wrap;
     margin: 54px 0 0 62px;
@@ -150,17 +209,11 @@
 
   .label-info-right {
     display: flex;
-    // flex: 1;
     flex-direction: column;
     justify-content: center;
     margin: 37px 0 1px 30px;
 
-    // .right-box {
-    //   // margin: 34px 0 1px 18px
-    // }
-
     .right-div {
-      // margin: 0 0 1px 18px;
       height: 17px;
     }
   }

+ 265 - 84
src/views/produce/components/juRenPackOne.vue

@@ -1,52 +1,134 @@
 <template>
-  <div class="label-container">
-    <div class="ju_ren_one_level">
-      <span>{{ productName ? productName : ' ' }}</span>
-      <span class="ju_ren_one_level_two">{{ '' }}</span>
-    </div>
+  <ele-modal
+    title="打印条码"
+    :visible.sync="QRvisible"
+    v-if="QRvisible"
+    width="800px"
+    :maxable="true"
+  >
+    <div id="printSection">
+      <div
+        style="
+          position: relative;
+          width: 98mm;
+          height: 70mm;
+          box-sizing: border-box;
+          font-size: 10px;
+          color: green;
+          margin: 0 auto;
+          font-weight: 700;
+        "
+      >
+        <div style="display: flex; margin: 62px 0 0 75px; flex-direction: row">
+          <span style="display: inline-block; width: 70px; height: 19px">{{
+            productName ? productName : ' '
+          }}</span>
+          <span
+            style="
+              display: inline-block;
+              margin-left: 35px;
+              width: 70px;
+              height: 19px;
+            "
+            >{{ '123' }}</span
+          >
+        </div>
 
-    <div class="ju_ren_two_level">
-      <span>{{ purchaseOrigins ? purchaseOrigins : ' ' }}</span>
-    </div>
+        <div style="margin-left: 75px">
+          <span style="display: inline-block; width: 70px; height: 19px">{{
+            purchaseOrigins ? purchaseOrigins : ' '
+          }}</span>
+        </div>
 
-    <div class="ju_ren_two_level">
-      <span>{{ specification ? specification : ' ' }}</span>
-      <span class="ju_ren_one_level_two"
-        >{{ netWeight ? netWeight : ' '
-        }}{{ weightUnit ? weightUnit : ' ' }}</span
-      >
-    </div>
+        <div style="margin-left: 75px">
+          <span style="display: inline-block; width: 70px; height: 19px">{{
+            specification ? specification : ' '
+          }}</span>
+          <span
+            style="
+              display: inline-block;
+              width: 70px;
+              margin-left: 35px;
+              height: 19px;
+            "
+            >{{ netWeight ? netWeight : ' '
+            }}{{ weightUnit ? weightUnit : ' ' }}</span
+          >
+        </div>
 
-    <div class="ju_ren_Three_level">
-      <span>{{ level ? level : ' ' }}</span>
-    </div>
+        <div style="margin: 2px 0 0 130px">
+          <span style="display: inline-block; height: 19px">{{
+            level ? level : ' '
+          }}</span>
+        </div>
 
-    <div class="ju_ren_four_level">
-      <span>{{ batchNo ? batchNo : ' ' }}</span>
-      <span class="ju_ren_two_level_two">{{
-        createDate ? createDate : ' '
-      }}</span>
-      <span class="ju_ren_two_level_two"
-        >{{ warrantyPeriod ? warrantyPeriod : ' '
-        }}{{ warrantyPeriodUnit ? warrantyPeriodUnit : ' ' }}</span
-      >
-    </div>
+        <div style="margin: 3px 0 0 75px">
+          <span style="display: inline-block; width: 60px; height: 19px">{{
+            batchNo ? batchNo : ' '
+          }}</span>
 
-    <div class="ju_ren_four_level">
-      <span>{{ notice ? notice : ' ' }}</span>
-    </div>
+          <span
+            style="
+              display: inline-block;
+              margin-left: 42px;
+              width: 67px;
+              height: 19px;
+            "
+            >{{ createDate ? createDate : ' ' }}</span
+          >
+          <span
+            style="
+              display: inline-block;
+              margin-left: 42px;
+              width: 60px;
+              height: 19px;
+            "
+            >{{ warrantyPeriod ? warrantyPeriod : 0
+            }}{{ warrantyPeriodUnit ? warrantyPeriodUnit : ' ' }}</span
+          >
+        </div>
 
-    <div class="ju_ren_four_level">
-      <span>{{ layBy ? layBy : ' ' }}</span>
+        <div style="margin: 3px 0 0 75px">
+          <span style="display: inline-block; height: 19px">{{
+            notice ? notice : ' '
+          }}</span>
+        </div>
+
+        <div style="margin: 3px 0 0 75px">
+          <span style="display: inline-block; height: 19px">{{
+            layBy ? layBy : ' '
+          }}</span>
+        </div>
+
+        <div style="margin: 3px 0 0 75px">
+          <span style="display: inline-block; height: 19px">{{
+            enforceStandards ? enforceStandards : ' '
+          }}</span>
+        </div>
+
+        <div
+          style="
+            position: absolute;
+            top: -15px;
+            right: 80px;
+            width: 50px;
+            height: 50px;
+          "
+        >
+          <img style="width: 100%; height: 100%" :src="url" />
+        </div>
+      </div>
     </div>
 
-    <div class="ju_ren_four_level">
-      <span>{{ enforceStandards ? enforceStandards : ' ' }}</span>
+    <div slot="footer">
+      <el-button @click="print">打印预览</el-button>
+      <el-button @click="close">关闭</el-button>
     </div>
-  </div>
+  </ele-modal>
 </template>
 
 <script>
+  import QRCode from 'qrcode';
   export default {
     data() {
       return {
@@ -62,67 +144,140 @@
         specification: '',
         warrantyPeriod: '',
         warrantyPeriodUnit: '',
-        weightUnit: ''
+        weightUnit: '',
+        url: '',
+        workOrderId: '',
+        qrCodeUrl: '',
+        QRvisible: false
       };
     },
-    mounted() {
-      const {
-        batchNo,
-        createDate,
-        enforceStandards,
-        layBy,
-        level,
-        netWeight,
-        notice,
-        productName,
-        purchaseOrigins,
-        specification,
-        warrantyPeriod,
-        warrantyPeriodUnit,
-        weightUnit
-      } = this.$route.query;
-      this.productName = productName ? productName : '';
-      this.batchNo = batchNo ? batchNo : '';
-      this.createDate = createDate ? createDate : '';
-      this.enforceStandards = enforceStandards ? enforceStandards : '';
-      this.layBy = layBy ? layBy : '';
-      this.level = level ? level : '';
-      this.netWeight = netWeight ? netWeight : '';
-      this.notice = notice ? notice : '';
-      this.purchaseOrigins = purchaseOrigins ? purchaseOrigins : '';
-      this.specification = specification ? specification : '';
-      this.warrantyPeriod =
-        warrantyPeriod && !warrantyPeriod ? warrantyPeriod : '';
-      this.warrantyPeriodUnit = warrantyPeriodUnit ? warrantyPeriodUnit : '';
-      this.weightUnit = weightUnit ? weightUnit : '';
-
-      if (this.warrantyPeriodUnit === '1') {
-        this.warrantyPeriodUnit = '分钟';
-      } else if (this.warrantyPeriodUnit === '2') {
-        this.warrantyPeriodUnit = '小时';
-      } else if (this.warrantyPeriodUnit === '3') {
-        this.warrantyPeriodUnit = '日';
-      } else if (this.warrantyPeriodUnit === '4') {
-        this.warrantyPeriodUnit = '月';
-      } else if (this.warrantyPeriodUnit === '5') {
-        this.warrantyPeriodUnit = '年';
-      } else {
-        this.warrantyPeriodUnit = '';
+    mounted() {},
+
+    methods: {
+      open(item, workOrderId) {
+        this.QRvisible = true;
+        const {
+          batchNo,
+          createDate,
+          enforceStandards,
+          layBy,
+          level,
+          netWeight,
+          notice,
+          productName,
+          purchaseOrigins,
+          specification,
+          warrantyPeriod,
+          warrantyPeriodUnit,
+          weightUnit
+        } = item;
+
+        this.productName = productName ? productName : '';
+        this.batchNo = batchNo ? batchNo : '';
+        this.createDate = createDate ? createDate : '';
+        this.enforceStandards = enforceStandards ? enforceStandards : '';
+        this.layBy = layBy ? layBy : '';
+        this.level = level ? level : '';
+        this.netWeight = netWeight ? netWeight : '';
+        this.notice = notice ? notice : '';
+        this.purchaseOrigins = purchaseOrigins ? purchaseOrigins : '';
+        this.specification = specification ? specification : '';
+        this.warrantyPeriod =
+          warrantyPeriod && !warrantyPeriod ? warrantyPeriod : '';
+        this.warrantyPeriodUnit = warrantyPeriodUnit ? warrantyPeriodUnit : '';
+        this.weightUnit = weightUnit ? weightUnit : '';
+        this.workOrderId = workOrderId ? workOrderId : '';
+
+        if (this.warrantyPeriodUnit === '1') {
+          this.warrantyPeriodUnit = '分钟';
+        } else if (this.warrantyPeriodUnit === '2') {
+          this.warrantyPeriodUnit = '小时';
+        } else if (this.warrantyPeriodUnit === '3') {
+          this.warrantyPeriodUnit = '日';
+        } else if (this.warrantyPeriodUnit === '4') {
+          this.warrantyPeriodUnit = '月';
+        } else if (this.warrantyPeriodUnit === '5') {
+          this.warrantyPeriodUnit = '年';
+        } else {
+          this.warrantyPeriodUnit = '';
+        }
+
+        this.qrCodeUrl =
+          window.location.origin + `/traceability?id=${this.workOrderId}`;
+
+        // this.qrCodeUrl = `http://192.168.1.22:9999/traceability?id=${this.workOrderId}`;
+
+        // console.log(window.location.origin, 'window.location.origin');
+
+        this.$nextTick(() => {
+          this.generateQRCodes();
+        });
+      },
+
+      generateQRCodes() {
+        if (this.workOrderId) {
+          QRCode.toDataURL(this.qrCodeUrl)
+            .then((url) => {
+              // item.qrcode = url;
+              this.url = url;
+              this.$forceUpdate();
+            })
+            .catch((err) => {
+              console.error(err);
+            });
+        }
+      },
+
+      close() {
+        this.QRvisible = false;
+      },
+
+      print() {
+        const printSection = document.getElementById('printSection');
+        // 创建打印任务
+        const printWindow = window.open('', '_blank');
+        printWindow.document.open();
+        printWindow.document.write('<html><head><title>打印预览</title>');
+        printWindow.document.write(
+          '<link rel="stylesheet" href="your-stylesheet-url.css" type="text/css" />'
+        );
+        printWindow.document.write('</head><body>');
+        printWindow.document.write(printSection.innerHTML);
+        printWindow.document.write('</body></html>');
+        printWindow.document.close();
+        printWindow.onload = function () {
+          printWindow.print();
+        };
       }
 
-      this.$nextTick(() => {
-        window.print();
-      });
+      // print() {
+      //   const printSection = document.getElementById('printSection');
+      //   // 创建打印任务
+      //   const printWindow = window.open('', '_blank');
+      //   printWindow.document.open();
+      //   printWindow.document.write('<html><head><title>打印预览</title>');
+      //   printWindow.document.write(
+      //     '<link rel="stylesheet" href="your-stylesheet-url.css" type="text/css" />'
+      //   );
+      //   printWindow.document.write('</head><body>');
+      //   printWindow.document.write(printSection.innerHTML);
+      //   printWindow.document.write('</body></html>');
+      //   printWindow.document.close();
+      //   // printWindow.onload = function () {
+      //   //   printWindow.print();
+      //   // };
+      // }
     }
   };
 </script>
 
 <style scoped lang="scss">
   .label-container {
+    position: relative;
     width: 90mm;
     height: 70mm;
     box-sizing: border-box;
-    font-size: 12px;
+    font-size: 8px;
     color: green;
     margin: 0 auto;
     font-weight: 700;
@@ -185,6 +340,32 @@
       .ju_ren_two_level_two {
         margin-left: 42px;
       }
+
+      .two_text {
+        width: 65px;
+      }
+    }
+
+    .ju_ren_five_level {
+      margin: 3px 0 0 64px;
+
+      span {
+        display: inline-block;
+        height: 19px;
+      }
+    }
+
+    .qr_code {
+      position: absolute;
+      top: 0;
+      right: 15px;
+      width: 60px;
+      height: 60px;
+
+      img {
+        width: 100%;
+        height: 100%;
+      }
     }
   }
 </style>

+ 46 - 23
src/views/produce/components/outsourcing/index.vue

@@ -3,10 +3,8 @@
     <div class="c_header_title">
       <!-- <el-tabs type="card" v-model="activeName" @tab-click="handleClick">
         <el-tab-pane label="委外记录" name="1"></el-tab-pane>
-        <el-tab-pane label="请托记录" name="2"></el-tab-pane> -->
-      <!-- <div class="c_title">委外记录</div>
-        <div class="c_title">委外记录</div> -->
-      <!-- </el-tabs> -->
+        <el-tab-pane label="请托记录" name="2"></el-tab-pane>
+      </el-tabs> -->
       <div class="c_title">委外记录</div>
     </div>
     <div style="overflow: auto">
@@ -214,12 +212,13 @@
             style="width: 260px"
           ></el-input>
         </el-form-item>
-        <el-form-item label="请托到:" prop="taskIds">
+        <el-form-item label="请托到:" prop="taskIdes">
           <el-select
-            v-model="taskIds"
+            v-model="attributeData.taskIdes"
             placeholder="请选择"
             style="width: 260px"
             @change="changeTaskId"
+            multiple
           >
             <el-option
               v-for="item in newStepsList"
@@ -271,7 +270,7 @@
 
         <el-form-item label="请托单位:">
           <el-select
-            v-model="attributeData.taskIds"
+            v-model="attributeData.factoriesId"
             placeholder="请选择"
             style="width: 260px"
             @change="changeTaskId"
@@ -316,7 +315,7 @@
         <el-form-item label="交付交期:" prop="requireDeliveryTime">
           <el-date-picker
             v-model="attributeData.requireDeliveryTime"
-            value-format="yyyy-MM-dd HH:mm:ss"
+            value-format="yyyy-MM-dd"
             style="width: 260px"
             type="date"
             placeholder="选择日期"
@@ -364,7 +363,9 @@
           produceRoutingId: '', //工艺路线id
           supplierId: '', //供应商id
           supplierName: '',
-          taskIdes: []
+          taskIdes: [],
+          factoriesId: '',
+          factoriesName: ''
         },
         isInWarehouse: true,
         produceList: [],
@@ -427,6 +428,10 @@
       outsourceFormVal: {
         type: Object,
         default: () => ({})
+      },
+      taskName: {
+        type: String,
+        default: ''
       }
     },
 
@@ -473,18 +478,10 @@
       this.getFactoryList();
       // if (this.activeName == '1') {
       //   // this.attributeData.name = this.outsourceFormVal.name + '委托';
-      //   this.$set(
-      //     this.outsourceFormVal,
-      //     'name',
-      //     this.outsourceFormVal.name + '委托'
-      //   );
+      //   this.$set(this.outsourceFormVal, 'name', this.taskName + '委托');
       // } else if (this.activeName == '2') {
       //   // this.attributeData.name = this.outsourceFormVal.name + '请托';
-      //   this.$set(
-      //     this.outsourceFormVal,
-      //     'name',
-      //     this.outsourceFormVal.name + '请托'
-      //   );
+      //   this.$set(this.outsourceFormVal, 'name', this.taskName + '请托');
       // }
     },
 
@@ -538,9 +535,11 @@
       handleClick(tab, event) {
         this.activeName = tab._props.name;
         if (this.activeName == '1') {
-          this.attributeData.name = this.outsourceFormVal.name + '委托';
+          this.resetData();
+          this.attributeData.name = this.taskName + '委托';
         } else if (this.activeName == '2') {
-          this.attributeData.name = this.outsourceFormVal.name + '请托';
+          this.resetData();
+          this.attributeData.name = this.taskName + '请托';
         }
       },
 
@@ -602,12 +601,26 @@
         }
       },
 
+      resetData() {
+        this.attributeData.type = '';
+        this.attributeData.sceneText = '';
+        this.attributeData.taskIds = '';
+        this.attributeData.isFirstTask = '';
+        this.attributeData.clientEnvironmentId = 1;
+        this.attributeData.requireDeliveryTime = '';
+        this.attributeData.warehouseId = '';
+        this.attributeData.produceRoutingId = '';
+        this.attributeData.supplierId = '';
+        this.attributeData.taskIdes = [];
+        this.attributeData.factoriesId = '';
+      },
+
       //跳转
 
       confirm() {
         this.$refs.form.validate((valid) => {
           if (valid) {
-            console.log(this.attributeData, '11111187887877');
+            // if (this.activeName == '1') {
             if (this.attributeData.supplierId) {
               const obj = this.gysList.find(
                 (item) => item.id === this.attributeData.supplierId
@@ -615,7 +628,17 @@
               this.attributeData.supplierName = obj ? obj.name : '';
             }
             this.attributeData.taskIds = this.attributeData.taskIdes.join(',');
-            this.$emit('changePlugIn', this.attributeData);
+            this.$emit('changePlugIn', this.attributeData, this.activeName);
+            // } else if (this.activeName == '2') {
+            //   const obj = this.factoryList.find(
+            //     (item) => item.id === this.attributeData.factoriesId
+            //   );
+            //   this.attributeData.factoriesName = obj ? obj.name : '';
+            //   this.attributeData.taskIds =
+            //     this.attributeData.taskIdes.join(',');
+            //   console.log(this.attributeData);
+            //   this.$emit('changePlugIn', this.attributeData, this.activeName);
+            // }
           } else {
             console.log('error submit!!');
             return false;

+ 12 - 3
src/views/produce/index.vue

@@ -240,6 +240,7 @@
                 ></outsourcingDetails>
                 <outsourcing
                   :outsourceFormVal="outsourceForm"
+                  :taskName="taskObj.name"
                   @changePlugIn="changePlugIn"
                   @changeCancel="changeCancel"
                   v-if="isStep"
@@ -362,7 +363,8 @@
     listTask,
     factoryworkstationPage,
     nextTask,
-    singleListTask
+    singleListTask,
+    pleaseEntrustManagement
   } from '@/api/produce/index';
   import prenatalExamination from './components/prenatalExamination/index.vue';
 
@@ -689,9 +691,9 @@
       },
 
       // 切换组件
-      async changePlugIn(e) {
+      async changePlugIn(e, index) {
+        // if (index == '1') {
         this.outObj = e;
-
         let req = {
           taskId: e.taskId,
           taskIds: e.taskIds,
@@ -704,6 +706,13 @@
 
         this.isStep = false;
         this.isOutsource = true;
+        // } else if (index == '2') {
+        //   this.outObj = e;
+
+        //   const res = await pleaseEntrustManagement(this.outObj);
+
+        //   console.log(res, '请托的结果');
+        // }
       },
 
       workSelect(data) {

+ 19 - 1
src/views/produceOrder/index.vue

@@ -52,6 +52,8 @@
           <el-button type="success" @click="cardPrinting()"
             >工艺卡打印</el-button
           >
+
+          <el-button type="success" @click="originCode()">朔源码</el-button>
         </template>
 
         <template v-slot:code="{ row }">
@@ -209,6 +211,8 @@
       @createSuccess="createSuccess"
       v-if="dispatchVisible"
     />
+
+    <originCode ref="originCodeRef" />
   </div>
 </template>
 
@@ -240,6 +244,7 @@
 
   import { debounce } from 'lodash';
   import tableColumnsMixin from '@/mixins/tableColumnsMixin';
+  import originCode from './originCode.vue';
 
   export default {
     mixins: [tableColumnsMixin],
@@ -256,7 +261,8 @@
       detailsPop,
       EquipmentDialog,
       xlhView,
-      workReport
+      workReport,
+      originCode
     },
 
     data() {
@@ -825,6 +831,18 @@
         this.reload();
       },
 
+      originCode() {
+        if (!this.selection.length) {
+          return this.$message.warning('请至少选择一条工单!');
+        }
+
+        if (this.selection.length > 1) {
+          return this.$message.warning('只能选择一条工单');
+        }
+
+        this.$refs.originCodeRef.open(this.selection[0].id);
+      },
+
       /* 表格数据源 */
       async datasource({ page, limit, where, order }) {
         // console.log('1123',where)

+ 139 - 0
src/views/produceOrder/originCode.vue

@@ -0,0 +1,139 @@
+<template>
+  <ele-modal
+    title="朔源码"
+    :visible.sync="QRvisible"
+    v-if="QRvisible"
+    width="800px"
+    :maxable="true"
+  >
+    <div id="printSection">
+      <div
+        style="
+          position: relative;
+          width: 98mm;
+          height: 70mm;
+          box-sizing: border-box;
+          font-size: 10px;
+          color: green;
+          margin: 0 auto;
+          font-weight: 700;
+        "
+      >
+        <div
+          style="
+            display: flex;
+            flex-direction: row;
+            width: 260px;
+            height: 260px;
+          "
+        >
+          <img style="width: 100%; height: 100%" :src="url" />
+        </div>
+      </div>
+    </div>
+
+    <div slot="footer">
+      <el-button @click="print">打印预览</el-button>
+      <el-button @click="close">关闭</el-button>
+    </div>
+  </ele-modal>
+</template>
+
+<script>
+  import QRCode from 'qrcode';
+  export default {
+    data() {
+      return {
+        batchNo: '',
+        createDate: '',
+        enforceStandards: '',
+        layBy: '',
+        level: '',
+        netWeight: '',
+        notice: '',
+        productName: '',
+        purchaseOrigins: '',
+        specification: '',
+        warrantyPeriod: '',
+        warrantyPeriodUnit: '',
+        weightUnit: '',
+        url: '',
+        workOrderId: '',
+        qrCodeUrl: '',
+        QRvisible: false
+      };
+    },
+    mounted() {},
+
+    methods: {
+      open(workOrderId) {
+        this.QRvisible = true;
+        this.workOrderId = workOrderId;
+
+        this.qrCodeUrl =
+          window.location.origin + `/traceability?id=${this.workOrderId}`;
+        // this.qrCodeUrl = `http://192.168.1.22:9999/traceability?id=${this.workOrderId}`;
+
+        this.$nextTick(() => {
+          this.generateQRCodes();
+        });
+      },
+
+      generateQRCodes() {
+        if (this.workOrderId) {
+          QRCode.toDataURL(this.qrCodeUrl)
+            .then((url) => {
+              // item.qrcode = url;
+              this.url = url;
+              this.$forceUpdate();
+            })
+            .catch((err) => {
+              console.error(err);
+            });
+        }
+      },
+
+      close() {
+        this.QRvisible = false;
+      },
+
+      print() {
+        const printSection = document.getElementById('printSection');
+        // 创建打印任务
+        const printWindow = window.open('', '_blank');
+        printWindow.document.open();
+        printWindow.document.write('<html><head><title>打印预览</title>');
+        printWindow.document.write(
+          '<link rel="stylesheet" href="your-stylesheet-url.css" type="text/css" />'
+        );
+        printWindow.document.write('</head><body>');
+        printWindow.document.write(printSection.innerHTML);
+        printWindow.document.write('</body></html>');
+        printWindow.document.close();
+        printWindow.onload = function () {
+          printWindow.print();
+        };
+      }
+
+      // print() {
+      //   const printSection = document.getElementById('printSection');
+      //   // 创建打印任务
+      //   const printWindow = window.open('', '_blank');
+      //   printWindow.document.open();
+      //   printWindow.document.write('<html><head><title>打印预览</title>');
+      //   printWindow.document.write(
+      //     '<link rel="stylesheet" href="your-stylesheet-url.css" type="text/css" />'
+      //   );
+      //   printWindow.document.write('</head><body>');
+      //   printWindow.document.write(printSection.innerHTML);
+      //   printWindow.document.write('</body></html>');
+      //   printWindow.document.close();
+      //   // printWindow.onload = function () {
+      //   //   printWindow.print();
+      //   // };
+      // }
+    }
+  };
+</script>
+
+<style scoped lang="scss"></style>

+ 1 - 1
src/views/produceOrder/workReport.vue

@@ -594,8 +594,8 @@
       },
 
       open(row) {
+        this.curTaskObj = null;
         this.workOrderInfo = row;
-        console.log(row, 'workOrderInfo');
         this.routeObj.id = this.workOrderInfo.id;
         this.getTaskFn();
         this.drawer = true;

+ 496 - 452
src/views/sample/detailList.vue

@@ -78,6 +78,7 @@
             v-model="disposeForm.disposeType"
             placeholder="请选择"
             style="width: 100%"
+            @change="disposeTypeChange"
           >
             <el-option
               v-for="item in sampleTypeList"
@@ -91,10 +92,29 @@
 
         <template v-if="disposeForm.disposeType == 6">
           <el-row>
+            <el-col :span="24">
+              <el-form-item
+                label="留样数量:"
+                prop="keepSampleQuantity"
+                align="center"
+              >
+                <el-input
+                  v-model="disposeForm.keepSampleQuantity"
+                  placeholder="请输入"
+                  style="width: 100%"
+                >
+                  <template slot="append">{{
+                    current?.measureUnit
+                  }}</template></el-input
+                >
+              </el-form-item>
+            </el-col>
+            <el-col :span="6"> </el-col>
+          </el-row>
+          <el-row style="margin-top: 12px">
             <el-col :span="24">
               <el-form-item label="留样日期:" prop="sampleDate" align="center">
                 <el-date-picker
-                  class="w100"
                   v-model="disposeForm.sampleDate"
                   type="date"
                   value-format="yyyy-MM-dd"
@@ -200,487 +220,511 @@
 </template>
 
 <script>
-  import { deepClone } from '@/utils';
-  import Edit from './components/edit.vue';
-  import { getWarehouseList } from '@/api/sample';
+import { deepClone } from '@/utils';
+import Edit from './components/edit.vue';
+import { getWarehouseList } from '@/api/sample';
 
-  import dictMixins from '@/mixins/dictMixins';
-  import { unacceptedProductStatus } from '@/utils/util';
+import dictMixins from '@/mixins/dictMixins';
+import { unacceptedProductStatus } from '@/utils/util';
 
-  import {
-    getDetail,
-    deleteUnacceptedProductDetail,
-    dispose,
-    removeSample
-  } from '@/api/sample';
+import {
+  getDetail,
+  deleteUnacceptedProductDetail,
+  dispose,
+  removeSample
+} from '@/api/sample';
 
-  import { saveData, updateData, getById, disposeApi } from '@/api/sample';
-  export default {
-    components: {
-      Edit
-    },
-    mixins: [dictMixins],
-    data() {
-      return {
-        dataList: [],
-        key: '',
-        response: {
-          dataName: 'sampleVOList'
-        },
-        warehouseList: [],
-        disposeForm: {
-          disposeType: '',
-          sampleCondition: '',
-          sampleDate: '',
-          samplePlace: '',
-          sampleRemark: '',
-          producerManufacturer: '',
-          depotId: '',
-          depotName: ''
-        },
-        id: '',
-        ids: [],
-        sampleType: '',
-        loading: false,
-        selection: [],
-        allSelectedData: [],
+import { saveData, updateData, getById, disposeApi } from '@/api/sample';
+export default {
+  components: {
+    Edit
+  },
+  mixins: [dictMixins],
+  data() {
+    return {
+      dataList: [],
+      key: '',
+      response: {
+        dataName: 'sampleVOList'
+      },
+      warehouseList: [],
+      disposeForm: {
         disposeType: '',
-        dialogVisible: false,
-        current: {},
-        formData: {},
-        all: false,
-        qualityType: null,
-        sampleTypeList: [
-          { value: 1, label: '返工' },
-          { value: 2, label: '返修' },
-          { value: 6, label: '留样' },
-          { value: 8, label: '归批/回用' },
-          { value: 3, label: '报废' },
-          { value: 10, label: '退货' },
-          { value: 7, label: '消耗' }
-        ],
-        rules: {
-          disposeType: [
-            { required: true, message: '请选择处置方式', trigger: 'change' }
-          ],
-          depotId: [
-            { required: true, message: '请选择仓库', trigger: 'change' }
-          ]
-        }
-      };
-    },
-    computed: {
-      showBtn() {
-        return !this.$route.query.type;
+        sampleCondition: '',
+        sampleDate: '',
+        samplePlace: '',
+        sampleRemark: '',
+        producerManufacturer: '',
+        depotId: '',
+        depotName: '',
+        keepSampleQuantity: ''
       },
-      // 表格列配置
-      columns() {
-        const arr = [
+      id: '',
+      ids: [],
+      sampleType: '',
+      loading: false,
+      selection: [],
+      allSelectedData: [],
+      disposeType: '',
+      dialogVisible: false,
+      current: {},
+      formData: {},
+      all: false,
+      qualityType: null,
+      sampleTypeList: [
+        { value: 1, label: '返工' },
+        { value: 2, label: '返修' },
+        { value: 6, label: '留样' },
+        { value: 8, label: '归批/回用' },
+        { value: 3, label: '报废' },
+        { value: 10, label: '退货' },
+        { value: 7, label: '消耗' }
+      ],
+      rules: {
+        disposeType: [
+          { required: true, message: '请选择处置方式', trigger: 'change' }
+        ],
+        depotId: [{ required: true, message: '请选择仓库', trigger: 'change' }],
+        keepSampleQuantity: [
           {
-            width: 45,
-            type: 'selection',
-            columnKey: 'selection',
-            selectable: (row, index) => {
-              return row.disposalStatus !== 2;
+            validator: (rule, value, callback) => {
+              if (
+                this.disposeForm.disposeType === 6 &&
+                this.current &&
+                this.current.measureQuantity !== undefined
+              ) {
+                const inputVal = Number(value);
+                const maxVal = Number(this.current.measureQuantity);
+                if (inputVal > maxVal) {
+                  return callback(new Error(`不能超过原计量数量${maxVal}`));
+                }
+              }
+              callback();
             },
-            align: 'center'
-          },
-          {
-            type: 'index',
-            columnKey: 'index',
-            align: 'center',
-            label: '序号',
-            width: 55,
-            showOverflowTooltip: true
-          },
-          {
-            label: '样品编码',
-            prop: 'sampleCode',
-            width: '150',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            label: '物品编码',
-            prop: 'categoryCode',
-            width: '150',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            label: '物品名称',
-            prop: 'categoryName',
-            width: '180',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'batchNo',
-            label: '批次号',
-            align: 'center',
-            width: '120',
-            showOverflowTooltip: true
-          },
-          {
-            label: '规格',
-            prop: 'specification',
-            width: '120',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            label: '牌号',
-            prop: 'brandNum',
-            width: '120',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'modelType',
-            label: '型号',
-            align: 'center',
-            width: '120',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'measureQuantity',
-            label: '计量数量',
-            align: 'center',
-            width: '120',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'measureUnit',
-            label: '计量单位',
-            align: 'center',
-            width: '120',
-            showOverflowTooltip: true
-          },
-
-          {
-            prop: 'weight',
-            label: '重量',
-            align: 'center',
-            width: '120',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'weightUnit',
-            label: '重量单位',
-            align: 'center',
-            width: '120',
-            showOverflowTooltip: true
-          },
-          // {
-          //   prop: 'disposeTime',
-          //   label: '处置时间',
-          //   align: 'center',
-          //   width: '180',
-          //   showOverflowTooltip: true
-          // },
-          {
-            prop: 'disposalStatus',
-            label: '处置状态',
-            align: 'center',
-            width: '120',
-            showOverflowTooltip: true,
-            formatter: (row, column, cellValue) => {
-              return this.disposalStatustList[cellValue ? cellValue : 0];
-            }
-          },
-          {
-            prop: 'disposeType',
-            label: '处置类型',
-            align: 'center',
-            width: '120',
-            showOverflowTooltip: true,
-            formatter: (row, column, cellValue) => {
-              return this.disposeTypeList[0][cellValue];
-            }
-          },
-          {
-            prop: 'qualityResults',
-            label: '质检结果',
-            align: 'center',
-            width: '120',
-            showOverflowTooltip: true,
-            formatter: (row, column, cellValue) => {
-              return this.qualityResultList[cellValue];
-            }
+            trigger: 'blur'
+          }
+        ]
+      }
+    };
+  },
+  computed: {
+    showBtn() {
+      return !this.$route.query.type;
+    },
+    // 表格列配置
+    columns() {
+      const arr = [
+        {
+          width: 45,
+          type: 'selection',
+          columnKey: 'selection',
+          selectable: (row, index) => {
+            return row.disposalStatus !== 2;
           },
+          align: 'center'
+        },
+        {
+          type: 'index',
+          columnKey: 'index',
+          align: 'center',
+          label: '序号',
+          width: 55,
+          showOverflowTooltip: true
+        },
+        {
+          label: '样品编码',
+          prop: 'sampleCode',
+          width: '150',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          label: '物品编码',
+          prop: 'categoryCode',
+          width: '150',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          label: '物品名称',
+          prop: 'categoryName',
+          width: '180',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'batchNo',
+          label: '批次号',
+          align: 'center',
+          width: '120',
+          showOverflowTooltip: true
+        },
+        {
+          label: '规格',
+          prop: 'specification',
+          width: '120',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          label: '牌号',
+          prop: 'brandNum',
+          width: '120',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'modelType',
+          label: '型号',
+          align: 'center',
+          width: '120',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'measureQuantity',
+          label: '计量数量',
+          align: 'center',
+          width: '120',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'measureUnit',
+          label: '计量单位',
+          align: 'center',
+          width: '120',
+          showOverflowTooltip: true
+        },
 
-          {
-            columnKey: 'action',
-            label: '操作',
-            align: 'center',
-            width: 180,
-            resizable: false,
-            slot: 'action',
-            fixed: 'right'
+        {
+          prop: 'weight',
+          label: '重量',
+          align: 'center',
+          width: '120',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'weightUnit',
+          label: '重量单位',
+          align: 'center',
+          width: '120',
+          showOverflowTooltip: true
+        },
+        // {
+        //   prop: 'disposeTime',
+        //   label: '处置时间',
+        //   align: 'center',
+        //   width: '180',
+        //   showOverflowTooltip: true
+        // },
+        {
+          prop: 'disposalStatus',
+          label: '处置状态',
+          align: 'center',
+          width: '120',
+          showOverflowTooltip: true,
+          formatter: (row, column, cellValue) => {
+            return this.disposalStatustList[cellValue ? cellValue : 0];
           }
-        ];
-
-        return this.$route.query.type ? arr.slice(0, -1) : arr;
-      },
-      seekList() {
-        return [
-          {
-            label: '编码:',
-            value: 'sampleCode',
-            type: 'input',
-            placeholder: ''
-          },
-          {
-            label: '物品编码:',
-            value: 'categoryCode',
-            type: 'input',
-            placeholder: ''
-          },
-          {
-            label: '物品名称:',
-            value: 'categoryName',
-            type: 'input',
-            placeholder: ''
+        },
+        {
+          prop: 'disposeType',
+          label: '处置类型',
+          align: 'center',
+          width: '120',
+          showOverflowTooltip: true,
+          formatter: (row, column, cellValue) => {
+            return this.disposeTypeList[0][cellValue];
           }
-        ];
-      },
-      disposeTypeList() {
-        return [
-          {
-            1: '返工',
-            2: '返修',
-            3: '报废',
-            4: '降级使用',
-            5: '让步接收',
-            6: '留样',
-            7: '消耗',
-            8: '回用',
-            9: '转试销',
-            10: '退货'
+        },
+        {
+          prop: 'qualityResults',
+          label: '质检结果',
+          align: 'center',
+          width: '120',
+          showOverflowTooltip: true,
+          formatter: (row, column, cellValue) => {
+            return this.qualityResultList[cellValue];
           }
-        ];
-      },
-      qualityResultList() {
-        return { 1: '合格', 2: '不合格' };
-      },
-      disposalStatustList() {
-        return { 0: '待处置', 1: '处置中', 2: '处置完成' };
-      }
-    },
+        },
 
-    watch: {
-      'disposeForm.disposeType': {
-        handler(newVal, oldVal) {
-          if (newVal == 6) {
-            this.rules.depotId = [];
-          } else {
-            this.rules.depotId = [
-              { required: true, message: '请选择仓库', trigger: 'change' }
-            ];
-          }
+        {
+          columnKey: 'action',
+          label: '操作',
+          align: 'center',
+          width: 180,
+          resizable: false,
+          slot: 'action',
+          fixed: 'right'
+        }
+      ];
 
-          this.disposeForm.sampleCondition = '';
-          this.disposeForm.sampleDate = '';
-          this.disposeForm.samplePlace = '';
-          this.disposeForm.sampleRemark = '';
-          this.disposeForm.producerManufacturer = '';
-          this.disposeForm.depotId = '';
-          this.disposeForm.depotName = '';
+      return this.$route.query.type ? arr.slice(0, -1) : arr;
+    },
+    seekList() {
+      return [
+        {
+          label: '编码:',
+          value: 'sampleCode',
+          type: 'input',
+          placeholder: ''
+        },
+        {
+          label: '物品编码:',
+          value: 'categoryCode',
+          type: 'input',
+          placeholder: ''
+        },
+        {
+          label: '物品名称:',
+          value: 'categoryName',
+          type: 'input',
+          placeholder: ''
         }
-      }
+      ];
+    },
+    disposeTypeList() {
+      return [
+        {
+          1: '返工',
+          2: '返修',
+          3: '报废',
+          4: '降级使用',
+          5: '让步接收',
+          6: '留样',
+          7: '消耗',
+          8: '回用',
+          9: '转试销',
+          10: '退货'
+        }
+      ];
     },
-    async created() {
-      this.getList();
-      this.warehouseList = await getWarehouseList();
-      this.qualityType = this.$route.query.qualityType;
+    qualityResultList() {
+      return { 1: '合格', 2: '不合格' };
     },
+    disposalStatustList() {
+      return { 0: '待处置', 1: '处置中', 2: '处置完成' };
+    }
+  },
 
-    methods: {
-      kk() {
-        console.log('fany');
-      },
-      handleSelectionChange(selection) {
-        console.log('choose');
+  watch: {
+    'disposeForm.disposeType': {
+      handler(newVal, oldVal) {
+        if (newVal == 6) {
+          this.rules.depotId = [];
+        } else {
+          this.rules.depotId = [
+            { required: true, message: '请选择仓库', trigger: 'change' }
+          ];
+        }
 
-        this.selection = selection;
-        // 更新所有选中的数据
-        this.allSelectedData = [
-          ...new Set([...this.allSelectedData, ...selection])
-        ];
-      },
-      handlePageChange() {
-        console.log('fan');
+        this.disposeForm.sampleCondition = '';
+        this.disposeForm.sampleDate = '';
+        this.disposeForm.samplePlace = '';
+        this.disposeForm.sampleRemark = '';
+        this.disposeForm.producerManufacturer = '';
+        this.disposeForm.depotId = '';
+        this.disposeForm.depotName = '';
+      }
+    }
+  },
+  async created() {
+    this.getList();
+    this.warehouseList = await getWarehouseList();
+    this.qualityType = this.$route.query.qualityType;
+  },
 
-        // 翻页时同步选中状态
-        const currentPageData = this.dataList;
-        const selectedOnCurrentPage = currentPageData.filter((item) =>
-          this.allSelectedData.some(
-            (selectedItem) => selectedItem.id === item.id
-          )
-        );
-        this.$refs.table.setSelectedRows(selectedOnCurrentPage);
-      },
-      chooseWarehouse(item) {
-        console.log(item);
-        this.disposeForm.depotId = item.id;
-        this.disposeForm.depotName = item.name;
-      },
-      async getList() {
-        let id = this.$route.query.id;
-        const arr = await getById(id);
-        this.dataList = arr.sampleVOList;
-      },
-      // /* 表格数据源 */
+  methods: {
+    disposeTypeChange() {
+      console.log(this.disposeForm.disposeType);
+      console.log(this.current.measureQuantity)
+      if (this.disposeForm.disposeType == 6) {
+        this.disposeForm.keepSampleQuantity =
+          this.current?.measureQuantity || '';
+      }
+    },
+    kk() {
+      console.log('fany');
+    },
+    handleSelectionChange(selection) {
+      console.log('choose');
 
-      async datasource({ page, where, limit }) {
-        let id = this.$route.query.id;
-        // where.id = this.$route.query.id;
-        const arr = await getById(id);
+      this.selection = selection;
+      // 更新所有选中的数据
+      this.allSelectedData = [
+        ...new Set([...this.allSelectedData, ...selection])
+      ];
+    },
+    handlePageChange() {
+      console.log('fan');
 
-        return arr.sampleVOList;
-      },
-      reload(where) {
-        console.log('reload');
-        this.key = Math.random();
-        this.$nextTick(() => {
-          // this.datasource();
-          // this.$refs.table.reRenderTable();
-          // this.getList()
-          // this.$refs.table.reload({ page: 1, where: where });
+      // 翻页时同步选中状态
+      const currentPageData = this.dataList;
+      const selectedOnCurrentPage = currentPageData.filter((item) =>
+        this.allSelectedData.some((selectedItem) => selectedItem.id === item.id)
+      );
+      this.$refs.table.setSelectedRows(selectedOnCurrentPage);
+    },
+    chooseWarehouse(item) {
+      console.log(item);
+      this.disposeForm.depotId = item.id;
+      this.disposeForm.depotName = item.name;
+    },
+    async getList() {
+      let id = this.$route.query.id;
+      const arr = await getById(id);
+      this.dataList = arr.sampleVOList;
+    },
+    // /* 表格数据源 */
+
+    async datasource({ page, where, limit }) {
+      let id = this.$route.query.id;
+      // where.id = this.$route.query.id;
+      const arr = await getById(id);
+
+      return arr.sampleVOList;
+    },
+    reload(where) {
+      console.log('reload');
+      this.key = Math.random();
+      this.$nextTick(() => {
+        // this.datasource();
+        // this.$refs.table.reRenderTable();
+        // this.getList()
+        // this.$refs.table.reload({ page: 1, where: where });
+      });
+    },
+    remove(row) {
+      let ids = row ? [row.id] : this.selection.map((item) => item.id);
+      removeSample(ids).then((res) => {
+        this.$message.success('删除' + res);
+        this.reload();
+        // 删除后更新 allSelectedData
+        this.allSelectedData = this.allSelectedData.filter(
+          (item) => !ids.includes(item.id)
+        );
+      });
+    },
+    close() {
+      this.$refs.disposeForm.resetFields();
+      this.dialogVisible = false;
+      this.disposeType = '';
+    },
+    // // 处置
+    disposeList(type, row) {
+      if (type == 1) {
+        this.all = true;
+        console.log(this.selection);
+      } else {
+        this.id = row.id;
+        this.current = row;
+        console.log(this.current, 'row');
+      }
+      this.formData = { ...row };
+      this.dialogVisible = true;
+      // let ids = this.current ? [this.current.id] : this.selection.map((item) => item.id);
+    },
+    async handleDispose() {
+      if (!this.formData.disposalStatus) {
+        return;
+      }
+      this.$refs.edit.open(
+        this.all ? this.selection : [this.current],
+        this.formData.disposalStatus
+      );
+      this.dialogVisible = false;
+    },
+    async save(data) {
+      if (data.data && data.data.length > 0) {
+        data.data.forEach((item) => {
+          item['fid'] = item.id || this.current.id;
         });
-      },
-      remove(row) {
-        let ids = row ? [row.id] : this.selection.map((item) => item.id);
-        removeSample(ids).then((res) => {
-          this.$message.success('删除' + res);
+      }
+      let ids =
+        data.type == 1 ? [this.current.id] : data.data.map((item) => item.id);
+      disposeApi({
+        disposeType: Number(data.type),
+        poList: data.data
+      })
+        .then((res) => {
+          console.log(res);
+          this.$message.success('处置成功!');
           this.reload();
-          // 删除后更新 allSelectedData
-          this.allSelectedData = this.allSelectedData.filter(
-            (item) => !ids.includes(item.id)
-          );
-        });
-      },
-      close() {
-        this.$refs.disposeForm.resetFields();
-        this.dialogVisible = false;
-        this.disposeType = '';
-      },
-      // // 处置
-      disposeList(type, row) {
-        if (type == 1) {
-          this.all = true;
-          console.log(this.selection);
-        } else {
-          this.id = row.id;
-          this.current = row;
-          console.log(this.current, 'row');
-        }
-        this.formData = { ...row };
-        this.dialogVisible = true;
-        // let ids = this.current ? [this.current.id] : this.selection.map((item) => item.id);
-      },
-      async handleDispose() {
-        if (!this.formData.disposalStatus) {
-          return;
-        }
-        this.$refs.edit.open(
-          this.all ? this.selection : [this.current],
-          this.formData.disposalStatus
-        );
-        this.dialogVisible = false;
-      },
-      async save(data) {
-        if (data.data && data.data.length > 0) {
-          data.data.forEach((item) => {
-            item['fid'] = item.id || this.current.id;
-          });
-        }
-        let ids =
-          data.type == 1 ? [this.current.id] : data.data.map((item) => item.id);
-        disposeApi({
-          disposeType: Number(data.type),
-          poList: data.data
         })
-          .then((res) => {
-            console.log(res);
-            this.$message.success('处置成功!');
-            this.reload();
-          })
-          .catch((err) => {
-            console.log(err);
-          });
-        this.dialogVisible = false;
-        this.current = null;
-      },
-      async consfirm() {
-        this.$refs['disposeForm'].validate(async (valid) => {
-          if (valid) {
-            let params = {
-              disposeType: this.disposeForm.disposeType,
-              poList: []
-            };
-            if (this.all) {
-              params.poList = this.selection.map((item) => {
-                return { ...item, ...this.disposeForm };
-              });
-            } else {
-              params.poList = [
-                { ...deepClone(this.current), ...this.disposeForm }
-              ];
-            }
-            console.log(params);
-            await disposeApi(params);
-            this.dialogVisible = false;
-            this.current = null;
-            this.$message.success('处置成功!');
-            this.reload();
-          }
-          return;
+        .catch((err) => {
+          console.log(err);
         });
-        return;
-
-        // if (this.disposeType == 6) {
-        //   this.$refs['disposeForm'].validate(async (valid) => {
-        //     if (valid) {
-        //       const pa = { ...deepClone(this.current), ...this.disposeForm };
-        //       const params = { disposeType: this.disposeType, poList: [pa] };
-        //       await disposeApi(params);
-        //       this.dialogVisible = false;
-        //       this.current = null;
-        //       this.$message.success('处置成功!');
-        //       this.reload();
-        //       return;
-        //     } else {
-        //       console.log('error submit!!');
-        //       return false;
-        //     }
-        //   });
-        //   return;
-        // }
-        this.$refs.edit.open(
-          this.all ? this.selection : [this.current],
-          this.disposeType
-        );
-        this.dialogVisible = false;
-      },
-      submitForm(formName) {
-        this.$refs[formName].validate((valid) => {
-          if (valid) {
-            alert('submit!');
+      this.dialogVisible = false;
+      this.current = null;
+    },
+    async consfirm() {
+      this.$refs['disposeForm'].validate(async (valid) => {
+        if (valid) {
+          let params = {
+            disposeType: this.disposeForm.disposeType,
+            poList: []
+          };
+          if (this.all) {
+            params.poList = this.selection.map((item) => {
+              return { ...item, ...this.disposeForm };
+            });
           } else {
-            console.log('error submit!!');
-            return false;
+            params.poList = [
+              { ...deepClone(this.current), ...this.disposeForm }
+            ];
           }
-        });
-      }
+          console.log(params);
+          await disposeApi(params);
+          this.dialogVisible = false;
+          this.current = null;
+          this.$message.success('处置成功!');
+          this.reload();
+        }
+        return;
+      });
+      return;
+
+      // if (this.disposeType == 6) {
+      //   this.$refs['disposeForm'].validate(async (valid) => {
+      //     if (valid) {
+      //       const pa = { ...deepClone(this.current), ...this.disposeForm };
+      //       const params = { disposeType: this.disposeType, poList: [pa] };
+      //       await disposeApi(params);
+      //       this.dialogVisible = false;
+      //       this.current = null;
+      //       this.$message.success('处置成功!');
+      //       this.reload();
+      //       return;
+      //     } else {
+      //       console.log('error submit!!');
+      //       return false;
+      //     }
+      //   });
+      //   return;
+      // }
+      this.$refs.edit.open(
+        this.all ? this.selection : [this.current],
+        this.disposeType
+      );
+      this.dialogVisible = false;
+    },
+    submitForm(formName) {
+      this.$refs[formName].validate((valid) => {
+        if (valid) {
+          alert('submit!');
+        } else {
+          console.log('error submit!!');
+          return false;
+        }
+      });
     }
-  };
+  }
+};
 </script>
 
 <style lang="scss" scoped>
-  .unacceptedProductSelect {
-    display: flex;
-    flex-direction: column;
-    align-items: center;
-  }
+.unacceptedProductSelect {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
 </style>

+ 484 - 437
src/views/unacceptedProduct/detail.vue

@@ -80,6 +80,7 @@
             v-model="disposeForm.disposeType"
             placeholder="请选择"
             style="width: 100%"
+            @change="disposeTypeChange"
           >
             <el-option
               v-for="item in disposeList"
@@ -112,6 +113,26 @@
 
         <template v-if="disposeForm.disposeType == 6">
           <el-row>
+            <el-col :span="24">
+              <el-form-item
+                label="留样数量:"
+                prop="keepSampleQuantity"
+                align="center"
+              >
+                <el-input
+                  v-model="disposeForm.keepSampleQuantity"
+                  placeholder="请输入"
+                  style="width: 100%"
+                >
+                  <template slot="append">{{
+                    current?.measureUnit
+                  }}</template></el-input
+                >
+              </el-form-item>
+            </el-col>
+            <el-col :span="6"> </el-col>
+          </el-row>
+          <el-row style="margin-top: 12px">
             <el-col :span="24">
               <el-form-item label="留样日期:" prop="sampleDate" align="center">
                 <el-date-picker
@@ -230,471 +251,497 @@
 </template>
 
 <script>
-  import OrderSearch from './components/detail-search.vue';
-  import Edit from './components/edit.vue';
-  import { getWarehouseLists } from '@/api/produce/index';
+import OrderSearch from './components/detail-search.vue';
+import Edit from './components/edit.vue';
+import { getWarehouseLists } from '@/api/produce/index';
 
-  import dictMixins from '@/mixins/dictMixins';
-  import { unacceptedProductStatus } from '@/utils/util';
-  import { deepClone } from '@/utils';
-  import { disposeApi, refluxTask } from '@/api/unacceptedProduct';
+import dictMixins from '@/mixins/dictMixins';
+import { unacceptedProductStatus } from '@/utils/util';
+import { deepClone } from '@/utils';
+import { disposeApi, refluxTask } from '@/api/unacceptedProduct';
 
-  import {
-    getDetail,
-    deleteUnacceptedProductDetail,
-    dispose,
-    getById
-  } from '@/api/unacceptedProduct/index';
-  export default {
-    components: {
-      OrderSearch,
-      Edit
-    },
-    mixins: [dictMixins],
-    data() {
-      return {
-        key: '',
-        warehouseList: [],
-        rules: {
-          disposeType: [
-            { required: true, message: '请选择处置方式', trigger: 'change' }
-          ],
-          depotId: [
-            { required: true, message: '请选择仓库', trigger: 'change' }
-          ]
-        },
-        disposeType: '',
-        disposeForm: {
-          disposeType: '',
-          sampleCondition: '',
-          sampleDate: '',
-          samplePlace: '',
-          sampleRemark: '',
-          producerManufacturer: '',
-          depotId: '',
-          depotName: '',
-          taskId: ''
-        },
-        loading: false,
-        selection: [],
-        dialogVisible: false,
-        current: {},
-        formData: {},
-        all: false,
-        qualityType: null,
-        allList: [
-          { value: 1, label: '返工' },
-          { value: 2, label: '返修' },
-          { value: 3, label: '报废' },
-          { value: 4, label: '降级使用' },
-          { value: 5, label: '让步接收' },
-          { value: 6, label: '留样' },
-          { value: 7, label: '消耗' },
-          { value: 8, label: '回用/归批' },
-          { value: 9, label: '转试销' },
-          { value: 10, label: '退货' }
+import {
+  getDetail,
+  deleteUnacceptedProductDetail,
+  dispose,
+  getById
+} from '@/api/unacceptedProduct/index';
+export default {
+  components: {
+    OrderSearch,
+    Edit
+  },
+  mixins: [dictMixins],
+  data() {
+    return {
+      key: '',
+      warehouseList: [],
+      rules: {
+        disposeType: [
+          { required: true, message: '请选择处置方式', trigger: 'change' }
         ],
-        //来料
-        disposalStatusListType: [
-          {
-            value: 5,
-            label: '让步接收'
-          },
-          {
-            value: 9,
-            label: '退货'
-          }
-        ],
-        //生产
-        disposalStatusList: [
-          {
-            value: 1,
-            label: '返工'
-          },
-          {
-            value: 2,
-            label: '返修'
-          },
-          {
-            value: 3,
-            label: '报废'
-          },
-          {
-            value: 4,
-            label: '降级使用'
-          },
-          {
-            value: 5,
-            label: '让步接收'
-          },
-          {
-            value: 6,
-            label: '留样'
-          },
-          {
-            value: 7,
-            label: '消耗'
-          },
+        depotId: [{ required: true, message: '请选择仓库', trigger: 'change' }],
+
+        keepSampleQuantity: [
           {
-            value: 8,
-            label: '回用'
+            validator: (rule, value, callback) => {
+              if (
+                this.disposeForm.disposeType === 6 &&
+                this.current &&
+                this.current.measureQuantity !== undefined
+              ) {
+                const inputVal = Number(value);
+                const maxVal = Number(this.current.measureQuantity);
+                if (inputVal > maxVal) {
+                  return callback(new Error(`不能超过原计量数量${maxVal}`));
+                }
+              }
+              callback();
+            },
+            trigger: 'blur'
           }
-        ],
-        refluxTaskList: []
-      };
-    },
-    computed: {
-      showBtn() {
-        return !this.$route.query.type;
+        ]
+      },
+      disposeType: '',
+      disposeForm: {
+        disposeType: '',
+        sampleCondition: '',
+        sampleDate: '',
+        samplePlace: '',
+        sampleRemark: '',
+        producerManufacturer: '',
+        depotId: '',
+        depotName: '',
+        taskId: '',
+        keepSampleQuantity: ''
       },
-      disposeList() {
-        if (this.$route.query.qualityType == 1) {
-          return this.allList.filter((item) => [5, 10].includes(item.value));
+      loading: false,
+      selection: [],
+      dialogVisible: false,
+      current: {},
+      formData: {},
+      all: false,
+      qualityType: null,
+      allList: [
+        { value: 1, label: '返工' },
+        { value: 2, label: '返修' },
+        { value: 3, label: '报废' },
+        { value: 4, label: '降级使用' },
+        { value: 5, label: '让步接收' },
+        { value: 6, label: '留样' },
+        { value: 7, label: '消耗' },
+        { value: 8, label: '回用/归批' },
+        { value: 9, label: '转试销' },
+        { value: 10, label: '退货' }
+      ],
+      //来料
+      disposalStatusListType: [
+        {
+          value: 5,
+          label: '让步接收'
+        },
+        {
+          value: 9,
+          label: '退货'
         }
-        if (
-          this.$route.query.qualityType == 2 ||
-          this.$route.query.qualityType == 3
-        ) {
-          return this.allList.filter(
-            (item) => item.value !== 8 && item.value !== 10
-          );
-        } else {
-          return this.allList;
+      ],
+      //生产
+      disposalStatusList: [
+        {
+          value: 1,
+          label: '返工'
+        },
+        {
+          value: 2,
+          label: '返修'
+        },
+        {
+          value: 3,
+          label: '报废'
+        },
+        {
+          value: 4,
+          label: '降级使用'
+        },
+        {
+          value: 5,
+          label: '让步接收'
+        },
+        {
+          value: 6,
+          label: '留样'
+        },
+        {
+          value: 7,
+          label: '消耗'
+        },
+        {
+          value: 8,
+          label: '回用'
         }
-      },
-      // 表格列配置
-      columns() {
-        const arr = [
-          {
-            width: 45,
-            type: 'selection',
-            columnKey: 'selection',
-            reserveSelection: true,
-            align: 'center',
-            selectable: (row, index) => {
-              return row.disposalStatus !== 2; //
-            }
-          },
-          {
-            columnKey: 'index',
-            label: '序号',
-            type: 'index',
-            width: 55,
-            align: 'center',
-            showOverflowTooltip: true,
-            fixed: 'left'
-          },
-          {
-            label: '样品编码',
-            prop: 'sampleCode',
-            width: '150',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'categoryCode',
-            label: '物品编码',
-            width: '150',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'categoryName',
-            label: '物品名称',
-            width: '150',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            label: '规格',
-            prop: 'specification',
-            width: '120',
-            align: 'center',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'brandNum',
-            label: '牌号',
-            align: 'center'
-          },
-          {
-            prop: 'modelType',
-            label: '型号',
-            align: 'center',
-            width: '120',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'batchNo',
-            label: '批次号',
-            align: 'center',
-            width: '120',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'weight',
-            label: '重量',
-            align: 'center',
-            width: '120',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'weightUnit',
-            label: '重量单位',
-            align: 'center',
-            width: '120',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'engrave',
-            label: '刻码',
-            align: 'center'
-          },
-          // {
-          //   prop: 'unqualifiedQuantity',
-          //   label: '数量',
-          //   align: 'center',
-          //   width: 60
-          // },
-          // { label: '包装数量', prop: 'packingQuantity', align: 'center' },
-          // { label: '包装单位', prop: 'packingUnit', align: 'center' },
-          { label: '计量数量', prop: 'measureQuantity', align: 'center' },
-          { label: '计量单位', prop: 'measureUnit', align: 'center' },
-          // { label: '物料代号', prop: 'materielDesignation', align: 'center' },
-          // { label: '客户代号', prop: 'clientCode', align: 'center' },
-          {
-            prop: 'produceRoutingName',
-            label: '工艺路线',
-            align: 'center'
-          },
-          {
-            prop: 'produceTaskName',
-            label: '工序',
-            align: 'center'
-          },
-          {
-            prop: 'unqualifiedReason',
-            label: '原因',
-            align: 'center'
-          },
-          {
-            prop: 'disposeTime',
-            label: '处置时间',
-            align: 'center',
-            width: '180',
-            showOverflowTooltip: true
-          },
-          {
-            prop: 'disposalStatus',
-            label: '处置状态',
-            align: 'center',
-            width: '120',
-            showOverflowTooltip: true,
-            formatter: (row, column, cellValue) => {
-              return this.disposalStatustList[cellValue ? cellValue : 0];
-            }
-          },
-          {
-            prop: 'disposeType',
-            label: '处置类型',
-            align: 'center',
-            width: '120',
-            showOverflowTooltip: true,
-            formatter: (row, column, cellValue) => {
-              console.log(this.allList.find((item) => item.value == cellValue));
-
-              return this.allList.find((item) => item.value == cellValue)
-                ?.label;
-            }
-          },
-
-          // {
-          //   prop: 'type',
-          //   label: '处置类型',
-          //   align: 'center',
-          //   // slot: 'SlottingType'
-          //   formatter: (row, column, cellValue) => {
-          //     return this.getDictValue('不良品处理类型', cellValue + '');
-          //   }
-          // },
-          // {
-          //   prop: 'status',
-          //   label: '状态',
-          //   align: 'center',
-          //   formatter: (row, column, cellValue) => {
-          //     return unacceptedProductStatus(cellValue);
-          //   }
-          // },
-
-          {
-            columnKey: 'action',
-            label: '操作',
-            width: 150,
-            align: 'center',
-            resizable: false,
-            fixed: 'right',
-            slot: 'action',
-            showOverflowTooltip: true
-          }
-        ];
-        return this.$route.query.type ? arr.slice(0, -1) : arr;
-      },
-      disposalStatustList() {
-        return { 0: '待处置', 1: '处置中', 2: '处置完成' };
-      }
+      ],
+      refluxTaskList: []
+    };
+  },
+  computed: {
+    showBtn() {
+      return !this.$route.query.type;
     },
-    async created() {
-      this.qualityType = this.$route.query.qualityType;
-      this.warehouseList = await getWarehouseLists();
-      if (this.$route.query.workOrderCode) {
-        this.getRefluxTask();
+    disposeList() {
+      if (this.$route.query.qualityType == 1) {
+        return this.allList.filter((item) => [5, 10].includes(item.value));
+      }
+      if (
+        this.$route.query.qualityType == 2 ||
+        this.$route.query.qualityType == 3
+      ) {
+        return this.allList.filter(
+          (item) => item.value !== 8 && item.value !== 10
+        );
+      } else {
+        return this.allList;
       }
-
-      // console.log(this.warehouseList, 'this.warehouseList');
     },
+    // 表格列配置
+    columns() {
+      const arr = [
+        {
+          width: 45,
+          type: 'selection',
+          columnKey: 'selection',
+          reserveSelection: true,
+          align: 'center',
+          selectable: (row, index) => {
+            return row.disposalStatus !== 2; //
+          }
+        },
+        {
+          columnKey: 'index',
+          label: '序号',
+          type: 'index',
+          width: 55,
+          align: 'center',
+          showOverflowTooltip: true,
+          fixed: 'left'
+        },
+        {
+          label: '样品编码',
+          prop: 'sampleCode',
+          width: '150',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'categoryCode',
+          label: '物品编码',
+          width: '150',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'categoryName',
+          label: '物品名称',
+          width: '150',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          label: '规格',
+          prop: 'specification',
+          width: '120',
+          align: 'center',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'brandNum',
+          label: '牌号',
+          align: 'center'
+        },
+        {
+          prop: 'modelType',
+          label: '型号',
+          align: 'center',
+          width: '120',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'batchNo',
+          label: '批次号',
+          align: 'center',
+          width: '120',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'weight',
+          label: '重量',
+          align: 'center',
+          width: '120',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'weightUnit',
+          label: '重量单位',
+          align: 'center',
+          width: '120',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'engrave',
+          label: '刻码',
+          align: 'center'
+        },
+        // {
+        //   prop: 'unqualifiedQuantity',
+        //   label: '数量',
+        //   align: 'center',
+        //   width: 60
+        // },
+        // { label: '包装数量', prop: 'packingQuantity', align: 'center' },
+        // { label: '包装单位', prop: 'packingUnit', align: 'center' },
+        { label: '计量数量', prop: 'measureQuantity', align: 'center' },
+        { label: '计量单位', prop: 'measureUnit', align: 'center' },
+        // { label: '物料代号', prop: 'materielDesignation', align: 'center' },
+        // { label: '客户代号', prop: 'clientCode', align: 'center' },
+        {
+          prop: 'produceRoutingName',
+          label: '工艺路线',
+          align: 'center'
+        },
+        {
+          prop: 'produceTaskName',
+          label: '工序',
+          align: 'center'
+        },
+        {
+          prop: 'unqualifiedReason',
+          label: '原因',
+          align: 'center'
+        },
+        {
+          prop: 'disposeTime',
+          label: '处置时间',
+          align: 'center',
+          width: '180',
+          showOverflowTooltip: true
+        },
+        {
+          prop: 'disposalStatus',
+          label: '处置状态',
+          align: 'center',
+          width: '120',
+          showOverflowTooltip: true,
+          formatter: (row, column, cellValue) => {
+            return this.disposalStatustList[cellValue ? cellValue : 0];
+          }
+        },
+        {
+          prop: 'disposeType',
+          label: '处置类型',
+          align: 'center',
+          width: '120',
+          showOverflowTooltip: true,
+          formatter: (row, column, cellValue) => {
+            console.log(this.allList.find((item) => item.value == cellValue));
 
-    methods: {
-      // /* 表格数据源 */
-      async datasource({ page, where, limit }) {
-        let id = this.$route.query.id;
-        const arr = await getById(id);
-        // where.unqualifiedProductsId = this.$route.query.id;
-        return arr.poList;
-      },
+            return this.allList.find((item) => item.value == cellValue)?.label;
+          }
+        },
 
-      async getRefluxTask() {
-        await refluxTask({
-          workOrderCode: this.$route.query.workOrderCode
-        }).then((res) => {
-          this.refluxTaskList = res;
-        });
-      },
+        // {
+        //   prop: 'type',
+        //   label: '处置类型',
+        //   align: 'center',
+        //   // slot: 'SlottingType'
+        //   formatter: (row, column, cellValue) => {
+        //     return this.getDictValue('不良品处理类型', cellValue + '');
+        //   }
+        // },
+        // {
+        //   prop: 'status',
+        //   label: '状态',
+        //   align: 'center',
+        //   formatter: (row, column, cellValue) => {
+        //     return unacceptedProductStatus(cellValue);
+        //   }
+        // },
 
-      reload(where) {
-        this.key = Math.random();
-        // this.$nextTick(() => {
-        //   if (this.$refs.searchRef && this.$refs.searchRef.reload)
-        //     this.$refs.searchRef.reload({ page: 1, where: where });
-        // });
-      },
-      remove(row) {
-        let ids = row ? [row.id] : this.selection.map((item) => item.id);
-        deleteUnacceptedProductDetail(ids).then((res) => {
-          this.$message.success('删除' + res);
-          this.getList();
-        });
-      },
-      close() {
-        this.$refs.disposeForm.resetFields();
-        this.dialogVisible = false;
-        this.disposeType = '';
-        this.all = false;
-        this.formData.disposalStatus = '';
-      },
-      // // 处置
-      disposeFn(type, row) {
-        if (type == 1) {
-          this.all = true;
-        } else {
-          this.current = row;
-          console.log(this.current, 'row');
+        {
+          columnKey: 'action',
+          label: '操作',
+          width: 150,
+          align: 'center',
+          resizable: false,
+          fixed: 'right',
+          slot: 'action',
+          showOverflowTooltip: true
         }
-        this.formData = { ...row };
-        this.dialogVisible = true;
-        // let ids = this.current ? [this.current.id] : this.selection.map((item) => item.id);
-      },
-      async handleDispose() {
-        this.$refs['disposeForm'].validate(async (valid) => {
-          if (valid) {
-            let params = {
-              disposeType: this.disposeForm.disposeType,
-              poList: [],
-              refluxTask: null
-            };
-            if (this.all) {
-              params.poList = this.selection.map((item) => {
-                return { ...item, ...this.disposeForm };
-              });
-            } else {
-              params.poList = [
-                { ...deepClone(this.current), ...this.disposeForm }
-              ];
-            }
+      ];
+      return this.$route.query.type ? arr.slice(0, -1) : arr;
+    },
+    disposalStatustList() {
+      return { 0: '待处置', 1: '处置中', 2: '处置完成' };
+    }
+  },
+  async created() {
+    this.qualityType = this.$route.query.qualityType;
+    this.warehouseList = await getWarehouseLists();
+    if (this.$route.query.workOrderCode) {
+      this.getRefluxTask();
+    }
+
+    // console.log(this.warehouseList, 'this.warehouseList');
+  },
 
-            if (this.disposeForm.taskId) {
-              params.refluxTask = this.refluxTaskList.find(
-                (item) => item.taskId == this.disposeForm.taskId
-              );
-            }
+  methods: {
+    disposeTypeChange() {
+      console.log(this.disposeForm.disposeType);
+      console.log(this.current.measureQuantity)
+      if (this.disposeForm.disposeType == 6) {
+        this.disposeForm.keepSampleQuantity =
+          this.current?.measureQuantity || '';
+      }
+    },
+    // /* 表格数据源 */
+    async datasource({ page, where, limit }) {
+      let id = this.$route.query.id;
+      const arr = await getById(id);
+      // where.unqualifiedProductsId = this.$route.query.id;
+      return arr.poList;
+    },
 
-            console.log(params);
-            await disposeApi(params);
-            this.dialogVisible = false;
-            this.current = null;
-            this.$message.success('处置成功!');
-            this.reload();
-            return;
+    async getRefluxTask() {
+      await refluxTask({
+        workOrderCode: this.$route.query.workOrderCode
+      }).then((res) => {
+        this.refluxTaskList = res;
+      });
+    },
+
+    reload(where) {
+      this.key = Math.random();
+      // this.$nextTick(() => {
+      //   if (this.$refs.searchRef && this.$refs.searchRef.reload)
+      //     this.$refs.searchRef.reload({ page: 1, where: where });
+      // });
+    },
+    remove(row) {
+      let ids = row ? [row.id] : this.selection.map((item) => item.id);
+      deleteUnacceptedProductDetail(ids).then((res) => {
+        this.$message.success('删除' + res);
+        this.getList();
+      });
+    },
+    close() {
+      this.$refs.disposeForm.resetFields();
+      this.dialogVisible = false;
+      this.disposeType = '';
+      this.all = false;
+      this.formData.disposalStatus = '';
+    },
+    // // 处置
+    disposeFn(type, row) {
+      if (type == 1) {
+        this.all = true;
+      } else {
+        this.current = row;
+        console.log(this.current, 'row');
+      }
+      this.formData = { ...row };
+      this.dialogVisible = true;
+      // let ids = this.current ? [this.current.id] : this.selection.map((item) => item.id);
+    },
+    async handleDispose() {
+      this.$refs['disposeForm'].validate(async (valid) => {
+        if (valid) {
+          let params = {
+            disposeType: this.disposeForm.disposeType,
+            poList: [],
+            refluxTask: null
+          };
+          if (this.all) {
+            params.poList = this.selection.map((item) => {
+              return { ...item, ...this.disposeForm };
+            });
           } else {
-            return false;
+            params.poList = [
+              { ...deepClone(this.current), ...this.disposeForm }
+            ];
           }
-          return;
-        });
 
-        return;
-      },
-      validate() {},
-      async save(data) {
-        if (data.data && data.data.length > 0) {
-          data.data.forEach((item) => {
-            item['fid'] = item.id || this.current.id;
-          });
+          if (this.disposeForm.taskId) {
+            params.refluxTask = this.refluxTaskList.find(
+              (item) => item.taskId == this.disposeForm.taskId
+            );
+          }
+
+          console.log(params);
+          await disposeApi(params);
+          this.dialogVisible = false;
+          this.current = null;
+          this.$message.success('处置成功!');
+          this.reload();
+          return;
+        } else {
+          return false;
         }
-        let ids =
-          data.type == 1 ? [this.current.id] : data.data.map((item) => item.id);
-        await dispose({
-          id: ids,
-          disposeType: Number(data.type),
-          poList: data.data
+        return;
+      });
+
+      return;
+    },
+    validate() {},
+    async save(data) {
+      if (data.data && data.data.length > 0) {
+        data.data.forEach((item) => {
+          item['fid'] = item.id || this.current.id;
         });
-        this.dialogVisible = false;
-        this.current = null;
-        this.$message.success('处置成功!');
-        this.reload();
-      },
-      chooseWarehouse(item) {
-        console.log(item);
-        this.disposeForm.depotId = item.id;
-        this.disposeForm.depotName = item.name;
       }
+      let ids =
+        data.type == 1 ? [this.current.id] : data.data.map((item) => item.id);
+      await dispose({
+        id: ids,
+        disposeType: Number(data.type),
+        poList: data.data
+      });
+      this.dialogVisible = false;
+      this.current = null;
+      this.$message.success('处置成功!');
+      this.reload();
     },
-    watch: {
-      'disposeForm.disposeType': {
-        handler(newVal, oldVal) {
-          if (newVal == 6) {
-            this.rules.depotId = [];
-          } else {
-            this.rules.depotId = [
-              { required: true, message: '请选择仓库', trigger: 'change' }
-            ];
-          }
-          this.disposeForm.sampleCondition = '';
-          this.disposeForm.sampleDate = '';
-          this.disposeForm.samplePlace = '';
-          this.disposeForm.sampleRemark = '';
-          this.disposeForm.producerManufacturer = '';
-          this.disposeForm.depotId = '';
-          this.disposeForm.depotName = '';
-          this.disposeForm.taskId = '';
+    chooseWarehouse(item) {
+      console.log(item);
+      this.disposeForm.depotId = item.id;
+      this.disposeForm.depotName = item.name;
+    }
+  },
+  watch: {
+    'disposeForm.disposeType': {
+      handler(newVal, oldVal) {
+        if (newVal == 6) {
+          this.rules.depotId = [];
+        } else {
+          this.rules.depotId = [
+            { required: true, message: '请选择仓库', trigger: 'change' }
+          ];
         }
+        this.disposeForm.sampleCondition = '';
+        this.disposeForm.sampleDate = '';
+        this.disposeForm.samplePlace = '';
+        this.disposeForm.sampleRemark = '';
+        this.disposeForm.producerManufacturer = '';
+        this.disposeForm.depotId = '';
+        this.disposeForm.depotName = '';
+        this.disposeForm.taskId = '';
       }
     }
-  };
+  }
+};
 </script>
 
 <style lang="scss" scoped>
-  .unacceptedProductSelect {
-    display: flex;
-    flex-direction: column;
-    align-items: center;
-  }
+.unacceptedProductSelect {
+  display: flex;
+  flex-direction: column;
+  align-items: center;
+}
 </style>

+ 1 - 1
vue.config.js

@@ -43,7 +43,7 @@ module.exports = {
         // target: 'http://192.168.1.33:18086',
         // target: 'http://192.168.1.251:18186',
         // target: 'http://192.168.1.251:18087',
-        target: 'http://192.168.1.116:18086',
+        // target: 'http://192.168.1.116:18086',
         changeOrigin: true, // 只有这个值为true的情况下 才表示开启跨域
         pathRewrite: {
           '^/api': ''

Разница между файлами не показана из-за своего большого размера
+ 303 - 303
yarn.lock


Некоторые файлы не были показаны из-за большого количества измененных файлов