Commit 9ab5a41c authored by chenjiahao's avatar chenjiahao

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

parent dbc23aab
<template> <template>
<div class="m-4 mr-0 overflow-hidden bg-white"> <div class="m-4 mr-0 overflow-hidden bg-white">
<BasicTree <BasicTree
title="质量模" title="质量模"
ref="treeRef" ref="treeRef"
toolbar toolbar
search search
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
:clickRowToExpand="true" :clickRowToExpand="true"
:defaultExpandAll="true" :defaultExpandAll="true"
:treeData="treeData" :treeData="treeData"
:fieldNames="{ key: 'key', title: 'title' }" :fieldNames="{ key: 'businessId', title: 'QualityName' }"
@select="handleSelect" @select="handleSelect"
/> />
</div> </div>
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
import { BasicTree, TreeActionType, TreeItem } from '@/components/Tree'; import { BasicTree, TreeActionType, TreeItem } from '@/components/Tree';
import { getDeptList } from '@/api/system/dept/dept'; import { getDeptList } from '@/api/system/dept/dept';
import { Nullable } from '@vben/types'; import { Nullable } from '@vben/types';
import { treeDataList } from './mock'; import { TreeData } from './mock';
defineOptions({ name: 'DeptTree' }); defineOptions({ name: 'DeptTree' });
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
const treeRef = ref<Nullable<TreeActionType>>(null); const treeRef = ref<Nullable<TreeActionType>>(null);
async function fetch() { async function fetch() {
treeData.value = treeDataList; treeData.value = handleTree(TreeData, 'businessId', undefined, undefined, undefined);
await nextTick(() => { await nextTick(() => {
getTree().expandAll(true); getTree().expandAll(true);
}); });
...@@ -42,6 +42,36 @@ ...@@ -42,6 +42,36 @@
return tree; 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) { function handleSelect(keys) {
emit('select', keys[0]); emit('select', keys[0]);
} }
......
...@@ -189,139 +189,55 @@ export const treeDataListTwo = [ ...@@ -189,139 +189,55 @@ export const treeDataListTwo = [
export const TreeData: any[] = [ export const TreeData: any[] = [
{ {
delFlag: '0',
flag: '1',
businessId: 100, businessId: 100,
fileName: '任务流', QualityName: '质量模版',
anotherName: '任务流', anotherName: '质量模版',
parentId: 0, parentId: 0,
'code:': '001', location: '/质量模版',
ancestors: '0', icon: 'ant-design:folder-open-outlined',
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',
}, },
{ {
delFlag: '0',
flag: '1',
businessId: 101, businessId: 101,
fileName: '典型案例', QualityName: 'CEA_POC_模版',
anotherName: '典型案例', anotherName: 'CEA_POC_模版',
parentId: 100, parentId: 100,
'code:': '002',
ancestors: '0,100', 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', icon: 'ant-design:folder-open-outlined',
}, },
{ {
delFlag: '0', businessId: 102,
flag: '1', QualityName: '数据中台工作区01',
businessId: 107, anotherName: '数据中台工作区01',
fileName: '个人体验',
anotherName: '个人体验',
parentId: 100, parentId: 100,
'code:': '003',
ancestors: '0,100', ancestors: '0,100',
orderNum: 2, location: '/质量模版/数据中台工作区01',
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', icon: 'ant-design:folder-open-outlined',
}, },
{ {
delFlag: '0',
flag: '1',
businessId: 201, businessId: 201,
fileName: '总-智慧财务总体流程', QualityName: '值域检查(倍数)',
anotherName: '总-智慧财务总体流程', anotherName: '值域检查(倍数)',
parentId: 101, parentId: 102,
'code:': '005', ancestors: '0,100,102',
ancestors: '0,100,101', location: '/质量模版/数据中台工作区01/值域检查(倍数)',
orderNum: 2,
selectType: null,
location: '/任务流/典型案例/总-智慧财务总体流程',
holder: 'admin',
createDate: '2024-10-22 8:04:04',
updateDate: '2024-10-22 8:04:04',
icon: 'ant-design:partition-outlined', icon: 'ant-design:partition-outlined',
}, },
{ {
delFlag: '0',
flag: '1',
businessId: 202, businessId: 202,
fileName: '分-落地区', QualityName: '值域检查(数值大于零)',
anotherName: '分-落地区', anotherName: '值域检查(数值大于零)',
parentId: 101, parentId: 102,
'code:': '006', ancestors: '0,100,102',
ancestors: '0,100,101', location: '/质量模版/数据中台工作区01/值域检查(数值大于零)',
orderNum: 3,
selectType: null,
location: '/任务流/典型案例/分-落地区',
holder: 'admin',
createDate: '2024-10-21 9:04:04',
updateDate: '2024-10-21 9:04:04',
icon: 'ant-design:partition-outlined', icon: 'ant-design:partition-outlined',
}, },
{ {
delFlag: '0', businessId: 204,
flag: '1', QualityName: '准取检查-数值大于等于n',
businessId: 203, anotherName: '准取检查-数值大于等于n',
fileName: '分-改良区',
anotherName: '分-改良区',
parentId: 101, parentId: 101,
'code:': '008',
ancestors: '0,100,101', ancestors: '0,100,101',
orderNum: 5, location: '/质量模版/CEA_POC_模版/准取检查-数值大于等于n',
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',
icon: 'ant-design:partition-outlined', icon: 'ant-design:partition-outlined',
}, },
]; ];
...@@ -14,10 +14,8 @@ ...@@ -14,10 +14,8 @@
import { BasicModal, useModalInner } from '@/components/Modal'; import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form'; import { BasicForm, useForm } from '@/components/Form';
import { MoveFormSchema } from './tempalte.data'; 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 { useMessage } from '@/hooks/web/useMessage';
import { TreeData } from '@/views/dataQuality/template/mock'; import { TreeData } from './mock';
defineOptions({ name: 'AccountModal' }); defineOptions({ name: 'AccountModal' });
...@@ -41,24 +39,24 @@ ...@@ -41,24 +39,24 @@
}); });
//初始化弹框 //初始化弹框
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => { const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
console.log('data', data) console.log('data', data);
//每次点击弹窗 需要清空存储的数据 // //每次点击弹窗 需要清空存储的数据
rowData.value = []; // rowData.value = [];
isMove.value = data.isMove; // isMove.value = data.isMove;
//重置表单数据 // //重置表单数据
resetFields(); // resetFields();
setModalProps({ confirmLoading: false }); // setModalProps({ confirmLoading: false });
if (data.idList != null && data.idList.length > 0) { // if (data.idList != null && data.idList.length > 0) {
/* empty */ // /* empty */
} else { // } else {
rowData.value.push(data.record); // rowData.value.push(data.record);
//单个移动 // //单个移动
rowId.value = data.record.businessId; // rowId.value = data.record.businessId;
data.record.taskId = data.record.businessId; // data.record.taskId = data.record.businessId;
setFieldsValue({ // setFieldsValue({
...data.record, // ...data.record,
}); // });
} // }
const treeList = handleTree(TreeData, 'businessId', undefined, undefined, undefined); const treeList = handleTree(TreeData, 'businessId', undefined, undefined, undefined);
updateSchema([ updateSchema([
{ {
......
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
import { formSchemaNewFolder } from './tempalte.data'; import { formSchemaNewFolder } from './tempalte.data';
import TreeTwo from './treeTwo.vue'; import TreeTwo from './treeTwo.vue';
import { useMessage } from '@/hooks/web/useMessage'; import { useMessage } from '@/hooks/web/useMessage';
import { treeDataList } from '@/views/dataQuality/template/mock'; import { TreeData, treeDataList } from '@/views/dataQuality/template/mock';
defineOptions({ name: 'AccountModal' }); defineOptions({ name: 'AccountModal' });
...@@ -63,12 +63,46 @@ ...@@ -63,12 +63,46 @@
}); });
} }
updateSchema({ const treeList = handleTree(TreeData, 'businessId', undefined, undefined, undefined);
field: 'path', updateSchema([
componentProps: { treeData: treeDataList }, {
}); field: 'path',
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) ? '新建主体' : '编辑主体')); const getTitle = computed(() => (!unref(isUpdate) ? '新建主体' : '编辑主体'));
async function handleSubmit() { async function handleSubmit() {
......
...@@ -63,7 +63,7 @@ export const MoveFormSchema: any[] = [ ...@@ -63,7 +63,7 @@ export const MoveFormSchema: any[] = [
componentProps: { componentProps: {
// border: 'none', // border: 'none',
fieldNames: { fieldNames: {
label: 'fileName', label: 'QualityName',
value: 'businessId', value: 'businessId',
}, },
getPopupContainer: () => document.body, getPopupContainer: () => document.body,
...@@ -85,7 +85,7 @@ export const formSchemaNewFolder: any = [ ...@@ -85,7 +85,7 @@ export const formSchemaNewFolder: any = [
], ],
componentProps: { componentProps: {
fieldNames: { fieldNames: {
label: 'label', label: 'QualityName',
value: 'businessId', value: 'businessId',
}, },
getPopupContainer: () => document.body, getPopupContainer: () => document.body,
...@@ -141,7 +141,7 @@ export const formSchemaTemplate: any = [ ...@@ -141,7 +141,7 @@ export const formSchemaTemplate: any = [
], ],
componentProps: { componentProps: {
fieldNames: { fieldNames: {
label: 'label', label: 'QualityName',
value: 'businessId', value: 'businessId',
}, },
getPopupContainer: () => document.body, getPopupContainer: () => document.body,
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
import TreeTwo from './treeTwo.vue'; import TreeTwo from './treeTwo.vue';
import { useMessage } from '@/hooks/web/useMessage'; import { useMessage } from '@/hooks/web/useMessage';
import { getMenuList } from '@/api/system/menu/menu'; 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' }); defineOptions({ name: 'AccountModal' });
...@@ -64,12 +64,48 @@ ...@@ -64,12 +64,48 @@
}); });
} }
updateSchema({ const treeList = handleTree(TreeData, 'businessId', undefined, undefined, undefined);
field: 'path', updateSchema([
componentProps: { treeData: treeDataList }, {
}); field: 'path',
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) ? '新建主体' : '编辑主体')); const getTitle = computed(() => (!unref(isUpdate) ? '新建主体' : '编辑主体'));
async function handleSubmit() { async function handleSubmit() {
......
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