From 6b0e09a9bda94bc14983b7d2749f275679f9d1a7 Mon Sep 17 00:00:00 2001
From: yangfeng <wanwan926_4@163.com>
Date: 星期四, 21 三月 2024 16:40:45 +0800
Subject: [PATCH] 新建调拨、现金出入库产品信息列表选择操作修改、源位置改为调出位置、新建调拨的仓库位置改为调入位置

---
 src/views/overview/AddOverviewDialog.vue            |  313 +++++++++++++++-----------
 src/components/makepager/CommonFormTableView.vue    |  170 +++++++++++---
 src/views/other/commonDialog/SelectCommonDialog.vue |  212 +++++++++++------
 3 files changed, 446 insertions(+), 249 deletions(-)

diff --git a/src/components/makepager/CommonFormTableView.vue b/src/components/makepager/CommonFormTableView.vue
index 2a8bd19..aae5424 100644
--- a/src/components/makepager/CommonFormTableView.vue
+++ b/src/components/makepager/CommonFormTableView.vue
@@ -55,7 +55,7 @@
                   ></el-input>
                 </div>
               </el-form-item>
-              <el-form-item
+              <!-- <el-form-item
                 v-else-if="item.productName"
                 label=" "
                 :prop="'tableData.' + scope.$index + '.' + item.prop"
@@ -69,6 +69,44 @@
                     @select-user="selProductNameClick"
                   >
                   </SimpleSearchInput>
+                </div>
+              </el-form-item> -->
+              <el-form-item
+                v-else-if="item.productName"
+                label=" "
+                :prop="'tableData.' + scope.$index + '.' + item.prop"
+              >
+                <div class="custom-name">
+                  <el-autocomplete
+                    v-model="scope.row[item.prop]"
+                    :fetch-suggestions="querySearchAsync"
+                    value-key="name"
+                    :disabled="!isOperate"
+                    size="mini"
+                    @select="
+                      (val) => {
+                        handleSelectClient(val, item.prop, scope.row)
+                      }
+                    "
+                  ></el-autocomplete>
+
+                  <div
+                    v-if="scope.row[item.prop] && scope.row[item.prop].length > 0 && isOperate"
+                    class="common-select-btn"
+                    @click="handleEditClient(scope, item.prop)"
+                  >
+                    <i class="el-icon-edit" title="缂栬緫"></i>
+                  </div>
+                  <div
+                    v-if="scope.row[item.prop] && scope.row[item.prop].length > 0 && isOperate"
+                    class="common-select-btn"
+                    @click="clearupClient(scope)"
+                  >
+                    <i class="el-icon-remove-outline" title="娓呴櫎"></i>
+                  </div>
+                  <div class="common-select-btn" v-else @click="selClientClick(scope, item.prop)">
+                    <i class="el-icon-circle-plus-outline" title="閫夋嫨"></i>
+                  </div>
                 </div>
               </el-form-item>
               <el-form-item
@@ -118,7 +156,7 @@
                     :controls="false"
                     size="mini"
                     style="width: 100%; margin-right: 5px"
-                    :min="item.prop==='minInventory'?0:1"
+                    :min="item.prop === 'minInventory' ? 0 : 1"
                     @change="
                       (val) => {
                         commonInputChange(val, item.prop, scope.row)
@@ -185,7 +223,7 @@
                     style="width: 80%"
                     @change="
                       (val) => {
-                        selLocationClick(val, item.prop,scope.row)
+                        selLocationClick(val, item.prop, scope.row)
                       }
                     "
                   >
@@ -286,7 +324,11 @@
                 </div>
               </el-form-item>
               <!-- 浠� -->
-              <el-form-item v-else-if="item.formLocation" label=" " :prop="'tableData.' + scope.$index + '.' + item.prop">
+              <el-form-item
+                v-else-if="item.formLocation"
+                label=" "
+                :prop="'tableData.' + scope.$index + '.' + item.prop"
+              >
                 <div class="custom-name">
                   <span v-if="scope.row.isEdit || scope.row.editable">{{ scope.row.formLocation }}</span>
                   <el-autocomplete
@@ -388,17 +430,19 @@
         <slot name="tableButton" />
       </el-table>
     </el-form>
-    <div v-if="!detailEnter && !isinventory  && !isReorder" style="margin: 10px">
-      <el-button size="small" type="primary" @click="add">娣诲姞鏄庣粏琛�</el-button>
-      <!-- <el-button size="small" type="primary" @click="empty">娓呯┖</el-button> -->
+    <div v-if="!detailEnter && !isinventory && !isReorder" style="margin: 10px">
+      <el-button size="small" type="primary" @click="add">鏂板</el-button>
+      <el-button size="small" type="primary" @click="empty">娓呯┖</el-button>
     </div>
     <!-- 浜у搧鍚嶇О -->
-    <!-- <SelectCommonDialog
+    <SelectCommonDialog
       v-if="editSelCommonConfig.editVisible"
       :edit-common-config="editSelCommonConfig"
-      :sign="sign"
+      :selectBoxList="tableList.tableData"
+      :quotationNumber="quotationNumber"
       @selClient="selClient"
-    /> -->
+      @getSelectArray="getSelectArray"
+    />
   </div>
 </template>
 
@@ -410,10 +454,10 @@
 import { getProductCategoryList } from "@/api/product/productCategory"
 import SimpleSearchInput from "@/components/makepager/SimpleSearchInput"
 import { getAmountAndPrediction } from "@/api/product/reorderRules"
-// import SelectCommonDialog from "@/views/other/commonDialog/SelectCommonDialog"
+import SelectCommonDialog from "@/views/other/commonDialog/SelectCommonDialog"
 export default {
   name: "CommmonFormTableView",
-  components: { SimpleSearchInput },
+  components: { SimpleSearchInput, SelectCommonDialog },
   props: {
     detailEnter: {
       type: Boolean,
@@ -448,6 +492,21 @@
     isReorder: {
       type: Boolean,
       default: false
+    },
+    // 鏍规嵁鎶ヤ环鍗曟煡璇骇鍝�
+    quotationNumber: {
+      type: [String, Number],
+      default: ""
+    },
+    // 鍒楄〃鏂板鏄惁澶氶��
+    addTypeIdMultiple: {
+      type: Boolean,
+      default: false
+    },
+    // 鏄惁鍙互鎿嶄綔 娣诲姞绛�
+    isOperate: {
+      type: Boolean,
+      default: true
     }
   },
   data() {
@@ -457,6 +516,7 @@
       tableList: [],
       editSelCommonConfig: {
         editVisible: false,
+        isSelectBox: false,
         title: "",
         infomation: {}
       },
@@ -478,8 +538,8 @@
       productName: "",
       productId: "",
       initialPosition: "",
-      formLocationList:[],
-      toLocationList:[],
+      formLocationList: [],
+      toLocationList: []
     }
   },
   created() {
@@ -549,7 +609,7 @@
         restaurants = this.productNameOptions
       } else if (value === "productType") {
         restaurants = this.productTypeNameOptions
-      }else if(value==="formLocation"){
+      } else if (value === "formLocation") {
         restaurants = this.selLocationOptions
       }
       var results = queryString ? restaurants.filter(this.createStateFilter(queryString, value)) : restaurants
@@ -563,6 +623,22 @@
       return (state) => {
         return state.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0
       }
+    },
+    // 鏂板
+    selClientClick(scope, prop) {
+      console.log(scope, prop)
+      this.productIndex = scope.$index
+      this.editSelCommonConfig.title = "浜у搧鍚嶇О"
+      this.editSelCommonConfig.isSelectBox = true
+      this.editSelCommonConfig.editVisible = true
+    },
+    // 缂栬緫
+    handleEditClient(scope, prop) {
+      console.log(scope, prop)
+      this.productIndex = scope.$index
+      this.editSelCommonConfig.title = "浜у搧鍚嶇О"
+      this.editSelCommonConfig.isSelectBox = false
+      this.editSelCommonConfig.editVisible = true
     },
     // 娓呴櫎閫変腑浜у搧
     setValueNull(val) {
@@ -642,8 +718,8 @@
       })
     },
     // 璁剧疆瀛愪綅缃�/婧愪綅缃�
-    async setLocationList(jointName,tag) {
-      if(tag==="fromLocation"){
+    async setLocationList(jointName, tag) {
+      if (tag === "fromLocation") {
         await getLocationList({
           jointName: jointName,
           page: 1,
@@ -653,7 +729,7 @@
             this.selSonLocationOptions = res.data
           }
         })
-      }else if(tag==="toLocation"){
+      } else if (tag === "toLocation") {
         await getLocationList({
           jointName: jointName,
           page: 1,
@@ -663,7 +739,7 @@
             this.selToLocationOptions = res.data
           }
         })
-      }else{
+      } else {
         await getLocationList({
           jointName: jointName,
           page: 1,
@@ -704,7 +780,7 @@
         let selIndex = 0
         this.tableList.tableData.map((ite, index) => {
           // ite.id 鏄笂鏋惰鍒欑殑, ite.productId鏄簱瀛樿皟鏁寸殑
-          if (ite.id === row.id&&ite.id!=undefined&&row.id!=undefined) {
+          if (ite.id === row.id && ite.id != undefined && row.id != undefined) {
             selIndex = index
             ite.productId = item.id
             ite.productName = item.name
@@ -712,7 +788,7 @@
             ite.productCategory = item.categoryName
             ite.amount = item.amount
             ite.unit = item.unit
-          }else if(ite.productId===row.productId){
+          } else if (ite.productId === row.productId) {
             selIndex = index
             ite.productId = item.id
             ite.productName = item.name
@@ -879,7 +955,14 @@
     },
     // 鏂板
     add() {
-      this.$emit("addProductClick")
+      if (this.addTypeIdMultiple) {
+        this.productIndex = this.tableList.tableData.length
+        this.editSelCommonConfig.title = "浜у搧鍚嶇О"
+        this.editSelCommonConfig.isSelectBox = true
+        this.editSelCommonConfig.editVisible = true
+      } else {
+        this.$emit("addProductClick")
+      }
     },
     commonInputChange(val, prop, row) {
       this.$emit("inputContent", val, prop, row)
@@ -889,24 +972,17 @@
       this.$emit("emptyProductClick")
     },
     // 娓呴櫎宸查�夋嫨鐢ㄦ埛
-    clearupClient(row, scope) {
+    clearupClient(scope) {
       this.productIndex = scope.$index
       this.tableList.tableData.map((ite, index) => {
-        if (scope.$index && scope.$index >= 0) {
-          if (index === this.productIndex) {
-            ite.name = ""
-            ite.amount = 1
-            ite.number = ""
-            ite.purchasePrice = 0
-            ite.unit = ""
-            ite.deliveryTime = 0
-            ite.shippingDuration = 0
-          }
-        } else {
+        if (index === this.productIndex) {
+          ite.productName = ""
+          ite.id = ""
           ite.name = ""
           ite.amount = 1
           ite.number = ""
-          ite.purchasePrice = 0
+          ite.model = ""
+          ite.specs = ""
           ite.unit = ""
           ite.deliveryTime = 0
           ite.shippingDuration = 0
@@ -935,7 +1011,29 @@
     setFormItem(val) {
       console.log(val)
     },
-    commoInput() {}
+    commoInput() {},
+    selClient(item) {
+      let list = this.tableList.tableData.map((item) => item.number)
+      if (list.findIndex((v) => v == item.number) == -1) {
+        this.isRecalculate = true
+        // this.editConfig.infomation.client_name = row.name
+        this.tableList.tableData.map((ite, index) => {
+          if (index === this.productIndex) {
+            ite.name = item.name
+            ite.amount = item.amount || 1
+            ite.number = item.number
+            ite.price = item.price
+            ite.total = item.amount ? item.amount * item.price : 1 * item.price
+            ite.unit = item.unit
+          }
+        })
+      } else {
+        this.$message.error("涓嶈兘閫夋嫨閲嶅鐨勪骇鍝侊紝 璇烽噸鏂伴�夋嫨")
+      }
+    },
+    getSelectArray(val) {
+      this.$emit("getSelectArray", val, this.productIndex)
+    }
   }
 }
 </script>
diff --git a/src/views/other/commonDialog/SelectCommonDialog.vue b/src/views/other/commonDialog/SelectCommonDialog.vue
index 2b0b915..2385fe8 100644
--- a/src/views/other/commonDialog/SelectCommonDialog.vue
+++ b/src/views/other/commonDialog/SelectCommonDialog.vue
@@ -1,80 +1,93 @@
 <template>
   <div class="edit-selClient-box">
     <el-dialog
-      :title="editCommonConfig.title"
       :visible.sync="editConfig.editVisible"
       :width="dialogWidth"
       :before-close="handleClose"
       :append-to-body="true"
       :close-on-click-modal="false"
     >
+      <div slot="title" class="tac drawerHeader">{{ editCommonConfig.title }}</div>
+
       <div class="bg-view">
         <div class="query-bg">
-          <!-- <el-input placeholder="璇疯緭鍏ュ唴瀹�" v-model="queryInput" size="mini" class="input-with-select">
-            <el-select v-model="select" slot="prepend" placeholder="璇烽�夋嫨">
-              <el-option v-for="item in commonOptions" :key="item.id" :label="item.name" :value="item.name">
-              </el-option>
-            </el-select>
-          </el-input> -->
-          <SearchCommonView
-            ref="searchCommonView"
-            :search-options="searchOptions"
-            @searchClick="searchClick"
-            @resetClick="resetClick"
-            :search-sel="searchSel"
-          />
-          <div class="btn">
-            <!-- <el-button type="primary" size="mini" disabled>璁剧疆瀛楁</el-button>
-            <el-button type="primary" size="mini" disabled>蹇�熷垱寤�</el-button> -->
-          </div>
+          <el-input
+            v-model="bomParams.keyword"
+            placeholder="鎼滅储浜у搧鍚嶇О锛岀紪鐮佺瓑鍏抽敭璇�"
+            style="width: 60%; margin-right: 10px"
+          ></el-input>
+          <el-button type="primary" @click="searchClick">鏌ヨ</el-button>
         </div>
-        <TableCommonView ref="tableListRef" :table-list="tableList" :select-box="false" @selCommonClick="selNameClick">
+        <TableCommonView
+          class="bg-list"
+          ref="tableListRef"
+          :loading="loading"
+          :table-list="tableList"
+          :select-box="editCommonConfig.isSelectBox"
+          @selCommonClick="selNameClick"
+          @selTableCol="selTableCol"
+          @getSelectArray="getSelectArray"
+        >
         </TableCommonView>
         <div slot="footer" class="dialog-footer">
-          <div class="remark">璇存槑锛氭敮鎸佸瀛楁妯$硦鏌ヨ锛屼粎鏄剧ず绗﹀悎鏉′欢鐨勫墠5鏉℃暟鎹�</div>
+          <div class="btn-pager">
+            <PagerView
+              class="page"
+              :pager-options="pagerOptions"
+              :pagerCount="pagerCount"
+              layout="total, sizes, prev, pager, next"
+              v-on="pagerEvents"
+            />
+          </div>
         </div>
+      </div>
+      <div slot="footer" class="dialog-footer" v-if="editCommonConfig.isSelectBox">
+        <el-button type="primary" @click="saveClick()">纭畾</el-button>
+        <el-button @click="editConfig.editVisible = false">鍙栨秷</el-button>
       </div>
     </el-dialog>
   </div>
 </template>
 
 <script>
-// import { getProductListFromGrpc,getProductList } from "@/api/productManage/product"
+import { getProductList } from "@/api/product/product"
+import pageMixin from "@/components/makepager/pager/mixin/pageMixin"
 export default {
   name: "EditSelCommonDialog",
+  mixins: [pageMixin],
   props: {
     editCommonConfig: {
       type: Object,
       default: () => {
         return {
           editVisible: false,
+          isSelectBox: false,
           title: "",
+          clientId: 0,
+          isRequest: true,
+          client_name: "",
           tableInfomation: []
         }
       }
-    },
-    sign: {
-      type: String,
-      default: ""
     }
   },
   components: {},
   computed: {},
   data() {
     return {
-      dialogWidth: "50%",
+      dialogWidth: "42rem",
+      pagerCount: 5,
       editConfig: this.editCommonConfig,
-      queryInput: "",
-      select: "鍏ㄩ儴瀛楁",
-      tableData: [],
-      searchSelOptions: [],
       loading: false,
       tableList: {},
-      searchOptions: [],
-      search_map: {},
-      searchSel: {},
-      keyword: "",
-      keywordType: ""
+      showcolTop: ["浜у搧瑙勬牸", "浜у搧鍨嬪彿"],
+      selectArray: [],
+      bomParams: {
+        keyword: "",
+        page: 1,
+        pageSize: 10,
+        types: ["鍘熸潗鏂�", "鍗婃垚鍝�", "鎴愬搧"]
+      }
     }
   },
   created() {
@@ -83,22 +96,66 @@
   },
   methods: {
     setTable() {
-      if (this.editConfig.title === "浜у搧鍚嶇О") {
-        this.tableList = {
-          tableInfomation: [],
-          tableColumn: [
-            { label: "浜у搧鍚嶇О", prop: "name", isClick: true },
-            { label: "浜у搧缂栧彿", prop: "number" }
-          ]
-        }
-        this.searchSel = { value: "name", label: "浜у搧鍚嶇О" }
+      this.tableList = {
+        tableInfomation: [],
+        selectIndex: false,
+        selectBox: this.editCommonConfig.isSelectBox,
+        showcol: this.showcolTop,
+        allcol: [],
+        tableColumn: this.setTopTableColumn(this.showcolTop)
       }
-      this.searchOptions = []
+      let allcol = []
       for (let i = 0; i < this.tableList.tableColumn.length; i++) {
-        const label = this.tableList.tableColumn[i].label
-        const value = this.tableList.tableColumn[i].prop
-        this.searchOptions.push({ value: value, label: label })
+        if (!this.tableList.tableColumn[i].default) {
+          const label = this.tableList.tableColumn[i].label
+          allcol.push(label)
+        }
       }
+      this.tableList.allcol = allcol
+    },
+    setTopTableColumn(showcol) {
+      let tableColumn = [
+        {
+          label: "浜у搧鍚嶇О",
+          prop: "name",
+          isShowColumn: true,
+          default: true,
+          isClick: true
+        },
+        {
+          label: "浜у搧缂栫爜",
+          prop: "id",
+          min: 110,
+          isShowColumn: true,
+          default: true
+        },
+        {
+          label: "浜у搧瑙勬牸",
+          prop: "specs",
+          isShowColumn: showcol.includes("浜у搧瑙勬牸"),
+          default: false
+        },
+        {
+          label: "浜у搧鍨嬪彿",
+          prop: "type",
+          width: 90,
+          isShowColumn: showcol.includes("浜у搧鍨嬪彿"),
+          default: false
+        }
+      ]
+      return tableColumn
+    },
+    selTableCol(val) {
+      this.showcolTop = val
+      this.tableList.tableColumn = this.setTopTableColumn(val)
+    },
+    // 鍒楄〃澶氶��
+    getSelectArray(val) {
+      this.selectArray = val
+    },
+    saveClick() {
+      this.$emit("getSelectArray", this.selectArray)
+      this.editConfig.editVisible = false
     },
     // 璇锋眰鏁版嵁
     async getData() {
@@ -109,21 +166,15 @@
     },
     // 浜у搧鍚嶇О
     async getProductList() {
-      // let fn = this.sign == "purchase" ? getProductList : getProductListFromGrpc;
-      let fn
-      await fn({
-        page: 1,
-        pageSize: 100
-      }).then((res) => {
+      this.bomParams.page = this.pagerOptions.currPage ? this.pagerOptions.currPage : 1
+      this.bomParams.pageSize = this.pagerOptions.pageSize ? this.pagerOptions.pageSize : 15
+      let params = JSON.parse(JSON.stringify(this.bomParams))
+      await getProductList(params).then((res) => {
         console.log(res.data)
-        if (res.data.code === 200) {
-          if (res.data.data.list && res.data.data.list.length > 0) {
-            const list = res.data.data.list.map((item) => {
-              return {
-                ...item
-              }
-            })
-            this.tableList.tableInfomation = list.slice(0, 5) || []
+        if (res.code === 200) {
+          if (res.data) {
+            this.tableList.tableInfomation = res.data || []
+            this.pagerOptions.totalCount = res.total ? res.total : 0
           } else {
             this.tableList.tableInfomation = []
           }
@@ -135,25 +186,22 @@
       this.editConfig.editVisible = false
     },
     selNameClick(row) {
+      if (this.editCommonConfig.isSelectBox) {
+        return true
+      }
       this.editConfig.editVisible = false
       if (this.editConfig.title === "浜у搧鍚嶇О") {
         this.$emit("selClient", row, "productName")
       }
     },
     // 鎼滅储
-    searchClick(val, content) {
-      console.log(val, content)
-      this.search_map = {
-        [val.value]: content
-      }
-      this.keyword = content
-      this.keywordType = val.label
+    searchClick() {
+      this.bomParams.page = 1
+      this.total = 0
       this.getData()
     },
     resetClick() {
-      this.search_map = {}
       this.keyword = ""
-      this.keywordType = ""
       this.getData()
     }
   }
@@ -163,18 +211,18 @@
 <!-- Add "scoped" attribute to limit CSS to this component only -->
 <style lang="scss" scoped>
 .bg-view {
-  margin: 10px;
+  .bg-list {
+    height: 370px;
+  }
   .query-bg {
-    margin-left: -20px;
     margin-bottom: 10px;
-    display: flex;
-    justify-content: space-between;
     .el-input {
       width: 310px;
       .el-select {
         width: 100px;
       }
     }
+
     .btn {
       float: right;
     }
@@ -185,13 +233,17 @@
   cursor: pointer;
 }
 .dialog-footer {
-  height: 40px;
-  line-height: 40px;
-  color: red;
+  .btn-pager {
+    display: flex;
+    margin-top: 0px;
+    .page {
+      margin-left: auto;
+    }
+  }
 }
 ::v-deep {
-  .input-with-select .el-input-group__prepend {
-    background-color: #fff;
+  .el-dialog__body {
+    padding-bottom: 10px !important;
   }
 }
 </style>
diff --git a/src/views/overview/AddOverviewDialog.vue b/src/views/overview/AddOverviewDialog.vue
index 446e496..d65496a 100644
--- a/src/views/overview/AddOverviewDialog.vue
+++ b/src/views/overview/AddOverviewDialog.vue
@@ -202,8 +202,8 @@
                   ></el-input>
                 </el-form-item>
               </el-col>
-              <el-col :span="12" >
-                <el-form-item :label="workType === 1?'浠撳簱浣嶇疆':'婧愪綅缃�'" prop="location">
+              <el-col :span="12">
+                <el-form-item :label="workType === 1 ? '浠撳簱浣嶇疆' : '璋冨嚭浣嶇疆'" prop="location">
                   <el-select
                     @change="rootLocationChange"
                     v-model="editConfig.infomation.location"
@@ -216,7 +216,7 @@
                       v-for="item in formLocationOptions"
                       :key="item.id"
                       :label="item.jointName"
-                      :value="{label:item.jointName,value:item.id}"
+                      :value="{ label: item.jointName, value: item.id }"
                     >
                     </el-option>
                   </el-select>
@@ -243,7 +243,7 @@
                 </el-form-item>
               </el-col>
               <el-col :span="12" v-if="workType === 3">
-                <el-form-item  label="浠撳簱浣嶇疆" prop="toLocation">
+                <el-form-item label="璋冨叆浣嶇疆" prop="toLocation">
                   <el-select
                     @change="toLocationChange"
                     v-model="editConfig.infomation.toLocation"
@@ -256,7 +256,7 @@
                       v-for="item in toLocationOptions"
                       :key="item.id"
                       :label="item.jointName"
-                      :value="{label:item.jointName,value:item.id}"
+                      :value="{ label: item.jointName, value: item.id }"
                     >
                     </el-option>
                   </el-select>
@@ -301,17 +301,22 @@
               <CommonFormTableView
                 ref="tableView"
                 :islistingrules="true"
+                :addTypeIdMultiple="true"
                 :product-table-list="productTableList"
                 :detail-enter="!showFooter"
                 @inputContent="inputContent"
                 @addProductClick="addProductClick('鎿嶄綔')"
+                @getSelectArray="getSelectArray"
+                @emptyProductClick="emptyProductClick"
+                @clearupProduct="clearupProduct"
               >
                 <template v-if="showFooter" slot="tableButton">
                   <el-table-column label="鎿嶄綔" width="60" fixed="right" align="center">
                     <template slot-scope="scope">
-                      <div @click="handleDelClick(scope, '鎿嶄綔')">
+                      <!-- <div @click="handleDelClick(scope, '鎿嶄綔')">
                         <i class="el-icon-delete"></i>
-                      </div>
+                      </div> -->
+                      <el-button type="text" size="small" @click.stop="handleDelClick(scope, '鎿嶄綔')">鍒犻櫎</el-button>
                     </template>
                   </el-table-column>
                 </template>
@@ -469,9 +474,9 @@
     },
     workType: {
       type: Number,
-      default: function() {  
-        // return JSON.parse(window.sessionStorage.getItem('paramsData')).workType|| 1; 
-        return 1; 
+      default: function () {
+        // return JSON.parse(window.sessionStorage.getItem('paramsData')).workType|| 1;
+        return 1
       }
     },
     addName: {
@@ -492,8 +497,8 @@
       rules: {
         sourceNumber: [{ required: true, message: "璇疯緭鍏ユ潵婧愬崟鎹�", trigger: "blur" }],
         operationDate: [{ required: true, message: "璇烽�夋嫨鏃ユ湡", trigger: "change" }],
-        toLocation: [{ required: true, message: "璇烽�夋嫨浠撳簱浣嶇疆", trigger: "change" }],
-        location: [{ required: true, message: "璇烽�夋嫨婧愪綅缃�", trigger: "change" }],
+        toLocation: [{ required: true, message: "璇烽�夋嫨浣嶇疆", trigger: "change" }],
+        location: [{ required: true, message: "璇烽�夋嫨璋冨嚭浣嶇疆", trigger: "change" }],
         operationTypeId: [{ required: true, message: "璇烽�夋嫨鍏ュ簱绫诲瀷", trigger: "change" }],
         number: [{ required: true, validator: this.validateCheckCode, trigger: ["change", "blur"] }]
       },
@@ -511,12 +516,12 @@
       supplierOptions: [], //渚涘簲鍟�
       clientOptions: [], //瀹㈡埛
       memberOptions: [{ id: 1, name: "绠$悊鍛�" }],
-      formLocationOptions:[],// 婧愪綅缃�
+      formLocationOptions: [], // 璋冨嚭浣嶇疆
       toLocationOptions: [], // 浠撳簱浣嶇疆
       showButton: true,
       activeName: "first",
       productTableList: {},
-      tableData:[],
+      tableData: [],
       countId: 0,
       isNoProduct: true, // 娣诲姞鏄庣粏琛屾椂鏄惁鏈変骇鍝佹湭閫夋嫨
       showEdit: false, // 鏄惁鏄剧ず缂栬緫鎸夐挳
@@ -564,14 +569,13 @@
     }
     this.getLogisticCompanyList()
     this.formInfo()
-    if(this.editConfig.title==="鏌ョ湅"||this.editConfig.title==="缂栬緫"){
+    if (this.editConfig.title === "鏌ョ湅" || this.editConfig.title === "缂栬緫") {
       setTimeout(() => {
         this.$refs.tableView.setLocationList(this.editConfig.infomation.location.label)
-      }, 100);
+      }, 100)
     }
   },
-  mounted(){
-  },
+  mounted() {},
   methods: {
     formInfo() {
       this.objCode.type = this.workType === 1 ? "鍏ュ簱缂栫爜" : this.workType === 2 ? "鍑哄簱缂栫爜" : "璋冩嫧缂栫爜"
@@ -624,7 +628,7 @@
         })
       }
     },
-    // 鑾峰彇婧愪綅缃�/浠撳簱浣嶇疆鍒楄〃
+    // 鑾峰彇璋冨嚭浣嶇疆/浠撳簱浣嶇疆鍒楄〃
     async getLocationList() {
       await getLocationList({
         keyWord: "",
@@ -785,46 +789,46 @@
             //   })
             // }
             // 浜у搧鍒楄〃瑙f瀯
-            if(this.editConfig.title === "缂栬緫"||this.editConfig.title === "鏌ョ湅"){
-              let arr=[]
-              if(this.workType===1){
-                params.details.map((item)=>{
+            if (this.editConfig.title === "缂栬緫" || this.editConfig.title === "鏌ョ湅") {
+              let arr = []
+              if (this.workType === 1) {
+                params.details.map((item) => {
                   arr.push({
-                    operationId:item.operationId,
-                    amount:item.amount,
-                    productId:item.productId
+                    operationId: item.operationId,
+                    amount: item.amount,
+                    productId: item.productId
                   })
                 })
-                params.details=arr
-              }else if(this.workType===2){
-                params.details.map((item)=>{
-                  if(item.fromLocationId.value){
+                params.details = arr
+              } else if (this.workType === 2) {
+                params.details.map((item) => {
+                  if (item.fromLocationId.value) {
                     arr.push({
-                      operationId:item.operationId,
-                      amount:item.amount,
-                      fromLocationId:item.fromLocationId.value,
-                      productId:item.productId,
+                      operationId: item.operationId,
+                      amount: item.amount,
+                      fromLocationId: item.fromLocationId.value,
+                      productId: item.productId
                     })
-                  }else{
+                  } else {
                     arr.push({
-                      operationId:item.operationId,
-                      amount:item.amount,
-                      fromLocationId:item.fromLocation.id,
-                      productId:item.productId,
+                      operationId: item.operationId,
+                      amount: item.amount,
+                      fromLocationId: item.fromLocation.id,
+                      productId: item.productId
                     })
                   }
                 })
-                params.details=arr
-              }else if(this.workType===3){
-                console.log(params.details,"鐪嬬湅")
-                params.details.map((item)=>{
+                params.details = arr
+              } else if (this.workType === 3) {
+                console.log(params.details, "鐪嬬湅")
+                params.details.map((item) => {
                   arr.push({
-                      operationId:item.operationId,
-                      amount:item.amount,
-                      fromLocationId:item.fromLocationId.value?item.fromLocationId.value:item.fromLocation.id,
-                      toLocationId:item.toLocationId.value?item.toLocationId.value:item.toLocation.id,
-                      productId:item.productId,
-                    })
+                    operationId: item.operationId,
+                    amount: item.amount,
+                    fromLocationId: item.fromLocationId.value ? item.fromLocationId.value : item.fromLocation.id,
+                    toLocationId: item.toLocationId.value ? item.toLocationId.value : item.toLocation.id,
+                    productId: item.productId
+                  })
                   // if(item.fromLocationId.value){
                   //   arr.push({
                   //     operationId:item.operationId,
@@ -843,17 +847,17 @@
                   //   })
                   // }
                 })
-                params.details=arr
+                params.details = arr
               }
-            }else if(this.editConfig.title === "鏂板缓"){
-              if(this.workType===2){
-                params.details.map((item)=>{
-                  item.fromLocationId=item.fromLocationId.value
+            } else if (this.editConfig.title === "鏂板缓") {
+              if (this.workType === 2) {
+                params.details.map((item) => {
+                  item.fromLocationId = item.fromLocationId.value
                 })
-              }else if(this.workType===3){
-                params.details.map((item)=>{
-                  item.fromLocationId=item.fromLocationId.value
-                  item.toLocationId=item.toLocationId.value
+              } else if (this.workType === 3) {
+                params.details.map((item) => {
+                  item.fromLocationId = item.fromLocationId.value
+                  item.toLocationId = item.toLocationId.value
                 })
               }
             }
@@ -870,7 +874,7 @@
                   this.$message.success("缂栬緫鎴愬姛")
                 }
                 this.$parent.getData()
-              }else{
+              } else {
                 this.$message.success(res.msg)
               }
             })
@@ -897,8 +901,8 @@
         contacterID = Object.keys(this.contacterObj).length === 0 ? data.contacterID : this.contacterObj.value
         contacterName = Object.keys(this.contacterObj).length === 0 ? data.contacterName : this.contacterObj.label
       }
-      let params={}
-      if(this.workType===1||this.workType===2){
+      let params = {}
+      if (this.workType === 1 || this.workType === 2) {
         params = {
           baseOperationType: data.baseOperationType,
           comment: data.comment || "",
@@ -913,7 +917,7 @@
           operationDate: data.operationDate || "",
           operationTypeId: this.showOperationType ? data.operationTypeId : this.editConfig.operationTypeId,
           operationTypeName: this.receiptType,
-          sourceNumber:data.sourceNumber || "" ,
+          sourceNumber: data.sourceNumber || "",
           status: 3,
           // toLocationId: data.toLocation.value||0,
           waybillNumber: data.waybillNumber || "",
@@ -924,7 +928,7 @@
           receiverName: data.receiverName || "",
           receiverPhone: data.receiverPhone || ""
         }
-      }else if(this.workType===3){
+      } else if (this.workType === 3) {
         params = {
           baseOperationType: data.baseOperationType,
           comment: data.comment || "",
@@ -939,9 +943,9 @@
           operationDate: data.operationDate || "",
           operationTypeId: this.showOperationType ? data.operationTypeId : this.editConfig.operationTypeId,
           operationTypeName: this.receiptType,
-          sourceNumber:data.sourceNumber || "" ,
+          sourceNumber: data.sourceNumber || "",
           status: 3,
-          toLocationId: data.toLocation.value||0,
+          toLocationId: data.toLocation.value || 0,
           waybillNumber: data.waybillNumber || "",
           weight: data.weight || 0,
           logisticWeight: data.logisticWeight || 0,
@@ -983,27 +987,36 @@
         this.tableData = []
       }
       // this.tableData = this.editConfig.title !== "鏂板缓" ? list : []
-      let tableColumnArr=[]
-      if(this.workType===1){
-        tableColumnArr= [
-          { label: "浜у搧", prop: "productName", productName: true, isRequird: true },
-          { label: "鏁伴噺", prop: "amount", inputFloat: true },
-          { label: "璁¢噺鍗曚綅", prop: "unit" }
-        ]
-      }else if(this.workType===2){
+      let tableColumnArr = []
+      if (this.workType === 1) {
         tableColumnArr = [
-          { label: "浜у搧", prop: "productName", productName: true, isRequird: true },
-          { label: "浠�", prop: "fromLocationId", sonLocation: true, isRequird: true },
-          { label: "鏁伴噺", prop: "amount", inputFloat: true },
-          { label: "璁¢噺鍗曚綅", prop: "unit" }
+          { label: "浜у搧鍚嶇О", prop: "productName", productName: true, isRequird: true },
+          { label: "浜у搧缂栫爜", prop: "id" },
+          { label: "璁¢噺鍗曚綅", prop: "unit" },
+          { label: "浜у搧瑙勬牸", prop: "specs" },
+          { label: "浜у搧鍨嬪彿", prop: "model" },
+          { label: "鏁伴噺", prop: "amount", inputFloat: true }
         ]
-      }else if(this.workType===3){
+      } else if (this.workType === 2) {
         tableColumnArr = [
-          { label: "浜у搧", prop: "productName", productName: true, isRequird: true },
-          { label: "浠�", prop: "fromLocationId", sonLocation: true, isRequird: true },
-          { label: "鑷�", prop: "toLocationId", toLocation: true,isRequird: true },
-          { label: "鏁伴噺", prop: "amount", inputFloat: true },
-          { label: "璁¢噺鍗曚綅", prop: "unit" }
+          { label: "浜у搧鍚嶇О", prop: "productName", productName: true, isRequird: true },
+          { label: "浜у搧缂栫爜", prop: "id" },
+          { label: "璁¢噺鍗曚綅", prop: "unit" },
+          { label: "浜у搧瑙勬牸", prop: "specs" },
+          { label: "浜у搧鍨嬪彿", prop: "model" },
+          // { label: "璋冨嚭浣嶇疆", prop: "fromLocationId", sonLocation: true, isRequird: true },
+          { label: "鏁伴噺", prop: "amount", inputFloat: true }
+        ]
+      } else if (this.workType === 3) {
+        tableColumnArr = [
+          { label: "浜у搧鍚嶇О", prop: "productName", productName: true, isRequird: true },
+          { label: "浜у搧缂栫爜", prop: "id" },
+          { label: "璁¢噺鍗曚綅", prop: "unit" },
+          { label: "浜у搧瑙勬牸", prop: "specs" },
+          { label: "浜у搧鍨嬪彿", prop: "model" },
+          { label: "璋冨嚭浣嶇疆", prop: "fromLocationId", sonLocation: true, isRequird: true },
+          { label: "璋冨叆浣嶇疆", prop: "toLocationId", toLocation: true, isRequird: true },
+          { label: "鏁伴噺", prop: "amount", inputFloat: true }
         ]
       }
       this.productTableList = {
@@ -1023,56 +1036,90 @@
     // 鏂板
     addProductClick(value) {
       console.log(value)
-      if (value === "鎿嶄綔") {
-        console.log(this.tableData)
-        for (let i = 0; i < this.tableData.length; i++) {
-          if (this.tableData[i].productName.length === 0) {
-            this.isNoProduct = false
-            break
-          } else {
-            this.isNoProduct = true
-          }
-        }
-        if (this.isNoProduct) {
-          this.countId++
-          this.tableData.push({
-            countId: this.countId,
-            productId: "",
-            amount: 0,
-            unit: "",
-            productName: "",
-          })
-        }
-      } else {
-        console.log(this.detailTableData)
-        for (let i = 0; i < this.detailTableData.length; i++) {
-          if (this.detailTableData[i].name.length === 0) {
-            this.isNoDetail = true
-            break
-          } else {
-            this.isNoDetail = false
-          }
-        }
-        if (!this.isNoDetail) {
-          this.detailId++
-          this.detailTableData.push({
-            detailId: this.detailId,
-            id: 0,
-            amount: 0,
-            desc: "",
-            name: "",
-            number: "",
-            price: 0,
-            total: 0
-          })
-        }
+      // if (value === "鎿嶄綔") {
+      //   console.log(this.tableData)
+      //   for (let i = 0; i < this.tableData.length; i++) {
+      //     if (this.tableData[i].productName.length === 0) {
+      //       this.isNoProduct = false
+      //       break
+      //     } else {
+      //       this.isNoProduct = true
+      //     }
+      //   }
+      //   if (this.isNoProduct) {
+      //     this.countId++
+      //     this.tableData.push({
+      //       countId: this.countId,
+      //       productId: "",
+      //       amount: 0,
+      //       unit: "",
+      //       productName: ""
+      //     })
+      //   }
+      // } else {
+      //   console.log(this.detailTableData)
+      //   for (let i = 0; i < this.detailTableData.length; i++) {
+      //     if (this.detailTableData[i].name.length === 0) {
+      //       this.isNoDetail = true
+      //       break
+      //     } else {
+      //       this.isNoDetail = false
+      //     }
+      //   }
+      //   if (!this.isNoDetail) {
+      //     this.detailId++
+      //     this.detailTableData.push({
+      //       detailId: this.detailId,
+      //       id: 0,
+      //       amount: 0,
+      //       desc: "",
+      //       name: "",
+      //       number: "",
+      //       price: 0,
+      //       total: 0
+      //     })
+      //   }
+      // }
+    },
+    // 鏂板鏂瑰紡淇敼
+    getSelectArray(val, index) {
+      if (this.tableData.length == 1 && this.tableData[0].number.length == 0) {
+        this.tableData = []
       }
+      if (index < this.tableData.length) {
+        this.tableData.splice(index, 1)
+        val.map((item, ind) => {
+          this.tableData.splice(index + ind, 0, item)
+        })
+      } else {
+        this.tableData = this.tableData.concat(val)
+      }
+      console.log(this.tableData)
+      let list = this.tableData.map((res) => {
+        return {
+          ...res,
+          productName: res.name
+        }
+      })
+      this.productTableList.tableData = list
+      // this.showSummary.show = true
+    },
+    //  浜у搧娓呯┖
+    emptyProductClick() {
+      this.tableData = []
+      this.productTableList.tableData = this.tableData
+    },
+    clearupProduct(data) {
+      this.tableData = data
+      this.productTableList.tableData = this.tableData
     },
     // 鍒犻櫎
     handleDelClick(scope, value) {
       console.log(scope)
       if (value === "鎿嶄綔") {
         this.tableData.splice(scope.$index, 1)
+        this.productTableList.tableData.splice(scope.$index, 1)
+        this.$message.success("鍒犻櫎鎴愬姛锛�")
       } else {
         this.detailTableData.splice(scope.$index, 1)
       }
@@ -1186,20 +1233,20 @@
         }
       }
     },
-    // 婧愪綅缃�夋嫨
-    rootLocationChange(val){
-      this.editConfig.infomation.location=val
+    // 璋冨嚭浣嶇疆閫夋嫨
+    rootLocationChange(val) {
+      this.editConfig.infomation.location = val
       // this.productTableList.tableData.map((item)=>{
       //   console.log(item,"item")
       //   // item.toLocationId={}
       //   // item.fromLocationId={}
       // })
-      this.$refs.tableView.setLocationList(val.label,"fromLocation")
+      this.$refs.tableView.setLocationList(val.label, "fromLocation")
     },
     // 浠撳簱浣嶇疆閫夋嫨
-    toLocationChange(val){
-      this.editConfig.infomation.toLocation=val
-      this.$refs.tableView.setLocationList(val.label,"toLocation")
+    toLocationChange(val) {
+      this.editConfig.infomation.toLocation = val
+      this.$refs.tableView.setLocationList(val.label, "toLocation")
     }
   }
 }

--
Gitblit v1.8.0