From 347bfd41a380983e0866009cfc83475c1cd4e322 Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期四, 01 六月 2023 20:25:26 +0800
Subject: [PATCH] 1.递交

---
 src/views/produceManager/productWarehouse.vue |  618 ++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 553 insertions(+), 65 deletions(-)

diff --git a/src/views/produceManager/productWarehouse.vue b/src/views/produceManager/productWarehouse.vue
index c245cd1..0bf9288 100644
--- a/src/views/produceManager/productWarehouse.vue
+++ b/src/views/produceManager/productWarehouse.vue
@@ -19,6 +19,9 @@
           <div style="font-size: 14px;margin-left: 5px;color: #a7a7a7">
             鏌ヨ椤�
           </div>
+          <div v-if="!isPermission" style="font-size: 14px;margin-left: 10px;color: red">
+            褰撳墠鐢ㄦ埛鍦‥RP绯荤粺涓笉瀛樺湪鎴栨湭鎺堟潈锛屾棤娉曞叆搴撴彁浜�
+          </div>
         </div>
         <el-form
           ref="form"
@@ -29,14 +32,14 @@
         >
           <div class="elForm" style="display: flex;flex-direction: column">
             <div style="display: flex">
-              <el-form-item label="鍗曟嵁绫诲瀷" style=" display: flex;">
+              <el-form-item label="鍗曟嵁绫诲瀷" required style=" display: flex;">
                 <el-select
                   v-model="form.documentType"
                   :popper-append-to-body="false"
                   filterable
                   style="width: 200px"
                   placeholder="璇烽�夋嫨"
-                  @change="getProductInHouseOrderSearch"
+                  @change="documentTypeChange"
                 >
                   <el-option
                     v-for="item in documentTypeArr"
@@ -46,19 +49,82 @@
                   />
                 </el-select>
               </el-form-item>
+              <el-form-item label="鐢熶骇杞﹂棿" required style=" display: flex;">
+                <el-select
+                  v-model="form.wkshopcode"
+                  :popper-append-to-body="false"
+                  filterable
+                  style="width: 200px"
+                  placeholder="璇烽�夋嫨"
+                  @change="wkshopcodeChange"
+                >
+                  <el-option
+                    v-for="item in WorkShopArr"
+                    :key="item.code"
+                    :label="item.name"
+                    :value="item.code"
+                  />
+                </el-select>
+              </el-form-item>
               <el-form-item
                 v-if="form.documentType==='Y'"
                 label="鐢熶骇璁㈠崟"
+                :required="form.documentType==='Y'"
+                style="display: flex;"
+              >
+
+                <el-select
+                  v-model="form.erpordercode"
+                  :popper-append-to-body="false"
+                  filterable
+                  style="width: 200px"
+                  placeholder="璇烽�夋嫨"
+                  @change="getProductInHouseOrderSearch"
+                >
+                  <el-option
+                    v-for="item in erpordercodeArr"
+                    :key="item.ordercode"
+                    :label="item.ordercode"
+                    :value="item.ordercode"
+                  />
+                </el-select>
+
+                <!--                <el-input-->
+                <!--                  v-model="form.erpordercode"-->
+                <!--                  placeholder="璇疯緭鍏�"-->
+                <!--                  style="width: 200px"-->
+                <!--                  @input="getProductInHouseOrderSearch"-->
+                <!--                />-->
+              </el-form-item>
+
+              <el-form-item
+                v-if="form.documentType==='N'"
+                label="鐢熶骇宸ュ崟"
+                :required="form.documentType==='N'"
                 style=" display: flex;"
               >
-                <el-input
-                  v-model="form.erpordercode"
-                  placeholder="璇疯緭鍏�"
+                <el-select
+                  v-model="form.mesordercode"
+                  :popper-append-to-body="false"
+                  filterable
                   style="width: 200px"
-                  @input="getProductInHouseOrderSearch"
-                />
+                  placeholder="璇烽�夋嫨"
+                  @change="getProductInHouseOrderSearch"
+                >
+                  <el-option
+                    v-for="item in mesordercodeArr"
+                    :key="item.ordercode"
+                    :label="item.ordercode"
+                    :value="item.ordercode"
+                  />
+                </el-select>
               </el-form-item>
-              <el-form-item label="鐢熶骇宸ュ崟" style=" display: flex;">
+
+              <el-form-item
+                v-if="form.documentType==='Y'"
+                label="鐢熶骇宸ュ崟"
+                style=" display: flex;"
+              >
                 <el-input
                   v-model="form.mesordercode"
                   placeholder="璇疯緭鍏�"
@@ -71,7 +137,12 @@
                 label="閿�鍞鍗�"
                 style="display: flex;"
               >
-                <el-input v-model="form.saleOrderCode" placeholder="璇疯緭鍏�" style="width: 200px" @input="getProductInHouseOrderSearch" />
+                <el-input
+                  v-model="form.saleOrderCode"
+                  readonly
+                  style="width: 200px"
+                />
+                <!--                disabled-->
               </el-form-item>
             </div>
 
@@ -106,8 +177,9 @@
           </div>
           <div
             class="bodySearchReset"
-            :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
           >
+            <!--            :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"-->
+
             <!--            <el-button v-waves type="primary" icon="el-icon-search" @click="search">鏌ヨ</el-button>-->
             <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">閲嶇疆</el-button>
           </div>
@@ -136,25 +208,12 @@
                 style="width: 200px"
                 type="date"
                 placeholder="閫夋嫨鏃ユ湡"
-              />            </el-form-item>
+              />
+            </el-form-item>
             <el-form-item label="鍗曟嵁缂栧彿" style=" display: flex;">
               <el-input v-model="form.OrgName" placeholder="璇疯緭鍏�" style="width: 200px" />
             </el-form-item>
-            <el-form-item label="鐢熶骇杞﹂棿" style=" display: flex;">
-              <el-select
-                v-model="form.WorkShop"
-                :popper-append-to-body="false"
-                filterable
-                style="width: 200px"
-                placeholder="璇烽�夋嫨"
-              >
-                <el-option
-                  v-for="item in WorkShopArr"
-                  :key="item.code"
-                  :label="item.name"
-                  :value="item.code"
-                />
-              </el-select>            </el-form-item>
+
             <el-form-item label="鍏ュ簱浠撳簱" style=" display: flex;">
               <el-select
                 v-model="form.stockcode"
@@ -162,6 +221,7 @@
                 filterable
                 style="width: 200px"
                 placeholder="璇烽�夋嫨"
+                @change="stockcodeChange"
               >
                 <el-option
                   v-for="item in stockcodeArr"
@@ -173,8 +233,11 @@
             </el-form-item>
 
           </div>
-          <div class="bodySearchReset" :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}">
-            <el-button v-waves type="primary" icon="el-icon-s-promotion" @click="search">鍏ュ簱鎻愪氦</el-button>
+          <div
+            class="bodySearchReset"
+            :style="{marginLeft:$store.state.app.sidebar.opened? $store.state.settings.menuIsHorizontal?'15%':'3%':'10%'}"
+          >
+            <el-button v-waves type="primary" icon="el-icon-s-promotion" @click="submit">鍏ュ簱鎻愪氦</el-button>
             <!--            <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">閲嶇疆</el-button>-->
           </div>
         </el-form>
@@ -196,7 +259,7 @@
           <!--            @click=""-->
           <!--          >鍏ュ簱鎻愪氦-->
           <!--          </el-button>-->
-          <el-tabs style="margin-top: 10px;">
+          <el-tabs style="margin-top: 10px;" @tab-click="tabClick">
             <el-tab-pane label="鏄庣粏">
               <div class="elTableDiv" style="margin: 0 auto 10px;">
                 <el-table
@@ -212,6 +275,8 @@
                   :header-cell-style="this.$headerCellStyle"
                   :cell-style="this.$cellStyle"
                   @selection-change="handleSelectionChange"
+                  @cell-dblclick="cellDblclick"
+                  @cell-click="cellClick"
                 >
                   <el-table-column
                     type="selection"
@@ -226,13 +291,29 @@
                   />
 
                   <el-table-column
-                    prop="stockname"
+                    prop="stockcode"
                     label="浠撳簱"
-                    width="110"
+                    width="160"
+                    show-tooltip-when-overflow
                   >
                     <template slot-scope="{row}">
-                      <div v-if="row.stockname">{{ row.stockname }}</div>
-                      <div v-else>/</div>
+                      <div
+                        v-if="!(row.index === tabClickIndex && tabClickLabel === '浠撳簱')"
+                      >
+                        {{ row.stockcode ? stockcodeArr.find(i => i.code === row.stockcode).name : '/' }}
+                      </div>
+                      <el-select
+                        v-if="row.index === tabClickIndex && tabClickLabel === '浠撳簱'"
+                        v-model="row.stockcode"
+                        placeholder="璇烽�夋嫨"
+                      >
+                        <el-option
+                          v-for="item in stockcodeArr"
+                          :key="item.code"
+                          :label="item.name"
+                          :value="item.code"
+                        />
+                      </el-select>
                     </template>
                   </el-table-column>
                   <el-table-column
@@ -277,7 +358,7 @@
                     show-tooltip-when-overflow
                   >
                     <template slot-scope="{row}">
-                      <div v-if="row.stockname">{{ row.stockname }}</div>
+                      <div v-if="row.partspec">{{ row.partspec }}</div>
                       <div v-else>/</div>
                     </template>
                   </el-table-column>
@@ -318,10 +399,13 @@
                   <el-table-column
                     prop="stinhouseqty"
                     label="鍙叆搴撴暟閲�"
-                    min-width="95"
+                    min-width="130"
                     fixed="right"
-                    show-tooltip-when-overflow
-                  />
+                  >
+                    <!--                    <template slot-scope="{row}">-->
+                    <!--                      <el-input-number v-model="row.stinhouseqty" :min="0" :max="row.good_qty" size="small" />-->
+                    <!--                    </template>-->
+                  </el-table-column>
                 </el-table>
                 <el-table
                   v-show="form.documentType==='N'"
@@ -358,6 +442,7 @@
                       <div v-if="row.stockname">{{ row.stockname }}</div>
                       <div v-else>/</div>
                     </template>
+
                   </el-table-column>
                   <el-table-column
                     prop="inbarcode"
@@ -449,7 +534,131 @@
                 </el-table>
               </div>
             </el-tab-pane>
-            <el-tab-pane label="姹囨��">姹囨��</el-tab-pane>
+            <el-tab-pane label="姹囨��">
+              <div class="elTableDiv" style="margin: 0 auto 10px;">
+                <el-table
+                  ref="tableDataRef"
+                  class="tableFixed"
+                  :data="tableDataSummary"
+                  :height="(tableHeight-25)+'px'"
+                  border
+                  :row-class-name="tableRowClassName2"
+                  :style="{width: 100+'%',height:(tableHeight-25)+'px',}"
+                  highlight-current-row
+                  :header-cell-style="this.$headerCellStyle"
+                  :cell-style="this.$cellStyle"
+                >
+                  <el-table-column
+                    type="index"
+                    width="50"
+                    fixed
+                    label="搴忓彿"
+                  />
+                  <el-table-column
+                    prop="stockcode"
+                    label="浠撳簱"
+                    width="110"
+                  >
+                    <template slot-scope="{row}">
+                      <div>{{ stockcodeArr.find(i=>i.code===row.stockcode).name }}</div>
+                    </template>
+                  </el-table-column>
+                  <!--                    <template slot-scope="{row}">-->
+                  <!--                      <div v-if="row.stockname">{{ row.stockname }}</div>-->
+                  <!--                      <div v-else>/</div>-->
+                  <!--                    </template>-->
+
+                  <!--                  </el-table-column>-->
+                  <!--                  <el-table-column-->
+                  <!--                    prop="inbarcode"-->
+                  <!--                    label="鍏ュ簱鏉$爜"-->
+                  <!--                    width="160"-->
+                  <!--                    show-tooltip-when-overflow-->
+                  <!--                  />-->
+                  <!--                  <el-table-column-->
+                  <!--                    prop="m_po"-->
+                  <!--                    label="璁㈠崟缂栧彿"-->
+                  <!--                    width="160"-->
+                  <!--                    show-tooltip-when-overflow-->
+                  <!--                  >-->
+                  <!--                    <template slot-scope="{row}">-->
+                  <!--                      <div v-if="row.m_po">{{ row.m_po }}</div>-->
+                  <!--                      <div v-else>/</div>-->
+                  <!--                    </template>-->
+                  <!--                  </el-table-column>-->
+                  <!--                  <el-table-column-->
+                  <!--                    prop="wo_code"-->
+                  <!--                    label="宸ュ崟缂栧彿"-->
+                  <!--                    width="160"-->
+                  <!--                    show-tooltip-when-overflow-->
+                  <!--                  />-->
+                  <el-table-column
+                    prop="partcode"
+                    label="浜у搧缂栫爜"
+                    min-width="160"
+                    show-tooltip-when-overflow
+                  />
+                  <el-table-column
+                    prop="partname"
+                    label="浜у搧鍚嶇О"
+                    min-width="160"
+                    show-tooltip-when-overflow
+                  />
+                  <el-table-column
+                    prop="partspec"
+                    label="浜у搧瑙勬牸"
+                    min-width="160"
+                    show-tooltip-when-overflow
+                  >
+                    <template slot-scope="{row}">
+                      <div v-if="row.stockname">{{ row.stockname }}</div>
+                      <div v-else>/</div>
+                    </template>
+                  </el-table-column>
+
+                  <el-table-column
+                    prop="qty"
+                    label="璁㈠崟鏁伴噺"
+                    min-width="95"
+
+                    show-tooltip-when-overflow
+                  >
+                    <template slot-scope="{row}">
+                      <div v-if="row.qty">{{ row.qty }}</div>
+                      <div v-else>/</div>
+                    </template>
+                  </el-table-column>
+                  <!--                  <el-table-column-->
+                  <!--                    prop="plan_qty"-->
+                  <!--                    label="宸ュ崟鏁伴噺"-->
+                  <!--                    min-width="95"-->
+                  <!--                    fixed="right"-->
+                  <!--                    show-tooltip-when-overflow-->
+                  <!--                  />-->
+                  <el-table-column
+                    prop="good_qty"
+                    label="瀹屽伐鏁伴噺"
+                    min-width="95"
+
+                    show-tooltip-when-overflow
+                  />
+                  <el-table-column
+                    prop="inhouseqty"
+                    label="宸插叆搴撴暟閲�"
+                    min-width="95"
+
+                    show-tooltip-when-overflow
+                  />
+                  <el-table-column
+                    prop="stinhouseqty"
+                    label="鍙叆搴撴暟閲�"
+                    min-width="95"
+
+                    show-tooltip-when-overflow
+                  />
+                </el-table>
+              </div>
+            </el-tab-pane>
           </el-tabs>
         </div>
 
@@ -463,10 +672,14 @@
 <script>
 import elDragDialog from '@/directive/el-drag-dialog'
 import waves from '@/directive/waves'
-import { WareHouseSelect } from '@/api/materialManager'
-import { ProductInHouseOrderSearch } from '@/api/produceManager'
-import { handleDatetime } from '@/utils/global'
-import { WorkShopSelect } from '@/api/deviceManager'
+import {
+  ProductInHouseOrderCodeSearch,
+  ProductInHouseOrderSearch, ProductInHouseOrderSeave,
+  ProductInHouseWkshopOrder
+} from '@/api/produceManager'
+import { handleDatetime, handleDatetime2 } from '@/utils/global'
+import { ErpUserSelect, ErpWarehouseSelect, ErpWkshopDepartmentSelect } from '@/api/basicInfo'
+import { getCookie } from '@/utils/auth'
 
 export default {
   name: 'Zzjg',
@@ -477,9 +690,12 @@
       mainHeight: 0,
       tableHeight: 0,
       form: {
+        hbillno: '', // 鍏ュ簱鍗曞彿
+        incbit: '', // 娴佹按鍙�
         documentType: 'Y', // 鍗曟嵁绫诲瀷
 
-        erpordercode: '', // 璁㈠崟缂栧彿
+        wkshopcode: 'CJ001', // 鐢熶骇杞﹂棿
+        erpordercode: 'MO-2023-05-0007', // 璁㈠崟缂栧彿
         mesordercode: '', // 宸ュ崟缂栧彿
         partcode: '', // 浜у搧缂栫爜
         partname: '', // 浜у搧鍚嶇О
@@ -487,47 +703,101 @@
         orderdate: '', // 宸ュ崟鏃ユ湡
 
         saleOrderCode: '', // 閿�鍞鍗�
-        WorkShop: '', // 鐢熶骇杞﹂棿
         lm_date: '', // 鍗曟嵁鏃ユ湡
-        stockcode: '', // 鍏ュ簱浠撳簱
-        xxx: ''
+        stockcode: '' // 鍏ュ簱浠撳簱
+
       },
       documentTypeArr: [
         { label: '鏈夋簮鍗�', value: 'Y' },
         { label: '鏃犳簮鍗�', value: 'N' }
       ],
-      tableDataDetail: [],
+      tableDataDetail: [], // 鏄庣粏琛�
       multipleSelection: [],
       stockcodeArr: [], // 鍏ュ簱浠撳簱鏁扮粍
       WorkShopArr: [], // 鐢熶骇杞﹂棿鏁扮粍
+      erpordercodeArr: [], // 鐢熶骇璁㈠崟鏁扮粍
+      mesordercodeArr: [], // 鐢熶骇宸ュ崟鏁扮粍
 
-      xxx: ''
+      tabClickIndex: null, // 鐐瑰嚮鐨勫崟鍏冩牸
+      tabClickLabel: '', // 褰撳墠鐐瑰嚮鐨勫垪鍚�
+
+      tableDataSummary: [], // 姹囨�昏〃
+
+      isPermission: true, // 鏄惁鏈夋潈闄愬彲鎻愪氦
+
+      userArr: [] // ERP浜哄憳鏁扮粍
 
     }
   },
   watch: {},
   created() {
-    this.handleRequest()
+    this.getErpUserSelect()
   },
   mounted() {
     window.addEventListener('resize', this.getHeight)
     this.getHeight()
+
+    this.getWareHouseSelect()
+    this.getWorkShopSelect()
+
+    this.getProductInHouseOrderCodeSearch()
+
+    this.getProductInHouseOrderSearch()
   },
   methods: {
-    handleRequest() {
-      this.getProductInHouseOrderSearch().then(res => {
-        if (res.code === '200') {
-          this.getWareHouseSelect()
-          this.getWorkShopSelect()
-        }
-      })
+    async getProductInHouseOrderCodeSearch() {
+      const { data: res } = await ProductInHouseOrderCodeSearch({ rightcode: '2064' })
+      this.form.hbillno = res[0]
+      this.form.incbit = res[1]
     },
-    async  getProductInHouseOrderSearch() {
+    async getErpUserSelect() {
+      const { data: res } = await ErpUserSelect()
+      this.userArr = res
+
+      if (!res.map(i => i.name).includes(getCookie('username'))) {
+        this.isPermission = false
+
+        await this.$alert('褰撳墠鐢ㄦ埛鍦‥RP绯荤粺涓笉瀛樺湪鎴栨湭鎺堟潈锛屾棤娉曞叆搴撴彁浜�', '鎻愮ず', {
+          confirmButtonText: '纭畾'
+          // callback: action => {
+          //   this.$message({
+          //     type: 'info',
+          //     message: `action: ${action}`
+          //   })
+          // }
+        })
+      }
+    },
+
+    // 鍗曟嵁绫诲瀷鏀瑰彉
+    documentTypeChange(val) {
+      this.form.erpordercode = ''
+      this.form.wkshopcode = ''
+    },
+    // 鐢熶骇杞﹂棿鏀瑰彉
+    async wkshopcodeChange(val) {
+      this.form.erpordercode = ''
+      this.form.mesordercode = ''
+      this.form.saleOrderCode = ''
+      const data = {
+        ordertype: this.form.documentType,
+        wkshopcode: val
+      }
+      const { data: res } = await ProductInHouseWkshopOrder(data)
+      if (this.form.documentType === 'Y') {
+        this.erpordercodeArr = res
+      } else {
+        this.mesordercodeArr = res
+      }
+    },
+
+    async getProductInHouseOrderSearch() {
       let tempDate = this.form.orderdate
       if (tempDate.length > 0) {
         tempDate = handleDatetime(tempDate[0]) + '~' + handleDatetime(tempDate[1])
       }
       const data = {
+        wkshopcode: this.form.wkshopcode, // 鐢熶骇杞﹂棿
         erpordercode: this.form.erpordercode, // 璁㈠崟缂栧彿
         mesordercode: this.form.mesordercode, // 宸ュ崟缂栧彿
         partcode: this.form.partcode, // 浜у搧缂栫爜
@@ -541,35 +811,248 @@
       // 鏍规嵁鍘熷崟鍋氳繃婊�
       this.tableDataDetail = res.data.filter(i => this.form.documentType === 'Y' ? i.m_po : !i.m_po)
 
+      this.form.saleOrderCode = res.data[0].saleOrderCode
+
       this.$nextTick(() => {
         this.$refs.tableDataRef.doLayout()
       })
-      return { code: res.code }
     },
     // 鑾峰彇浠撳簱鎺ュ彛
     async getWareHouseSelect() {
-      const { data: res } = await WareHouseSelect()
+      const { data: res } = await ErpWarehouseSelect()
       this.stockcodeArr = res
     },
     // 鑾峰彇鎵�灞炶溅闂�
     async getWorkShopSelect() {
-      const { data: res } = await WorkShopSelect()
+      const { data: res } = await ErpWkshopDepartmentSelect()
       this.WorkShopArr = res
     },
 
     // 閲嶇疆
     reset() {
-      this.form.OrgCode = ''
-      this.form.OrgName = ''
-      this.form.OrgType = ''
-      this.form.UserName = ''
-      this.getOrganizationSearch()
+      this.form.wkshopcode = ''
+      this.form.erpordercode = ''
+      this.form.mesordercode = ''
+      this.form.partcode = ''
+      this.form.partname = ''
+      this.form.partspec = ''
+      this.form.orderdate = ''
+
+      this.tableDataDetail = []
     },
 
+    // 琛ㄦ牸鍗曞厓鏍煎弻鍑�
+    cellDblclick(row, column, cell, event) {
+      switch (column.label) {
+        case '浠撳簱':
+          this.tabClickIndex = row.index
+          this.tabClickLabel = column.label
+          break
+        case '鍙叆搴撴暟閲�':
+          this.tabClickIndex = row.index
+          this.tabClickLabel = column.label
+          break
+        // case '鍒よ矗閲戦(鍏�)':
+        //   this.tabClickIndex = row.index
+        //   this.tabClickLabel = column.label
+        //   break
+        default:
+          return
+      }
+    },
+    // 琛ㄦ牸鍗曞嚮浜嬩欢
+    cellClick() {
+      this.tabClickLabel = ''
+    },
+    // 鍏ュ簱浠撳簱鍊兼敼鍙�
+    stockcodeChange(val) {
+      this.tableDataDetail.forEach(i => {
+        i.stockcode = val
+      })
+    },
+
+    // 澶氶�夐�変腑
     handleSelectionChange(val) {
       this.multipleSelection = val
     },
 
+    // tab鐐瑰嚮
+    tabClick(val) {
+      // this.$nextTick(() => {
+      //   this.$refs.tableDataRef.doLayout()
+      // })
+
+      const stockcodeArr = [...new Set(this.multipleSelection.map(i => i.stockcode))]// 鏁扮粍鍘婚噸
+
+      // const partcodeArr = [...new Set(this.multipleSelection.map(i => i.partcode))]// 鏁扮粍鍘婚噸
+      const newData = []
+
+      const Array2D = []
+
+      stockcodeArr.forEach(i => {
+        Array2D.push(this.multipleSelection.filter(j => j.stockcode === i))
+      })
+
+      Array2D.forEach(k => {
+        const partcodeArr = [...new Set(k.map(j => j.partcode))]
+        partcodeArr.forEach(i => {
+          const t = k.find(j => j.partcode === i)
+          let sum = 0
+          const good_qty = k.filter(j => j.partcode === i).map(j => parseFloat(j.good_qty)).reduce((pre, curr) => {
+            sum = pre + curr
+            return sum
+          })
+          sum = 0
+          const inhouseqty = k.filter(j => j.partcode === i).map(j => parseFloat(j.inhouseqty)).reduce((pre, curr) => {
+            sum = pre + curr
+            return sum
+          })
+          sum = 0
+          const stinhouseqty = k.filter(j => j.partcode === i).map(j => parseFloat(j.stinhouseqty)).reduce((pre, curr) => {
+            sum = pre + curr
+            return sum
+          })
+          newData.push(
+            {
+              stockcode: t.stockcode,
+              partcode: t.partcode,
+              partname: t.partname,
+              partspec: t.partspec,
+              qty: t.qty,
+              good_qty,
+              inhouseqty,
+              stinhouseqty,
+              unitid: t.unitid,
+              unitname: t.unitname,
+              sourceVoucherDetailId: t.sbid,
+              saleOrderDetailId: t.saleOrderDetailId,
+              ManufactureOrderDetailId: t.sbid,
+              stck_id: this.stockcodeArr.find(i => i.code === t.stockcode).id,
+              SourceVoucherDetailIdByMergedFlow: t.sbid,
+              materiel_code: t.partcode,
+              warehouse: t.stockcode,
+              materiel_id: t.materiel_id
+            }
+          )
+        })
+      })
+      // console.log(Array2D, 'Array2D')
+      // console.log(newData, 'newData')
+
+      // partcodeArr.forEach(i => {
+      //   const t = this.multipleSelection.find(j => j.partcode === i)
+      //   let sum = 0
+      //   const good_qty = this.multipleSelection.filter(j => j.partcode === i).map(j => parseFloat(j.good_qty)).reduce((pre, curr) => {
+      //     sum = pre + curr
+      //     return sum
+      //   })
+      //   sum = 0
+      //   const inhouseqty = this.multipleSelection.filter(j => j.partcode === i).map(j => parseFloat(j.inhouseqty)).reduce((pre, curr) => {
+      //     sum = pre + curr
+      //     return sum
+      //   })
+      //   sum = 0
+      //   const stinhouseqty = this.multipleSelection.filter(j => j.partcode === i).map(j => parseFloat(j.stinhouseqty)).reduce((pre, curr) => {
+      //     sum = pre + curr
+      //     return sum
+      //   })
+      //   newData.push(
+      //     {
+      //       partcode: i,
+      //       partname: t.partname,
+      //       partspec: t.partspec,
+      //       qty: t.qty,
+      //       good_qty,
+      //       inhouseqty,
+      //       stinhouseqty
+      //     }
+      //   )
+      // })
+      this.tableDataSummary = newData.flat()
+    },
+
+    // 鍏ュ簱鎻愪氦
+    async  submit() {
+      await this.tabClick()
+      this.multipleSelection.forEach(i => {
+        i.stockname = this.stockcodeArr.find(j => j.code === i.stockcode).name
+        i.id = this.stockcodeArr.find(j => j.code === i.stockcode).id
+      })
+
+      const head = {
+        rightcode: '2064',
+        hbillno: this.form.hbillno,
+        incbit: this.form.incbit,
+        wkshpcode: this.form.wkshopcode,
+        sourceVoucherId: this.form.documentType === 'Y' ? this.tableDataDetail[0].mpoid : '',
+        sourceVoucherCode: this.form.documentType === 'Y' ? this.tableDataDetail[0].m_po : this.tableDataDetail[0].wo_code,
+        saleOrderId: this.tableDataDetail[0].saleOrderid,
+        saleOrderCode: this.tableDataDetail[0].saleOrderCode,
+        rdDirectionFlag: 1,
+        makerid: this.userArr.find(i => i.name === getCookie('username')).id,
+        maker: getCookie('username'),
+        accountingyear: new Date().getFullYear(),
+        VoucherYear: new Date().getFullYear(),
+        VoucherPeriod: new Date().getMonth() + 1,
+        ManufactureOrderCode: this.form.documentType === 'Y' ? this.tableDataDetail[0].m_po : this.tableDataDetail[0].wo_code,
+        idbusitype: '03',
+        iddepartment: this.WorkShopArr.find(i => i.code === this.form.wkshopcode).id,
+        idrdstyle: 21,
+        idwarehouse: '',
+        voucherState: 181,
+        idvouchertype: 15,
+        voucherdate: handleDatetime(new Date().getTime()),
+        madedate: handleDatetime(new Date().getTime()),
+        createdtime: handleDatetime2(new Date().getTime()),
+        DataSource: '56133'
+      }
+
+      const subsum = []
+      this.tableDataSummary.forEach((i, index) => {
+        subsum.push({
+          code: index.toString().padStart(4, '0'),
+          rownumber: index + 1,
+          arrivalQuantity: i.qty,
+          quantity: i.stinhouseqty,
+          compositionQuantity: i.stinhouseqty + i.unitname,
+          baseQuantity: i.stinhouseqty,
+          sourceVoucherId: this.form.documentType === 'Y' ? this.tableDataDetail[0].mpoid : '',
+          sourceVoucherCode: this.form.documentType === 'Y' ? this.tableDataDetail[0].m_po : this.tableDataDetail[0].wo_code,
+          sourceVoucherDetailId: i.sourceVoucherDetailId,
+          idsourcevouchertype: 69,
+          saleOrderId: this.tableDataDetail[0].saleOrderid,
+          saleOrderCode: this.tableDataDetail[0].saleOrderCode,
+          saleOrderDetailId: i.saleOrderDetailId,
+          ManufactureOrderId: this.form.documentType === 'Y' ? this.tableDataDetail[0].mpoid : '',
+          ManufactureOrderCode: this.form.documentType === 'Y' ? this.tableDataDetail[0].m_po : this.tableDataDetail[0].wo_code,
+          ManufactureOrderDetailId: i.ManufactureOrderDetailId,
+          idbusiTypeByMergedFlow: 3,
+          idinventory: i.materiel_id,
+          idbaseunit: i.unitid,
+          idunit: i.unitid,
+          idwarehouse: i.stck_id,
+          SourceVoucherIdByMergedFlow: this.tableDataDetail[0].mpoid,
+          SourceVoucherCodeByMergedFlow: this.tableDataDetail[0].m_po,
+          SourceVoucherDetailIdByMergedFlow: i.SourceVoucherDetailIdByMergedFlow,
+          idsourceVoucherTypeByMergedFlow: 69,
+          createdtime: handleDatetime2(new Date().getTime()),
+          DataSource: '56133',
+          materiel_code: i.materiel_code,
+          warehouse: i.warehouse
+        })
+      })
+
+      const data = {
+        head, sub: this.multipleSelection, subsum
+      }
+
+      // console.log(JSON.stringify(data))
+
+      const res = await ProductInHouseOrderSeave(data)
+      if (res.code === '200') {
+        this.$message.success('鍏ュ簱鎻愪氦鎴愬姛锛�')
+      }
+    },
     // 鑾峰彇椤甸潰楂樺害
     getHeight() {
       this.$nextTick(() => {
@@ -579,6 +1062,11 @@
       })
     },
     tableRowClassName({ row, rowIndex }) {
+      // 鎶婃瘡涓�琛岀殑绱㈠紩鏀捐繘row
+      row.index = rowIndex
+      return 'custom-row'
+    },
+    tableRowClassName2({ row, rowIndex }) {
       return 'custom-row'
     }
   }

--
Gitblit v1.9.3