From 9edc20f04ae1cdc847a2f709831b8d0e6f4f0eda Mon Sep 17 00:00:00 2001
From: loulijun2021 <1694218219@qq.com>
Date: 星期三, 07 六月 2023 14:47:36 +0800
Subject: [PATCH] 1.生产入库无源单提交测试OK   生产入库开发完成2.MES工单 流程单新增工单编码二维码

---
 src/views/produceManager/productWarehouse.vue |  857 ++++++++++++++++++++++++++++++++++++++++++--------------
 1 files changed, 640 insertions(+), 217 deletions(-)

diff --git a/src/views/produceManager/productWarehouse.vue b/src/views/produceManager/productWarehouse.vue
index 4c94483..30e0b39 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"
@@ -67,7 +70,7 @@
                 v-if="form.documentType==='Y'"
                 label="鐢熶骇璁㈠崟"
                 :required="form.documentType==='Y'"
-                style=" display: flex;"
+                style="display: flex;"
               >
 
                 <el-select
@@ -138,6 +141,7 @@
                   v-model="form.saleOrderCode"
                   readonly
                   style="width: 200px"
+                  @change="getProductInHouseOrderSearch"
                 />
                 <!--                disabled-->
               </el-form-item>
@@ -145,13 +149,13 @@
 
             <div style="display: flex">
               <el-form-item label="浜у搧缂栫爜" style=" display: flex;">
-                <el-input v-model="form.partcode" placeholder="璇疯緭鍏�" style="width: 200px" />
+                <el-input v-model="form.partcode" placeholder="璇疯緭鍏�" style="width: 200px" @change="getProductInHouseOrderSearch" />
               </el-form-item>
               <el-form-item label="浜у搧鍚嶇О" style=" display: flex;">
-                <el-input v-model="form.partname" style="width: 200px" placeholder="璇疯緭鍏�" />
+                <el-input v-model="form.partname" style="width: 200px" placeholder="璇疯緭鍏�" @change="getProductInHouseOrderSearch" />
               </el-form-item>
               <el-form-item label="浜у搧瑙勬牸" style=" display: flex;">
-                <el-input v-model="form.partspec" style="width: 200px" placeholder="璇疯緭鍏�" />
+                <el-input v-model="form.partspec" style="width: 200px" placeholder="璇疯緭鍏�" @change="getProductInHouseOrderSearch" />
               </el-form-item>
               <el-form-item
                 label="宸ュ崟鏃ユ湡"
@@ -167,6 +171,7 @@
                   :clearable="false"
                   start-placeholder="寮�濮嬫棩鏈�"
                   end-placeholder="缁撴潫鏃ユ湡"
+                  @change="getProductInHouseOrderSearch"
                 />
               </el-form-item>
             </div>
@@ -203,15 +208,21 @@
               <el-date-picker
                 v-model="form.lm_date"
                 style="width: 200px"
+                readonly
                 type="date"
                 placeholder="閫夋嫨鏃ユ湡"
               />
             </el-form-item>
             <el-form-item label="鍗曟嵁缂栧彿" style=" display: flex;">
-              <el-input v-model="form.OrgName" placeholder="璇疯緭鍏�" style="width: 200px" />
+              <el-input
+                v-model="form.hbillno"
+                readonly
+                placeholder="璇疯緭鍏�"
+                style="width: 200px"
+              />
             </el-form-item>
 
-            <el-form-item label="鍏ュ簱浠撳簱" style=" display: flex;">
+            <el-form-item label="鍏ュ簱浠撳簱" required style=" display: flex;">
               <el-select
                 v-model="form.stockcode"
                 :popper-append-to-body="false"
@@ -234,7 +245,14 @@
             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="primary"
+              icon="el-icon-s-promotion"
+              :disabled="$store.state.app.buttonIsDisabled"
+              @click="submit"
+            >鍏ュ簱鎻愪氦
+            </el-button>
             <!--            <el-button v-waves type="info" icon="el-icon-refresh" @click="reset">閲嶇疆</el-button>-->
           </div>
         </el-form>
@@ -272,9 +290,9 @@
                   :header-cell-style="this.$headerCellStyle"
                   :cell-style="this.$cellStyle"
                   @selection-change="handleSelectionChange"
-                  @cell-dblclick="cellDblclick"
-                  @cell-click="cellClick"
                 >
+                  <!--                  @cell-dblclick="cellDblclick"-->
+                  <!--                  @cell-click="cellClick"-->
                   <el-table-column
                     type="selection"
                     width="50"
@@ -287,32 +305,33 @@
                     label="搴忓彿"
                   />
 
-                  <el-table-column
-                    prop="stockcode"
-                    label="浠撳簱"
-                    width="160"
-                    show-tooltip-when-overflow
-                  >
-                    <template slot-scope="{row}">
-                      <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-->
+                  <!--                    prop="stockcode"-->
+                  <!--                    label="浠撳簱"-->
+                  <!--                    width="160"-->
+                  <!--                    show-tooltip-when-overflow-->
+                  <!--                  >-->
+                  <!--                    <template slot-scope="{row}">-->
+                  <!--                      <div>{{ row.stockcode ? stockcodeArr.find(i => i.code === row.stockcode).name : '/' }}</div>-->
+                  <!--                      &lt;!&ndash;                      <div&ndash;&gt;-->
+                  <!--                      &lt;!&ndash;                        v-if="!(row.index === tabClickIndex && tabClickLabel === '浠撳簱')"&ndash;&gt;-->
+                  <!--                      &lt;!&ndash;                      >&ndash;&gt;-->
+                  <!--                      &lt;!&ndash;                        {{ row.stockcode ? stockcodeArr.find(i => i.code === row.stockcode).name : '/' }}&ndash;&gt;-->
+                  <!--                      &lt;!&ndash;                      </div>&ndash;&gt;-->
+                  <!--                      &lt;!&ndash;                      <el-select&ndash;&gt;-->
+                  <!--                      &lt;!&ndash;                        v-if="row.index === tabClickIndex && tabClickLabel === '浠撳簱'"&ndash;&gt;-->
+                  <!--                      &lt;!&ndash;                        v-model="row.stockcode"&ndash;&gt;-->
+                  <!--                      &lt;!&ndash;                        placeholder="璇烽�夋嫨"&ndash;&gt;-->
+                  <!--                      &lt;!&ndash;                      >&ndash;&gt;-->
+                  <!--                      &lt;!&ndash;                        <el-option&ndash;&gt;-->
+                  <!--                      &lt;!&ndash;                          v-for="item in stockcodeArr"&ndash;&gt;-->
+                  <!--                      &lt;!&ndash;                          :key="item.code"&ndash;&gt;-->
+                  <!--                      &lt;!&ndash;                          :label="item.name"&ndash;&gt;-->
+                  <!--                      &lt;!&ndash;                          :value="item.code"&ndash;&gt;-->
+                  <!--                      &lt;!&ndash;                        />&ndash;&gt;-->
+                  <!--                      &lt;!&ndash;                      </el-select>&ndash;&gt;-->
+                  <!--                    </template>-->
+                  <!--                  </el-table-column>-->
                   <el-table-column
                     prop="inbarcode"
                     label="鍏ュ簱鏉$爜"
@@ -399,21 +418,9 @@
                     min-width="130"
                     fixed="right"
                   >
-                    <template slot-scope="{row}">
-                      <el-input-number v-model="row.stinhouseqty" :max="row.good_qty" size="small" />
-
-                      <!--                      <div-->
-                      <!--                        v-if="!(row.index === tabClickIndex && tabClickLabel === '鍙叆搴撴暟閲�')"-->
-                      <!--                      >-->
-                      <!--                        {{ row.stinhouseqty }}-->
-                      <!--                      </div>-->
-                      <!--                      <el-input-->
-                      <!--                        v-if="row.index === tabClickIndex && tabClickLabel === '鍙叆搴撴暟閲�'"-->
-                      <!--                        v-model="row.stinhouseqty"-->
-                      <!--                        oninput="value=value.replace(/[^0-9]/g,'')"-->
-                      <!--                      />-->
-
-                    </template>
+                    <!--                    <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
@@ -442,17 +449,17 @@
                     label="搴忓彿"
                   />
 
-                  <el-table-column
-                    prop="stockname"
-                    label="浠撳簱"
-                    width="110"
-                  >
-                    <template slot-scope="{row}">
-                      <div v-if="row.stockname">{{ row.stockname }}</div>
-                      <div v-else>/</div>
-                    </template>
+                  <!--                  <el-table-column-->
+                  <!--                    prop="stockname"-->
+                  <!--                    label="浠撳簱"-->
+                  <!--                    width="110"-->
+                  <!--                  >-->
+                  <!--                    <template slot-scope="{row}">-->
+                  <!--                      <div v-if="row.stockname">{{ row.stockname }}</div>-->
+                  <!--                      <div v-else>/</div>-->
+                  <!--                    </template>-->
 
-                  </el-table-column>
+                  <!--                  </el-table-column>-->
                   <el-table-column
                     prop="inbarcode"
                     label="鍏ュ簱鏉$爜"
@@ -564,10 +571,14 @@
                     label="搴忓彿"
                   />
                   <!--                  <el-table-column-->
-                  <!--                    prop="stockname"-->
+                  <!--                    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>-->
@@ -677,11 +688,20 @@
 <script>
 import elDragDialog from '@/directive/el-drag-dialog'
 import waves from '@/directive/waves'
-import { WareHouseSelect } from '@/api/materialManager'
-import { ProductInHouseOrderSearch, ProductInHouseWkshopOrder } from '@/api/produceManager'
-import { handleDatetime } from '@/utils/global'
-import { WorkShopSelect } from '@/api/deviceManager'
-import $ from 'jquery'
+import {
+  ProductInHouseOrderCodeSearch,
+  ProductInHouseOrderSearch, ProductInHouseOrderSeave,
+  ProductInHouseWkshopOrder
+} from '@/api/produceManager'
+import { getTPlusToken, handleDatetime, handleDatetime2 } from '@/utils/global'
+import {
+  ErpUserSelect,
+  ErpWarehouseSelect,
+  ErpWkshopDepartmentSelect
+} from '@/api/basicInfo'
+import { getCookie } from '@/utils/auth'
+import Vue from 'vue'
+import axios from 'axios'
 
 export default {
   name: 'Zzjg',
@@ -692,6 +712,8 @@
       mainHeight: 0,
       tableHeight: 0,
       form: {
+        hbillno: '', // 鍏ュ簱鍗曞彿
+        incbit: '', // 娴佹按鍙�
         documentType: 'Y', // 鍗曟嵁绫诲瀷
 
         wkshopcode: '', // 鐢熶骇杞﹂棿
@@ -703,7 +725,7 @@
         orderdate: '', // 宸ュ崟鏃ユ湡
 
         saleOrderCode: '', // 閿�鍞鍗�
-        lm_date: '', // 鍗曟嵁鏃ユ湡
+        lm_date: new Date(), // 鍗曟嵁鏃ユ湡
         stockcode: '' // 鍏ュ簱浠撳簱
 
       },
@@ -723,30 +745,66 @@
 
       tableDataSummary: [], // 姹囨�昏〃
 
-      xxx: ''
+      isPermission: true, // 鏄惁鏈夋潈闄愬彲鎻愪氦
+
+      userArr: [] // ERP浜哄憳鏁扮粍
 
     }
   },
   watch: {},
   created() {
-    this.getWareHouseSelect()
-    this.getWorkShopSelect()
+    this.getErpUserSelect()
   },
   mounted() {
     window.addEventListener('resize', this.getHeight)
     this.getHeight()
+
+    this.getWareHouseSelect()
+    this.getWorkShopSelect()
+
+    this.getProductInHouseOrderCodeSearch()
+
+    // this.getProductInHouseOrderSearch()
   },
   methods: {
+    async getProductInHouseOrderCodeSearch() {
+      const { data: res } = await ProductInHouseOrderCodeSearch({ rightcode: '2064' })
+      this.form.hbillno = res[0]
+      this.form.incbit = res[1]
+    },
+    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 = ''
+      this.reset()
     },
     // 鐢熶骇杞﹂棿鏀瑰彉
     async wkshopcodeChange(val) {
       this.form.erpordercode = ''
       this.form.mesordercode = ''
       this.form.saleOrderCode = ''
+      this.tableDataDetail = []
+      this.tableDataSummary = []
+      this.multipleSelection = []
       const data = {
         ordertype: this.form.documentType,
         wkshopcode: val
@@ -787,12 +845,12 @@
     },
     // 鑾峰彇浠撳簱鎺ュ彛
     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
     },
 
@@ -805,8 +863,11 @@
       this.form.partname = ''
       this.form.partspec = ''
       this.form.orderdate = ''
+      this.form.stockcode = ''
 
       this.tableDataDetail = []
+      this.tableDataSummary = []
+      this.multipleSelection = []
     },
 
     // 琛ㄦ牸鍗曞厓鏍煎弻鍑�
@@ -846,161 +907,523 @@
 
     // tab鐐瑰嚮
     tabClick(val) {
-      console.log(val.label)
       // this.$nextTick(() => {
       //   this.$refs.tableDataRef.doLayout()
       // })
 
-      const data = [
-        {
-          'inbarcode': 'IN23053150',
-          'saleOrderid': 13,
-          'saleOrderCode': 'SO-2023-05-0009',
-          'saleOrderDetailId': 19,
-          'mpoid': 19,
-          'm_po': 'MO-2023-05-0007',
-          'sbid': 30,
-          'wo_code': 'MO-2023-05-0007_4',
-          'materiel_id': 11,
-          'partcode': '301',
-          'partname': '鐢佃剳',
-          'partspec': '',
-          'step_code': 'Step08',
-          'wkshp_id': 1,
-          'wkshp_code': 'CJ001',
-          'stck_id': 3,
-          'stockcode': '03',
-          'stockname': '鎴愬搧浠撳簱',
-          'qty': 80.00,
-          'plan_qty': 40.0,
-          'good_qty': 20.00,
-          'inhouseqty': 0.00,
-          'stinhouseqty': 20.00,
-          'lm_date': '2023-05-31 09:52:24',
-          'style': 'S'
-        },
-        {
-          'inbarcode': 'IN23053148',
-          'saleOrderid': 13,
-          'saleOrderCode': 'SO-2023-05-0009',
-          'saleOrderDetailId': 19,
-          'mpoid': 19,
-          'm_po': 'MO-2023-05-0007',
-          'sbid': 30,
-          'wo_code': 'MO-2023-05-0007_3',
-          'materiel_id': 11,
-          'partcode': '301',
-          'partname': '鐢佃剳',
-          'partspec': '',
-          'step_code': 'Step08',
-          'wkshp_id': 1,
-          'wkshp_code': 'CJ001',
-          'stck_id': 3,
-          'stockcode': '03',
-          'stockname': '鎴愬搧浠撳簱',
-          'qty': 80.00,
-          'plan_qty': 40.0,
-          'good_qty': 1.00,
-          'inhouseqty': 0.00,
-          'stinhouseqty': 1.00,
-          'lm_date': '2023-05-31 09:52:31',
-          'style': 'S'
-        },
-        {
-          'inbarcode': 'IN23053149',
-          'saleOrderid': 13,
-          'saleOrderCode': 'SO-2023-05-0009',
-          'saleOrderDetailId': 19,
-          'mpoid': 19,
-          'm_po': 'MO-2023-05-0007',
-          'sbid': 30,
-          'wo_code': 'MO-2023-05-0007_3',
-          'materiel_id': 11,
-          'partcode': '301',
-          'partname': '鐢佃剳',
-          'partspec': '',
-          'step_code': 'Step08',
-          'wkshp_id': 1,
-          'wkshp_code': 'CJ001',
-          'stck_id': 3,
-          'stockcode': '03',
-          'stockname': '鎴愬搧浠撳簱',
-          'qty': 80.00,
-          'plan_qty': 40.0,
-          'good_qty': 9.00,
-          'inhouseqty': 0.00,
-          'stinhouseqty': 9.00,
-          'lm_date': '2023-05-31 09:52:31',
-          'style': 'S'
-        },
-        {
-          'inbarcode': 'IN23053145',
-          'saleOrderid': 13,
-          'saleOrderCode': 'SO-2023-05-0009',
-          'saleOrderDetailId': 20,
-          'mpoid': 19,
-          'm_po': 'MO-2023-05-0007',
-          'sbid': 31,
-          'wo_code': 'MO-2023-05-0007_5',
-          'materiel_id': 24,
-          'partcode': '308',
-          'partname': '鐢垫睜鍖�',
-          'partspec': '',
-          'step_code': 'Step08',
-          'wkshp_id': 1,
-          'wkshp_code': 'CJ001',
-          'stck_id': 2,
-          'stockcode': '02',
-          'stockname': '鍗婃垚鍝佸簱',
-          'qty': 70.00,
-          'plan_qty': 70.0,
-          'good_qty': 5.00,
-          'inhouseqty': 0.00,
-          'stinhouseqty': 5.00,
-          'lm_date': '2023-05-31 09:52:40',
-          'style': 'S'
-        },
-        {
-          'inbarcode': 'IN23053147',
-          'saleOrderid': 13,
-          'saleOrderCode': 'SO-2023-05-0009',
-          'saleOrderDetailId': 20,
-          'mpoid': 19,
-          'm_po': 'MO-2023-05-0007',
-          'sbid': 31,
-          'wo_code': 'MO-2023-05-0007_5',
-          'materiel_id': 24,
-          'partcode': '308',
-          'partname': '鐢垫睜鍖�',
-          'partspec': '',
-          'step_code': 'Step08',
-          'wkshp_id': 1,
-          'wkshp_code': 'CJ001',
-          'stck_id': 2,
-          'stockcode': '02',
-          'stockname': '鍗婃垚鍝佸簱',
-          'qty': 70.00,
-          'plan_qty': 70.0,
-          'good_qty': 10.00,
-          'inhouseqty': 0.00,
-          'stinhouseqty': 10.00,
-          'lm_date': '2023-05-31 09:52:40',
-          'style': 'S'
-        }
-      ]
+      // const stockcodeArr = [...new Set(this.multipleSelection.map(i => i.stockcode))]// 鏁扮粍鍘婚噸
 
-      const partcodeArr = data.map(i => i.partcode)
+      const partcodeArr = [...new Set(this.multipleSelection.map(i => i.partcode))]// 鏁扮粍鍘婚噸
       const newData = []
-      if (val.label === '姹囨��') {
-        data.forEach(i => {
-          // if ()
+
+      // 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
+
+            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: t.stockcode ? this.stockcodeArr.find(i => i.code === t.stockcode).id : '/',
+            SourceVoucherDetailIdByMergedFlow: t.sbid,
+            materiel_code: t.partcode,
+            warehouse: t.stockcode,
+            materiel_id: t.materiel_id
+
+          }
+        )
+      })
+      // this.tableDataSummary = newData.flat()
+      this.tableDataSummary = newData
     },
 
-    // 鎻愪氦
-    submit() {
+    async submit() {
+      if (!this.form.stockcode) {
+        return this.$message.error('鍏ュ簱浠撳簱涓嶈兘涓虹┖锛�')
+      }
+      if (this.multipleSelection.length === 0) {
+        return this.$message.error('鏈�夋嫨浜у搧锛�')
+      }
 
+      this.$store.state.app.buttonIsDisabled = true
+      await this.tabClick()
+      const openToken = await getTPlusToken() // 鑾峰彇TPlus   token
+
+      // const openToken =
+
+      // 鏈夋簮鍗�
+      if (this.form.documentType === 'Y') {
+        const RDRecordDetails = []
+        this.tableDataSummary.forEach((i, index) => {
+          RDRecordDetails.push({
+            Code: index + 1, // 琛屽彿锛屼粠1寮�濮嬭嚜澧為暱
+            SourceVoucherId: this.tableDataDetail[0].mpoid, // 鏉ユ簮鍗曟嵁鐨勫崟鎹甀D
+            BaseQuantity: i.stinhouseqty, // 涓昏閲忓崟浣嶆暟閲�
+            SourceVoucherDetailId: i.sourceVoucherDetailId, // 鏉ユ簮鍗曟嵁鐨勫搴旀槑缁咺D
+            Inventory: {
+              Code: i.materiel_code // 瀛樿揣缂栫爜
+            },
+            IdSourceVoucherType: 69
+          })
+        })
+        const data = {
+          'dto': {
+            'Warehouse': {
+              'Code': this.form.stockcode// 浠撳簱缂栫爜
+            },
+            'Code': this.form.hbillno, // 鍗曟嵁缂栫爜
+            'IsModifiedCode': true,
+            'BusiType': {
+              'Code': '03'// 涓氬姟绫诲瀷缂栫爜
+            },
+            'Department': {
+              'Code': this.form.wkshopcode// 閮ㄩ棬缂栫爜
+            },
+            'VoucherDate': handleDatetime(new Date().getTime()), // 鍗曟嵁鏃ユ湡
+            'RdStyle': {
+              'Code': '21'// 鍑哄簱绫诲埆缂栫爜
+            },
+            'RDRecordDetails': RDRecordDetails,
+            // 'Clerk': {
+            //   'Code': this.userArr.find(i => i.name === getCookie('username')).code // 涓氬姟鍛榗ode
+            //   // 'Code': '001' // 涓氬姟鍛榗ode
+            //   // 'Name': getCookie('username')
+            // },
+            'ExternalCode': this.form.hbillno,
+            'VoucherType': {
+              'Code': 'ST1002'
+            }
+          }
+        }
+        const res = await axios.post(Vue.prototype.$chanjetBaseUrl + '/tplus/api/v2/ProductReceiveOpenApi/Create',
+          data, {
+            headers: {
+              'openToken': openToken,
+              'appKey': Vue.prototype.$AppKey,
+              'appSecret': Vue.prototype.$AppSecret,
+              'Content-Type': 'application/json'
+            }
+          }
+        )
+        if (res.data.code === 0) {
+          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',
+            idsourcevouchertype: 69
+          }
+
+          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
+          }
+
+          const r1 = await ProductInHouseOrderSeave(data)
+          if (r1.code === '200') {
+            this.$message.success('鍏ュ簱鎴愬姛锛�')
+            this.$store.state.app.buttonIsDisabled = false
+            await this.getProductInHouseOrderCodeSearch()
+            await this.wkshopcodeChange(this.form.wkshopcode)
+            this.tableDataDetail = []
+            this.tableDataSummary = []
+            this.multipleSelection = []
+            this.form.stockcode = ''
+          }
+        } else {
+          this.$message.error('鍏ュ簱澶辫触锛�')
+          this.$store.state.app.buttonIsDisabled = false
+        }
+      }
+
+      // 鏃犳簮鍗�
+      if (this.form.documentType === 'N') {
+        const RDRecordDetails = []
+        this.tableDataSummary.forEach((i, index) => {
+          RDRecordDetails.push({
+            Code: index + 1, // 琛屽彿锛屼粠1寮�濮嬭嚜澧為暱
+            Inventory: {
+              Code: i.materiel_code // 瀛樿揣缂栫爜
+            },
+            BaseQuantity: i.stinhouseqty, // 涓昏閲忓崟浣嶆暟閲�
+            SNObject: {
+              SnAccountDetails: [
+                {
+                  SNCode: index.toString().padStart(4, '0')
+                }
+              ]
+            }
+          })
+        })
+        const data = {
+          'dto': {
+            'IsModifiedCode': true,
+            'ExternalCode': this.form.hbillno,
+            'Code': this.form.hbillno,
+            'VoucherType': {
+              'Code': 'ST1002'
+            },
+            'VoucherDate': handleDatetime(new Date().getTime()),
+            'BusiType': {
+              'Code': '03'
+            },
+            'Warehouse': {
+              'Code': this.form.stockcode
+            },
+            'Department': {
+              'Code': this.form.wkshopcode,
+              'Name': this.WorkShopArr.find(i => i.code === this.form.wkshopcode).name
+            },
+            'RDRecordDetails': RDRecordDetails
+          }
+        }
+        const res = await axios.post(Vue.prototype.$chanjetBaseUrl + '/tplus/api/v2/productReceive/Create',
+          data, {
+            headers: {
+              'openToken': openToken,
+              'appKey': Vue.prototype.$AppKey,
+              'appSecret': Vue.prototype.$AppSecret,
+              'Content-Type': 'application/json'
+            }
+          }
+        )
+
+        if (res.data === null) {
+          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 : this.tableDataDetail[0].wo_id, // 涓嬪崍鎶婅繖涓弬鏁板姞涓�
+            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',
+            idsourcevouchertype: 69
+          }
+
+          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,
+              sourceVoucherCode: '',
+              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(data, 2)
+          const r1 = await ProductInHouseOrderSeave(data)
+          if (r1.code === '200') {
+            this.$message.success('鍏ュ簱鎴愬姛锛�')
+            this.$store.state.app.buttonIsDisabled = false
+            await this.getProductInHouseOrderCodeSearch()
+            await this.wkshopcodeChange(this.form.wkshopcode)
+            this.tableDataDetail = []
+            this.tableDataSummary = []
+            this.multipleSelection = []
+            this.form.stockcode = ''
+            this.$store.state.app.buttonIsDisabled = false
+          }
+        } else {
+          this.$message.error('鍏ュ簱澶辫触锛�')
+          this.$store.state.app.buttonIsDisabled = false
+        }
+      }
+    },
+    // 鍏ュ簱鎻愪氦
+    submit2() {
+      this.tabClick()
+
+      this.$confirm('鏄惁纭鎻愪氦?', '鎻愮ず', {
+        confirmButtonText: '纭畾',
+        cancelButtonText: '鍙栨秷',
+        type: 'warning'
+      }).then(() => {
+        if (this.multipleSelection.length === 0) {
+          return this.$message.error('鏈�夋嫨浜у搧锛�')
+        }
+        if (this.multipleSelection.find(i => !i.stockcode)) {
+          return this.$message.error('鏄庣粏閲岄潰鏈変骇鍝佹湭濉啓浠撳簱锛�')
+        }
+        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',
+          idsourcevouchertype: 69
+        }
+
+        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
+        }
+
+        ProductInHouseOrderSeave(data).then(res => {
+          if (res.code === '200') {
+            this.$message.success('鍏ュ簱鎻愪氦鎴愬姛锛�')
+            this.getProductInHouseOrderCodeSearch()
+            this.wkshopcodeChange(this.form.wkshopcode)
+            this.tableDataDetail = []
+            this.tableDataSummary = []
+            this.multipleSelection = []
+          }
+        })
+      })
     },
     // 鑾峰彇椤甸潰楂樺害
     getHeight() {

--
Gitblit v1.9.3