Browse Source

feat: 账号管理 - 关联账号"清空"逻辑

zhengxy 2 years ago
parent
commit
f150cf083a

+ 2 - 2
project/src/components/manage/roleManage.vue

@@ -105,13 +105,13 @@
105 105
         <div class="itemBox">
106 106
           <div class="name">关联ADQ账号:</div>
107 107
           <div class="ipt">
108
-            <adqAccountOptions style="margin: 0;" width="330px" :accountListResult="adq_account" @change="onChangeAdqAccount" />
108
+            <adqAccountOptions style="margin: 0;" width="330px" clearable :accountListResult="adq_account" @change="onChangeAdqAccount" />
109 109
           </div>
110 110
         </div>
111 111
         <div class="itemBox">
112 112
           <div class="name">关联MP账号:</div>
113 113
           <div class="ipt">
114
-            <mpAccountOptions style="margin: 0;" width="330px" :accountListResult="mp_account" @change="onChangeMpAccount" />
114
+            <mpAccountOptions style="margin: 0;" width="330px" clearable :accountListResult="mp_account" @change="onChangeMpAccount" />
115 115
           </div>
116 116
         </div>
117 117
         <div class="itemBox">

+ 17 - 16
project/src/components/manage/roleManageComp/adqAccountOptions.vue

@@ -4,7 +4,11 @@
4 4
       <div
5 5
         slot="reference"
6 6
         :style="width ? 'width:' + width : ''"
7
-        :class="['common-screen-self-box', 'common-input-select', accountListResult.length ? 'common-input-select-hover' : '']"
7
+        :class="[
8
+          'common-screen-self-box',
9
+          'common-input-select',
10
+          accountListResult.length && clearable ? 'common-input-select-hover' : ''
11
+        ]"
8 12
         @click="dialogVisible = true"
9 13
       >
10 14
         <div :class="['common-screen-self-con', accountListResult.length ? '' : 'common-screen-self-placeholder']">
@@ -12,6 +16,7 @@
12 16
             <span v-if="accountListResult.length">{{ accountListResultName }}</span>
13 17
             <span v-else>请选择</span>
14 18
           </div>
19
+          <i class="el-icon-circle-close other-icon" @click.stop="onClickClearBtn"></i>
15 20
         </div>
16 21
         <div class="common-screen-self-icon"><i class="el-icon-arrow-down" /></div>
17 22
       </div>
@@ -92,6 +97,10 @@ export default {
92 97
       type: String,
93 98
       default: () => ''
94 99
     },
100
+    clearable: {
101
+      type: Boolean,
102
+      default: () => false
103
+    },
95 104
     accountListResult: { // 最终确认选择的账号列表
96 105
       type: Array,
97 106
       default: () => []
@@ -165,22 +174,9 @@ export default {
165 174
         this.loading = false
166 175
       }
167 176
     },
168
-
169
-    // 根据关键字过滤"可选择的账号列表"
170
-    handleFilterAccountList() {
171
-      this.accountListFilter = this.accountList.filter(account => {
172
-        const currentName = account.name.toLowerCase()
173
-        const keyword = this.keyword.toLowerCase()
174
-        return currentName.includes(keyword)
175
-      })
176
-    },
177
+    // 监听关键字变化
177 178
     onChangeKeyword(val) {
178
-      console.log('val => ', val)
179 179
       this.keyword = val
180
-      // this.handleGetAccountList()
181
-      // if (this.keyword) {
182
-      //   this.handleFilterAccountList()
183
-      // }
184 180
     },
185 181
     // 取消可选列表中所有的已选状态
186 182
     handleCloseAllChatList() {
@@ -279,12 +275,17 @@ export default {
279 275
     // 根据已选列表 判断当前是否全选
280 276
     handleGetIsSelectAll() {
281 277
       const currentSelectedLength = this.accountListSelected.length
282
-      if (currentSelectedLength === this.accountList.length) {
278
+      if (this.accountList.length && (currentSelectedLength === this.accountList.length)) {
283 279
         this.isSelectAll = true
284 280
       } else {
285 281
         this.isSelectAll = false
286 282
       }
287 283
     },
284
+    // 监听点击输入框“清空”按钮
285
+    onClickClearBtn() {
286
+      this.handleDelAllSelectedAccount()
287
+      this.onClickConfirm()
288
+    },
288 289
   },
289 290
 };
290 291
 </script>

+ 17 - 16
project/src/components/manage/roleManageComp/mpAccountOptions.vue

@@ -4,7 +4,11 @@
4 4
       <div
5 5
         slot="reference"
6 6
         :style="width ? 'width:' + width : ''"
7
-        :class="['common-screen-self-box', 'common-input-select', accountListResult.length ? 'common-input-select-hover' : '']"
7
+        :class="[
8
+          'common-screen-self-box',
9
+          'common-input-select',
10
+          accountListResult.length && clearable ? 'common-input-select-hover' : ''
11
+        ]"
8 12
         @click="dialogVisible = true"
9 13
       >
10 14
         <div :class="['common-screen-self-con', accountListResult.length ? '' : 'common-screen-self-placeholder']">
@@ -12,6 +16,7 @@
12 16
             <span v-if="accountListResult.length">{{ accountListResultName }}</span>
13 17
             <span v-else>请选择</span>
14 18
           </div>
19
+          <i class="el-icon-circle-close other-icon" @click.stop="onClickClearBtn"></i>
15 20
         </div>
16 21
         <div class="common-screen-self-icon"><i class="el-icon-arrow-down" /></div>
17 22
       </div>
@@ -92,6 +97,10 @@ export default {
92 97
       type: String,
93 98
       default: () => ''
94 99
     },
100
+    clearable: {
101
+      type: Boolean,
102
+      default: () => false
103
+    },
95 104
     accountListResult: { // 最终确认选择的账号列表
96 105
       type: Array,
97 106
       default: () => []
@@ -165,22 +174,9 @@ export default {
165 174
         this.loading = false
166 175
       }
167 176
     },
168
-
169
-    // 根据关键字过滤"可选择的账号列表"
170
-    handleFilterAccountList() {
171
-      this.accountListFilter = this.accountList.filter(account => {
172
-        const currentName = account.name.toLowerCase()
173
-        const keyword = this.keyword.toLowerCase()
174
-        return currentName.includes(keyword)
175
-      })
176
-    },
177
+    // 监听关键字变化
177 178
     onChangeKeyword(val) {
178
-      console.log('val => ', val)
179 179
       this.keyword = val
180
-      // this.handleGetAccountList()
181
-      // if (this.keyword) {
182
-      //   this.handleFilterAccountList()
183
-      // }
184 180
     },
185 181
     // 取消可选列表中所有的已选状态
186 182
     handleCloseAllChatList() {
@@ -279,12 +275,17 @@ export default {
279 275
     // 根据已选列表 判断当前是否全选
280 276
     handleGetIsSelectAll() {
281 277
       const currentSelectedLength = this.accountListSelected.length
282
-      if (currentSelectedLength === this.accountList.length) {
278
+      if (this.accountList.length && (currentSelectedLength === this.accountList.length)) {
283 279
         this.isSelectAll = true
284 280
       } else {
285 281
         this.isSelectAll = false
286 282
       }
287 283
     },
284
+    // 监听点击输入框“清空”按钮
285
+    onClickClearBtn() {
286
+      this.handleDelAllSelectedAccount()
287
+      this.onClickConfirm()
288
+    },
288 289
   },
289 290
 };
290 291
 </script>