lilei hace 2 años
padre
commit
67045fefbf

+ 106 - 0
src/views/common/dealerSearchList.vue

@@ -0,0 +1,106 @@
+<template>
+  <a-select
+    show-search
+    label-in-value
+    :size="size"
+    :value="dealerName"
+    mode="combobox"
+    :placeholder="placeholder"
+    style="width: 100%"
+    :filter-option="false"
+    :not-found-content="fetching ? undefined : null"
+    :dropdownMatchSelectWidth="false"
+    :defaultActiveFirstOption="false"
+    @search="fetchUser"
+    @change="handleChange"
+    allowClear
+    :disabled="disabled"
+  >
+    <a-spin v-if="fetching" slot="notFoundContent" size="small" />
+    <a-select-option v-for="item in data" :key="item.dealerSn" :value="item.dealerName">
+      {{ item.dealerName }}
+    </a-select-option>
+  </a-select>
+</template>
+<script>
+import debounce from 'lodash/debounce'
+import { dealerSubareaScopeList, dealerDetailBySn } from '@/api/dealer'
+export default {
+  props: {
+    size: {
+      type: String,
+      default: 'default'
+    },
+    placeholder: {
+      type: String,
+      default: '请输入名称搜索'
+    },
+    disabled: {
+      type: Boolean,
+      default: false
+    }
+  },
+  data () {
+    this.lastFetchId = 0
+    this.fetchUser = debounce(this.fetchUser, 800)
+    return {
+      data: [],
+      dealerName: [],
+      fetching: false
+    }
+  },
+  methods: {
+    fetchUser (dealerName) {
+      console.log('fetching user', dealerName)
+      if (dealerName == '') return
+      this.lastFetchId += 1
+      const fetchId = this.lastFetchId
+      this.data = []
+      this.fetching = true
+      dealerSubareaScopeList({ nameLike: dealerName.replace(/\s+/g, ''), pageNo: 1, pageSize: 20 }).then(res => {
+        if (fetchId !== this.lastFetchId) {
+          return
+        }
+        this.data = res.data && res.data.list ? res.data.list : []
+        this.fetching = false
+      })
+    },
+    handleChange (value) {
+      if (value && value.key) {
+        const obj = this.data.find(item => item.dealerName.replace(/\s+/g, '') == value.key)
+        value.name = obj ? obj.dealerName : ''
+        value.row = obj
+      }
+      Object.assign(this, {
+        dealerName: value,
+        data: [],
+        fetching: false
+      })
+      this.$emit('change', value || { key: undefined })
+    },
+    resetForm () {
+      this.dealerName = []
+      Object.assign(this, {
+        dealerName: undefined,
+        data: [],
+        fetching: false
+      })
+    },
+    // 查询详细
+    getDetail (sn) {
+      dealerDetailBySn({ sn: sn }).then(res => {
+        const val = { key: sn }
+        val.label = res.data.dealerName
+        val.row = res.data
+        Object.assign(this, {
+          dealerName: val,
+          data: [res.data],
+          fetching: false
+        })
+        this.$emit('change', val)
+        this.$emit('dealerDetail', res.data || null)
+      })
+    }
+  }
+}
+</script>

+ 20 - 6
src/views/financialManagement/financialCollection/selectGlAllocatModal.vue

@@ -22,12 +22,12 @@
               </a-col>
               <a-col :md="6" :sm="24">
                 <a-form-item label="客户名称" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
-                  <dealerSubareaScopeList ref="dealerSubareaScopeList" id="pushOrder-buyerName" @change="custChange" />
+                  <dealerSearchList ref="dealerSubareaScopeList" id="pushOrder-buyerName" @change="custChange" />
                 </a-form-item>
               </a-col>
               <a-col :md="6" :sm="24">
                 <a-form-item label="收货客户名称" :label-col="{ span:7 }" :wrapper-col="{ span:17}">
-                  <dealerSubareaScopeList ref="shbuyerName" id="pushOrder-shbuyerName" @change="shcustChange" />
+                  <dealerSearchList ref="shbuyerName" id="pushOrder-shbuyerName" @change="shcustChange" />
                 </a-form-item>
               </a-col>
               <a-col :md="4" :sm="24">
@@ -92,10 +92,10 @@ import { STable, VSelect } from '@/components'
 import { allocateBillList } from '@/api/allocateBill'
 import commonModal from '@/views/common/commonModal.vue'
 import allocationDetailModal from '@/views/allocationManagement/transferOut/detail.vue'
-import dealerSubareaScopeList from '@/views/common/dealerSubareaScopeList.vue'
+import dealerSearchList from '@/views/common/dealerSearchList.vue'
 export default {
   name: 'SelectGlAllocatModal',
-  components: { STable, VSelect, dealerSubareaScopeList, commonModal, allocationDetailModal },
+  components: { STable, VSelect, dealerSearchList, commonModal, allocationDetailModal },
   props: {
     openModal: { //  弹框显示状态
       type: Boolean,
@@ -179,10 +179,24 @@ export default {
   },
   methods: {
     custChange (val) {
-      this.queryParam.targetSn = val.key
+      console.log(val)
+      if(val.row){
+        this.queryParam.targetSn = val.row.dealerSn
+        this.queryParam.targetName = undefined
+      }else{
+        this.queryParam.targetSn = undefined
+        this.queryParam.targetName = val.key
+      }
     },
     shcustChange (val) {
-      this.queryParam.receiverSn = val.key
+      console.log(val)
+      if(val.row){
+        this.queryParam.receiverSn = val.row.dealerSn
+        this.queryParam.receiverName = undefined
+      }else{
+        this.queryParam.receiverSn = undefined
+        this.queryParam.receiverName = val.key
+      }
     },
     handleDetail (row, type) {
       this.bizSn = row.allocateSn