From bca37111d964040198c5ea1cc52739f9745931a5 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期五, 22 九月 2023 16:29:33 +0800
Subject: [PATCH] 1.工单实现70%

---
 src/views/workOrder/workOrderList.vue |  693 +++++++++++++++++++++++++--------------------------------
 1 files changed, 305 insertions(+), 388 deletions(-)

diff --git a/src/views/workOrder/workOrderList.vue b/src/views/workOrder/workOrderList.vue
index 0e53388..1f3ad55 100644
--- a/src/views/workOrder/workOrderList.vue
+++ b/src/views/workOrder/workOrderList.vue
@@ -5,7 +5,7 @@
       <div class="bodyTopButtonGroup" style="justify-content: space-between">
         <div style="display: flex">
           <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="add('add')">鏂板</el-button>
-          <el-button v-waves type="success" icon="el-icon-connection" @click="send('send')">娲惧彂</el-button>
+          <el-button v-waves type="success" icon="el-icon-connection" @click="send">娲惧彂</el-button>
         </div>
 
         <el-button v-waves icon="el-icon-switch-button" @click="orderClose">鍏抽棴宸ュ崟</el-button>
@@ -138,24 +138,13 @@
           :cell-style="this.$cellStyle"
           @sort-change="sortChange"
           @row-click="rowClick"
+          @selection-change="handleSelectionChange"
         >
-          <!--          <el-table-column-->
-          <!--            type="selection"-->
-          <!--            width="50"-->
-          <!--          />-->
           <el-table-column
+            type="selection"
             width="50"
-            fixed
-          >
-            <template slot-scope="{row}">
-              <el-radio
-                v-model="radioSelected"
-                :label="row.wo_code"
-                style="color: transparent;padding-left: 10px;"
-              />
-              <!--              @change.native="getCurrentRow(row.wo_code)"-->
-            </template>
-          </el-table-column>
+            :selectable="selected"
+          />
           <el-table-column
             prop="rowNum"
             width="50"
@@ -276,7 +265,7 @@
             width="130"
           >
             <template slot-scope="{row}">
-              <div v-if="row.saleOrderDeliveryDate">{{ row.saleOrderDeliveryDate.substring(0,11) }}</div>
+              <div v-if="row.saleOrderDeliveryDate">{{ row.saleOrderDeliveryDate.substring(0, 11) }}</div>
               <div v-else>/</div>
             </template>
           </el-table-column>
@@ -303,7 +292,11 @@
             <template slot-scope="{row}">
               <div class="operationClass">
                 <el-tooltip class="item" effect="dark" content="淇敼" placement="top">
-                  <i class="el-icon-edit-outline" :style="{color:$store.state.settings.theme}" @click="edit(row)" />
+                  <i
+                    class="el-icon-edit-outline"
+                    :style="{color:$store.state.settings.theme}"
+                    @click="edit('edit',row)"
+                  />
                 </el-tooltip>
 
                 <el-tooltip v-del-tab-index class="item" effect="dark" content="鍒犻櫎" placement="top">
@@ -325,7 +318,12 @@
                 </el-tooltip>
 
                 <el-tooltip class="item" effect="dark" content="璇︽儏" placement="top">
-                  <i class="el-icon-view" style="cursor: pointer;" :style="{color:$store.state.settings.theme}" @click="view(row)" />
+                  <i
+                    class="el-icon-view"
+                    style="cursor: pointer;"
+                    :style="{color:$store.state.settings.theme}"
+                    @click="edit('view',row)"
+                  />
                 </el-tooltip>
 
               </div>
@@ -373,22 +371,22 @@
             width="160"
           />
 
-          <el-table-column
-            prop="partcode"
-            label="浜у搧缂栫爜"
-            width="150"
-            show-tooltip-when-overflow
-          />
-          <el-table-column
-            prop="partname"
-            label="浜у搧鍚嶇О"
-            width="200"
-            show-tooltip-when-overflow
-          />
+          <!--          <el-table-column-->
+          <!--            prop="partcode"-->
+          <!--            label="浜у搧缂栫爜"-->
+          <!--            width="150"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--          />-->
+          <!--          <el-table-column-->
+          <!--            prop="partname"-->
+          <!--            label="浜у搧鍚嶇О"-->
+          <!--            width="200"-->
+          <!--            show-tooltip-when-overflow-->
+          <!--          />-->
 
           <el-table-column
             label="宸ュ簭缂栫爜"
-            prop="stepcode"
+            prop="step_code"
             show-tooltip-when-overflow
             width="150"
           />
@@ -399,9 +397,9 @@
             width="150"
           />
           <el-table-column
-            label="浠诲姟鏁伴噺"
+            label="宸茬敓浜ф暟閲�"
             show-tooltip-when-overflow
-            prop="plan_qty"
+            prop="produceq_qty"
           />
           <el-table-column
             label="鍚堟牸鏁伴噺"
@@ -414,33 +412,48 @@
             prop="ng_qty"
           />
           <el-table-column
-            label="鎿嶄綔"
-            width="120"
-            fixed="right"
-          >
-            <template slot-scope="{row}">
-              <div class="operationClass">
-                <el-tooltip class="item" effect="dark" content="鎵撳嵃宸ュ簭" placement="top">
-                  <i
-                    v-if="tableDataDetail.length!==row.seq"
-                    class="el-icon-printer"
-                    :style="{color:$store.state.settings.theme}"
-                    style="cursor: pointer;margin-right: 15px"
-                    @click="supplementSmallClick(row)"
-                  />
-                </el-tooltip>
-                <el-tooltip class="item" effect="dark" content="琛ユ墦鐢熶骇鍏ュ簱鏉$爜" placement="top">
-                  <i
-                    v-if="tableDataDetail.length===row.seq"
-                    class="  el-icon-camera"
-                    :style="{color:$store.state.settings.theme}"
-                    style="cursor: pointer;margin-right: 15px"
-                    @click="getProductInHouseLabCode(row.wo_code)"
-                  />
-                </el-tooltip>
-              </div>
-            </template>
-          </el-table-column>
+            label="宸ュ簾鏁伴噺"
+            show-tooltip-when-overflow
+            prop="laborbad_qty"
+          />
+          <el-table-column
+            label="鏂欏簾鏁伴噺"
+            show-tooltip-when-overflow
+            prop="materielbad_qty"
+          />
+          <el-table-column
+            label="寰呬骇鏁伴噺"
+            show-tooltip-when-overflow
+            prop="delive_qty"
+          />
+          <!--          <el-table-column-->
+          <!--            label="鎿嶄綔"-->
+          <!--            width="120"-->
+          <!--            fixed="right"-->
+          <!--          >-->
+          <!--            <template slot-scope="{row}">-->
+          <!--              <div class="operationClass">-->
+          <!--                <el-tooltip class="item" effect="dark" content="鎵撳嵃宸ュ簭" placement="top">-->
+          <!--                  <i-->
+          <!--                    v-if="tableDataDetail.length!==row.seq"-->
+          <!--                    class="el-icon-printer"-->
+          <!--                    :style="{color:$store.state.settings.theme}"-->
+          <!--                    style="cursor: pointer;margin-right: 15px"-->
+          <!--                    @click="supplementSmallClick(row)"-->
+          <!--                  />-->
+          <!--                </el-tooltip>-->
+          <!--                <el-tooltip class="item" effect="dark" content="琛ユ墦鐢熶骇鍏ュ簱鏉$爜" placement="top">-->
+          <!--                  <i-->
+          <!--                    v-if="tableDataDetail.length===row.seq"-->
+          <!--                    class="  el-icon-camera"-->
+          <!--                    :style="{color:$store.state.settings.theme}"-->
+          <!--                    style="cursor: pointer;margin-right: 15px"-->
+          <!--                    @click="getProductInHouseLabCode(row.wo_code)"-->
+          <!--                  />-->
+          <!--                </el-tooltip>-->
+          <!--              </div>-->
+          <!--            </template>-->
+          <!--          </el-table-column>-->
         </el-table>
       </div>
     </div>
@@ -536,13 +549,12 @@
         <el-form-item label="宸ュ崟鏁伴噺" prop="mesqty">
           <el-input
             v-model="dialogForm.mesqty"
-            oninput="value=value.replace(/[^0-9.]/g,'')"
-            :disabled="operation!=='add'"
+            oninput="value=value.replace(/[^\d]/g,'')"
             style="width: 200px"
           />
+          <!--          oninput="value=value.replace(/[^0-9*.{1}0-9*]/g,'')"-->
         </el-form-item>
         <el-form-item
-          v-if="operation==='add'"
           label="浜у搧鍚嶇О/缂栫爜"
           prop="partcode"
         >
@@ -563,15 +575,16 @@
             />
           </el-select>
         </el-form-item>
-        <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 v-if="operation!=='add'" label="浜у搧缂栫爜">
-          <el-input v-model="dialogForm.partcode" disabled style="width: 200px" />
-        </el-form-item>
+        <!--        <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 v-if="operation!=='add'" label="浜у搧缂栫爜">-->
+        <!--          <el-input v-model="dialogForm.partcode" disabled style="width: 200px" />-->
+        <!--        </el-form-item>-->
         <el-form-item label="浜у搧瑙勬牸" prop="partspec">
-          <el-input v-model="dialogForm.partspec" style="width: 200px" />
+          <el-input v-model="dialogForm.partspec" disabled style="width: 200px" />
         </el-form-item>
+        <!--        :disabled="dialogForm.partcode===''"-->
         <el-form-item label="鎵�灞炶溅闂�" prop="wkshopcode">
           <el-select
             v-model="dialogForm.wkshopcode"
@@ -579,8 +592,6 @@
             :popper-append-to-body="false"
             style="width: 200px;"
             placeholder="璇烽�夋嫨杞﹂棿"
-            :disabled="dialogForm.partcode===''"
-            @change="val=>wkshopcodeChange(val,dialogForm.partcode)"
           >
             <el-option
               v-for="item in wkshopArr"
@@ -599,13 +610,31 @@
             class="dateMini"
             :picker-options="pickerOptions"
             format="yyyy-MM-dd"
+            value-format="yyyy-MM-dd"
             placeholder="閫夋嫨鏃ユ湡"
           />
           <!--          :disabled="dialogForm.deliverydate"-->
         </el-form-item>
 
         <el-divider content-position="left">宸ュ簭淇℃伅</el-divider>
-        <el-button v-waves type="primary" icon="el-icon-circle-plus-outline" @click="addStep">鏂板</el-button>
+
+        <div style="display: flex;align-items: center">
+          <div style="font-weight: bolder">宸ュ簭閫夋嫨锛�</div>
+          <el-drag-select
+            v-model="stepSelectedValue"
+            style="width:930px;"
+            multiple
+            placeholder="璇烽�夋嫨鐩稿搴斿伐搴�"
+            @change="stepSelectedValueChange"
+          >
+            <el-option
+              v-for="item in stepSelectArr"
+              :key="item.stepcode"
+              :label="item.stepname"
+              :value="item.stepcode"
+            />
+          </el-drag-select>
+        </div>
 
         <el-table
           ref="stepTableDataRef"
@@ -620,7 +649,7 @@
           row-key="stepcode"
         >
           <el-table-column
-            prop="seq"
+            type="index"
             label="搴忓彿"
             width="50"
           />
@@ -635,10 +664,20 @@
             show-tooltip-when-overflow
           />
           <el-table-column
-            prop="stepname"
+            prop="stepprice"
             label="鐢熶骇鍗曚环"
             show-tooltip-when-overflow
-          />
+          >
+            <template slot-scope="{row}">
+              <el-input
+                v-model="row.stepprice"
+                placeholder="璇疯緭鍏ュ伐搴忓崟浠�"
+                oninput="value=value.replace(/[^0-9.]/g,'')"
+                style="width: 100%"
+                @click.stop=""
+              />
+            </template>
+          </el-table-column>
           <el-table-column
             label="鎿嶄綔"
             width="120"
@@ -653,90 +692,32 @@
                 />
                 <!--                </el-tooltip>-->
                 <!--                @click="edit('edit',row)"-->
+
+                <el-tooltip v-del-tab-index class="item" effect="dark" content="鍒犻櫎" placement="top">
+                  <i
+                    class="el-icon-delete"
+                    :style="{color:$store.state.settings.theme}"
+                    style="margin-left: 15px;"
+                    @click="stepDel(row)"
+                  />
+                </el-tooltip>
               </div>
             </template>
           </el-table-column>
         </el-table>
 
       </el-form>
-      <div style="display: flex;justify-content: flex-end">
-        {{ routeStepArr }}
-      </div>
-
-      <!--        宸ヨ壓璺嚎鏀惧ぇ闀滃璇濇-->
-      <el-dialog
-        title="宸ヨ壓璺嚎"
-        :visible.sync="dialogVisibleSearch"
-        width="840px"
-        top="20vh"
-        class="dialogVisibleSearch"
-        append-to-body
-        :close-on-click-modal="false"
-      >
-        <el-table
-          :data="searchTableData"
-          border
-          :row-class-name="tableRowClassName"
-          height="300"
-          style="width: 100%;"
-          highlight-current-row
-          :header-cell-style="this.$headerCellStyle"
-          :cell-style="this.$cellStyle"
-        >
-          <el-table-column
-            prop="seq"
-            label="搴忓彿"
-            width="50"
-            fixed
-          />
-          <el-table-column
-            prop="stepcode"
-            show-tooltip-when-overflow
-            label="宸ュ簭缂栫爜"
-          />
-          <el-table-column
-            prop="stepname"
-            label="宸ュ簭鍚嶇О"
-            show-tooltip-when-overflow
-          />
-          <el-table-column
-            prop="flwtype"
-            label="宸ュ簭绫诲瀷"
-            show-tooltip-when-overflow
-          >
-            <template slot-scope="{row}">
-              <div v-if="row.flwtype==='W'">澶栧崗</div>
-              <div v-if="row.flwtype==='Z'">鑷埗</div>
-            </template>
-          </el-table-column>
-          <el-table-column
-            prop="descr"
-            label="宸ュ簭鎻忚堪"
-            show-tooltip-when-overflow
-            fixed="right"
-          />
-        </el-table>
-      </el-dialog>
 
       <span slot="footer" class="dialog-footer">
         <div class="footerButton">
           <el-button v-waves @click="dialogVisibleCancel">鍙� 娑�</el-button>
           <!--          <el-button v-waves v-if="operation==='add'" type="primary" @click="dialogVisibleConfirmPreview('add')">棰勮</el-button>-->
-
           <el-button
-            v-if="!submitButtonIsDisabled"
+            v-if="operation!=='view'"
             v-waves
             type="primary"
             :loading="$store.state.app.buttonIsDisabled"
             :disabled="$store.state.app.buttonIsDisabled"
-            @click="dialogVisibleConfirm"
-          >纭� 瀹�</el-button>
-
-          <el-button
-            v-if="submitButtonIsDisabled"
-            v-waves
-            type="primary"
-            disabled
             @click="dialogVisibleConfirm"
           >纭� 瀹�</el-button>
         </div>
@@ -1931,15 +1912,22 @@
 import $ from 'jquery'
 import elDragDialog from '@/directive/el-drag-dialog'
 import waves from '@/directive/waves'
-import { AddMesOrderCodeSearch, MesBadOrderSearch, MesOrderSearch } from '@/api/WorkOrder'
+import {
+  AddMesOrderCodeSearch,
+  AddUpdateMesOrder, DeleteMesOrder,
+  MesBadOrderSearch, MesOrderDistribution,
+  MesOrderSearch,
+  UpdateMesOrderStepSearch
+} from '@/api/WorkOrder'
 import { PartSelect } from '@/api/ProductModel'
-import { PrentOrganization } from '@/api/GeneralBasicData'
+import { PrentOrganization, StepData } from '@/api/GeneralBasicData'
 import Sortable from 'sortablejs'
+import ElDragSelect from '@/components/DragSelect' // base on element-ui
 
 export default {
-  name: 'GD',
+  name: 'WorkOrderList',
   components: {
-    Pagination
+    Pagination, ElDragSelect
   },
   directives: { elDragDialog, waves },
   data() {
@@ -1978,7 +1966,6 @@
         { code: 'SCHED', name: '宸叉帓绋�' }
       ],
       total: 10,
-      radioSelected: '',
       tableData: [],
       dialogVisible: false,
       dialogForm: {
@@ -1997,11 +1984,8 @@
         wkshopname: '', // 鐢熶骇杞﹂棿鍚嶇О
 
         deliverydate: '', // 浜や粯鏃堕棿
-        data_sources: '', // 鏁版嵁鏉ユ簮
-
-        OperType: '' // 鎿嶄綔绫诲瀷
+        data_sources: '' // 鏁版嵁鏉ユ簮
       },
-      bomIdArr: [], // 鐗╂枡娓呭崟涓嬫媺
       ordertypeArr: [// 宸ュ崟绫诲瀷
         { code: 'PO', name: '鏍囧噯宸ュ崟' },
         { code: 'FO', name: '鎶ュ簾琛ュ崟' }
@@ -2125,8 +2109,9 @@
       dialogVisibleSource: false,
       sourceTableData: [],
       sourceForm: {
-        mesordercode: '', // 璁㈠崟鐘舵�佺爜
-        sourceorder: '', // 宸ュ崟缂栧彿
+        mesordercode: '', // 宸ュ崟缂栧彿
+        sourceorder: '', // 璁㈠崟缂栧彿
+        saleordercode: '', // 閿�鍞鍗曞彿
         partcode: '', // 浜у搧缂栫爜
         partname: '', // 浜у搧鍚嶇О
         partspec: '', // 浜у搧瑙勬牸
@@ -2169,7 +2154,6 @@
           return time.getTime() < Date.now() - 8.64e7
         }
       },
-      submitButtonIsDisabled: false,
 
       isLastPrint: false, // 鏄惁鏄湯閬撴墦鍗�
       lastPrintArr: [], // 鏈亾鎵撳嵃鐨勬暟缁�(鎵�鏈�)
@@ -2179,15 +2163,33 @@
 
       routeStepArr: '',
 
-      stepTableData: [
-        { stepcode: '001' },
-        { stepcode: '002' },
-        { stepcode: '003' },
-        { stepcode: '004' },
-        { stepcode: '005' }
-      ],
-      sortable: null
+      stepTableData: [],
+      sortable: null,
+      stepSelectArr: [], // 宸ュ簭涓嬫媺鏁版嵁
+      stepSelectedValue: [], // 涓嬫媺閫変腑鍊�
 
+      multipleSelection: []
+    }
+  },
+  watch: {
+    'stepSelectedValue': {
+      // deep: true,
+      handler: function(val) {
+        // do something with the new and old value of stepSelectedValue
+        console.log(val, 1)
+        const arr = JSON.parse(JSON.stringify(this.stepTableData))
+        const arrStepcode = arr.map(i => i.stepcode)
+        this.stepTableData = []
+        val.forEach(i => {
+          this.stepTableData.push(
+            {
+              stepcode: i,
+              stepname: this.stepSelectArr.find(j => j.stepcode === i).stepname,
+              stepprice: arrStepcode.includes(i) ? arr.find(j => j.stepcode === i).stepprice : 0
+            }
+          )
+        })
+      }
     }
   },
   created() {
@@ -2215,6 +2217,7 @@
           const targetRow = this.stepTableData.splice(evt.oldIndex, 1)[0]
           this.stepTableData.splice(evt.newIndex, 0, targetRow)
 
+          this.stepSelectedValue = this.stepTableData.map(i => i.stepcode)
           // for show the changes, you can delete in you code
           // const tempIndex = this.newList.splice(evt.oldIndex, 1)[0]
           // this.newList.splice(evt.newIndex, 0, tempIndex)
@@ -2268,6 +2271,10 @@
       // 鑾峰彇缁勭粐
       const { data: res2 } = await PrentOrganization()
       this.wkshopArr = res2
+
+      // 鑾峰彇宸ュ簭
+      const { data: res3 } = await StepData()
+      this.stepSelectArr = res3
     },
     // 璁㈠崟鐘舵�佹敼鍙樻椂
     erporderstusChange(val) {
@@ -2317,117 +2324,17 @@
       this.form.createdate = ''
       this.getMesOrderSearch()
     },
-    // 鍗曢�夋閫変腑鑾峰彇褰撳墠琛屼俊鎭�
-    getCurrentRow(wo_code) {
-      this.radioSelected = wo_code
-    },
     // 鏂板鎸夐挳
     async add(operation) {
       const { data: res } = await AddMesOrderCodeSearch()
       this.dialogForm.mesordercode = res
       this.operation = operation
       this.dialogVisible = true
-      this.dialogForm.planstartdate = handleDatetime(new Date())
-      this.dialogForm.planenddate = handleDatetime(new Date())
-      this.dialogForm.orderlev = 3
+      this.dialogForm.data_sources = 'MES'
 
       this.$nextTick(() => {
         this.setSort()
       })
-    },
-    // 浜у搧淇℃伅鍊兼敼鍙�
-    async partcodeChange(val) {
-      const { data: res } = await RouteSelectWkshop({ partcode: val })
-      this.wkshopArr = res
-
-      // this.dialogForm.wkshopcode=res.length === 1?res[0].org_code:''
-      if (res.length === 1) {
-        this.dialogForm.wkshopcode = res[0].org_code
-        await this.wkshopcodeChange(res[0].org_code, val)
-      } else {
-        this.dialogForm.wkshopcode = ''
-      }
-
-      // this.routeArr = res
-
-      // let flag = false
-      // this.routeArr.forEach(item => {
-      //   if (item.code === item.default_route) {
-      //     this.dialogForm.routecode = item.code
-      //     // this.routecodeChange(this.dialogForm.routecode)
-      //     this.wkshopcodeChange(this.dialogForm.routecode)
-      //     flag = true
-      //   }
-      // })
-      // if (!flag) {
-      //   this.dialogForm.routecode = ''
-      // }
-      //
-      // this.dialogForm.wkshopcode = ''
-      //
-      // this.submitButtonIsDisabled = false
-    },
-    // 宸ヨ壓璺嚎鍊兼敼鍙�
-    async routecodeChange() {
-      const data = {
-        partcode: this.dialogForm.partcode,
-        routecode: this.dialogForm.routecode,
-        wkshopcode: this.dialogForm.wkshopcode
-      }
-      await SelectRouteOrWkshop(data).then((res) => {
-        console.log(res, 1)
-
-        SelectRouteStep({ routecode: this.dialogForm.routecode }).then(res2 => {
-          console.log(res2)
-          this.routeStepArr = res2.data.map(i => i.stepname).join('锛�')
-        })
-
-        this.submitButtonIsDisabled = false
-      }).catch(err => {
-        // console.log(err, 2)
-        this.submitButtonIsDisabled = true
-      })
-    },
-    // 鐢熶骇杞﹂棿鍊兼敼鍙樻椂
-    async  wkshopcodeChange(wkshopcode, partcode) {
-      const data = {
-        partcode,
-        wkshopcode
-      }
-
-      const { data: res } = await PartSelectRoute(data)
-      this.routeArr = res
-
-      if (res.length === 1) {
-        this.dialogForm.routecode = res[0].code
-        await this.routecodeChange()
-      } else {
-        this.dialogForm.routecode = ''
-      }
-
-      // const data = {
-      //   partcode: this.dialogForm.partcode,
-      //   routecode: this.dialogForm.routecode,
-      //   wkshopcode: val
-      // }
-      // SelectRouteOrWkshop(data).then((res) => {
-      //
-      // }).catch(err => {
-      //   this.submitButtonIsDisabled = true
-      // })
-    },
-
-    // 鏄惁鎺掔▼鍊兼敼鍙樻椂
-    changeIsAps(val) {
-      if (val === 'N') {
-        this.dialogForm.bomId = ''
-      }
-      if (val === 'Y') {
-        JobCreationSonAddVison({ partnumber: this.dialogForm.partcode }).then(res => {
-          this.bomIdArr = res.data
-          this.dialogForm.bomId = this.bomIdArr[0].id
-        })
-      }
     },
     // 宸ュ簭浠诲姟
     async check(row) {
@@ -2443,35 +2350,36 @@
     dialogVisibleBack() {
       this.dialogVisibleTask = false
     },
+    handleSelectionChange(val) {
+      this.multipleSelection = val.map(i => i.wo_code)
+    },
+
+    selected(row, index) {
+    // && row.isstep === 'Y'
+      if (row.status === 'NEW') {
+        return true
+      } else {
+        return false
+      }
+    },
     // 娲惧彂
-    send(operation) {
-      if (this.radioSelected.length < 1) {
-        return this.$message.info('璇峰厛閫夋嫨宸ュ崟锛�')
-      }
-
-      const row = this.tableData.find(item => item.wo_code === this.radioSelected)
-
-      if (row.status !== 'NEW') {
-        return this.$message.info('姝ゅ伐鍗曚负闈炴柊宸ュ崟鐘舵�侊紝涓嶅彲娲惧彂锛�')
-      }
-      this.operation = operation
-      this.dialogVisible = true
-      this.$nextTick(() => {
-        this.dialogForm.mesorderstus = row.status
-        this.dialogForm.mesordercode = row.wo_code
-        this.dialogForm.partcode = row.partcode
-        this.partcodeChange(row.partcode)
-        this.dialogForm.partname = row.partname
-        this.dialogForm.mesqty = row.plan_qty
-        this.dialogForm.partspec = row.partspec
-        this.dialogForm.sourceorder = row.m_po
-        this.dialogForm.ordertype = row.wotype
-
-        // this.routecodeChange(this.dialogForm.routecode)
-
-        this.dialogForm.planstartdate = row.plan_startdate !== null ? row.plan_startdate : handleDatetime(new Date())
-        this.dialogForm.planenddate = row.plan_enddate !== null ? row.plan_enddate : handleDatetime(new Date())
-        this.dialogForm.orderlev = row.piroque !== null ? row.piroque : 3 // 绛夌骇
+    send() {
+      this.$confirm('鏄惁纭娲惧彂?', '鎻愮ず', {
+        confirmButtonText: '纭畾',
+        cancelButtonText: '鍙栨秷',
+        type: 'warning'
+      }).then(() => {
+        MesOrderDistribution(this.multipleSelection).then(res => {
+          if (res.code === '200') {
+            this.$notify.success('娲惧彂鎴愬姛!')
+            if (this.form.page > 1 && this.tableData.length === 1) {
+              this.form.page--
+            }
+            this.getMesOrderSearch()
+          }
+        })
+      }).catch(() => {
+        this.$notify.info('宸插彇娑堟淳鍙�')
       })
     },
     // 鍒犻櫎鎸夐挳
@@ -2484,7 +2392,6 @@
         cancelButtonText: '鍙栨秷',
         type: 'warning'
       }).then(() => {
-        console.log(row, 1)
         const data = {
           souceid: row.sourceid ? row.sourceid : '',
           wocode: row.wo_code,
@@ -2493,7 +2400,7 @@
         }
         DeleteMesOrder(data).then(res => {
           if (res.code === '200') {
-            this.$message.success('鍒犻櫎鎴愬姛!')
+            this.$notify.success('鍒犻櫎鎴愬姛!')
             if (this.form.page > 1 && this.tableData.length === 1) {
               this.form.page--
             }
@@ -2501,49 +2408,50 @@
           }
         })
       }).catch(() => {
-        this.$message.info('宸插彇娑堝垹闄�')
+        this.$notify.info('宸插彇娑堝垹闄�')
       })
     },
 
     // 淇敼鎸夐挳
-    edit() {
+    async edit(operation, row) {
+      this.operation = operation
 
+      this.dialogForm.data_sources = row.data_sources
+      this.dialogForm.mesorderstus = row.status
+      this.dialogForm.mesordercode = row.wo_code
+      this.dialogForm.ordertype = row.wotype
+      this.dialogForm.sourceorderid = row.sourceid
+      this.dialogForm.sourceorder = row.m_po
+      this.dialogForm.partcode = row.partcode
+      this.dialogForm.partname = row.partname
+      this.dialogForm.partspec = row.partspec
+      this.dialogForm.wkshopcode = row.wkshp_code
+      this.dialogForm.deliverydate = row.saleOrderDeliveryDate.substring(0, 11)
+
+      const data = {
+        sourceid: this.dialogForm.sourceorderid,
+        sourcewo: this.dialogForm.sourceorder,
+        wocode: this.dialogForm.mesordercode,
+        data_sources: this.dialogForm.data_sources
+      }
+      const { data: res } = await UpdateMesOrderStepSearch(data)
+      this.dialogForm.mesqty = res.canupdate_qty
+      res.stepdata.forEach(i => {
+        this.stepTableData.push(
+          {
+            stepcode: i.step_code,
+            stepname: i.stepname,
+            stepprice: i.stepprice
+          }
+        )
+      })
+      this.stepSelectedValue = this.stepTableData.map(i => i.stepcode)
+
+      this.dialogVisible = true
     },
     // 宸ュ崟鍏抽棴浜嬩欢
     orderClose() {
-      if (this.radioSelected.length < 1) {
-        return this.$message.info('璇峰厛閫夋嫨宸ュ崟锛�')
-      }
       console.log('宸ュ崟鍏抽棴浜嬩欢')
-      this.tableData.forEach(item => {
-        if (item.wo_code === this.radioSelected) {
-          if (item.status === 'START') {
-            return this.$message.info('褰撳墠宸ュ崟鏈畬宸ワ紝鏃犳硶鍏抽棴锛�')
-          } else if (item.status === 'CLOSED') {
-            return this.$message.info('宸ュ崟宸插叧闂紝鏃犻渶鍐嶅叧闂紒')
-          } else {
-            this.$confirm('鏄惁纭鍏抽棴宸ュ崟?', '鎻愮ず', {
-              confirmButtonText: '纭畾',
-              cancelButtonText: '鍙栨秷',
-              type: 'warning'
-            }).then(() => {
-              const data = {
-                wocode: item.wo_code,
-                m_po: item.m_po
-              }
-              ClosedMesOrder(data).then(res => {
-                if (res.code === '200') {
-                  this.$message.success('宸ュ崟鍏抽棴鎴愬姛!')
-                  this.getMesOrderSearch()
-                  // this.radioSelected = ''
-                }
-              })
-            }).catch(() => {
-              this.$message.info('宸插彇娑堝叧闂紒')
-            })
-          }
-        }
-      })
     },
     // 瀵硅瘽妗嗕骇鍝佷俊鎭�兼敼鍙�
     partcodeChangeDialog(val) {
@@ -2551,36 +2459,30 @@
       this.dialogForm.partname = this.partArr.find(item => item.partcode === val).partname
       this.dialogForm.partcode = this.partArr.find(item => item.partcode === val).partcode
       this.dialogForm.partspec = this.partArr.find(item => item.partcode === val).partspec
-
-      // this.partcodeChange(val)
     },
     // 瀵硅瘽妗嗗叧闂簨浠�
     handleClose() {
-      this.routeStepArr = ''
-      this.dialogForm.partname = '' // 浜у搧鍚嶇О
-      this.dialogForm.partspec = '' // 浜у搧瑙勬牸
-      this.dialogForm.wkshopname = '' // 鐢熶骇杞﹂棿鍚嶇О
-      this.dialogForm.routename = '' // 宸ヨ壓璺嚎鍚嶇О
+      this.dialogForm = {
+        mesorderstus: 'NEW', // 宸ュ崟鐘舵�佺爜
+        mesordercode: '', // 宸ュ崟缂栧彿
+        ordertype: 'PO', // 宸ュ崟绫诲瀷
+        sourceorderid: '', // 婧愬崟id
+        sourceorder: '', // 婧愬崟鍗曞彿
 
-      this.dialogForm.mesorderstus = 'NEW' // 宸ュ崟鐘舵�佺爜
-      this.dialogForm.mesordercode = '' // 宸ュ崟缂栧彿
-      this.dialogForm.partcode = '' // 浜у搧缂栫爜
-      this.dialogForm.mesqty = '' // 宸ュ崟鏁伴噺
+        partcode: '', // 浜у搧缂栫爜
+        partname: '', // 浜у搧鍚嶇О
+        partspec: '', // 浜у搧瑙勬牸
 
-      this.dialogForm.ordertype = 'PO' // 宸ュ崟绫诲瀷
-      this.dialogForm.sourceorder = '' // 婧愬崟鍗曞彿
+        mesqty: '', // 宸ュ崟鏁伴噺
+        wkshopcode: '', // 鐢熶骇杞﹂棿缂栫爜
+        wkshopname: '', // 鐢熶骇杞﹂棿鍚嶇О
 
-      this.dialogForm.routecode = '' // 宸ヨ壓璺嚎缂栫爜
-      this.dialogForm.wkshopcode = '' // 鐢熶骇杞﹂棿缂栫爜
-      this.dialogForm.planstartdate = '' // 璁″垝寮�濮嬫椂闂�
-      this.dialogForm.planenddate = '' // 璁″垝瀹屾垚鏃堕棿
-      this.dialogForm.orderlev = '' // 宸ュ崟绛夌骇
-      this.dialogForm.isAps = 'N' // 鏄惁鎺掔▼
-      this.dialogForm.bomId = ''
-
-      this.bomIdArr = []
+        deliverydate: '', // 浜や粯鏃堕棿
+        data_sources: '' // 鏁版嵁鏉ユ簮
+      }
+      this.stepSelectedValue = []
+      this.stepTableData = []
       this.$refs.dialogForm.clearValidate()
-      this.submitButtonIsDisabled = false
     },
     // 瀵硅瘽妗嗗彇娑�
     dialogVisibleCancel() {
@@ -2594,36 +2496,40 @@
             return this.$message.info('婧愬崟鍗曞彿涓嶈兘涓虹┖锛�')
           }
 
-          const data = {
-            // partname: this.dialogForm.partname, // 浜у搧鍚嶇О
-            // partspec: this.dialogForm.partspec, // 浜у搧瑙勬牸
-            // wkshopname: this.dialogForm.wkshopname, // 鐢熶骇杞﹂棿鍚嶇О
-            // routename: this.dialogForm.routename, // 宸ヨ壓璺嚎鍚嶇О
+          const workListSub = []
+          this.stepTableData.forEach((i, j) => {
+            workListSub.push(
+              {
+                stepseq: j + 1,
+                stepcode: i.stepcode,
+                stepprice: i.stepprice,
+                isbott: j === 0 ? 'Y' : 'N',
+                isend: j === this.stepTableData.length - 1 ? 'Y' : 'N'
+              }
+            )
+          })
 
-            mesorderstus: this.dialogForm.mesorderstus, // 宸ュ崟鐘舵�佺爜
-            mesordercode: this.dialogForm.mesordercode, // 宸ュ崟缂栧彿
-            partcode: this.dialogForm.partcode, // 浜у搧缂栫爜
-            mesqty: this.dialogForm.mesqty, // 宸ュ崟鏁伴噺
-            ordertype: this.dialogForm.ordertype, // 鍗曟嵁绫诲瀷
-            sourceorder: this.dialogForm.sourceorder, // 婧愬崟鍗曞彿
-            routecode: this.dialogForm.routecode, // 宸ヨ壓璺嚎缂栫爜
-            wkshopcode: this.dialogForm.wkshopcode, // 鐢熶骇杞﹂棿缂栫爜
-            planstartdate: this.dialogForm.planstartdate, // 璁″垝寮�濮嬫椂闂�
-            planenddate: this.dialogForm.planenddate, // 璁″垝瀹屾垚鏃堕棿
-            orderlev: this.dialogForm.orderlev, // 宸ュ崟绛夌骇
-            is_aps: this.dialogForm.isAps, // 鏄惁鎺掔▼
-            bom_id: this.dialogForm.bomId, // 鐗╂枡娓呭崟id
-            OperType: this.operation === 'add' ? 'Add' : 'Update'
+          const data = {
+            wostatus: this.dialogForm.mesorderstus, // 宸ュ崟鐘舵��
+            wocode: this.dialogForm.mesordercode, // 宸ュ崟鍙�
+            wotype: this.dialogForm.ordertype, // 宸ュ崟绫诲瀷
+            sourceid: this.dialogForm.sourceorderid, // 婧愬崟id
+            sourcewo: this.dialogForm.sourceorder, // 婧愬崟鍗曞彿
+            partcode: this.dialogForm.partcode, // 浜у搧缂栧彿
+            wkshopcode: this.dialogForm.wkshopcode,
+            woqty: this.dialogForm.mesqty, // 宸ュ崟鏁伴噺
+            deliverydate: this.dialogForm.deliverydate, // 浜や粯鏃堕棿
+            data_sources: this.dialogForm.data_sources, // 鏁版嵁鏉ユ簮
+            isstep: workListSub.length > 0 ? 'Y' : 'N', //
+            workListSub
           }
+
           this.$store.state.app.buttonIsDisabled = true
-          AddUpdateMesOrder(data).then(res => {
+          AddUpdateMesOrder(data, this.operation === 'add' ? 'Add' : 'Update').then(res => {
             if (res.code === '200') {
               this.dialogVisible = false
-
-              this.handlePrint()
-
+              // this.handlePrint()
               this.$message.success(this.operation === 'add' ? '娣诲姞鎴愬姛锛�' : '娲惧彂鎴愬姛锛�')
-              // this.dialogVisible = false
               this.getMesOrderSearch()
               this.$store.state.app.buttonIsDisabled = false
             } else {
@@ -2899,8 +2805,9 @@
       }
 
       const data = {
-        mesordercode: this.sourceForm.mesordercode, // 璁㈠崟鐘舵�佺爜
-        sourceorder: this.sourceForm.sourceorder, // 宸ュ崟缂栧彿
+        mesordercode: this.sourceForm.mesordercode, // 宸ュ崟缂栧彿
+        sourceorder: this.sourceForm.sourceorder, // 璁㈠崟璁㈠崟鍙�
+        saleordercode: this.sourceForm.sourceorder, // 璁㈠崟璁㈠崟鍙�
         partcode: this.sourceForm.partcode, // 浜у搧缂栫爜
         partname: this.sourceForm.partname, // 浜у搧鍚嶇О
         partspec: this.sourceForm.partspec, // 浜у搧瑙勬牸
@@ -2973,7 +2880,6 @@
         }
       })
       this.dialogVisibleSource = false
-      this.partcodeChange(this.dialogForm.partcode)
     },
     mesordertypeChange(val) {
       if (val === 'PO') {
@@ -3069,9 +2975,20 @@
     },
     //  琛岀偣鍑讳簨浠�
     async rowClick(row, event, column) {
-      this.radioSelected = row.wo_code ? row.wo_code : this.radioSelected
-      const { data: res } = await SearchWorkStep({ wo_code: this.radioSelected, storg_code: this.$store.state.settings.orgType === 'W' ? (this.switchButton ? '' : getCookie('stu_torgcode')) : '' })
-      this.tableDataDetail = res
+      const data = {
+        sourceid: row.sourceid,
+        sourcewo: row.m_po,
+        wocode: row.wo_code,
+        data_sources: row.data_sources
+      }
+      const { data: res } = await UpdateMesOrderStepSearch(data)
+      this.tableDataDetail = res.stepdata
+    },
+    // 宸ュ簭鍒犻櫎
+    stepDel(row) {
+      console.log(row)
+      const index = this.stepSelectedValue.findIndex(i => i === row.stepcode)
+      this.stepSelectedValue.splice(index, 1)
     },
     // 鎵撳嵃宸ュ崟
     printOrder() {
@@ -3120,17 +3037,17 @@
         this.$forceUpdate()
       }, 500)
     },
-    addStep() {
-
+    stepSelectedValueChange(val) {
+      // console.log(val, 123)
     }
   }
 }
 </script>
 <style>
-.sortable-ghost{
+.sortable-ghost {
   opacity: .8;
-  color: #fff!important;
-  background: #42b983!important;
+  color: #fff !important;
+  background: #42b983 !important;
 }
 </style>
 <style lang="scss" scoped>

--
Gitblit v1.9.3