Browse Source

bug修复

chenrui 4 năm trước cách đây
mục cha
commit
af298dda13
1 tập tin đã thay đổi với 57 bổ sung32 xóa
  1. 57 32
      src/views/salesManagement/salesReturn/chooseCustomModal.vue

+ 57 - 32
src/views/salesManagement/salesReturn/chooseCustomModal.vue

@@ -5,7 +5,7 @@
     centered
     :maskClosable="false"
     :confirmLoading="confirmLoading"
-    width="80%"
+    :width="960"
     :footer="null"
     @cancel="cancel"
   >
@@ -21,7 +21,19 @@
         <a-row :gutter="15">
           <a-col :span="8">
             <a-form-model-item label="客户名称" required>
-              <custList id="chooseCustom-dealerName" ref="custList" @dealerDetail="dealerDetail" @change="custChange"></custList>
+              <a-select
+                show-search
+                id="chooseCustom-buyerSn"
+                v-model="form.buyerSn"
+                placeholder="请选择"
+                :filter-option="false"
+                :not-found-content="fetching ? undefined : null"
+                @search="fetchUser"
+                @change="handleChange"
+              >
+                <a-spin v-if="fetching" slot="notFoundContent" size="small" />
+                <a-select-option v-for="item in dealerData" :key="item.dealerSn" :value="item.dealerSn">{{ item.dealerName }}</a-select-option>
+              </a-select>
             </a-form-model-item>
           </a-col>
         </a-row>
@@ -38,7 +50,7 @@
           </a-col>
           <a-col :span="10">
             <a-form-model-item label="客户地址">
-              <p style="line-height: 1.5em;margin: 0;">{{ form.provinceName }}{{ form.cityName }}{{ form.countyName }}{{ form.customerAddr }}</p>
+              {{ form.provinceName }}{{ form.cityName }}{{ form.countyName }}{{ form.customerAddr }}
             </a-form-model-item>
           </a-col>
         </a-row>
@@ -62,12 +74,12 @@
 </template>
 
 <script>
-import { salesReturnInsert } from '@/api/salesReturn'
 import { VSelect } from '@/components'
-import custList from '@/views/common/custList.vue'
+import { dealerSubareaScopeList, dealerFindUpdateInfoBySn } from '@/api/dealer'
+import { salesReturnInsert } from '@/api/salesReturn'
 export default {
   name: 'ChooseCustomModal',
-  components: { VSelect, custList },
+  components: { VSelect },
   props: {
     show: [Boolean]
   },
@@ -96,35 +108,49 @@ export default {
         customerAddr: '', //  详细地址
         grabFlag: '1' // 是否抓单
       },
-      rules: {}
+      rules: {},
+      fetching: false,
+      dealerData: []
     }
   },
   methods: {
-    custChange (val) {
-      this.form.buyerSn = val.key
-      this.$refs.custList.getDetail(val.key)
+    // 搜索经销商
+    fetchUser (value) {
+      console.log('fetching user', value)
+      this.fetching = true
+      dealerSubareaScopeList({ nameLike: value, pageNo: 1, pageSize: 20 }).then(res => {
+        if (res.status == 200) {
+          this.dealerData = res.data.list
+          this.fetching = false
+        } else {
+          this.dealerData = []
+          this.fetching = false
+        }
+      })
     },
-    //  获取详情
-    dealerDetail (data) {
-      console.log(data)
-      if (data) {
-        this.form = Object.assign(this.form, {
-          buyerName: data.dealerName, // 客户名称
-          buyerSn: data.dealerSn, // 客户sn
-          contactTel: data.contactMobile, //  联系电话
-          contactName: data.contact, //  联系人
-          provinceSn: data.provinceSn, //  省
-          provinceName: data.provinceName,
-          citySn: data.citySn, // 市
-          cityName: data.cityName,
-          countySn: data.districtSn, // 区
-          countyName: data.districtName,
-          customerAddr: data.address //  详细地址
-        })
-      } else {
-        this.$message.error('获取客户信息失败')
-        this.$refs.ruleForm.resetFields()
-      }
+    // 客户  change
+    handleChange (value) {
+      dealerFindUpdateInfoBySn({ sn: this.form.buyerSn }).then(res => {
+        if (res.data) {
+          const data = res.data
+          this.form = Object.assign(this.form, {
+            buyerName: data.dealerName, // 客户名称
+            buyerSn: data.dealerSn, // 客户sn
+            contactTel: data.contactMobile, //  联系电话
+            contactName: data.contact, //  联系人
+            provinceSn: data.provinceSn, //  省
+            provinceName: data.provinceName,
+            citySn: data.citySn, // 市
+            cityName: data.cityName,
+            countySn: data.districtSn, // 区
+            countyName: data.districtName,
+            customerAddr: data.address //  详细地址
+          })
+        } else {
+          this.$message.error('获取客户信息失败')
+          this.$refs.ruleForm.resetFields()
+        }
+      })
     },
     //  保存
     handleSubmit (e) {
@@ -178,7 +204,6 @@ export default {
         customerAddr: '', //  详细地址
         grabFlag: '1' // 是否抓单
       }
-      this.$refs.custList.resetForm()
       this.$emit('cancel')
     }
   },