From c6232dfd32dff97178f193c4c4e4345159eab19a Mon Sep 17 00:00:00 2001
From: zuozhengqing <a13193816592@163.com>
Date: 星期一, 16 十月 2023 17:54:15 +0800
Subject: [PATCH] 销售明细单添加销售子单

---
 src/views/sales/salesDetails/AddSalesDetailsDialog.vue |   78 ++++++++++++++++++++++++++++++++++++--
 1 files changed, 73 insertions(+), 5 deletions(-)

diff --git a/src/views/sales/salesDetails/AddSalesDetailsDialog.vue b/src/views/sales/salesDetails/AddSalesDetailsDialog.vue
index 76b4762..7a86d41 100644
--- a/src/views/sales/salesDetails/AddSalesDetailsDialog.vue
+++ b/src/views/sales/salesDetails/AddSalesDetailsDialog.vue
@@ -104,6 +104,38 @@
                   </div>
                 </el-form-item>
               </el-col>
+              <el-col :span="12">
+                <el-form-item label="閿�鍞瓙鍗�" prop="subbill_name">
+                  <div class="custom-name">
+                    <el-autocomplete
+                      style="width: 100%"
+                      v-model="editConfig.infomation.subbill_name"
+                      :fetch-suggestions="
+                        (queryString, callback) => {
+                          querySearchAsync(queryString, callback, 'subbill')
+                        }
+                      "
+                      value-key="name"
+                      @select="handleSelectClient('subbill', $event)"
+                      :disabled="isNameChanceEdit"
+                    ></el-autocomplete>
+                    <div v-if="!isNameChanceEdit" class="common-select-btn" @click="selClientClick('client')">
+                      <i class="el-icon-circle-plus-outline" title="閫夋嫨"></i>
+                    </div>
+                    <div
+                      v-if="
+                        editConfig.infomation.subbill_name &&
+                        editConfig.infomation.subbill_name.length > 0 &&
+                        !isNameChanceEdit
+                      "
+                      class="common-select-btn"
+                      @click="clearupClient('subbill')"
+                    >
+                      <i class="el-icon-remove-outline" title="娓呴櫎"></i>
+                    </div>
+                  </div>
+                </el-form-item>
+              </el-col>
               <!-- <el-col :span="12">
                 <el-form-item label="閫夋嫨婧愬崟" prop="selSourceOrder">
                   <el-select v-model="editConfig.infomation.selSourceOrder" size="mini" style="width: 63%">
@@ -386,6 +418,8 @@
 import AddCollectionPlan from "@/views/other/payment/collectionPlan/AddCollectionPlan"
 import codeMixin from "@/views/client/followupRecords/mixin/codeMixin"
 import { getSaleChanceList} from "@/api/sales/salesOpportunity"
+import { getSubOrderList } from "@/api/sales/subOrder"
+
 import {mapActions} from "vuex"
 
 export default {
@@ -410,6 +444,9 @@
     },
     saleChancelist() {
       return this.$store.state.getClientName.saleChancelist
+    },
+    subOrderList(){
+      return this.$store.state.getClientName.subOrderList
     }
   },
   data() {
@@ -418,6 +455,7 @@
       editConfig: this.editCommonConfig,
       rules: {
         client_name: [{ required: true, message: "璇烽�夋嫨瀹㈡埛鍚嶇О", trigger: "change" }],
+        subbill_name: [{ required: true, message: "璇烽�夋嫨閿�鍞瓙鍗�", trigger: "change" }],
         number: [{ required: true, message: "璇疯緭鍏ヨ鍗曠紪鍙�", trigger: "blur" }],
         signTime: [{ required: true, message: "璇烽�夋嫨绛剧害鏃ユ湡", trigger: "change" }],
         memberId: [{ required: true, message: "璇烽�夋嫨閿�鍞礋璐d汉", trigger: "change" }]
@@ -447,6 +485,7 @@
       },
       clientId: this.editCommonConfig.infomation.client_id,
       saleChanceId: this.editCommonConfig.infomation.saleChanceId,
+      subbillId:this.editCommonConfig.infomation.subbillId,
       productId: 1,
       isNoProduct: true,
       addCollectionConfig: {
@@ -461,12 +500,13 @@
   created() {
     this.$store.dispatch("geClient")
     this.$store.dispatch("geChance")
+    this.$store.dispatch("getSubunit")
     this.setTableForm()
     this.getCommonData()
     this.formInfo()
-    if (this.editConfig.title === "鏂板缓" && this.editConfig.infomation.client_name.length > 0) {
-      this.isNameChanceEdit = true
-    }
+    // if (this.editConfig.title === "鏂板缓" && this.editConfig.infomation.client_name.length > 0) {
+    //   this.isNameChanceEdit = true
+    // }
     // else {
 
     // }
@@ -482,7 +522,7 @@
     }
   },
   methods: {
-    ...mapActions(["getChanceFilter"]), 
+    ...mapActions(["getChanceFilter","getSubunitFliter"]), 
     formInfo() {
       this.objCode.type = "閿�鍞槑缁嗙紪鐮�"
       this.objCode.codeStandID = ""
@@ -602,8 +642,16 @@
       var restaurants = []
       if (value === "client") {
         restaurants = this.clientList
+        console.log(restaurants,"瀹㈡埛鍗�")
       } else if (value === "chance") {
         restaurants = this.saleChancelist
+      }else if(value==="subbill"){
+        let arr=[]
+         this.subOrderList.map((item)=>{
+          arr.push(item.client)
+         })
+         restaurants=arr
+        console.log("瀛愪腹",restaurants,arr)
       }
       var results = queryString ? restaurants.filter(this.createStateFilter(queryString)) : restaurants
       cb(results)
@@ -621,17 +669,31 @@
         await getSaleChanceList({
           client_id:this.clientId
         }).then((res)=>{
-          this.getChanceFilter(res.data.list)
+        })
+        await getSubOrderList({
+          page:1,
+          pageSize:15,
+          search_map:{
+            client_id:item.id
+          }
+        }).then((res)=>{
+          this.getSubunitFliter(res.data.list)
         })
       } else if (value === "chance") {
         this.saleChanceId = item.id
         this.editConfig.infomation.client_name = item.name
+      }else if(value==="subbill"){
+        console.log("涓嬫媺妗嗙偣鍑�",item)
+        this.subbillId = item.id
+        this.editConfig.infomation.subbill_name = item.name
       }
     },
     selClientClick(value) {
       if (value === "client") {
         this.editSelectClientConfig.editVisible = true
       } else if (value === "chance") {
+        this.editSelectChanceConfig.editVisible = true
+      }else if(value==="subbill"){
         this.editSelectChanceConfig.editVisible = true
       }
     },
@@ -642,6 +704,9 @@
       } else if (value === "chance") {
         this.editConfig.infomation.sale_chance_name = row.name
         this.saleChanceId = row.id
+      }else if(value==="subbill"){
+        this.editConfig.infomation.subbill_name = row.name
+        this.subbillId=row.id
       }
     },
     // 娓呴櫎宸查�夋嫨鐢ㄦ埛
@@ -652,6 +717,9 @@
       } else if (value === "chance") {
         this.editConfig.infomation.sale_chance_name = ""
         this.saleChanceId = 0
+      }else if(value==="subbill"){
+        this.editConfig.infomation.subbill_name = ""
+        this.subbillId=0
       }
     },
     // 娣诲姞闄勪欢

--
Gitblit v1.8.0