From 8ff18ada93d1e3a6174a28f9339bec8221f03e6a Mon Sep 17 00:00:00 2001
From: 小小儁爺 <1694218219@qq.com>
Date: 星期一, 12 八月 2024 19:09:51 +0800
Subject: [PATCH] 1.生产加工单  批量派发功能优化

---
 src/views/produceManager/workOrder.vue |  187 +++++++++++++++++++++++++++-------------------
 1 files changed, 109 insertions(+), 78 deletions(-)

diff --git a/src/views/produceManager/workOrder.vue b/src/views/produceManager/workOrder.vue
index 5b9d60e..6c3f8e7 100644
--- a/src/views/produceManager/workOrder.vue
+++ b/src/views/produceManager/workOrder.vue
@@ -289,16 +289,7 @@
               <div v-else>/</div>
             </template>
           </el-table-column>
-          <!--          <el-table-column-->
-          <!--            prop="route_name"-->
-          <!--            label="鍏宠仈宸ヨ壓璺嚎"-->
-          <!--            min-width="110"-->
-          <!--          >-->
-          <!--            <template slot-scope="{row}">-->
-          <!--              <i v-if="row.route_name" class="el-icon-share" @click="routeClick(row)" />-->
-          <!--              <i v-else style="color:rgb(180 ,181, 185)" class="el-icon-share" @click="routeClick(row)" />-->
-          <!--            </template>-->
-          <!--          </el-table-column>-->
+
           <el-table-column
             prop="plan_startdate"
             label="璁″垝寮�濮嬫椂闂�"
@@ -1945,26 +1936,26 @@
         </div>
       </div>
 
-      <el-divider />
-      <div>
-        <i class="el-icon-s-operation" style="color:#42b983;" /> 榛樿宸ヨ壓璺嚎
-      </div>
-      <div style="margin-top: 20px">
-        <el-select
-          v-model="defaultroute_code"
-          filterable
-          style="width: 200px;"
-          placeholder="璇烽�夋嫨"
-          class="defaultroute_code"
-        >
-          <el-option
-            v-for="item in defaultroute_codeArr"
-            :key="item.code"
-            :label="item.name"
-            :value="item.code"
-          />
-        </el-select>
-      </div>
+      <!--      <el-divider />-->
+      <!--      <div>-->
+      <!--        <i class="el-icon-s-operation" style="color:#42b983;" /> 榛樿宸ヨ壓璺嚎-->
+      <!--      </div>-->
+      <!--      <div style="margin-top: 20px">-->
+      <!--        <el-select-->
+      <!--          v-model="defaultroute_code"-->
+      <!--          filterable-->
+      <!--          style="width: 200px;"-->
+      <!--          placeholder="璇烽�夋嫨"-->
+      <!--          class="defaultroute_code"-->
+      <!--        >-->
+      <!--          <el-option-->
+      <!--            v-for="item in defaultroute_codeArr"-->
+      <!--            :key="item.code"-->
+      <!--            :label="item.name"-->
+      <!--            :value="item.code"-->
+      <!--          />-->
+      <!--        </el-select>-->
+      <!--      </div>-->
       <el-divider />
       <div style="margin-bottom: 10px">
         <i class="el-icon-s-operation" style="color:#42b983;" /> 宸ュ簭鍒楄〃
@@ -2034,12 +2025,15 @@
       @close="handleClose3"
     >
 
-      <div style="height: 600px;padding-right: 20px;overflow: auto">
+      <div style="height: 30px;width: 100%;margin-bottom: 10px;">
         <el-alert
-          v-if="multipleSelection.length-formData3.length>0"
-          :title="'褰撳墠閫変腑'+multipleSelection.length+'涓伐鍗曪紝鏈�'+(multipleSelection.length-formData3.length)+'涓伐鍗曟湭鎸囧畾宸ヨ壓璺嚎锛屽凡杩囨护锛�'"
+          v-if="formData3.filter(i => i.routecode==='').length>0"
+          :title="'褰撳墠閫変腑'+multipleSelection.length+'涓伐鍗曪紝鏈�'+(formData3.filter(i => i.routecode==='').length)+'涓伐鍗曟湭鎸囧畾宸ヨ壓璺嚎锛岃鎸囧畾锛�'"
           type="error"
         />
+      </div>
+      <div style="height: 600px;padding-right: 20px;overflow: auto">
+
         <div v-for="(i,index) in formData3" :key="index">
           <el-divider content-position="left">绗瑊{ index+1 }}涓伐鍗�</el-divider>
 
@@ -2047,6 +2041,7 @@
             ref="dialogForm"
             inline
             :model="i"
+            style="margin-bottom: 20px"
             label-width="110px"
           >
             <el-form-item
@@ -2164,7 +2159,7 @@
               <!--              </el-select>-->
             </el-form-item>
 
-            <el-form-item label="宸ヨ壓璺嚎" prop="routecode">
+            <el-form-item label="宸ヨ壓璺嚎">
               <el-select
                 v-model="i.routecode"
                 filterable
@@ -2182,18 +2177,24 @@
               </el-select>
             </el-form-item>
             <el-form-item label="宸ヤ环绠℃帶" required>
-              <el-switch
-                v-model="i.is_steprice"
-                active-color="#13ce66"
-                inactive-color="#eee"
-                @change="routecodeChange2(i)"
-              />
+              <div style="display: flex;align-items: center;justify-content: space-between;width: 200px;">
+                <el-switch
+                  v-model="i.is_steprice"
+                  active-color="#13ce66"
+                  inactive-color="#eee"
+                  style="width: 60px;"
+                  @change="routecodeChange2(i)"
+                />
+
+                <el-button type="primary" @click="routeClick(i,routeIndex=index)">宸ヨ壓閫夋嫨</el-button>
+              </div>
+
             </el-form-item>
 
           </el-form>
 
           <div style="display: flex;justify-content: flex-end;margin-top: -50px;margin-right: 50px">
-            {{ i.children.find(it=>it.routecode===i.routecode).stepname }}
+            {{ i.children.length>0? i.children.find(it=>it.routecode===i.routecode).stepname:'' }}
           </div>
         </div>
       </div>
@@ -2203,7 +2204,6 @@
           <el-button v-waves @click="dialogVisible3=false">鍙� 娑�</el-button>
           <el-button
             v-waves
-
             type="primary"
             :disabled="submitButtonIsDisabled"
             @click="dialogVisibleConfirm3"
@@ -2503,8 +2503,14 @@
 
       dialogVisible3: false,
       multipleSelection: [],
-      formData3: []
+      formData3: [],
 
+      routeIndex: ''
+      // dialogFormRules2: {
+      //   routecode: [
+      //     { required: true, message: '璇烽�夋嫨宸ヨ壓璺嚎', trigger: ['blur', 'change'] }
+      //   ]
+      // }
     }
   },
   created() {
@@ -3288,14 +3294,20 @@
     },
     /* 鍏宠仈宸ヨ壓璺嚎妯″潡*/
     // 鍏宠仈宸ヨ壓璺嚎
-    async routeClick(row) {
-      console.log(row)
-      // this.defaultroute_code = row.default_route
-      this.dialogFormRoute.projectCode = row.partcode
-      this.dialogFormRoute.projectName = row.partname
+    async routeClick(i) {
+      // console.log(row)
+      // // this.defaultroute_code = row.default_route
+      this.dialogFormRoute.projectCode = i.partcode
+      this.dialogFormRoute.projectName = i.partname
+
+      const { data: res } = await InventoryFileAssociationRoute({ partcode: i.partcode })
+      this.dialogFormRoute.routeOperationArr = res.filter(j => j.wkshopcode === i.wkshopcode)
+
+      if (this.dialogFormRoute.routeOperationArr.length === 0) {
+        return this.$message.info('姝よ溅闂翠笅鏃犲伐鑹鸿矾绾匡紒')
+      }
+
       this.dialogVisibleRoute = true
-      const { data: res } = await InventoryFileAssociationRoute({ partcode: this.dialogFormRoute.projectCode })
-      this.dialogFormRoute.routeOperationArr = res
 
       this.dialogFormRoute.routeOperationArr.forEach((item, index) => {
         item.isSelected1 = false
@@ -3307,7 +3319,7 @@
         if (item.flag === 'Y') {
           item.isSelected2 = true
           this.$nextTick(() => {
-            $('input:checkbox').eq(index).prop('checked', true)
+            $('.myCheckboxInput').eq(index).prop('checked', true)
           })
         }
       })
@@ -3327,23 +3339,36 @@
     },
     // 纭畾
     async routeDialogVisibleConfirm() {
-      const temp = this.dialogFormRoute.routeOperationArr.filter(item => item.isSelected2)
-      if (this.defaultroute_code === '' && temp.length > 0) {
-        return this.$message.info('榛樿宸ヨ壓璺嚎涓嶈兘涓虹┖锛�')
+      if (!this.dialogFormRoute.routeOperationArr.find(i => i.isSelected2)) {
+        return this.$message.info('璇峰厛閫夋嫨宸ヨ壓璺嚎锛�')
       }
+
+      // const temp = this.dialogFormRoute.routeOperationArr.filter(item => item.isSelected2)
+      // if (this.defaultroute_code === '' && temp.length > 0) {
+      //   return this.$message.info('榛樿宸ヨ壓璺嚎涓嶈兘涓虹┖锛�')
+      // }
 
       // 鎻愪氦鏍煎紡
       const data = []
+      this.formData3[this.routeIndex].children = []
       this.dialogFormRoute.routeOperationArr.forEach(item => {
         if (item.isSelected2) {
-          data.push({ code: item.code, name: item.name })
+          // console.log(item, 8)
+
+          data.push({ code: item.code, name: item.name, wkshopcode: this.formData3[this.routeIndex].wkshopcode, stepname: item.Data.map(i => { if (i.enable === 'Y') { return i.stepname } }).join(',') })
+          this.formData3[this.routeIndex].children.push({
+            routecode: item.code,
+            routename: item.name,
+            stepname: item.Data.map(i => { if (i.enable === 'Y') { return i.stepname } }).join(',')
+          })
         }
       })
 
       const res = await SaveInventoryFile(this.dialogFormRoute.projectCode, this.defaultroute_code, data)
       if (res.code === '200') {
         this.$message.success('淇濆瓨鎴愬姛锛�')
-        await this.getMesOrderSearch()
+        this.formData3[this.routeIndex].routecode = this.formData3[this.routeIndex].children[0].routecode
+        this.formData3[this.routeIndex].stepname = this.formData3[this.routeIndex].children[0].stepname
         this.dialogVisibleRoute = false
       }
     },
@@ -3453,29 +3478,30 @@
       this.formData3 = []
       this.multipleSelection.forEach((item, index) => {
         item.stepname = res[index].children.length > 0 ? res[index].children[0].stepname : ''
-        if (item.stepname) {
-          this.formData3.push({
-            'mesorderstus': item.status,
-            'sourceorder': item.m_po,
-            'ordertype': item.wotype,
-            'mesordercode': item.wo_code,
-            'partcode': item.partcode,
-            'mesqty': item.plan_qty,
-            'routecode': res[index].children.length > 0 ? res[index].children[0].routecode : '',
-            'wkshopcode': item.wkshp_code,
-            'wkshopname': item.wkshp_name,
-            'partname': item.partname,
-            'partspec': item.partspec,
-            'planstartdate': item.plan_startdate,
-            'planenddate': item.plan_enddate,
-            'orderlev': item.piroque,
-            children: res[index].children,
-            is_steprice: false,
+        console.log(item.stepname)
+        // if (item.stepname) {
+        this.formData3.push({
+          'mesorderstus': item.status,
+          'sourceorder': item.m_po,
+          'ordertype': item.wotype,
+          'mesordercode': item.wo_code,
+          'partcode': item.partcode,
+          'mesqty': item.plan_qty,
+          'routecode': res[index].children.length > 0 ? res[index].children[0].routecode : '',
+          'wkshopcode': item.wkshp_code,
+          'wkshopname': item.wkshp_name,
+          'partname': item.partname,
+          'partspec': item.partspec,
+          'planstartdate': item.plan_startdate,
+          'planenddate': item.plan_enddate,
+          'orderlev': item.piroque,
+          children: res[index].children.length > 0 ? res[index].children : [],
+          is_steprice: false,
 
-            'is_aps': '',
-            'bom_id': ''
-          })
-        }
+          'is_aps': '',
+          'bom_id': ''
+        })
+        // }
       })
 
       if (this.formData3.length === 0) {
@@ -3486,6 +3512,10 @@
     },
     // 鎵归噺娲惧彂纭畾浜嬩欢
     async dialogVisibleConfirm3() {
+      if (this.formData3.filter(i => i.routecode === '').length > 0) {
+        return this.$message.info('杩樻湁' + this.formData3.filter(i => i.routecode === '').length + '涓伐鍗曟湭鎸囧畾锛�')
+      }
+
       const data = []
       this.formData3.forEach(i => {
         data.push({
@@ -3539,6 +3569,7 @@
         })
       }
     }
+
   }
 }
 </script>

--
Gitblit v1.9.3