From 854cbc47742ee83eb30062a12b9f3ed7c8ed0941 Mon Sep 17 00:00:00 2001
From: futian.liu <liufutianyoo@163.com>
Date: 星期三, 20 十二月 2023 16:58:27 +0800
Subject: [PATCH] 盘点物品型号修改

---
 admin-web/src/views/departmentitem/itemret/returnNote/edit.vue |  352 +++++++++++++++++++++++++++++++++++-----------------------
 1 files changed, 214 insertions(+), 138 deletions(-)

diff --git a/admin-web/src/views/departmentitem/itemret/returnNote/edit.vue b/admin-web/src/views/departmentitem/itemret/returnNote/edit.vue
index 1b439af..1035425 100644
--- a/admin-web/src/views/departmentitem/itemret/returnNote/edit.vue
+++ b/admin-web/src/views/departmentitem/itemret/returnNote/edit.vue
@@ -1,16 +1,20 @@
 <template>
-  <win-md class="stock-edit" title="鐗╁搧閫�鍥�" @close="close" :width="'800px'">
+  <win-md class="stock-edit" title="鐗╁搧閫�鍥�" @close="close" width="900px" :loading="loading">
     <el-form class="form" ref="ruleForm" :model="formData" :rules="rules" label-width="120px">
       <div class="main-w">
         <el-row :gutter="24" class="headerHeight">
           <el-col :span="12">
-            <el-form-item label="閮ㄩ棬" prop="warehouseId">
-              <el-input v-model="formData.departmentName" disabled></el-input>
+            <el-form-item label="閮ㄩ棬" prop="departmentId">
+              <el-select ref="department" v-model="formData.departmentId" clearable placeholder="璇烽�夋嫨"
+                         style="width: 100%">
+                <el-option v-for="item in departmentOptions" :key="item.id" :label="item.name" :value="item.id"
+                           clearable/>
+              </el-select>
             </el-form-item>
           </el-col>
           <el-col :span="12">
-            <el-form-item label="閫�鍥炰汉" prop="createName">
-              <el-input v-model="formData.createName" disabled></el-input>
+            <el-form-item label="閫�鍥炰汉" prop="operatorName">
+              <el-input v-model="formData.operatorName" disabled></el-input>
             </el-form-item>
           </el-col>
           <el-col :span="12">
@@ -39,17 +43,20 @@
             <el-col :span="12">
               <el-form-item
                 label="鐗╁搧鍒嗙被"
-                :prop="`goods[${goodsIndex}].baseCategoryIds`"
+                :prop="`goods.${goodsIndex}.baseCategoryId`"
                 :rules="{
                   required: true,
-                  message: '璇烽�夋嫨',
+                  message: '璇烽�夋嫨鐗╁搧鍒嗙被',
                   trigger: 'change',
                 }"
               >
                 <el-cascader
-                  v-model="goodsItem.baseCategoryIds"
+                  v-model="goodsItem.baseCategoryId"
                   :options="categoryOptions"
-                  :props="{ value: 'id' }"
+                  :props="{ value: 'id',emitPath: false }"
+                  :show-all-levels="false"
+                  filterable
+                  clearable
                   @change="categoryChange($event, goodsIndex)"
                   style="width: 100%"
                 ></el-cascader>
@@ -58,13 +65,14 @@
             <el-col :span="12">
               <el-form-item
                 label="鐗╁搧鍚嶇О"
-                :prop="`goods[${goodsIndex}].baseGoodsTemplateId`"
+                :prop="`goods.${goodsIndex}.baseGoodsTemplateId`"
                 :rules="rules.baseGoodsTemplateId"
               >
                 <el-select
                   v-model="goodsItem.baseGoodsTemplateId"
-                  placeholder="璇峰厛鎷╃墿鍝佸垎绫�"
+                  :placeholder="goodsItem.baseCategoryId?'璇烽�夋嫨鐗╁搧':'璇峰厛閫夋嫨鐗╁搧鍒嗙被'"
                   filterable
+                  clearable
                   :disabled="!goodsItem.baseCategoryId"
                   style="width: 100%"
                   @change="goodsTemplateChange($event, goodsIndex)"
@@ -78,64 +86,72 @@
                 </el-select>
               </el-form-item>
             </el-col>
-          </el-row>
-          <el-row :gutter="24">
             <el-col :span="12">
-              <el-form-item label="閫夋嫨鍒嗗彂鍗�" :prop="`goods[${goodsIndex}].modelsIds`">
-                <el-input v-if="!goodsItem.baseGoodsTemplateId" placeholder="璇峰厛鎷╃墿鍝佸悕绉�" readonly suffix-icon="el-icon-arrow-down" class="cursor-p"></el-input>
-                <div v-else @click="fenfaSetting.show=true">
-                  <el-input placeholder="璇烽�夋嫨" readonly suffix-icon="el-icon-arrow-down" class="cursor-p"></el-input>
+              <el-form-item
+                label="閫夋嫨鍒嗗彂鍗�"
+                :prop="`goods.${goodsIndex}.businessFormCode`"
+                :rules="rules.businessFormCode">
+                <div @click="showFenFa(goodsIndex)">
+                  <el-input
+                    placeholder="璇烽�夋嫨鍒嗗彂鍗�"
+                    readonly
+                    v-model="goodsItem.businessFormCode"
+                    :placeholder="goodsItem.baseGoodsTemplateId?'璇烽�夋嫨鍒嗗彂鍗�':'璇峰厛閫夋嫨鐗╁搧'"
+                    :disabled="!goodsItem.baseGoodsTemplateId"
+                    suffix-icon="el-icon-arrow-down"
+                    class="cursor-p"></el-input>
                 </div>
               </el-form-item>
             </el-col>
           </el-row>
           <div class="card3" v-for="(mItem, mIndex) in goodsItem.models" :key="mIndex">
             <el-row :gutter="24" type="flex" align="middle" style="height: 50px">
-              <el-col :span="8">
+              <el-col :span="12">
                 <el-form-item label="瑙勬牸鍨嬪彿:" prop="baseGoodsModelsId" style="margin-bottom: 0">
-                  {{ getGoodsModelsName(mItem.baseGoodsModelsId) }}
+                  {{ mItem[0].modelName }}
                 </el-form-item>
               </el-col>
               <el-col :span="6">
                 <el-form-item label="鍗曚綅:" prop="baseGoodsModelsId" style="margin-bottom: 0" label-width="80">
-                  50
+                  {{ mItem[0].unit }}
                 </el-form-item>
               </el-col>
               <el-col :span="6">
                 <el-form-item label="鐗╁搧绫诲埆:" prop="baseGoodsModelsId" style="margin-bottom: 0" label-width="80">
-                  A绫�
+                  {{ mItem[0].classification }}
                 </el-form-item>
               </el-col>
             </el-row>
-            <el-table :data="mItem.models" :stripe="true">
+            <el-table :data="mItem" :stripe="true">
               <!-- A绫诲晢鍝佹樉绀� -->
-              <el-table-column prop="price" label="浣跨敤浜�" align="center" v-if="goodsItem.models.type===1">
+              <el-table-column prop="price" label="浣跨敤浜�" align="center" v-if="mItem[0].nowUserName">
                 <template slot-scope="scope">
-                  {{ scope.row.worehouseCount }}
+                  {{ scope.row.nowUserName }}
                 </template>
               </el-table-column>
               <el-table-column prop="price" label="鍒嗗彂鏁伴噺" align="center">
                 <template slot-scope="scope">
-                  {{ scope.row.worehouseCount }}
+                  {{ scope.row.goodsNum }}
                 </template>
               </el-table-column>
               <el-table-column prop="price" label="鍙��鏁伴噺" align="center">
                 <template slot-scope="scope">
-                  {{ scope.row.worehouseCount }}
+                  {{ scope.row.userUseCount }}
                 </template>
               </el-table-column>
               <el-table-column prop="counts" label="閫�鍥炴暟閲�" align="center">
-                <template slot-scope="scope">
+                <template slot-scope="{row,$index}">
                   <el-form-item
                     label-width="0"
-                    style="margin-bottom: 0"
-                    :prop="`goods[${goodsIndex}].models[${scope.$index}].counts`"
-                    :rules="rules.counts"
+                    :prop="`goods.${goodsIndex}.models.${mIndex}.counts`"
+                    :rules="[
+                          {validator: checkCounts,counts:row.counts,userUseCount: row.userUseCount, trigger: ['blur', 'change']}
+                        ]"
                   >
                     <el-input
+                      clearable
                       type="number"
-                      v-model="scope.row.counts"
-                      @change="countsChange($event, goodsIndex, scope.$index)"
+                      v-model.number="row.counts"
                     ></el-input>
                   </el-form-item>
                 </template>
@@ -150,7 +166,8 @@
               plain
               size="mini"
               @click="removeGoods(goodsIndex)"
-              >绉婚櫎</el-button
+            >绉婚櫎
+            </el-button
             >
             <el-button
               v-if="formData.goods.length - 1 == goodsIndex"
@@ -159,96 +176,107 @@
               plain
               size="mini"
               @click="addGoods"
-              >鏂板鐗╁搧</el-button
+            >鏂板鐗╁搧
+            </el-button
             >
           </div>
         </div>
       </div>
     </el-form>
     <div slot="footer" align="center" class="dialog-footer">
-      <my-button name="鍙栨秷" site="form" @click="close" />
-      <my-button name="淇濆瓨" site="form" @click="handleSubmit" />
+      <my-button name="鍙栨秷" site="form" @click="close"/>
+      <my-button name="淇濆瓨" site="form" @click="handleSubmit"/>
     </div>
-    <div v-if="fenfaSetting.show">
-      <win-sm title="閫夋嫨鍒嗗彂鍗�" @close="fenfaSetting.show=false" :width="'800px'">
-      <el-table :data="fenfaData">
-        <el-table-column type="selection" width="55"> </el-table-column>
-        <el-table-column label="鍒嗗彂鍗曞彿" prop="businessFormCode"></el-table-column>
-        <el-table-column label="鐗╁搧鍚嶇О" prop="modelName"></el-table-column>
-        <el-table-column label="鍒嗗彂鏁伴噺" prop="fenfaCount"></el-table-column>
-        <el-table-column label="鍓╀綑鏁伴噺" prop="count"></el-table-column>
-        <el-table-column label="鍒嗗彂鏃堕棿" prop="time"></el-table-column>
+    <win-md v-if="fenfaSetting.show" title="閫夋嫨鍒嗗彂鍗�" @close="fenfaSetting.show=false" :width="'800px'">
+      <el-table @current-change="handleCurrentChange" :data="fenfaData" highlight-current-row height="407">
+        <el-table-column label="鍒嗗彂鍗曞彿" prop="businessFormCode" align="left"></el-table-column>
+        <el-table-column label="鐗╁搧鍚嶇О" prop="baseGoodsTemplateName" align="left"></el-table-column>
+        <el-table-column label="鍒嗗彂鏁伴噺" prop="totalCount" align="center"></el-table-column>
+        <el-table-column label="鍓╀綑鏁伴噺" prop="useCount" align="center"></el-table-column>
+        <el-table-column label="鍒嗗彂鏃堕棿" prop="inTime" width="160" align="center">
+          <template slot-scope="{row}">
+            {{ DateFormatter.LongToDateTime(row.inTime) }}
+          </template>
+        </el-table-column>
       </el-table>
       <div slot="footer" align="center" class="dialog-footer">
-        <my-button name="鍙栨秷" site="form" @click="fenfaSetting.show=false" />
-        <my-button name="纭畾" site="form" @click="handleConfirm" />
+        <my-button name="鍙栨秷" site="form"
+                   @click="fenfaSetting.show=false;fenfaSetting.baseGoodsTemplateId=null;curFenfa=null;fenfaData=[]"/>
+        <el-button @click="handleConfirm" type="primary" size="medium">纭畾</el-button>
       </div>
-    </win-sm>
-    </div>
+    </win-md>
   </win-md>
 </template>
 <script>
-import {
-  goodsTemplate,
-  goodsModel,
-  selectTenantWarehouse,
-  warehouseSelectNumber,
-} from '@/api/baseSetting/finsystenant';
-import { outputAdd } from '@/api/stock/accessStock';
-import { getTree } from '@/api/foudation/classification';
+import {departmentListAll} from '@/api/system/deptment';
+import {goodsTemplate} from '@/api/baseSetting/finsystenant';
+import {getTree} from '@/api/foudation/classification';
 import MyButton from '@/components/myButton/myButton';
 import winMd from '@/components/win/win-md';
 import winSm from '@/components/win/win-sm';
 import upload from '@/components/upload/index';
-import { getUploadUrl } from '@/utils/base';
-import { mapGetters } from 'vuex';
+import {getUploadUrl} from '@/utils/base';
+import {mapGetters} from 'vuex';
+import * as DateFormatter from '@/utils/DateFormatter';
+import {getFfOrderByGoodsIdAndDept, getGoodsUseInfoByFfOrderAndGoodId} from "@/api/deptGoods/scrap";
+import {returnAdd} from "@/api/deptGoods/itemret";
 
 export default {
-  components: { MyButton, winMd, winSm, upload },
+  components: {MyButton, winMd, winSm, upload},
   props: {
     setting: {
       type: Object,
-      default: () => {},
+      default: () => {
+      },
     },
   },
   data() {
-    // 鑷畾涔夋牎楠�
-    // 鐗╁搧閲嶅鏍¢獙
-    var checkGoodsTemplateId = (rule, value, callback) => {
-      if (!value) {
-        return callback(new Error('璇烽�夋嫨'));
-      }
-      let temp = this.formData.goods.filter((v) => v.baseGoodsTemplateId == value);
-      if (!temp || temp.length != 1) {
-        return callback(new Error('宸查�夎繃姝ょ墿鍝�'));
-      }
-      callback();
-    };
     return {
-      loading: false,
-      warehouseOptions: [], // 閫�鍥炰粨搴撳垪琛�
+      checkCounts: (rule, value, callback) => {
+        if (!rule.counts) {
+          return callback(new Error('璇疯緭鍏ラ��鍥炴暟閲�'));
+        }
+        if (!Number.isInteger(rule.counts)) {
+          // this.$message.warning('璇疯緭鍏ユ暟瀛楀��');
+          return callback(new Error('璇疯緭鍏ユ暟瀛楀��'));
+        }
+        if (rule.counts < 1) {
+          // this.$message.warning('鏁板瓧鍊间笉鑳戒负0');
+          return callback(new Error('鏁板瓧鍊煎繀椤诲ぇ浜�0'));
+        }
+        if (rule.counts > rule.userUseCount) {
+          // this.$message.warning('鍒嗗彂鏁伴噺涓嶈兘澶т簬鍓╀綑鏁伴噺');
+          return callback(new Error('閫�鍥炴暟閲忎笉鑳藉ぇ浜庡湪鐢ㄦ暟閲�'));
+        }
+        callback();
+      },
+      DateFormatter: DateFormatter,
+      loading: true,
+      departmentOptions: [], // 閮ㄩ棬鍒楄〃
       categoryOptions: [], // 鐗╁搧鍒嗙被鍒楄〃
       modelList: [], //鍨嬪彿鍒楄〃
       fenfaSetting: {
         show: false,
+        goodsIdx: null,
+        baseGoodsTemplateId: null,
         id: '',
       },
-      fenfaData:[],
+      curFenfa: null,
+      fenfaData: [],
       formData: {
-        warehouseId: '', // 閫�鍥炰粨搴搃d
-        dealTime: '', // 閫�鍥炴椂闂�
+        departmentId: '', // 閫�鍥為儴闂╥d
+        dealTime: DateFormatter.formatDate(new Date(), 'yyyyMMddhhmmss'), // 閫�鍥炴椂闂�
         procureDoc: '',
         goods: [],
       },
       goodsItem: {
-        baseCategoryIds: '', // 鍒嗙被缂栧彿鏁扮粍
+        businessFormCode: '', // 鍒嗗彂鍗昳d
+        transBusinessId: '', // 鍒嗗彂鍗昳d
         baseCategoryId: '', // 鍒嗙被缂栧彿
         baseGoodsTemplateId: '', // 鐗╁搧妯$増缂栧彿
         goodsTemplateName: '', // 鐗╁搧妯$増鍚嶇О
         goodsOptions: [], // 鐗╁搧鍒楄〃select
-        modelsOptions: [], //瑙勬牸鍨嬪彿select
         models: [], // 鐗╁搧鍚嶇О
-        modelsIds: [], //瑙勬牸鍨嬪彿
       },
       modelsItem: {
         baseGoodsModelsId: '', // 瑙勬牸鍨嬪彿缂栧彿
@@ -257,26 +285,29 @@
         unit: null, //鍗曚綅
       },
       rules: {
-        warehouseId: [{ required: true, message: '璇烽�夋嫨', trigger: 'change' }],
-        dealTime: [{ required: true, message: '璇烽�夋嫨', trigger: 'change' }],
-        buyType: [{ required: true, message: '璇烽�夋嫨', trigger: 'change' }],
-
-        baseCategoryIds: [{ required: true, message: '璇烽�夋嫨', trigger: 'change' }],
-        baseGoodsTemplateId: [{ validator: checkGoodsTemplateId, trigger: ['blur', 'change'] }],
-        modelsIds: [{ required: true, message: '璇烽�夋嫨', trigger: 'change' }],
-        counts: [{ required: true, message: '璇疯緭鍏�', trigger: 'change' }],
+        departmentId: [{required: true, message: '璇烽�夋嫨閮ㄩ棬', trigger: 'change'}],
+        dealTime: [{required: true, message: '璇烽�夋嫨', trigger: 'change'}],
+        procureDoc: [{required: true, message: '璇蜂笂浼�', trigger: 'change'}],
+        baseCategoryId: [{required: true, message: '璇烽�夋嫨', trigger: 'change'}],
+        baseGoodsTemplateId: [{
+          required: true,
+          message: '璇烽�夋嫨鐗╁搧',
+          trigger: 'change'
+        }],
+        businessFormCode: [{required: true, message: '璇烽�夋嫨鍒嗗彂鍗�', trigger: 'change'}],
+        counts: [{required: true, message: '璇疯緭鍏�', trigger: 'change'}],
+        reason: [{required: true, message: '璇烽�夋嫨', trigger: 'change'}],
       },
 
       uploadSettings: {
         title: '涓婁紶',
         max: 20, // 鏈�澶уぇ灏忥紝鍗曚綅M
         num: 10, // 鏀寔涓婁紶鍥剧墖涓暟
-        accept: '.jpg,.png', // 闄愬埗鏍煎紡
+        accept: '', // 闄愬埗鏍煎紡
         tip: '', // 鎻愮ず 榛樿锛歚鍙兘涓婁紶${this.defaultSettings.num}涓�${this.defaultSettings.accept}鏂囦欢锛屼笖涓嶈秴杩�${this.defaultSettings.max}kb`
         uploadUrl: getUploadUrl(), // 涓婁紶璺緞
         multiple: true, // 鏄惁鏀寔鎵归噺涓婁紶
         disabled: false, // 鏄惁绂佺敤
-        type: 'picture', // text/picture
       },
     };
   },
@@ -288,27 +319,22 @@
   },
   methods: {
     async init() {
-      this.getWarehouseList();
-      this.getgoodsTemplate();
-      // 鑾峰彇鐗╁搧鍒嗙被鍒楄〃
+      await this.getdeptmentList();
       const treeRes = await getTree();
       this.categoryOptions = this.removeEmptyChildren(treeRes);
-      this.formData.departmentName = this.userInfo.sysDeptName;
-      this.formData.createName = this.userInfo.userName;
+      this.getgoodsTemplate();
+      // 鑾峰彇鐗╁搧鍒嗙被鍒楄〃
+      this.formData.departmentId = this.userInfo.sysDeptId;
+      this.formData.operatorName = this.userInfo.userName;
+      this.loading = false
     },
 
-    // 鑾峰彇閫�鍥炰粨搴撳垪琛�
-    getWarehouseList() {
-      selectTenantWarehouse({ agencyId: this.userInfo.tenantId })
+    // 鑾峰彇閮ㄩ棬鍒楄〃
+    async getdeptmentList() {
+      await departmentListAll({tenantId: this.userInfo.tenantId})
         .then((res) => {
-          this.warehouseOptions = res;
-          if (res.length) {
-            this.formData.goods.push(JSON.parse(JSON.stringify(this.goodsItem)));
-          }
-          if (this.warehouseOptions.length && !this.formData.warehouseId) {
-            // 榛樿閫変腑绗竴涓粨搴�
-            this.formData.warehouseId = this.warehouseOptions[0].id;
-          }
+          this.departmentOptions = res;
+          this.formData.goods.push(JSON.parse(JSON.stringify(this.goodsItem)));
         })
         .catch((err) => {
           console.log('err', err);
@@ -328,7 +354,7 @@
 
     // 鑾峰彇鐗╁搧鍚嶇О鍒楄〃
     getgoodsTemplate(id, index) {
-      goodsTemplate({ categoryId: id || '' }).then((res) => {
+      goodsTemplate({categoryId: id || ''}).then((res) => {
         if (index || index == 0) {
           this.$set(this.formData.goods[index], 'goodsOptions', res);
         } else {
@@ -360,24 +386,36 @@
       this.formData.goods[index].goodsOptions = [];
       this.formData.goods[index].baseGoodsTemplateId = '';
       this.formData.goods[index].goodsTemplateName = '';
-      this.formData.goods[index].modelsOptions = [];
-      this.formData.goods[index].modelsIds = [];
       this.formData.goods[index].models = [];
-
-      this.formData.goods[index].baseCategoryId = e[e.length - 1];
       // 鏍规嵁閫変腑鍒嗙被璇锋眰鐗╁搧鍚嶇О鍒楄〃
-      this.getgoodsTemplate(e[e.length - 1], index);
+      this.getgoodsTemplate(e, index);
     },
 
     // 鐗╁搧鍚嶇О鍒楄〃閫夋嫨
     goodsTemplateChange(e, index) {
-      this.formData.goods[index].modelsOptions = [];
-      this.formData.goods[index].modelsIds = [];
       this.formData.goods[index].models = [];
-
+      this.formData.goods[index].businessFormCode = '';
       this.formData.goods[index].goodsTemplateName = this.getGoodsTemplateName(e);
     },
-
+    showFenFa(index) {
+      this.loading = true
+      getFfOrderByGoodsIdAndDept({
+        departmentId: this.formData.departmentId,
+        baseGoodsTemplateId: this.formData.goods[index].baseGoodsTemplateId
+      }).then(res => {
+        this.loading = false
+        if (!res || res.length === 0) {
+          this.$message.error('鏈煡璇㈠埌闇�瑕侀��鍥炵殑鍒嗗彂鍗�');
+          return
+        }
+        this.fenfaSetting.show = true
+        this.fenfaSetting.baseGoodsTemplateId = this.formData.goods[index].baseGoodsTemplateId
+        this.fenfaSetting.goodsIdx = index
+        this.fenfaData = res
+      }).catch((err) => {
+        this.loading = false
+      });
+    },
     // 涓婁紶
     uploadChange() {
       let arr = this.$refs.uploadRef.fileList;
@@ -393,38 +431,74 @@
     removeGoods(index) {
       this.formData.goods.splice(index, 1);
     },
-
-    // 閫�鍥炴暟閲忔牎楠�
-    countsChange(e, goodsIndex, index) {
-      const curItem = this.formData.goods[goodsIndex].models[index];
-      const worehouseCount = curItem.worehouseCount;
-      if (e == 0) {
-        this.$message.warning('鏁伴涓嶈兘涓�0');
-        curItem.counts = null;
-      }
-      if (e > worehouseCount) {
-        this.$message.warning('鏁伴瓒呰繃鐜版湁搴撳瓨');
-        curItem.counts = worehouseCount > 0 ? worehouseCount : null;
-      }
+    handleCurrentChange(e) {
+      this.curFenfa = e
     },
+    handleConfirm() {
+      if (!this.curFenfa) {
+        this.$message.error('璇烽�夋嫨鍒嗗彂鍗�');
+        return
+      }
+      let bIdx = this.formData.goods.findIndex((v) => v.businessFormCode == this.curFenfa.businessFormCode);
+      let gIdx = this.formData.goods.findIndex((v) => v.baseGoodsTemplateId == this.fenfaSetting.baseGoodsTemplateId);
 
-    handleConfirm(){
-
+      if (gIdx !== -1 && gIdx !== this.fenfaSetting.goodsIdx && bIdx !== -1 && bIdx !== this.fenfaSetting.goodsIdx) {
+        this.$message.error('鍚屼竴涓墿鍝佷笉鑳介�夋嫨鐩稿悓鐨勫垎鍙戝崟');
+        return;
+      }
+      getGoodsUseInfoByFfOrderAndGoodId({
+        transBusinessId: this.curFenfa.transBusinessId,
+        baseGoodsTemplateId: this.fenfaSetting.baseGoodsTemplateId
+      }).then(res => {
+        if (res) {
+          let arr = []
+          for (let resKey in res) {
+            const item = res[resKey]
+            item.map(t => {
+              t.counts = null
+            })
+            arr.push(item)
+          }
+          this.formData.goods[this.fenfaSetting.goodsIdx].models = arr
+          this.formData.goods[this.fenfaSetting.goodsIdx].businessFormCode = this.curFenfa.businessFormCode
+          this.formData.goods[this.fenfaSetting.goodsIdx].transBusinessId = this.curFenfa.transBusinessId
+        }
+        this.fenfaSetting.show = false
+      })
     },
-
     // 鎻愪氦
     handleSubmit() {
       this.$refs['ruleForm'].validate((valid) => {
         if (valid) {
-          console.log('this.formData', this.formData);
-          outputAdd(this.formData)
+          let params = JSON.parse(JSON.stringify(this.formData))
+          params.goods.map(g => {
+            delete g.goodsOptions
+            let arr = []
+            g.models.map(m => {
+              m.map(item=>{
+                if(item.counts&&item.counts>0){
+                  arr.push(item)
+                }
+              })
+            })
+            g.models = arr
+          })
+          params.goods = params.goods.filter(g=>g.models.length>0)
+          if(params.goods.length===0){
+            this.$message.error('璇疯嚦灏戝~鍐欎竴涓��鍥炵墿鍝�');
+            return;
+          }
+          if (this.loading) return
+          this.loading = true
+          returnAdd(params)
             .then((res) => {
+              this.loading = false
               this.$message.success('淇濆瓨鎴愬姛锛�');
               this.close();
               this.$emit('search');
             })
             .catch((err) => {
-              console.log('edit err', err);
+              this.loading = false
               this.$message.error('淇濆瓨澶辫触');
             });
         } else {
@@ -435,8 +509,8 @@
 
     close() {
       this.formData = {
-        warehouseId: '', // 閫�鍥炰粨搴搃d
-        dealTime: '', // 閫�鍥炴椂闂�
+        warehouseId: '', // 鎶ュ簾浠撳簱id
+        dealTime: '', // 鎶ュ簾鏃堕棿
         goods: [],
       };
       this.$emit('close');
@@ -446,6 +520,7 @@
 </script>
 <style scoped lang="scss">
 @import url(../../../../styles/store.scss);
+
 .cursor-p {
   ::v-deep {
     .el-input__inner {
@@ -453,6 +528,7 @@
     }
   }
 }
+
 .card3 {
   border-radius: 2px;
   background: #ffffff;

--
Gitblit v1.9.1