From ad1f744603fe2712324ed839716f7ace2ec47eee Mon Sep 17 00:00:00 2001 From: wujingjing <gersonwu@qq.com> Date: 星期一, 03 三月 2025 16:44:58 +0800 Subject: [PATCH] 完成核心内容 --- vite.config.ts | 2 src/components/chat/components/playBar/businessTable/index.vue | 66 ++++++++++++++++++++++++++------- 2 files changed, 53 insertions(+), 15 deletions(-) diff --git a/src/components/chat/components/playBar/businessTable/index.vue b/src/components/chat/components/playBar/businessTable/index.vue index 1082ee8..e886004 100644 --- a/src/components/chat/components/playBar/businessTable/index.vue +++ b/src/components/chat/components/playBar/businessTable/index.vue @@ -17,11 +17,12 @@ <template #aside> <!-- 鐩綍鏍� --> <LeftTreeByMgr + showCheckbox v-loading="treeLoading" class="h100" ref="leftTreeRef" :defaultProps="{ - id: 'id', + id: 'logicalId', label: 'title', children: 'children', }" @@ -31,7 +32,7 @@ :show-more-operate="false" :show-add="false" :current-node-key="currentListID" - :node-icon="() => 'ele-Document'" + :folder-icon="(_, data) => data.type === 'group'" @click="handleClickNode" > </LeftTreeByMgr> @@ -87,6 +88,7 @@ import LeftTreeByMgr from '/@/components/tree/leftTreeByMgr.vue'; import { useCompRef } from '/@/utils/types'; import { convertListToTree, debounce, travelTree } from '/@/utils/util'; +import { ElMessage } from 'element-plus'; const dialogIsShow = defineModel({ type: Boolean, }); @@ -97,11 +99,13 @@ }; const submitLoading = ref(false); const getSubmitData = async () => { + const checkedList = leftTreeRef.value?.treeRef.getCheckedNodes().filter((item) => item.type === 'item'); + submitLoading.value = true; - await getUnGetData().finally(() => { + await getUnGetData(checkedList).finally(() => { submitLoading.value = false; }); - const tables = listTreeData.value.map((item) => { + const tables = checkedList.map((item) => { return { title: item.title, columns: item.columns.map((item) => { @@ -117,6 +121,7 @@ }; const submitFormValue = async () => { const data = await getSubmitData(); + emit('submit', data); dialogIsShow.value = false; }; @@ -126,15 +131,39 @@ const listData = ref([]); const currentListID = computed(() => currentNode.value?.id); const currentNode = ref(null); +const getRowByLogicalId = (logicalId) => { + let row; + travelTree(listTreeData.value, (value, index, array, parent) => { + if (value.logicalId === logicalId) { + row = value; + + return true; + } + }); + return row; +}; const listTreeData = computed(() => { - const treeData = convertListToTree(listData.value, { - ID: 'id', - ParentID: 'group', + const listDataWithType = listData.value.map((item) => ({ + id: item.id, + logicalId: `item-${item.id}`, + logicalParentId: `group-${item.group}`, + ...item, + type: 'item', + })); + const groupList = Array.from(new Set(listDataWithType.filter((item) => item.group).map((item) => item.group))).map((item) => ({ + id: item, + title: item, + logicalId: `group-${item}`, + type: 'group', + })); + const treeData = convertListToTree(listDataWithType.concat(groupList), { + ID: 'logicalId', + ParentID: 'logicalParentId', Children: 'children', }); travelTree(treeData, (value, index, array, parent) => { - if (value.columns) { + if (value.type === 'item') { value.columns = value.columns.map((item) => { return { ...item, @@ -144,7 +173,6 @@ }); } }); - return treeData; }); /** @@ -157,8 +185,12 @@ }; const handleClickNode = (data) => { + if (data.type === 'group') { + ElMessage.warning('璇烽�夋嫨涓氬姟琛�'); + return; + } nextTick(() => { - leftTreeRef.value?.treeRef.setCurrentKey(data.id); + leftTreeRef.value?.treeRef.setCurrentKey(data.logicalId); }); currentNode.value = data; setOrderMap(data); @@ -170,7 +202,13 @@ treeLoading.value = false; }); listData.value = res.tables || []; - const firstListTreeNode = listTreeData.value[0]; + let firstListTreeNode; + travelTree(listTreeData.value, (value, index, array, parent) => { + if (value.type === 'item') { + firstListTreeNode = value; + return true; + } + }); if (firstListTreeNode) { handleClickNode(firstListTreeNode); } else { @@ -227,7 +265,7 @@ }); const getUnEmptyFilter = (columns) => { const result = columns - .map((item) => { + ?.map((item) => { return { col: item.name, filter: item.filter, @@ -318,9 +356,9 @@ handleSearchItem(currentNode.value, prop, order, column); }; -const getUnGetData = async () => { +const getUnGetData = async (checkedList: any[]) => { const getDataPromiseList = []; - for (const item of listTreeData.value) { + for (const item of checkedList) { if (!item.tableData) { getDataPromiseList.push(handleSearchItem(item)); } diff --git a/vite.config.ts b/vite.config.ts index 27dae42..1c82ca0 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -58,7 +58,7 @@ host: '0.0.0.0', port: env.VITE_PORT as unknown as number, open: JSON.parse(env.VITE_OPEN), - hmr: true, + hmr: false, proxy: { '/events': { target: 'http://localhost:3000', -- Gitblit v1.9.3