Browse Source

bug修复

chenrui 4 years ago
parent
commit
257a9ee129

+ 27 - 10
src/views/dealerManagement/dealerRelationshipBinding/associateModal.vue

@@ -63,13 +63,14 @@ export default {
         wrapperCol: { span: 16 }
       },
       dealerLevelList: [],
-      subDealerSn: ''
+      subDealerSn: '',
+      isRelation: '' //  是否已被关联过
     }
   },
   methods: {
-    handleDisassociate (val) {
-      console.log('选中', val)
+    handleDisassociate (val, parentDealerSn) {
       this.subDealerSn = val.key
+      this.isRelation = parentDealerSn
     },
     //  保存
     handleSave () {
@@ -84,18 +85,34 @@ export default {
             subDealerSn: _this.subDealerSn,
             parentDealerSn: _this.nowData && _this.nowData.dealerSn ? _this.nowData.dealerSn : undefined
           }
-          bindRelation(formData).then(res => {
-            if (res.status == 200) {
-              _this.$message.success(res.message)
-              _this.$emit('ok', formData.parentDealerSn)
-              _this.isShow = false
-            }
-          })
+          if (_this.isRelation) {
+            _this.$confirm({
+              title: '提示',
+              content: '确认要解除原有绑定关系,建立新的绑定关系吗?',
+              centered: true,
+              closable: true,
+              onOk () {
+                _this.handleBind(formData)
+              }
+            })
+          } else {
+            _this.handleBind(formData)
+          }
         } else {
           return false
         }
       })
     },
+    handleBind (formData) {
+      const _this = this
+      bindRelation(formData).then(res => {
+        if (res.status == 200) {
+          _this.$message.success(res.message)
+          _this.$emit('ok', formData.parentDealerSn)
+          _this.isShow = false
+        }
+      })
+    },
     filterOption (input, option) {
       return (
         option.componentOptions.children[0].text.toLowerCase().indexOf(input.toLowerCase()) >= 0

+ 7 - 4
src/views/dealerManagement/dealerRelationshipBinding/queryChild.vue

@@ -5,14 +5,15 @@
     :value="dealerName"
     placeholder="请输入下级名称搜索"
     style="width: 100%"
+    option-label-prop="label"
     :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 data" :key="item.dealerSn" :value="item.dealerSn">
-      {{ item.dealerName }}
+    <a-select-option v-for="item in data" :key="item.dealerSn" :value="item.dealerSn" :label="item.dealerName">
+      {{ item.dealerName }} - {{ item.parentDealerSn ? '已关联' : '未关联' }}
     </a-select-option>
   </a-select>
 </template>
@@ -45,7 +46,7 @@ export default {
       const fetchId = this.lastFetchId
       this.data = []
       this.fetching = true
-      dealerRelationList({ 'dealerName': dealerName, 'dealerLevelList': this.dealerLevelList, pageNo: 1, pageSize: 1000 }).then(res => {
+      dealerRelationList({ 'dealerName': dealerName, 'dealerLevelList': this.dealerLevelList, pageNo: 1, pageSize: 20 }).then(res => {
         if (fetchId !== this.lastFetchId) {
           return
         }
@@ -54,12 +55,14 @@ export default {
       })
     },
     handleChange (value) {
+      const ind = this.data.findIndex(item => item.dealerSn == value.key)
+      const parentDealerSn = ind != -1 && this.data[ind].parentDealerSn ? this.data[ind].parentDealerSn : ''
       Object.assign(this, {
         dealerName: value,
         data: [],
         fetching: false
       })
-      this.$emit('change', value)
+      this.$emit('change', value, parentDealerSn)
     },
     resetForm () {
       this.dealerName = []