Commit 9ab5a41c authored by chenjiahao's avatar chenjiahao

数据质量-质量模板-树结构修改

parent dbc23aab
<template>
<div class="m-4 mr-0 overflow-hidden bg-white">
<BasicTree
title="质量模"
title="质量模"
ref="treeRef"
toolbar
search
......@@ -9,7 +9,7 @@
:clickRowToExpand="true"
:defaultExpandAll="true"
:treeData="treeData"
:fieldNames="{ key: 'key', title: 'title' }"
:fieldNames="{ key: 'businessId', title: 'QualityName' }"
@select="handleSelect"
/>
</div>
......@@ -19,7 +19,7 @@
import { BasicTree, TreeActionType, TreeItem } from '@/components/Tree';
import { getDeptList } from '@/api/system/dept/dept';
import { Nullable } from '@vben/types';
import { treeDataList } from './mock';
import { TreeData } from './mock';
defineOptions({ name: 'DeptTree' });
......@@ -29,7 +29,7 @@
const treeRef = ref<Nullable<TreeActionType>>(null);
async function fetch() {
treeData.value = treeDataList;
treeData.value = handleTree(TreeData, 'businessId', undefined, undefined, undefined);
await nextTick(() => {
getTree().expandAll(true);
});
......@@ -42,6 +42,36 @@
return tree;
}
/**数组对象转成树*/
function handleTree(data, id, parentId, children, rootId) {
id = id || 'id';
parentId = parentId || 'parentId';
children = children || 'children';
rootId =
rootId ||
Math.min.apply(
Math,
data.map((item) => {
return item[parentId];
}),
) ||
0;
// 对源数据深度克隆
const cloneData = JSON.parse(JSON.stringify(data));
// 循环所有项
const treeData = cloneData.filter((father) => {
const branchArr = cloneData.filter((child) => {
// 返回每一项的子级数组
return father[id] === child[parentId];
});
branchArr.length > 0 ? (father.children = branchArr) : '';
// 返回第一层
return father[parentId] === rootId;
});
return treeData !== '' ? treeData : data;
}
function handleSelect(keys) {
emit('select', keys[0]);
}
......
......@@ -189,139 +189,55 @@ export const treeDataListTwo = [
export const TreeData: any[] = [
{
delFlag: '0',
flag: '1',
businessId: 100,
fileName: '任务流',
anotherName: '任务流',
QualityName: '质量模版',
anotherName: '质量模版',
parentId: 0,
'code:': '001',
ancestors: '0',
orderNum: 0,
selectType: null,
location: '/任务流',
holder: 'admin',
createDate: '2024-10-24 10:04:04',
updateDate: '2024-10-24 10:04:04',
icon: 'ant-design:partition-outlined',
location: '/质量模版',
icon: 'ant-design:folder-open-outlined',
},
{
delFlag: '0',
flag: '1',
businessId: 101,
fileName: '典型案例',
anotherName: '典型案例',
QualityName: 'CEA_POC_模版',
anotherName: 'CEA_POC_模版',
parentId: 100,
'code:': '002',
ancestors: '0,100',
orderNum: 1,
selectType: null,
location: '/任务流/典型案例',
holder: 'admin',
createDate: '2024-10-24 10:04:04',
updateDate: '2024-10-24 10:04:04',
icon: 'ant-design:folder-open-outlined',
},
{
delFlag: '0',
flag: '1',
businessId: 107,
fileName: '个人体验',
anotherName: '个人体验',
businessId: 102,
QualityName: '数据中台工作区01',
anotherName: '数据中台工作区01',
parentId: 100,
'code:': '003',
ancestors: '0,100',
orderNum: 2,
selectType: null,
location: '/任务流/个人体验',
holder: 'admin',
createDate: '2024-10-24 10:04:04',
updateDate: '2024-10-24 10:04:04',
location: '/质量模版/数据中台工作区01',
icon: 'ant-design:folder-open-outlined',
},
{
delFlag: '0',
flag: '1',
businessId: 201,
fileName: '总-智慧财务总体流程',
anotherName: '总-智慧财务总体流程',
parentId: 101,
'code:': '005',
ancestors: '0,100,101',
orderNum: 2,
selectType: null,
location: '/任务流/典型案例/总-智慧财务总体流程',
holder: 'admin',
createDate: '2024-10-22 8:04:04',
updateDate: '2024-10-22 8:04:04',
QualityName: '值域检查(倍数)',
anotherName: '值域检查(倍数)',
parentId: 102,
ancestors: '0,100,102',
location: '/质量模版/数据中台工作区01/值域检查(倍数)',
icon: 'ant-design:partition-outlined',
},
{
delFlag: '0',
flag: '1',
businessId: 202,
fileName: '分-落地区',
anotherName: '分-落地区',
parentId: 101,
'code:': '006',
ancestors: '0,100,101',
orderNum: 3,
selectType: null,
location: '/任务流/典型案例/分-落地区',
holder: 'admin',
createDate: '2024-10-21 9:04:04',
updateDate: '2024-10-21 9:04:04',
QualityName: '值域检查(数值大于零)',
anotherName: '值域检查(数值大于零)',
parentId: 102,
ancestors: '0,100,102',
location: '/质量模版/数据中台工作区01/值域检查(数值大于零)',
icon: 'ant-design:partition-outlined',
},
{
delFlag: '0',
flag: '1',
businessId: 203,
fileName: '分-改良区',
anotherName: '分-改良区',
businessId: 204,
QualityName: '准取检查-数值大于等于n',
anotherName: '准取检查-数值大于等于n',
parentId: 101,
'code:': '008',
ancestors: '0,100,101',
orderNum: 5,
selectType: null,
location: '/任务流/典型案例/分-改良区',
holder: 'admin',
createDate: '2024-10-23 12:04:04',
updateDate: '2024-10-23 12:04:04',
icon: 'ant-design:partition-outlined',
},
{
delFlag: '0',
flag: '1',
businessId: 204,
fileName: '分-个人体验1',
anotherName: '分-个人体验1',
parentId: 107,
'code:': '009',
ancestors: '0,100,107',
orderNum: 1,
selectType: null,
location: '/任务流/典型案例/分-个人体验1',
holder: 'admin',
createDate: '2024-10-24 13:04:04',
updateDate: '2024-10-24 13:04:04',
icon: 'ant-design:partition-outlined',
},
{
delFlag: '0',
flag: '0',
businessId: 205,
fileName: '分-个人体验2',
anotherName: '分-个人体验2',
parentId: 107,
'code:': '010',
ancestors: '0,100,107',
orderNum: 2,
selectType: null,
location: '/任务流/典型案例/分-个人体验2',
holder: 'admin',
createDate: '2024-10-24 14:04:04',
updateDate: '2024-10-25 14:04:04',
location: '/质量模版/CEA_POC_模版/准取检查-数值大于等于n',
icon: 'ant-design:partition-outlined',
},
];
......@@ -14,10 +14,8 @@
import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form';
import { MoveFormSchema } from './tempalte.data';
import { getDeptList } from '@/api/system/dept/dept';
import { resetUserPwd } from '@/api/system/user/user';
import { useMessage } from '@/hooks/web/useMessage';
import { TreeData } from '@/views/dataQuality/template/mock';
import { TreeData } from './mock';
defineOptions({ name: 'AccountModal' });
......@@ -41,24 +39,24 @@
});
//初始化弹框
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
console.log('data', data)
//每次点击弹窗 需要清空存储的数据
rowData.value = [];
isMove.value = data.isMove;
//重置表单数据
resetFields();
setModalProps({ confirmLoading: false });
if (data.idList != null && data.idList.length > 0) {
/* empty */
} else {
rowData.value.push(data.record);
//单个移动
rowId.value = data.record.businessId;
data.record.taskId = data.record.businessId;
setFieldsValue({
...data.record,
});
}
console.log('data', data);
// //每次点击弹窗 需要清空存储的数据
// rowData.value = [];
// isMove.value = data.isMove;
// //重置表单数据
// resetFields();
// setModalProps({ confirmLoading: false });
// if (data.idList != null && data.idList.length > 0) {
// /* empty */
// } else {
// rowData.value.push(data.record);
// //单个移动
// rowId.value = data.record.businessId;
// data.record.taskId = data.record.businessId;
// setFieldsValue({
// ...data.record,
// });
// }
const treeList = handleTree(TreeData, 'businessId', undefined, undefined, undefined);
updateSchema([
{
......
......@@ -31,7 +31,7 @@
import { formSchemaNewFolder } from './tempalte.data';
import TreeTwo from './treeTwo.vue';
import { useMessage } from '@/hooks/web/useMessage';
import { treeDataList } from '@/views/dataQuality/template/mock';
import { TreeData, treeDataList } from '@/views/dataQuality/template/mock';
defineOptions({ name: 'AccountModal' });
......@@ -63,11 +63,45 @@
});
}
updateSchema({
const treeList = handleTree(TreeData, 'businessId', undefined, undefined, undefined);
updateSchema([
{
field: 'path',
componentProps: { treeData: treeDataList },
componentProps: {
treeData: treeList,
},
},
]);
});
/**数组对象转成树*/
function handleTree(data, id, parentId, children, rootId) {
id = id || 'id';
parentId = parentId || 'parentId';
children = children || 'children';
rootId =
rootId ||
Math.min.apply(
Math,
data.map((item) => {
return item[parentId];
}),
) ||
0;
// 对源数据深度克隆
const cloneData = JSON.parse(JSON.stringify(data));
// 循环所有项
const treeData = cloneData.filter((father) => {
const branchArr = cloneData.filter((child) => {
// 返回每一项的子级数组
return father[id] === child[parentId];
});
branchArr.length > 0 ? (father.children = branchArr) : '';
// 返回第一层
return father[parentId] === rootId;
});
return treeData !== '' ? treeData : data;
}
const getTitle = computed(() => (!unref(isUpdate) ? '新建主体' : '编辑主体'));
......
......@@ -63,7 +63,7 @@ export const MoveFormSchema: any[] = [
componentProps: {
// border: 'none',
fieldNames: {
label: 'fileName',
label: 'QualityName',
value: 'businessId',
},
getPopupContainer: () => document.body,
......@@ -85,7 +85,7 @@ export const formSchemaNewFolder: any = [
],
componentProps: {
fieldNames: {
label: 'label',
label: 'QualityName',
value: 'businessId',
},
getPopupContainer: () => document.body,
......@@ -141,7 +141,7 @@ export const formSchemaTemplate: any = [
],
componentProps: {
fieldNames: {
label: 'label',
label: 'QualityName',
value: 'businessId',
},
getPopupContainer: () => document.body,
......
......@@ -32,7 +32,7 @@
import TreeTwo from './treeTwo.vue';
import { useMessage } from '@/hooks/web/useMessage';
import { getMenuList } from '@/api/system/menu/menu';
import { treeDataList } from '@/views/dataQuality/template/mock';
import {TreeData, treeDataList} from '@/views/dataQuality/template/mock';
defineOptions({ name: 'AccountModal' });
......@@ -64,11 +64,47 @@
});
}
updateSchema({
const treeList = handleTree(TreeData, 'businessId', undefined, undefined, undefined);
updateSchema([
{
field: 'path',
componentProps: { treeData: treeDataList },
componentProps: {
treeData: treeList,
},
},
]);
});
/**数组对象转成树*/
function handleTree(data, id, parentId, children, rootId) {
id = id || 'id';
parentId = parentId || 'parentId';
children = children || 'children';
rootId =
rootId ||
Math.min.apply(
Math,
data.map((item) => {
return item[parentId];
}),
) ||
0;
// 对源数据深度克隆
const cloneData = JSON.parse(JSON.stringify(data));
// 循环所有项
const treeData = cloneData.filter((father) => {
const branchArr = cloneData.filter((child) => {
// 返回每一项的子级数组
return father[id] === child[parentId];
});
branchArr.length > 0 ? (father.children = branchArr) : '';
// 返回第一层
return father[parentId] === rootId;
});
return treeData !== '' ? treeData : data;
}
const getTitle = computed(() => (!unref(isUpdate) ? '新建主体' : '编辑主体'));
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment