3f73d0f0 by xukangle

fix : 分类分级bug修改

1 parent 7daf9d9d
......@@ -90,6 +90,10 @@ const pageInfo = computed(() => {
return props.tableInfo.page;
});
// const expandRowKeys = computed(() => {
// return Array.isArray(props.tableInfo.expandedKey) ? props.tableInfo.expandedKey : [];;
// });
const tableRowClassName = (row, rowIndex) => {
if (rowIndex === 1) {
return "warning-row";
......@@ -236,7 +240,7 @@ onMounted(() => {
:show-header="props.tableInfo.showHeader ?? true" stripe :border="props.tableInfo.border
?? true" :height="props.tableInfo.height === null ? null : (props.tableInfo.height ?? '100%')"
:max-height="maxHeight" :row-key="rowKey" :current-row-key="currentRowKey" :row-class-name="rowClassName"
:expand-row-keys="props.tableInfo.expandRowKeys" v-loading="tableDataLoading" @row-click="rowClick"
:expand-row-keys="props.tableInfo.expandedKey" v-loading="tableDataLoading" @row-click="rowClick"
@row-dblclick="rowDblClick" @selection-change="selectionChange" @select="tableCheckboxSelectChange"
@select-all="tableCheckboxAllSelectChange" style="width: 100%; display: inline-block"
:style="{ 'min-height': props.tableInfo.minHeight ?? '200px' }" tooltip-effect="light"
......
......@@ -5,9 +5,15 @@ import useSettingsStore from '@/store/modules/settings'
import type { Menu } from '#/global'
import { getDownloadUrl, download } from "@/utils/common";
import { getImageContent } from "@/api/modules/queryService";
import {createSVG } from "@/utils/common"
import { createSVG } from "@/utils/common"
import { onBeforeMount } from "vue"
import { resolve } from 'path-browserify';
import { ElMessage } from "element-plus";
import {
parseAndDecodeUrl,
getDownFileSignByUrl,
obsDownloadRequest
} from '@/api/modules/obsService';
const props = defineProps({
item: {
type: Object as () => Menu.recordRaw,
......@@ -19,7 +25,7 @@ const props = defineProps({
},
})
const settingsStore = useSettingsStore()
const item1:any = ref()
const item1: any = ref()
const hasChildren = computed(() => {
let flag = true
if (props.item.children) {
......@@ -32,70 +38,79 @@ const hasChildren = computed(() => {
}
return flag
})
onBeforeMount( async ()=>{
await getSvgElement(props.item)
onBeforeMount(async () => {
await getSvgElement(props.item)
})
const getSvgElement = async (item:any)=>{
const getSvgElement = async (item: any) => {
console.log(item)
item1.value = item
//// return new Promise( async (reslove,inject)=>{
if(item1.value.meta.icon && item1.value.meta.icon.indexOf("https")>-1) {
const res1:any = await getImageContent(item1.value.meta?.icon)
let ele:any
if (res1 && !res1.msg) {
let name = item1.value.meta?.icon;
var fileSuffix = name ? name.substring(name.lastIndexOf('.') + 1) : '';
if (fileSuffix === 'svg') { //浏览器可以支持图片和pdf预览
let blob= getDownloadUrl(res1, name, fileSuffix,false) as Blob
ele = await createSVG(blob)
item1.value.meta.isEle = false
item1.value.meta.icon = ele
// reslove({})
}
//// return new Promise( async (reslove,inject)=>{
if (item1.value.meta.icon && item1.value.meta.icon.indexOf("https") > -1) {
const refSignInfo: any = await getDownFileSignByUrl(parseAndDecodeUrl(item1.value.meta.icon).fileName);
if (!refSignInfo?.data) {
refSignInfo?.msg && ElMessage.error(refSignInfo?.msg);
return;
}
console.log(refSignInfo, '------')
const res1: any = await obsDownloadRequest(refSignInfo?.data)
let ele: any
console.log(res1, '*********')
// if (res1 && !res1.msg) {
// ele = await createSVG(res1)
// item1.value.meta.isEle = false
// item1.value.meta.icon = ele
// // reslove({})
// }
}
// reslove(122)
}
// reslove(122)
// })
}
</script>
<template>
<div class="sidebar-item">
<router-link v-if="!hasChildren" v-slot="{ href, navigate, isActive, isExactActive }" custom :to="resolveRoutePath(basePath, item1.path)">
<a :href="item1.meta?.link ? item1.meta.link : href" :class="[isActive && 'router-link-active', isExactActive && 'router-link-exact-active']" :target="item.meta?.link ? '_blank' : '_self'" @click="navigate" v-preReClick>
<router-link v-if="!hasChildren" v-slot="{ href, navigate, isActive, isExactActive }" custom
:to="resolveRoutePath(basePath, item1.path)">
<a :href="item1.meta?.link ? item1.meta.link : href"
:class="[isActive && 'router-link-active', isExactActive && 'router-link-exact-active']"
:target="item.meta?.link ? '_blank' : '_self'" @click="navigate" v-preReClick>
<el-menu-item :title="item1.meta?.title ?? '[ 无标题 ]'" :index="resolveRoutePath(basePath, item1.path || '')">
<el-icon v-if="item1.meta?.icon" class="title-icon" >
<el-icon v-if="item1.meta?.icon" class="title-icon">
<!-- <img :src="item.meta.icon" v-if="item.meta.icon.indexOf('http')>-1" alt=""> -->
<!-- {{ item.meta.icon }} -->
<template v-if="item1.meta.icon.indexOf('svg')>-1">
<template v-if="item1.meta.icon.indexOf('svg') > -1">
<i v-html="item1.meta.icon" :key="item1.meta.icon" v-if="!item1.meta.isEle"></i>
</template>
<template v-else>
<svg-icon :name="item1.meta.icon"/>
<svg-icon :name="item1.meta.icon" />
</template>
</el-icon>
<span class="title">{{ item1.meta?.title ?? '[ 无标题 ]' }}</span>
</el-menu-item>
</a>
</router-link>
<el-sub-menu v-else :title="item1.meta?.title ?? '[ 无标题 ]'" :index="settingsStore.settings.app.routeBaseOn !== 'filesystem' ? resolveRoutePath(basePath, item1.path) : JSON.stringify(item1)">
<el-sub-menu v-else :title="item1.meta?.title ?? '[ 无标题 ]'"
:index="settingsStore.settings.app.routeBaseOn !== 'filesystem' ? resolveRoutePath(basePath, item1.path) : JSON.stringify(item1)">
<template #title>
<el-icon v-if="item1.meta?.icon" class="title-icon" >
<el-icon v-if="item1.meta?.icon" class="title-icon">
<!-- <img :src="item.meta.icon" v-if="item.meta.icon.indexOf('http')>-1" alt="">
<svg-icon :name="item.meta.icon" v-else /> -->
<template v-if="item1.meta.icon.indexOf('svg')>-1">
<i v-html="item1.meta.icon" :key="item1.meta.icon" v-if="!item1.meta.isEle"></i>
</template>
<template v-else>
<svg-icon :name="item1.meta.icon"/>
</template>
<template v-if="item1.meta.icon.indexOf('svg') > -1">
<i v-html="item1.meta.icon" :key="item1.meta.icon" v-if="!item1.meta.isEle"></i>
</template>
<template v-else>
<svg-icon :name="item1.meta.icon" />
</template>
</el-icon>
<span class="title">{{ item.meta?.title ?? '[ 无标题 ]' }}</span>
</template>
<template v-for="route in (item1.children as Menu.recordRaw[])">
<SidebarItem v-if="route.meta?.sidebar !== false" :key="route.path" :item="route" :base-path="resolveRoutePath(basePath, item1.path)" />
<SidebarItem v-if="route.meta?.sidebar !== false" :key="route.path" :item="route"
:base-path="resolveRoutePath(basePath, item1.path)" />
</template>
</el-sub-menu>
</div>
......@@ -128,7 +143,7 @@ const getSvgElement = async (item:any)=>{
color: #B2B2B2;
}
.title-icon + .title {
.title-icon+.title {
margin-left: 10px;
}
......@@ -154,7 +169,7 @@ a {
}
.el-sub-menu__title {
> .badge {
>.badge {
&-dot {
right: 40px;
}
......@@ -171,7 +186,7 @@ a {
background-color: var(--g-sub-sidebar-menu-bg) !important;
.el-menu-item,
.el-sub-menu > .el-sub-menu__title {
.el-sub-menu>.el-sub-menu__title {
color: var(--g-sub-sidebar-menu-color);
background-color: var(--g-sub-sidebar-menu-bg) !important;
......@@ -194,7 +209,7 @@ a {
}
.el-menu-item.is-active,
.el-menu--collapse .el-sub-menu.is-active > .el-sub-menu__title,
.el-menu--collapse .el-sub-menu.is-active>.el-sub-menu__title,
.el-sub-menu .el-menu--inline .el-menu-item.is-active {
color: var(--g-sub-sidebar-menu-active-color) !important;
background-color: var(--g-sub-sidebar-menu-active-bg) !important;
......@@ -203,10 +218,12 @@ a {
.el-sub-menu__icon-arrow {
color: unset;
}
.title-icon {
color: var(--g-sub-sidebar-menu-active-color);
}
}
svg {
g {
fill: inherit !important;
......
......@@ -80,7 +80,7 @@ const drawerRef = ref<any>('');
const heightlightRow = ref<any>('');
const scopeRow = ref<any>(null);
const tableInfo = ref({
id: "data-class-standard-table",
id: "data-class-table",
multiple: false,
fields: [
{ label: "序号", type: "index", width: 56, align: "center" },
......@@ -110,7 +110,7 @@ const tableInfo = ref({
data: [],
rowKey: 'guid',
currentRowKey: '',
expandedKeys: [] as any,
expandedKey: [],
showPage: false,
actionInfo: {
label: "操作",
......@@ -119,6 +119,7 @@ const tableInfo = ref({
btns: [
{
label: "编辑", value: "edit", click: (scope) => {
console.log(scope);
tableInfo.value.currentRowKey = scope.row.guid;
heightlightRow.value = scope.row.guid;
scopeRow.value = scope.row;
......@@ -823,11 +824,40 @@ const handleTableRowClick = (row, id) => {
tableInfo.value.currentRowKey = row.guid;
}
const findParentsGuids = (treeList, targetGuid) => {
let result = null;
const recursiveSearch = (nodes) => {
for (let node of nodes) {
if (node.guid === targetGuid) {
result = node.parentGuids;
return;
}
if (node.children) {
recursiveSearch(node.children);
}
}
};
recursiveSearch(treeList);
return result;
};
const drawerSelectChange = (val, row, info) => {
const tree = tableRef.value.tableRef;
console.log(val, row, info, tree);
tableInfo.value.expandedKeys.push(val);
console.log(tableInfo.value.expandedKeys);
if (row.field === 'gradeGuid') {
return;
}
tableInfo.value.expandedKey = [];
const parentGuids: any = findParentsGuids(treeListData.value, val);
if (parentGuids) {
tableInfo.value.expandedKey.push(val);
parentGuids.forEach((guid) => {
tableInfo.value.expandedKey.push(guid);
});
} else {
console.log('No matching item found.');
}
}
</script>
......
......@@ -30,8 +30,6 @@ import {
import { TableColumnWidth } from "@/utils/enum";
import router from "@/router";
import { download } from "@/utils/common";
import { getLabelList } from "@/api/modules/dataLabel";
import { de } from "element-plus/es/locale";
const currentPath = ref<string[]>([]);
const currentDatabasePath = ref<string[]>([]);
......@@ -485,7 +483,7 @@ const dataBaseTreeInfo = ref<any>({
value: "guid",
},
nodeKey: 'guid',
expandedKey: ['0'],
expandedKey: [] as any,
currentNodeKey: '',
expandOnNodeClick: false,
data: [],
......@@ -565,7 +563,8 @@ const dataBaseTableInfo = ref({
databaseChName: scope.row.databaseChName,
}
});
}
},
disabled: scope.row.state == 0 ? true : false
},
{
label: "编辑表结构", value: "edit", click: (scope) => {
......@@ -870,7 +869,6 @@ const drawerBtnClick = async (btn, info) => {
execGuid: execGuidInfo.value.execGuid,
classifyDetail: classifyDetailGuidInfo.value,
gradeDetailGuid: levelGuidInfo.value,
labelGuid: labelGuidInfo.value,
databaseGuid: selectedA.value,
tableGuid: selectedB.value,
fieldGuid: selectedC.value,
......@@ -940,14 +938,31 @@ const getDataBaseTreeData = async () => {
const dataArray = res.data;
// 遍历并添加 GUIDs
dataArray.forEach(addGuids);
console.log('dataArray', dataArray, localStorage.getItem("onActiveInfo"));
// 更新到绑定的响应式数据
dataBaseTreeData.value = dataArray;
dataBaseTreeInfo.value.data = dataArray;
if (localStorage.getItem("shouldReloadData")) {
console.log('reload');
dataBaseTreeInfo.value.expandedKey = [];
const info = JSON.parse(localStorage.getItem("onActiveInfo") || '{}');
dataBaseTreeInfo.value.expandedKey.push(dataArray[info.dbindex].guid);
dataBaseTreeInfo.value.currentNodeKey = dataArray[info.dbindex].guid;
dataBaseGuid.value = dataArray[info?.dbindex].databaseGuid;
currentDatabasePath.value = info?.path;
if (dataArray[info?.dbindex].dicType === 1) {
isShowCreateBtn.value = true;
}
if (dataArray[info?.dbindex].dicType === 2) {
isShowCreateBtn.value = false;
}
dataBaseTreeInfo.value.loading = false;
return;
}
dataBaseTreeInfo.value.expandedKey.push(dataArray[0].guid);
dataBaseTreeInfo.value.currentNodeKey = dataArray[0].guid;
dataBaseGuid.value = dataArray[0].databaseGuid;
currentDatabasePath.value = [dataArray[0].name];
console.log('dataArray', dataArray);
if (dataArray[0].dicType === 1) {
isShowCreateBtn.value = true;
}
......@@ -1110,11 +1125,23 @@ const tableGuid = ref('');
const dataBaseGuid = ref('');
const dataBaseInfo = ref<any>({});
// 记录onActive的信息
const onActiveInfo = ref<any>({});
const dataBasenodeClick = (data: any) => {
isShowCreateBtn.value = false;
console.log('dataBasenodeClick', data, dataBaseTreeData.value);
console.log('dataBasenodeClick', data.databaseGuid, dataBaseTreeData.value);
// 找到data.databaseGuid 在dataBaseTreeData.value 中的下标索引,普通数组遍历就行
const dbindex = dataBaseTreeData.value.findIndex((item) => {
return item.guid === data.databaseGuid;
});
const path = findDDatabasePath(dataBaseTreeData.value, data.guid);
console.log('path', path);
onActiveInfo.value = {
dbindex,
path
}
localStorage.setItem('onActiveInfo', JSON.stringify(onActiveInfo.value));
if (path) {
currentDatabasePath.value = path;
} else {
......@@ -1230,7 +1257,6 @@ const addIsShowDatabaseTip = () => {
const activeTab = ref('table');
const isShowWordSearch = ref(true);
const setActiveTab = (tab) => {
console.log('setActiveTab', tab);
activeTab.value = tab;
if (tab === 'word' && activeName.value === 'second') {
searchItemList.value[0].visible = true;
......@@ -1422,8 +1448,7 @@ const exportDB = async () => {
}
// 标签guid
const labelGuidInfo = ref('');
// 分级guid信息
const levelGuidInfo = ref('');
// 标签选择
......@@ -1436,11 +1461,11 @@ const selectChange = (val, row, info) => {
// 这里应该是onActivated 钩子,路由从configure-路由从configure-rules跳转过来要重新请求数据、
onActivated(async () => {
if (route.query.reload === 'true') {
if (localStorage.getItem('shouldReloadData') === 'true') {
await getExecGuid();
activeName.value = 'second';
getDataBaseTreeData();
getDataBaseTableData({
await getDataBaseTreeData();
await getDataBaseTableData({
exexGuid: execGuidInfo.value.execGuid
});
getDataBaseFieldData(
......@@ -1449,14 +1474,25 @@ onActivated(async () => {
}
);
getDbDirTableSelectData(1, {});
localStorage.removeItem('shouldReloadData');
}
});
const gradeTreeRef = ref<any>();
const treeSelectNodeClick = (node, item) => {
console.log('treeSelectNodeClick', node, item);
classifyDetailGuidInfo.value = node.classifyDetailGuid;
treeInfo.value.expandedKey = [];
treeInfo.value.expandedKey.push(node.classifyDetailGuid);
treeInfo.value.currentNodeKey = node.classifyDetailGuid;
const path = findPath(CgDirTreeList.value, node.guid);
if (path) {
currentPath.value = path;
console.log('找到路径:', path);
} else {
console.error('未找到路径');
}
console.log('treeSelectNodeClick', treeInfo.value.expandedKey);
}
</script>
......@@ -1483,7 +1519,7 @@ const treeSelectNodeClick = (node, item) => {
<div class="aside_wrap">
<el-tabs v-model="activeName" class="v-tabs" @tab-click="handleClick">
<el-tab-pane label="分类分级目录" name="first">
<Tree :treeInfo="treeInfo" @nodeClick="nodeClick" />
<Tree :treeInfo="treeInfo" @nodeClick="nodeClick" ref="gradeTreeRef" />
<!-- <Tree ref="treeInfoRef" :treeInfo="treeInfo" @nodeClick="nodeClick" /> -->
</el-tab-pane>
<el-tab-pane label="数据库目录" name="second">
......
......@@ -138,8 +138,10 @@ const findRefGradeGuid = (data, targetClassifyDetailGuid) => {
};
const refGradeGuid = ref<any>('');
const editRow = (row) => {
console.log('row', row)
// 进入编辑模式时,查找classifyDetailGuid所在的refGradeGuid
refGradeGuid.value = findRefGradeGuid(treeSelectOptions.value, row.classifyDetailGuid);
console.log('refGradeGuid', refGradeGuid.value)
if (refGradeGuid.value) {
getGradeList({ classifyGradeGuid: refGradeGuid.value.refGradeGuid, pageIndex: 1, pageSize: -1 }).then((res: any) => {
if (res.code === proxy.$passCode) {
......@@ -294,6 +296,7 @@ const findDDatabasePath = (data: any[], targetGuid: string, path: string[] = [],
// 存储分级数据
const gradeInfo = ref<any>();
const handleClassifyChange = (row, value) => {
console.log('row2', row, value)
const pathInfo = findDDatabasePath(treeSelectOptions.value, value)
row.classifyDetailNameRoutes = pathInfo.path;
row.classifyDetailGuidRoutes = pathInfo.route;
......@@ -302,25 +305,42 @@ const handleClassifyChange = (row, value) => {
// row.gradeOptions = [];
// return;
// }
// refGradeGuid.value = findRefGradeGuid(treeSelectOptions.value, row.classifyDetailGuid);
// row.classifyDetailName = refGradeGuid.value.classifyName;
// getGradeList({ classifyGradeGuid: refGradeGuid.value.refGradeGuid, pageIndex: 1, pageSize: -1 }).then((res: any) => {
// if (res.code === proxy.$passCode) {
// row.gradeOptions = res.data.records || [];
// } else {
// ElMessage.error(res.msg);
// }
// });
// if (gradeInfo.value) {
// refGradeGuid.value = findRefGradeGuid(treeSelectOptions.value, row.classifyDetailGuid);
// row.classifyDetailName = refGradeGuid.value.classifyName;
// getGradeList({ classifyGradeGuid: refGradeGuid.value.refGradeGuid, pageIndex: 1, pageSize: -1 }).then((res: any) => {
// if (res.code === proxy.$passCode) {
// row.gradeOptions = res.data.records || [];
// } else {
// ElMessage.error(res.msg);
// }
// });
// }
};
const handleNodeClick = (row, node, data) => {
console.log('row1', row, node, data)
// 在gradeInfo找到item.guid === row.gradeGuid
const matchedItem = gradeInfo.value.find((item) => item.guid === node.gradeGuid);
if (matchedItem) {
row.gradeDetailGuid = matchedItem.guid;
row.gradeDetailName = matchedItem.name;
if (gradeInfo.value) {
const matchedItem = gradeInfo.value.find((item) => item.guid === node.gradeGuid);
if (matchedItem) {
row.gradeDetailGuid = matchedItem.guid;
row.gradeDetailName = matchedItem.name;
}
} else {
getGradeList({ classifyGradeGuid: node.refGradeGuid, pageIndex: 1, pageSize: -1 }).then((res: any) => {
if (res.code === proxy.$passCode) {
gradeInfo.value = res.data.records || [];
row.gradeOptions = res.data.records || [];
const matchedItem = gradeInfo.value.find((item) => item.guid === node.gradeGuid);
row.gradeDetailGuid = matchedItem.guid;
row.gradeDetailName = matchedItem.name;
} else {
ElMessage.error(res.msg);
}
});
}
}
const isPrevious = ref(false);
......@@ -763,12 +783,14 @@ const saveOrUpdate = async (params: any = {}, type) => {
if (params.isDraft === 'Y') {
proxy.$ElMessage.success('保存为草稿成功!');
userStore.setTabbar(userStore.tabbar.filter((tab: any) => tab.fullPath !== fullPath));
router.push({ name: 'classifyGradeCatalogue', query: { reload: 'true' } });
localStorage.setItem('shouldReloadData', 'true');
router.push({ name: 'classifyGradeCatalogue' });
return
}
proxy.$ElMessage.success('保存成功!');
userStore.setTabbar(userStore.tabbar.filter((tab: any) => tab.fullPath !== fullPath));
router.push({ name: 'classifyGradeCatalogue', query: { reload: 'true' } });
localStorage.setItem('shouldReloadData', 'true');
router.push({ name: 'classifyGradeCatalogue' });
} else {
saveBtn.value = false
proxy.$ElMessage.error(res.msg);
......@@ -780,7 +802,7 @@ const saveOrUpdate = async (params: any = {}, type) => {
if (res1.code === proxy.$passCode) {
proxy.$ElMessage.success('编辑成功!');
userStore.setTabbar(userStore.tabbar.filter((tab: any) => tab.fullPath !== fullPath));
router.push({ name: 'classifyGradeCatalogue', query: { reload: 'true' } });
router.push({ name: 'classifyGradeCatalogue' });
} else {
saveBtn.value = false
proxy.$ElMessage.error(res1.msg);
......
......@@ -1487,7 +1487,8 @@ const saveTable = async () => {
if (res.code === proxy.$passCode) {
proxy.$ElMessage.success('保存成功!');
userStore.setTabbar(userStore.tabbar.filter((tab: any) => tab.fullPath !== fullPath));
router.push({ name: 'classifyGradeCatalogue', query: { reload: 'true' } });
localStorage.setItem('shouldReloadData', 'true');
router.push({ name: 'classifyGradeCatalogue' });
} else {
proxy.$ElMessage.error(res.msg);
}
......@@ -1610,7 +1611,8 @@ const saveDraftTable = async () => {
if (res.code === proxy.$passCode) {
proxy.$ElMessage.success('保存草稿成功!');
userStore.setTabbar(userStore.tabbar.filter((tab: any) => tab.fullPath !== fullPath));
router.push({ name: 'classifyGradeCatalogue', query: { reload: 'true' } });
localStorage.setItem('shouldReloadData', 'true');
router.push({ name: 'classifyGradeCatalogue' });
} else {
proxy.$ElMessage.error(res.msg);
}
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!