From 5e7ae67155a1e62ea27cfda98bbf9f90f56de405 Mon Sep 17 00:00:00 2001 From: lihui Date: Thu, 31 Jul 2025 12:43:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E7=BA=A7=E8=81=94=20=E6=94=B9=E4=BA=86?= =?UTF-8?q?=E5=89=A9=E4=B8=8B=E7=9A=84=E5=87=A0=E4=B8=AA=20=EF=BC=8C?= =?UTF-8?q?=E8=BF=98=E6=B2=A1=E6=94=B9=E6=9D=83=E9=99=90=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/audit/rechargeAudit.vue | 104 +++++++++++------ src/views/audit/refundAudit.vue | 148 +++++++++++++++--------- src/views/consume/coinConsumeDetail.vue | 160 +++++++++++++++----------- src/views/recharge/coinRechargeDetail.vue | 2 - src/views/refund/coinRefundDetail.vue | 153 +++++++++++++++---------- src/views/usergold/clientCountBalance.vue | 149 ++++++++++++++++--------- src/views/usergold/clientCountDetail.vue | 180 +++++++++++++++++++----------- 7 files changed, 567 insertions(+), 329 deletions(-) diff --git a/src/views/audit/rechargeAudit.vue b/src/views/audit/rechargeAudit.vue index 0bf446b..9373877 100644 --- a/src/views/audit/rechargeAudit.vue +++ b/src/views/audit/rechargeAudit.vue @@ -24,11 +24,14 @@ 所属地区: @@ -218,7 +221,7 @@ const rechargeAudit = ref({ payModel: "", // 支付方式 startTime: "", // 充值时间开始 endTime: "", // 充值时间结束 - market: "", // 地区 + markets: [], // 地区 auditStatus: "0", }) @@ -233,7 +236,7 @@ const total = ref(50) const getTime = ref([]) const activity = ref([]) // 搜索地区列表 -const market = ref([]) +const markets = ref([]) // 驳回弹出框 const rejectDialogVisible = ref(false) // 驳回理由 @@ -373,7 +376,7 @@ const resetSearch = function () { payModel: "", startTime: "", endTime: "", - market: "", + markets: [], auditStatus: rechargeAudit.value.auditStatus, } @@ -623,56 +626,91 @@ const previewImage = (imageUrl) => { const selectedMarketPath = ref([]) //处理地区选择变化 const handleMarketChange = (value) => { - if (value && value.length > 0) { - const lastValue = value[value.length - 1]; - let selectedName = lastValue.endsWith('_all') - ? lastValue.replace('_all', '') - : lastValue; - - // 反向映射 - rechargeAudit.value.market = reverseMarketMapping[selectedName] || ''; + if (Array.isArray(value) && value.length > 0) { + const ids = new Set(); + + value.forEach(path => { + const lastName = path[path.length - 1]; + const id = reverseMarketMapping[lastName]; + if (id) ids.add(Number(id)); + }); + + // 添加额外处理:如果一个父节点下所有子节点都被选中,则把父节点也加入 + const getAllLeafNames = (nodes) => { + const leafNames = []; + + const traverse = (node, parentName = null) => { + if (!node.children || node.children.length === 0) { + leafNames.push({name: node.label, parent: parentName}); + } else { + node.children.forEach(child => traverse(child, node.label)); + } + }; + + nodes.forEach(node => traverse(node)); + return leafNames; + }; + + const leafNameMap = getAllLeafNames(markets.value); // 所有叶子节点和对应父级名称 + + // 列表构建 + const parentToChildren = {}; + leafNameMap.forEach(({name, parent}) => { + if (!parentToChildren[parent]) parentToChildren[parent] = []; + parentToChildren[parent].push(name); + }); + + // 构建当前被选中的叶子节点 + const selectedLeafNames = value.map(path => path[path.length - 1]); + + // 如果 parent 下所有子节点都选中了,就把 parent 加进来 + Object.entries(parentToChildren).forEach(([parent, children]) => { + const allChildrenSelected = children.every(child => selectedLeafNames.includes(child)); + if (allChildrenSelected && reverseMarketMapping[parent]) { + ids.add(Number(reverseMarketMapping[parent])); + } + }); + + rechargeAudit.value.markets = Array.from(ids); } else { - rechargeAudit.value.market = ''; + rechargeAudit.value.markets = []; } + + console.log('最终映射后的 market IDs:', rechargeAudit.value.markets); }; +const props = {multiple: true} // 获取地区,修改为级联下拉框 const getMarket = async function () { - console.log('获取地区adminid', adminData.value) try { // 发送POST请求 const result = await API({ url: '/market/selectMarket', - data: {account: adminData.value.account} }); // 将响应结果存储到响应式数据中 console.log('请求成功', result) - // 递归转换树形结构为级联选择器需要的格式 + // 递归转换树形结构为级联选择器需要的格式(跳过第一级节点) const transformTree = (nodes) => { - return nodes.map(node => { - const children = node.children && node.children.length - ? transformTree(node.children) + // 直接处理第一级节点的子节点 + const allChildren = nodes.flatMap(node => node.children || []); + + return allChildren.map(child => { + const grandchildren = child.children && child.children.length + ? transformTree([child]) // 递归处理子节点 : null; - // 如果有子节点,添加“全部”选项 - if (children) { - children.unshift({ - value: `${node.name}_all`, // 唯一标识 - label: '全部', - children: null - }); - } + return { - value: node.name, //使用地区名称作为值 - label: node.name, //显示名称 - children + value: child.name, + label: child.name, + children: grandchildren }; }); - } + }; // 存储地区信息 - market.value = transformTree(result.data) - console.log('转换后的地区树', market.value) + markets.value = transformTree(result.data) + console.log('转换后的地区树==============', markets.value) } catch (error) { console.log('请求失败', error) } diff --git a/src/views/audit/refundAudit.vue b/src/views/audit/refundAudit.vue index 1a1eb53..d54d361 100644 --- a/src/views/audit/refundAudit.vue +++ b/src/views/audit/refundAudit.vue @@ -25,11 +25,14 @@ 所属地区: @@ -195,7 +198,7 @@ const searchForm = ref({ jwcode: '', refundModel: '', goodsName: '', - market: '', + markets: [], startTime: '', endTime: '', auditStatus: '0' @@ -286,48 +289,8 @@ const showRejectDialog = (row) => { rejectDialogVisible.value = true } // 查地区 -const market = ref([]) -// 获取地区,修改为级联下拉框 -const getMarket = async function () { - console.log('获取地区adminid', adminInfo.value) - try { - // 发送POST请求 - const result = await API({ - - url: '/market/selectMarket', - data: {account: adminInfo.value.account} - }); - // 将响应结果存储到响应式数据中 - console.log('请求成功', result) +const markets = ref([]) - // 递归转换树形结构为级联选择器需要的格式 - const transformTree = (nodes) => { - return nodes.map(node => { - const children = node.children && node.children.length - ? transformTree(node.children) - : null; - // 如果有子节点,添加“全部”选项 - if (children) { - children.unshift({ - value: `${node.name}_all`, // 唯一标识 - label: '全部', - children: null - }); - } - return { - value: node.name, //使用地区名称作为值 - label: node.name, //显示名称 - children - }; - }); - } - // 存储地区信息 - market.value = transformTree(result.data) - console.log('转换后的地区树', market.value) - } catch (error) { - console.log('请求失败', error) - } -} // 查商品名 const getRefundGoods = async () => { try { @@ -453,7 +416,7 @@ const resetSearch = function () { jwcode: '', refundType: '', goodsName: '', - market: '', + markets: [], startTime: '', endTime: '', sortField: '', @@ -463,6 +426,8 @@ const resetSearch = function () { dateRange.value = [] activeTimeRange.value = '' // 清除激活状态 selectedMarketPath.value = [] + get() + getStats() } // 今天 @@ -569,19 +534,96 @@ const adminReject = async function () { const selectedMarketPath = ref([]) //处理地区选择变化 const handleMarketChange = (value) => { - if (value && value.length > 0) { - const lastValue = value[value.length - 1]; - let selectedName = lastValue.endsWith('_all') - ? lastValue.replace('_all', '') - : lastValue; - - // 反向映射 - searchForm.value.market = reverseMarketMapping[selectedName] || ''; + if (Array.isArray(value) && value.length > 0) { + const ids = new Set(); + + value.forEach(path => { + const lastName = path[path.length - 1]; + const id = reverseMarketMapping[lastName]; + if (id) ids.add(Number(id)); + }); + + // 添加额外处理:如果一个父节点下所有子节点都被选中,则把父节点也加入 + const getAllLeafNames = (nodes) => { + const leafNames = []; + + const traverse = (node, parentName = null) => { + if (!node.children || node.children.length === 0) { + leafNames.push({name: node.label, parent: parentName}); + } else { + node.children.forEach(child => traverse(child, node.label)); + } + }; + + nodes.forEach(node => traverse(node)); + return leafNames; + }; + + const leafNameMap = getAllLeafNames(markets.value); // 所有叶子节点和对应父级名称 + + // 列表构建 + const parentToChildren = {}; + leafNameMap.forEach(({name, parent}) => { + if (!parentToChildren[parent]) parentToChildren[parent] = []; + parentToChildren[parent].push(name); + }); + + // 构建当前被选中的叶子节点 + const selectedLeafNames = value.map(path => path[path.length - 1]); + + // 如果 parent 下所有子节点都选中了,就把 parent 加进来 + Object.entries(parentToChildren).forEach(([parent, children]) => { + const allChildrenSelected = children.every(child => selectedLeafNames.includes(child)); + if (allChildrenSelected && reverseMarketMapping[parent]) { + ids.add(Number(reverseMarketMapping[parent])); + } + }); + + searchForm.value.markets = Array.from(ids); } else { - searchForm.value.market = ''; + searchForm.value.markets = []; } + + console.log('最终映射后的 market IDs:', searchForm.value.markets); }; +const props = {multiple: true} +// 获取地区,修改为级联下拉框 +const getMarket = async function () { + try { + // 发送POST请求 + const result = await API({ + + url: '/market/selectMarket', + }); + // 将响应结果存储到响应式数据中 + console.log('请求成功', result) + + // 递归转换树形结构为级联选择器需要的格式(跳过第一级节点) + const transformTree = (nodes) => { + // 直接处理第一级节点的子节点 + const allChildren = nodes.flatMap(node => node.children || []); + + return allChildren.map(child => { + const grandchildren = child.children && child.children.length + ? transformTree([child]) // 递归处理子节点 + : null; + + return { + value: child.name, + label: child.name, + children: grandchildren + }; + }); + }; + // 存储地区信息 + markets.value = transformTree(result.data) + console.log('转换后的地区树==============', markets.value) + } catch (error) { + console.log('请求失败', error) + } +} + onMounted(async () => { await getAdminData() diff --git a/src/views/consume/coinConsumeDetail.vue b/src/views/consume/coinConsumeDetail.vue index 0cd563a..6a154c0 100644 --- a/src/views/consume/coinConsumeDetail.vue +++ b/src/views/consume/coinConsumeDetail.vue @@ -26,7 +26,7 @@ const tableData = ref([]) const consumeUser = ref({ jwcode: null, payPlatform: "", - market: "", + markets: [], startTime: '', endTime: '', @@ -60,7 +60,7 @@ const getTime = ref({ const activity = ref([]) // 搜索地区列表 -const market = ref([]) +const markets = ref([]) // 新增排序字段和排序方式 const sortField = ref('') @@ -112,7 +112,7 @@ const goods = ref([]) const totalGoldSearch = ref({ jwcode: null, payPlatform: "", - market: "", + markets: [], startTime: "", endTime: "", goodsName: "" @@ -191,7 +191,7 @@ const ConsumeSelectBy = async function (val) { totalGoldSearch.value.startTime = consumeUser.value.startTime totalGoldSearch.value.endTime = consumeUser.value.endTime totalGoldSearch.value.payPlatform = consumeUser.value.payPlatform - totalGoldSearch.value.market = consumeUser.value.market + totalGoldSearch.value.markets = consumeUser.value.markets totalGoldSearch.value.goodsName = consumeUser.value.goodsName totalGoldSearch.value.jwcode = consumeUser.value.jwcode // @@ -264,7 +264,7 @@ const reset = function () { consumeUser.value.goodsName = '' - consumeUser.value.market = '' + consumeUser.value.markets = [] consumeUser.value.payPlatform = '' @@ -362,51 +362,6 @@ const getGoods = async function () { } } -// 获取地区列表的方法 - -// 获取地区,修改为级联下拉框 -const getMarket = async function () { - console.log('获取地区adminid', adminData.value) - try { - // 发送POST请求 - const result = await API({ - - url: '/market/selectMarket', - data: {account: adminData.value.account} - }); - // 将响应结果存储到响应式数据中 - console.log('请求成功', result) - - // 递归转换树形结构为级联选择器需要的格式 - const transformTree = (nodes) => { - return nodes.map(node => { - const children = node.children && node.children.length - ? transformTree(node.children) - : null; - // 如果有子节点,添加“全部”选项 - if (children) { - children.unshift({ - value: `${node.name}_all`, // 唯一标识 - label: '全部', - children: null - }); - } - return { - value: node.name, //使用地区名称作为值 - label: node.name, //显示名称 - children - }; - }); - } - // 存储地区信息 - market.value = transformTree(result.data) - console.log('转换后的地区树', market.value) - } catch (error) { - console.log('请求失败', error) - } -} - - // 处理排序事件 const handleSortChange = (column) => { console.log('排序字段:', column.prop) @@ -463,7 +418,7 @@ const exportExcel = async function () { consumeUser: { jwcode: consumeUser.value.jwcode || '', payPlatform: consumeUser.value.payPlatform || '', - market: consumeUser.value.market || '', + markets: consumeUser.value.markets || [], startTime: consumeUser.value.startTime || '', endTime: consumeUser.value.endTime || '', goodsName: consumeUser.value.goodsName || '', @@ -549,24 +504,100 @@ const getTagText = (state) => { return '未知状态'; } } - // 存储地区选择变化 const selectedMarketPath = ref([]) //处理地区选择变化 const handleMarketChange = (value) => { - if (value && value.length > 0) { - const lastValue = value[value.length - 1]; - let selectedName = lastValue.endsWith('_all') - ? lastValue.replace('_all', '') - : lastValue; - - // 反向映射 - consumeUser.value.market = reverseMarketMapping[selectedName] || ''; + if (Array.isArray(value) && value.length > 0) { + const ids = new Set(); + + value.forEach(path => { + const lastName = path[path.length - 1]; + const id = reverseMarketMapping[lastName]; + if (id) ids.add(Number(id)); + }); + + // 添加额外处理:如果一个父节点下所有子节点都被选中,则把父节点也加入 + const getAllLeafNames = (nodes) => { + const leafNames = []; + + const traverse = (node, parentName = null) => { + if (!node.children || node.children.length === 0) { + leafNames.push({name: node.label, parent: parentName}); + } else { + node.children.forEach(child => traverse(child, node.label)); + } + }; + + nodes.forEach(node => traverse(node)); + return leafNames; + }; + + const leafNameMap = getAllLeafNames(markets.value); // 所有叶子节点和对应父级名称 + + // 列表构建 + const parentToChildren = {}; + leafNameMap.forEach(({name, parent}) => { + if (!parentToChildren[parent]) parentToChildren[parent] = []; + parentToChildren[parent].push(name); + }); + + // 构建当前被选中的叶子节点 + const selectedLeafNames = value.map(path => path[path.length - 1]); + + // 如果 parent 下所有子节点都选中了,就把 parent 加进来 + Object.entries(parentToChildren).forEach(([parent, children]) => { + const allChildrenSelected = children.every(child => selectedLeafNames.includes(child)); + if (allChildrenSelected && reverseMarketMapping[parent]) { + ids.add(Number(reverseMarketMapping[parent])); + } + }); + + consumeUser.value.markets = Array.from(ids); } else { - consumeUser.value.market = ''; + consumeUser.value.markets = []; } + + console.log('最终映射后的 market IDs:', consumeUser.value.markets); }; +const props = {multiple: true} +// 获取地区,修改为级联下拉框 +const getMarket = async function () { + try { + // 发送POST请求 + const result = await API({ + + url: '/market/selectMarket', + }); + // 将响应结果存储到响应式数据中 + console.log('请求成功', result) + + // 递归转换树形结构为级联选择器需要的格式(跳过第一级节点) + const transformTree = (nodes) => { + // 直接处理第一级节点的子节点 + const allChildren = nodes.flatMap(node => node.children || []); + + return allChildren.map(child => { + const grandchildren = child.children && child.children.length + ? transformTree([child]) // 递归处理子节点 + : null; + + return { + value: child.name, + label: child.name, + children: grandchildren + }; + }); + }; + // 存储地区信息 + markets.value = transformTree(result.data) + console.log('转换后的地区树==============', markets.value) + } catch (error) { + console.log('请求失败', error) + } +} +