diff --git a/src/assets/serviceIcon/ver_single.svg b/src/assets/serviceIcon/ver_single.svg new file mode 100644 index 0000000..5337e6c --- /dev/null +++ b/src/assets/serviceIcon/ver_single.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/views/agent/siteAddChooseService.vue b/src/views/agent/siteAddChooseService.vue index af2cb08..83dda80 100644 --- a/src/views/agent/siteAddChooseService.vue +++ b/src/views/agent/siteAddChooseService.vue @@ -6,40 +6,39 @@ 选择品牌

{{ }}

- - +
选择服务
- 全选 + 全选
- 共{{ addlist.length }}条,已选{{ serviceTotal }}条 + 共{{ ver2types[activeVerid] ? ver2types[activeVerid].length : 0 }}条,已选{{ addlist[activeVerid] ? addlist[activeVerid].length : 0 }}条
-
@@ -62,18 +61,29 @@ export default { }, data() { return { - selectAll: false, - isIndeterminate: false, - datenow:Date.now(), - serviceTotal:0, - activeCategory:0, uid: 0, type: 0, prodid: 0, + + activeVerid:0, + addlist:[], + selectAll: [], + + type2name:[], + classifyId2Name: [], + classifyId2Vers: [], + ver2types: [], + ver2info: [], + type2info: [], + supplyPriceList: [], + salePolicy: [], + + // isIndeterminate: true, + datenow:Date.now(), + serviceTotal:0, + menuList:null, - addlist:[ - - ], + serviceAddUrl: '/agent/siteServiceAdd', } @@ -84,53 +94,35 @@ export default { created() { if (!this.$route.query.uid && !this.$route.query.prodid) { this.$message.error('非法请求'); - this.$router.push('/agent/siteAdd') + this.$router.go(-1) } this.uid = this.$route.query.uid this.prodid = this.$route.query.prodid - // this.loadPddSDK() }, mounted() { store.commit('SET_PAGETITLE', '站点信息'); this.getAddServiceList(); }, - computed: { - // 计算选中的总数 - 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) - } - }) - return list.length; - }, - }, methods: { cancel(){ this.$router.go(-1) }, - 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() { const result = {}; - Object.entries(this.menuList).forEach(([key, category]) => { - // 筛选出选中的子项 - const selectedList = category.list.filter(item => item.checked); - // 只有当分类被选中或有选中的子项时才添加到结果中 - if (category.checked || selectedList.length > 0) { + Object.entries(this.addlist).forEach(([key, category]) => { + if(category.length>0){ + let list = [] + category.forEach(type=>{ + list.push({ + type: type, + name: this.type2name[type], + }) + }) + result[key] = { - ...category, - list: selectedList + type: key, + name: this.ver2info[key].name, + list: list }; } }); @@ -146,16 +138,68 @@ export default { prodid: that.prodid, }).then(response => { that.$nextTick(() => { - console.log(response,'response==='); - // 暂时注释 数据格式改变渲染报错 - // that.menuList = response.data - // that.activeCategory = Object.keys(response.data)[0]; - // that.setMenuList() + that.classifyId2Name = response.data.classifyid2name; + that.classifyId2Vers = response.data.classifyid2vers; + that.ver2types = response.data.ver2types; + that.ver2info = response.data.ver2info; + that.type2name = response.data.type2name; + that.type2info = response.data.type2info; + that.supplyPriceList = response.data.supply_price; + that.salePolicy = response.data.sale_policy; + + if(!that.classifyId2Vers[that.prodid]){ + that.$message.error('非法请求'); + that.$router.go(-1) + } + + that.classifyId2Vers[that.prodid].forEach(verid => { + that.activeVerid = that.activeVerid ? that.activeVerid : verid; + that.addlist[verid] = []; + }) }) }).catch(error => { console.error(error, 'error') }) }, + scrollToCategory(index) { + this.activeVerid = index; + this.datenow = Date.now() + }, + updateSelectedCount(type) { + if (this.addlist[this.activeVerid] && this.addlist[this.activeVerid].includes(type)) { + this.addlist[this.activeVerid] = this.addlist[this.activeVerid].filter(item => item !== type); + this.serviceTotal-- + } else { + this.addlist[this.activeVerid].push(type); + this.serviceTotal++ + } + this.datenow = Date.now() + }, + isAllSelected() { + const selected = this.addlist[this.activeVerid] || []; + const total = this.ver2types[this.activeVerid] || []; + return selected.length > 0 && selected.length === total.length; + }, + isIndeterminate() { + const selected = this.addlist[this.activeVerid] || []; + const total = this.ver2types[this.activeVerid] || []; + return selected.length > 0 && selected.length < total.length; + }, + handleSelectAllChange(){ + if (this.isAllSelected(this.activeVerid)) { + // 全选 → 全不选 + this.$set(this.addlist, this.activeVerid, []); + } else { + // 全不选 → 全选 + const total = this.ver2types[this.activeVerid] || []; + this.$set(this.addlist, this.activeVerid, [...total]); + } + + this.serviceTotal = 0 + this.addlist.forEach(types=>{ + this.serviceTotal += types.length + }) + }, setMenuList(type, status) { this.addNum = 0 Object.values(this.menuList).forEach((item) => { @@ -174,23 +218,7 @@ export default { if (ver_select) item.is_select = true }) this.serviceTotal = 0; - this.scrollToCategory(this.activeCategory) - }, - scrollToCategory(index) { - this.activeCategory = index; - this.addlist = this.menuList[index]['list'] - this.serviceTotal = this.addlist.filter(item => item.checked).length; - 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; + this.scrollToCategory(this.activeVerid) }, } }