From 37aeda6eb63c96af4d67b73995c850eb34ef79fa Mon Sep 17 00:00:00 2001 From: zq <136432190602163.com> Date: Fri, 12 Dec 2025 18:46:47 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8B=E6=8B=89=E9=80=89=E6=8B=A9=E6=A1=86?= =?UTF-8?q?=E8=81=94=E5=8A=A8=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/agent/addCustomCoupon.vue | 114 +++++++++++++++++++++++++++++++++--- 1 file changed, 105 insertions(+), 9 deletions(-) diff --git a/src/views/agent/addCustomCoupon.vue b/src/views/agent/addCustomCoupon.vue index 25244b7..7aaeea2 100644 --- a/src/views/agent/addCustomCoupon.vue +++ b/src/views/agent/addCustomCoupon.vue @@ -16,7 +16,7 @@
- +
@@ -31,15 +31,15 @@
- +
- +
- +
@@ -53,8 +53,23 @@
- - +
+ + + +
@@ -64,11 +79,15 @@
+ -
+ + +
+
-
@@ -178,7 +197,50 @@ export default { ], walletType:1, - link:'' + link:'', + allData: [ + { + id: '1', + name: '餐饮服务', + children: [ + { id: '0', name: '不限服务' }, + { id: '11', name: '中餐厅' }, + { id: '12', name: '西餐厅' }, + { id: '13', name: '快餐店' } + ] + }, + { + id: '2', + name: '医疗服务', + children: [ + { id: '0', name: '不限服务' }, + { id: '21', name: '综合医院' }, + { id: '22', name: '专科医院' }, + { id: '23', name: '诊所' } + ] + }, + { + id: '3', + name: '教育培训', + children: [] // 没有二级数据 + }, + { + id: '4', + name: '金融服务', + children: [ + { id: '0', name: '不限服务' }, + { id: '41', name: '银行' }, + { id: '42', name: '证券' }, + { id: '43', name: '保险' } + ] + } + ], + + firstSelected: '', // 一级选择值 + secondSelected: '0', // 二级选择值,默认为"不限服务" + showSecondSelect: false, // 是否显示二级选择框 + firstOptions: [], // 一级选项列表 + secondOptions: [], // 二级选项列表 } }, mounted() { @@ -186,11 +248,45 @@ export default { if (type) { this.curAddTab = type; } + this.firstOptions = this.allData.map(item => ({ + value: item.id, + label: item.name + })); }, watch: { }, methods: { + handleFirstChange(value) { + // 根据一级选择的值,找到对应的数据项 + const selectedItem = this.allData.find(item => item.id === value); + + if (selectedItem && selectedItem.children && selectedItem.children.length > 0) { + // 有二级数据,显示二级选择框 + this.showSecondSelect = true; + + // 动态赋值二级选项 + this.secondOptions = selectedItem.children.map(child => ({ + value: child.id, + label: child.name + })); + + // 设置默认值为"不限服务" + const hasUnlimited = selectedItem.children.some(child => child.id === '0'); + if (hasUnlimited) { + this.secondSelected = '0'; + } else if (this.secondOptions.length > 0) { + // 如果没有"不限服务"选项,默认选择第一个 + this.secondSelected = this.secondOptions[0].value; + } + } else { + // 没有二级数据,隐藏二级选择框并重置 + this.showSecondSelect = false; + this.secondOptions = []; + this.secondSelected = ''; + } + }, + handleClickCopy(){ this.$copy(this.form.input1, { successMsg: '内容已复制到剪贴板',