商品名称:
-
@@ -594,11 +625,14 @@ const handleMarketChange = (value) => {
所属地区:
diff --git a/src/views/recharge/coinRechargeDetail.vue b/src/views/recharge/coinRechargeDetail.vue
index 52cb5da..a77bd3a 100644
--- a/src/views/recharge/coinRechargeDetail.vue
+++ b/src/views/recharge/coinRechargeDetail.vue
@@ -179,13 +179,11 @@ const getActivity = async function () {
const marketsTree = ref("")
// 获取地区,修改为级联下拉框
const getArea = async function () {
- console.log('获取地区adminid', adminData.value)
try {
// 发送POST请求
const result = await API({
url: '/market/selectMarket',
- data: {account: adminData.value.account}
});
// 将响应结果存储到响应式数据中
console.log('请求成功', result)
diff --git a/src/views/refund/coinRefundDetail.vue b/src/views/refund/coinRefundDetail.vue
index f590651..eefb11d 100644
--- a/src/views/refund/coinRefundDetail.vue
+++ b/src/views/refund/coinRefundDetail.vue
@@ -47,7 +47,9 @@ const getAdminData = async function () {
const tableData = ref([])
// 搜索======================================
// 搜索detail
-const refundUser = ref({})
+const refundUser = ref({
+ markets:[]
+})
// 搜索对象
const getObj = ref({
pageNum: 1,
@@ -59,7 +61,7 @@ const total = ref(100)
const getTime = ref([])
// 搜索地区列表
-const market = ref([])
+const markets = ref([])
// 定义响应式变量存储金币合计数
const permanentGolds = ref(0)
@@ -183,7 +185,7 @@ const search = function () {
}
// 重置
const reset = function () {
- refundUser.value = {}
+ refundUser.value = {markets: []}
sortField.value = ''
sortOrder.value = ''
getTime.value = {}
@@ -265,49 +267,6 @@ const handleClick = function (tab, event) {
}
}
-// 获取地区,修改为级联下拉框
-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 delObj = ref({})
const del = function (row) {
delObj.value.detailId = row.detailId
@@ -403,7 +362,7 @@ const exportExcel = async function () {
refundUser: {
jwcode: refundUser.value.jwcode || '',
refundModel: refundUser.value.refundModel || '',
- market: refundUser.value.market || '',
+ markets: refundUser.value.markets || [],
startTime: refundUser.value.startTime || '',
endTime: refundUser.value.endTime || '',
goodsName: refundUser.value.goodsName || '',
@@ -504,18 +463,95 @@ const getTagText = (state) => {
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;
-
- // 反向映射
- refundUser.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]));
+ }
+ });
+
+ refundUser.value.markets = Array.from(ids);
} else {
- refundUser.value.market = '';
+ refundUser.value.markets = [];
}
+
+ console.log('最终映射后的 markets IDs:', refundUser.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)
+ }
+}
@@ -559,11 +595,14 @@ const handleMarketChange = (value) => {
所属地区:
diff --git a/src/views/usergold/clientCountBalance.vue b/src/views/usergold/clientCountBalance.vue
index 8e0aa1b..03704eb 100644
--- a/src/views/usergold/clientCountBalance.vue
+++ b/src/views/usergold/clientCountBalance.vue
@@ -26,48 +26,8 @@ const getAdminData = async function () {
// 定义加载状态,获取地区数据
const isLoadingmarket = ref(false);
-const market = ref([])
-// 获取地区,修改为级联下拉框
-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 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 tableData = ref([])
@@ -94,7 +54,9 @@ const total = ref(100)
// 搜索对象时间
const getTime = ref([])
// 搜索User
-const user = ref({})
+const user = ref({
+ markets: [],
+})
// 不分页的搜索对象
const getAllObj = ref({})
// 搜索对象
@@ -205,7 +167,7 @@ const search = function () {
}
// 重置
const reset = function () {
- user.value = {}
+ user.value = {markets: []}
sortField.value = ''
sortOrder.value = ''
get()
@@ -341,18 +303,96 @@ const getTagText = (state) => {
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;
-
- // 反向映射
- rechargeUser.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]));
+ }
+ });
+
+ user.value.markets = Array.from(ids);
} else {
- rechargeUser.value.market = '';
+ user.value.markets = [];
}
+
+ console.log('最终映射后的 market IDs:', user.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)
+ }
+}
+
@@ -368,11 +408,14 @@ const handleMarketChange = (value) => {
所属地区:
查询
diff --git a/src/views/usergold/clientCountDetail.vue b/src/views/usergold/clientCountDetail.vue
index 00f3f1b..3ae28ce 100644
--- a/src/views/usergold/clientCountDetail.vue
+++ b/src/views/usergold/clientCountDetail.vue
@@ -7,7 +7,7 @@ import moment from 'moment'
import API from '@/util/http'
import {writeFile, utils} from 'xlsx'
import request from "@/util/request.js";
-import {marketMapping} from "../../utils/marketMap.js";
+import {marketMapping, reverseMarketMapping} from "../../utils/marketMap.js";
// 标记当前激活的时间范围按钮
const activeTimeRange = ref('')
@@ -90,48 +90,9 @@ const type = [
// 定义加载状态,获取地区数据
// 定义加载状态,获取地区数据
const isLoadingmarket = ref(false);
-const market = ref([])
+const markets = ref([])
-const getmarket = async () => {
- isLoadingmarket.value = true;
- try {
- const result = await API({
- url: '/general/adminMarkets',
- data: {account: adminData.value.account}
- });
- console.log('获取地区数据成功', result)
- // 假设后端返回的是字符串数组,转换为 { value, label } 格式
- if (Array.isArray(result.data) && typeof result.data[0] === 'string') {
- market.value = result.data
- .filter(item => item !== null && item !== undefined && item.trim() !== '') // 过滤空值
- .map(item => ({ value: item, label: item }));
- } else {
- market.value = result.data;
- }
- } catch (error) {
- console.error('获取地区数据失败:', error);
- ElMessage.error('获取地区数据失败,请稍后重试');
- // 可以提供默认数据
- market.value = [];
- } finally {
- isLoadingmarket.value = false;
- }
-};
-/*// 地区下拉框
-const getMarket = async function () {
- try {
- const result = await API({
- url: '/general/market',
- data: {}
- })
- console.log('@@@@@@@@@@@@@地区数据', result)
- market.value = result.data
- console.log('@@@@@@@@@@@@@@@@地区', market.value)
- } catch (error) {
- console.log('请求失败', error)
- }
-}*/
// 充值明细表格
const tableData = ref([])
@@ -146,7 +107,9 @@ const total = ref(100)
// 搜索对象时间
const getTime = ref([])
// 搜索goldDetail
-const goldDetail = ref({})
+const goldDetail = ref({
+ markets: [],
+})
// 搜索对象
const getObj = ref({
pageNum: 1,
@@ -239,7 +202,8 @@ const reset = function () {
delete goldDetail.value.type
delete goldDetail.value.startTime
delete goldDetail.value.endTime
- delete goldDetail.value.markets
+ // delete goldDetail.value.markets
+ goldDetail.value.markets = []
delete sortField.value
delete sortOrder.value
getTime.value = []
@@ -368,7 +332,7 @@ const handleCurrentChange = function (val) {
onMounted(async function () {
await getAdminData()
await get()
- await getmarket()
+ await getMarket()
await getPlatform() // 调用获取平台信息的函数
})
@@ -446,24 +410,103 @@ const getTagText = (state) => {
return '未知状态';
}
}
-const handleMarketChange = (val) => {
- if (!Array.isArray(val)) return
- const hasHeadquarters = val.includes('总部')
- const hasOther = val.some(item => item !== '总部')
- if (hasHeadquarters && hasOther) {
- if (val[val.length - 1] === '总部') {
- // 用户最后点的是总部,保留总部,清除其他
- goldDetail.value.markets = ['总部']
- ElMessage.warning('“总部”与其他地区不可同时选择,系统已为您保留“总部”')
- } else {
- // 用户最后点的是其他,保留其他,移除总部
- goldDetail.value.markets = val.filter(item => item !== '总部')
- ElMessage.warning('“总部”与其他地区不可同时选择,系统已为您去除“总部”')
- }
+
+// 存储地区选择变化
+const selectedMarketPath = ref([])
+//处理地区选择变化
+const handleMarketChange = (value) => {
+ 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]));
+ }
+ });
+
+ goldDetail.value.markets = Array.from(ids);
+ } else {
+ goldDetail.value.markets = [];
+ }
+
+ console.log('最终映射后的 market IDs:', goldDetail.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)
}
}
+
@@ -498,16 +541,17 @@ const handleMarketChange = (val) => {
所属地区:
-
-
-
+