From d5cec48e52edf89636a7fd0a2e3ba6aca5f3ce78 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Wed, 13 Jul 2022 15:08:41 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=9B=E4=BA=8B=E8=8C=83=E5=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/match/add/index.vue | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/pages/match/add/index.vue b/src/pages/match/add/index.vue index 16b0f5b..02bf050 100644 --- a/src/pages/match/add/index.vue +++ b/src/pages/match/add/index.vue @@ -233,6 +233,7 @@ export default { lazyLoad (node, resolve) { // 如果是在模糊搜索中,则不再用懒加载请求数据 const input = document.querySelector('.el-cascader__search-input') + const checked = that.rangeChecked if (input && input.value.trim()) { const val = input.value.trim() @@ -248,6 +249,7 @@ export default { e.value = e.provinceId e.label = e.provinceName e.children = [] + e.disabled = !!checked.find(n => n.provinceId == e.provinceId) data.push(e) }) resolve(data) @@ -262,6 +264,7 @@ export default { e.value = e.cityId e.label = e.cityName e.children = [] + e.disabled = !!checked.find(n => n.cityId == e.cityId) data.push(e) }) resolve(data) @@ -278,6 +281,7 @@ export default { e.value = e.schoolId e.label = e.schoolName e.leaf = true + e.disabled = !!checked.find(n => n.schoolId == e.schoolId) data.push(e) }) resolve(data) @@ -386,7 +390,7 @@ export default { checked.map(e => { rangeChecked.find(n => n.value === e.value) || name.push(e.data) }) - this.rangeChecked = checked + this.rangeChecked.push(...name) }, // 获取学校列表 getSchool() { @@ -408,13 +412,19 @@ export default { // 范围筛选 rangeSearch(el) { const val = el.target.value.trim() + const checked = this.rangeChecked if (!val) { this.rangeList = [] return false } clearTimeout(this.rangeTimer) this.rangeTimer = setTimeout(() => { - let result = this.schools.filter(e => e.label.includes(val)) // 用学校列表做比对 + let result = this.schools.filter(e => { + if (e.label.includes(val)) { + e.disabled = !!checked.find(n => n.schoolId == e.schoolId) + return e + } + }) // 用学校列表做比对 this.rangeList = result }, 100) }, @@ -425,18 +435,19 @@ export default { rangeSubmit() { // 处理提交需要的id const data = [] - this.range.map(e => { + const isSearch = this.rangeList.length // 如果是搜索,则只存schoolId + const checked = this.rangeChecked + checked.map(e => { data.push({ - provinceId: e[0] || '', - cityId: e[1] || '', - schoolId: e[2] || '', - type: e.length > 2 ? 0 : 1 + provinceId: e.provinceId || '', + cityId: e.cityId || '', + schoolId: e.schoolId || '', + type: e.schoolId ? 0 : 1 }) }) this.form.contestRangeList = data // 处理显示的name - const checked = this.$refs.range.getCheckedNodes() const name = [] checked.map(e => { name.push(e.label)