From 0159c69171860516e9476bd77285329e9d507ec8 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期四, 01 九月 2022 10:42:21 +0800
Subject: [PATCH] 工单新增 关联工艺路线功能

---
 src/views/scgl/gd.vue |  318 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 306 insertions(+), 12 deletions(-)

diff --git a/src/views/scgl/gd.vue b/src/views/scgl/gd.vue
index e26bf4f..14ac9bf 100644
--- a/src/views/scgl/gd.vue
+++ b/src/views/scgl/gd.vue
@@ -8,7 +8,7 @@
           <el-button type="primary" icon="el-icon-connection" @click="send('send')">娲惧彂</el-button>
         </div>
 
-        <el-button icon="el-icon-switch-button" @click="orderClose">宸ュ崟鍏抽棴</el-button>
+        <el-button icon="el-icon-switch-button" @click="orderClose">鍏抽棴宸ュ崟</el-button>
       </div>
 
       <div class="bodyTopFormGroup">
@@ -238,15 +238,25 @@
           <el-table-column
             prop="route_name"
             label="宸ヨ壓璺嚎"
+            show-tooltip-when-overflow
             sortable="custom"
-            min-width="130"
+            min-width="140"
           >
             <template slot-scope="{row}">
               <div v-if="row.route_name">{{ row.route_name }}</div>
               <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="璁″垝寮�濮嬫椂闂�"
@@ -376,8 +386,9 @@
               style="width: 200px"
               :disabled="operation!=='add'"
               placeholder="璇烽�夋嫨"
+              @change="mesordertypeChange"
             >
-              <!--            @change="mesordertypeChange"-->
+
               <el-option
                 v-for="item in ordertypeArr"
                 :key="item.code"
@@ -398,7 +409,7 @@
               type="primary"
               style="padding: 0 10px;margin-left: -8px;margin-top: 3px"
               class="el-icon-search"
-              :disabled="operation!=='add'"
+              :disabled="operation!=='add'||dialogForm.ordertype==='PO'"
               @click="mesordertsourcesearchclick"
             />
           </div>
@@ -436,7 +447,7 @@
         <el-form-item v-if="operation!=='add'" label="浜у搧鍚嶇О" prop="partname">
           <el-input v-model="dialogForm.partname" disabled style="width: 200px" />
         </el-form-item>
-        <el-form-item label="浜у搧缂栫爜" prop="partcode">
+        <el-form-item label="浜у搧缂栫爜">
           <el-input v-model="dialogForm.partcode" disabled style="width: 200px" />
         </el-form-item>
         <el-form-item label="浜у搧瑙勬牸" prop="partspec">
@@ -1188,6 +1199,116 @@
       </span>
     </el-dialog>
 
+    <!--    宸ヨ壓璺嚎瀵硅瘽妗�-->
+    <el-dialog
+      :close-on-click-modal="false"
+      title="鍏宠仈宸ヨ壓璺嚎"
+      :visible.sync="dialogVisibleRoute"
+      width="800px"
+      top="10vh"
+      :fullscreen="isIpad"
+      class="dialogVisibleRoute"
+      @closed="handleCloseRoute"
+      @close="handleCloseRoute"
+    >
+      <div>
+        <i class="el-icon-s-comment" style="color:#42b983;" /> 浜у搧鍚嶇О锛歿{ dialogFormRoute.projectName }}
+      </div>
+      <el-divider />
+      <div style="margin-bottom: 10px">
+        <i class="el-icon-s-operation" style="color:#42b983;" /> 宸ヨ壓璺嚎闆嗗悎
+      </div>
+
+      <div class="myCheckboxGroup">
+        <div
+          v-for="item in dialogFormRoute.routeOperationArr"
+          :key="item.code"
+          :style="{border:item.isSelected1?'1px solid #42b983':'1px solid #eee'}"
+          class="myCheckbox"
+          @click="myCheckboxClick(item)"
+        >
+          <input
+            class="myCheckboxInput"
+            type="checkbox"
+            :value="item.code"
+            :name="item.name"
+            :style="{color:item.isSelected2?'#42b983':'#fff'}"
+            @click="myCheckboxInputClick(item)"
+          >{{ item.name }}
+          <!--            鐖跺瓙鐐瑰嚮浜嬩欢涓嶅奖鍝�-->
+          <!--            onClick="event.cancelBubble = true"-->
+        </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 style="margin-bottom: 10px">
+        <i class="el-icon-s-operation" style="color:#42b983;" /> 宸ュ簭鍒楄〃
+      </div>
+      <div style="overflow-y: scroll">
+        <el-table
+          ref="projectTableData"
+          :data="projectTableData"
+          border
+          height="280"
+          :row-class-name="tableRowClassName"
+          highlight-current-row
+          :header-cell-style="this.$headerCellStyle"
+          :cell-style="this.$cellStyle"
+        >
+          <el-table-column
+            prop="seq"
+            width="100"
+            label="宸ュ簭搴忓彿"
+            fixed
+          />
+          <el-table-column
+            prop="stepcode"
+            label="宸ュ簭缂栫爜"
+          />
+          <el-table-column
+            prop="stepname"
+            label="宸ュ簭鍚嶇О"
+          />
+          <el-table-column
+            prop="enable"
+            label="鍚敤鐘舵��"
+            fixed="right"
+          >
+            <template slot-scope="{row}">
+              <div v-if="row.enable==='Y'"><svg-icon icon-class="circleYes" style="margin-right: 2px" />鏄�</div>
+              <div v-if="row.enable==='N'"><svg-icon icon-class="circleNo" style="margin-right: 2px" />鍚�</div>
+            </template>
+          </el-table-column>
+        </el-table>
+      </div>
+      <span slot="footer" class="dialog-footer">
+        <div class="footerButton">
+          <el-button @click="routeDialogVisibleCancel">鍙� 娑�</el-button>
+          <el-button type="primary" @click="routeDialogVisibleConfirm">纭� 瀹�</el-button>
+        </div>
+      </span>
+    </el-dialog>
+
   </div>
 </template>
 
@@ -1200,12 +1321,13 @@
   MesOrderSearch, PartSelectRoute, RouteSelectWkshop, SearchWorkStep,
   SelectRouteStep
 } from '@/api/scgl'
-import { PartSelect } from '@/api/zzmx'
+import { InventoryFileAssociationRoute, PartSelect, SaveInventoryFile } from '@/api/zzmx'
 import { handleDatetime, handleDatetime2 } from '@/utils/global'
 import { getCookie } from '@/utils/auth'
 import { MesOrderPrintSearch1, PrintOrder } from '@/api/utils'
 import { urlAddRandomNo, webapp_ws_ajax_run, webapp_ws_autoupdate } from '@/utils/grwebapp'
 import QRCode from 'qrcodejs2'
+import $ from 'jquery'
 
 const SER_HZ = /^[\u4e00-\u9fa5]+$/
 export default {
@@ -1413,7 +1535,16 @@
       },
       sourceFormTotal: 10,
       radioSelectedId: '',
-      isExpand: false// 鏄惁寮犲紑锛岄粯璁や笉灞曞紑
+      isExpand: false, // 鏄惁寮犲紑锛岄粯璁や笉灞曞紑
+      dialogVisibleRoute: false,
+      dialogFormRoute: {
+        projectName: '', // 浜у搧鍚嶇О
+        projectCode: '', // 浜у搧浠g爜
+        routeOperationArr: [] // 宸ヨ壓璺嚎闆嗗悎
+      },
+      defaultroute_code: '', // 榛樿宸ヨ壓璺嚎閫変腑鍊�
+      defaultroute_codeArr: '', // 榛樿宸ヨ壓璺嚎鏁扮粍
+      projectTableData: []// 璁惧鍒楄〃
     }
   },
   created() {
@@ -1609,7 +1740,6 @@
     },
     // 鍒犻櫎鎸夐挳
     async del(row) {
-      console.log(row.status)
       if (row.status === 'START' || row.status === 'CLOSED') {
         return this.$message.info('姝ゅ伐鍗曚笉鍙垹闄わ紒')
       }
@@ -1620,11 +1750,11 @@
       }).then(() => {
         console.log(row, 1)
         const data = {
+          souceid: row.sourceid,
           wocode: row.wo_code,
           m_po: row.m_po,
           orderqty: row.plan_qty
         }
-        console.log(data, 2)
         DeleteMesOrder(data).then(res => {
           if (res.code === '200') {
             this.$message.success('鍒犻櫎鎴愬姛!')
@@ -1999,7 +2129,7 @@
       }
 
       const res = await ErpOrderSearch(data)
-      this.sourceTableData = res.data
+      this.sourceTableData = res.data.filter(item => item.status !== 'NEW')
       this.sourceFormTotal = res.count
     },
     // 鍗曢�夋閫変腑鑾峰彇褰撳墠琛屼俊鎭�
@@ -2045,18 +2175,181 @@
       this.sourceTableData.forEach(item => {
         if (item.id === this.radioSelectedId) {
           this.dialogForm.sourceorder = item.wo
+          this.dialogForm.partcode = item.partcode
+          this.dialogForm.partspec = item.partspec
         }
       })
       this.dialogVisibleSource = false
-    }
+      this.partcodeChange(this.dialogForm.partcode)
+    },
+    mesordertypeChange(val) {
+      if (val === 'PO') {
+        this.dialogForm.sourceorder = ''
+        this.dialogForm.partcode = ''
+        this.dialogForm.partspec = ''
+      }
+    },
+    /* 鍏宠仈宸ヨ壓璺嚎妯″潡*/
+    // 鍏宠仈宸ヨ壓璺嚎
+    async routeClick(row) {
+      console.log(row)
+      // this.defaultroute_code = row.default_route
+      this.dialogFormRoute.projectCode = row.partcode
+      this.dialogFormRoute.projectName = row.partname
+      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
+        item.isSelected2 = false
+        if (index === 0) {
+          item.isSelected1 = true
+          this.projectTableData = item.Data
+        }
+        if (item.flag === 'Y') {
+          item.isSelected2 = true
+          this.$nextTick(() => {
+            $('input:checkbox').eq(index).prop('checked', true)
+          })
+        }
+      })
+
+      this.defaultroute_codeArr = this.dialogFormRoute.routeOperationArr.filter(item => item.flag === 'Y')
+    },
+    // 瀵硅瘽妗嗗叧闂�
+    handleCloseRoute() {
+      this.dialogFormRoute.routeOperationArr = []
+      this.defaultroute_codeArr = []
+      this.defaultroute_code = ''
+      this.projectTableData = []
+    },
+    // 鍙栨秷
+    routeDialogVisibleCancel() {
+      this.dialogVisibleRoute = false
+    },
+    // 纭畾
+    async routeDialogVisibleConfirm() {
+      const temp = this.dialogFormRoute.routeOperationArr.filter(item => item.isSelected2)
+      if (this.defaultroute_code === '' && temp.length > 0) {
+        return this.$message.info('榛樿宸ヨ壓璺嚎涓嶈兘涓虹┖锛�')
+      }
+
+      // 鎻愪氦鏍煎紡
+      const data = []
+      this.dialogFormRoute.routeOperationArr.forEach(item => {
+        if (item.isSelected2) {
+          data.push({ code: item.code, name: item.name })
+        }
+      })
+
+      const res = await SaveInventoryFile(this.dialogFormRoute.projectCode, this.defaultroute_code, data)
+      if (res.code === '200') {
+        this.$message.success('淇濆瓨鎴愬姛锛�')
+        await this.getMesOrderSearch()
+        this.dialogVisibleRoute = false
+      }
+    },
+    // 澶х洅瀛愮偣鍑讳簨浠�
+    myCheckboxClick(val) {
+      console.log(val, 1)
+      this.dialogFormRoute.routeOperationArr.forEach(item => {
+        item.isSelected1 = val.code === item.code
+      })
+
+      this.projectTableData = val.Data
+    },
+    // 灏忕洅瀛愮偣鍑讳簨浠�
+    myCheckboxInputClick(val) {
+      console.log(val, 2)
+      val.isSelected2 = !val.isSelected2
+
+      this.dialogFormRoute.routeOperationArr.forEach((item, index) => {
+        if (val.code === item.code) {
+          item.flag = !item.flag
+        }
+      })
+      if (val.code === this.defaultroute_code) {
+        this.defaultroute_code = ''
+      }
+      this.defaultroute_codeArr = this.dialogFormRoute.routeOperationArr.filter(item => item.isSelected2)
+    }
   }
 }
 </script>
 
 <style lang="scss" scoped>
 $main_color: #42b983;
+.dialogVisibleRoute {
+  .myCheckboxGroup {
+    display: flex;
+    flex-wrap: wrap;
 
+    .myCheckbox {
+      //border: 1px solid $main_color;
+      border: 1px solid #eee;
+      display: flex;
+      min-width: 100px;
+      padding: 10px;
+      margin: 10px 30px 0 0;
+      border-radius: 5px;
+      cursor: default;
+
+      .myCheckboxInput {
+        margin: 1px 5px 0 0;
+        cursor: pointer;
+      }
+
+    }
+
+    //.myCheckbox{
+    //  border: 1px solid $main_color;
+    //}
+
+    input[type=checkbox] {
+      cursor: pointer;
+      position: relative;
+      width: 14px;
+      height: 14px;
+      font-size: 14px;
+    }
+
+    input[type=checkbox]::after {
+      position: absolute;
+      top: 0;
+      //color: rgb(130, 35, 35);
+      color: $main_color;
+      width: 14px;
+      height: 14px;
+      display: inline-block;
+      visibility: visible;
+      padding-left: 0px;
+      text-align: center;
+      content: ' ';
+      border-radius: 3px
+    }
+
+    input[type=checkbox]:checked::after {
+      //content: "鉁�";
+      content: "鈭�";
+      color: #fff;
+      font-size: 12px;
+      font-weight: bold;
+      background-color: $main_color;
+    }
+  }
+}
+.dialogVisibleRoute {
+  ::v-deep .el-dialog__body {
+    padding: 20px 20px !important;
+  }
+}
+.defaultroute_code ::v-deep .el-input__suffix-inner{
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  margin-top: -3px;
+}
 .el-date-editor {
   font-size: 14px;
 }
@@ -2145,6 +2438,7 @@
 <!--鍏叡椤甸潰鏍峰紡-->
 <style lang="scss" scoped>
 $main_color: #42b983;
+
 ::v-deep  .el-range-input{
   font-size: 14px !important;
 }

--
Gitblit v1.9.3