From 81f8e2a307aa12eef5d62a8e9efa7429e888eb55 Mon Sep 17 00:00:00 2001 From: zq <136432190602163.com> Date: Mon, 25 Aug 2025 10:04:33 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=8D=E5=8A=A1=E9=80=89?= =?UTF-8?q?=E6=8B=A9=E5=85=A8=E9=80=89=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/agent/siteAddChooseService.vue | 96 ++++++++++++++++++++++++-------- 1 file changed, 74 insertions(+), 22 deletions(-) diff --git a/src/views/agent/siteAddChooseService.vue b/src/views/agent/siteAddChooseService.vue index dd2e8c2..af2cb08 100644 --- a/src/views/agent/siteAddChooseService.vue +++ b/src/views/agent/siteAddChooseService.vue @@ -2,9 +2,12 @@
-

添加查重服务

+

添加查重服务

+ 选择品牌 +

{{ }}

- + +
-
    + 选择服务 +
    +
    + 全选 +
    + 共{{ addlist.length }}条,已选{{ serviceTotal }}条 +
    +
    • @@ -27,7 +38,7 @@
      -

      看见啊还是看见阿水

      +

      {{ }}

      ¥{{ item.price }} / {{ item.word }}

    @@ -51,14 +62,18 @@ export default { }, data() { return { + selectAll: false, + isIndeterminate: false, datenow:Date.now(), serviceTotal:0, activeCategory:0, uid: 0, type: 0, prodid: 0, - menuList:[], - addlist:[], + menuList:null, + addlist:[ + + ], serviceAddUrl: '/agent/siteServiceAdd', } @@ -83,14 +98,13 @@ export default { // 计算选中的总数 selectedCount() { const newaddlist = JSON.parse(JSON.stringify(this.addlist)) + if(!newaddlist.length)return 0 let list = [] newaddlist.forEach(item => { if (item.checked) { list.push(item) } }) - console.log(list, 'list----', this.addlist); - // store.commit('SET_ADDSERVICELIST', list); return list.length; }, }, @@ -101,6 +115,10 @@ export default { updateSelectedCount() { this.serviceTotal = this.addlist.filter(item => item.checked).length; this.$set(this.menuList[this.activeCategory],'list',this.addlist) + const allSelected = this.serviceTotal === this.addlist.length; + const noneSelected = this.serviceTotal === 0; + this.selectAll = allSelected; + this.isIndeterminate = !noneSelected && !allSelected; this.datenow = Date.now() }, nextGoSettingPrice() { @@ -110,17 +128,17 @@ export default { const selectedList = category.list.filter(item => item.checked); // 只有当分类被选中或有选中的子项时才添加到结果中 if (category.checked || selectedList.length > 0) { - result[key] = { - ...category, - list: selectedList - }; + result[key] = { + ...category, + list: selectedList + }; } }); - // console.log(this.menuList,result,'result===筛选出来的数据'); store.commit('SET_SECOND_MENU', result); localStorage.setItem('selectedServices',JSON.stringify(result)) this.$router.push(this.serviceAddUrl + '?uid=' + this.uid + '&prodid=' + this.prodid) }, + // 初始化请求 getAddServiceList() { const that = this that.$http('POST', '/agentnew/ajax_get_service_add_list', { @@ -128,10 +146,11 @@ export default { prodid: that.prodid, }).then(response => { that.$nextTick(() => { - that.menuList = response.data - that.activeCategory = Object.keys(response.data)[0]; - // store.commit('SET_SECOND_MENU', response.data); - that.setMenuList() + console.log(response,'response==='); + // 暂时注释 数据格式改变渲染报错 + // that.menuList = response.data + // that.activeCategory = Object.keys(response.data)[0]; + // that.setMenuList() }) }).catch(error => { console.error(error, 'error') @@ -164,11 +183,45 @@ export default { console.log(this.addlist,'addlist==='); // const element = this.$refs[`category-${index}`][0]; // element.scrollIntoView({ behavior: 'smooth' }); - }, + }, + handleSelectAllChange(){ + this.addlist.forEach(item =>{ + if(item.checked == !this.selectAll){ + item.checked = !item.checked; + } + }) + this.serviceTotal = this.addlist.filter(item => item.checked).length; + }, } }