Commit 98bdf246 authored by baiyinhao's avatar baiyinhao

架构规划 数据分层代码提交

parent 6c81abdf
<template>
<div>数据分层</div>
<PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
<!-- <ModelTree class="w-1/4 xl:w-1/5" @select="handleSelect" /> -->
<BasicTable @register="registerTable" class="w-1 xl:w-5/5" :searchInfo="searchInfo">
<template #toolbar>
<!-- <a-button type="primary" @click="handleCreateModel">导出</a-button>
<a-button type="primary" @click="handleCreateModel">导入</a-button>
<a-button type="primary" @click="handleCreateFolder">新建文件夹</a-button> -->
<a-button type="primary" @click="handleCreateFile">新建分层</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{
icon: 'clarity:note-edit-line',
label: '编辑',
onClick: handleEdit.bind(null, record),
},
]"
:dropDownActions="[
{
icon: 'ant-design:delete-outlined',
label: '删除',
color: 'error',
popConfirm: {
title: '是否确认删除',
placement: 'left',
confirm: handleDelete.bind(null, record),
},
},
{
icon: 'ant-design:caret-up-filled',
label: '上移',
onClick: handleMove.bind(null, record),
},
{
icon: 'ant-design:caret-down-filled',
label: '下移',
onClick: handleMove.bind(null, record),
},
]"
/>
</template>
</template>
</BasicTable>
<ModelModal @register="registerModal" @success="handleSuccess" />
</PageWrapper>
</template>
<script lang="ts" setup>
</script>
import { reactive, unref, onDeactivated, onMounted, ref } from 'vue';
import { BasicTable, useTable, TableAction } from '@/components/Table';
import { getAccountList, deleteUser, exportUserList } from '@/api/system/user/user';
import { PageWrapper } from '@/components/Page';
import { useMessage } from '@/hooks/web/useMessage';
import { useModal } from '@/components/Modal';
import ModelModal from './modelModal.vue';
import { columns, searchFormSchema } from './model.data';
import { useGo } from '@/hooks/web/usePage';
import { useRoute, onBeforeRouteLeave } from 'vue-router';
import { useFilterStore } from '@/store/modules/filterData';
import { modelData, TreeData } from './mock';
// import ModelTree from '@/views/dataWarehousePlanning/physicalModel/ModelTree.vue';
defineOptions({ name: 'AccountManagement' });
const { createMessage } = useMessage();
const filterStore = useFilterStore();
const route = useRoute();
const go = useGo();
const [registerModal, { openModal }] = useModal();
const [registerAddUserModal, { openModal: addUserModal }] = useModal();
const [registerMoveUser, { openModal: openMoveUserModal }] = useModal();
const searchInfo = reactive<Recordable>({});
const tableData = ref([]);
const [
registerTable,
{ reload, updateTableDataRecord, getSearchInfo, getForm, getRowSelection },
] = useTable({
title: '',
api: async (params) => {
console.log('params:', params);
const response = {
pageNu: '1',
pageSize: '10',
pages: '1',
total: tableData.value.length,
code: '',
message: '',
data: [],
};
var data = [];
var data = [];
data = tableData.value.filter((item) => item.businessId !== 100);
return { ...response, data: data };
},
rowKey: 'businessId',
columns,
rowSelection: true,
formConfig: {
labelWidth: 10,
schemas: searchFormSchema,
autoSubmitOnEnter: true,
resetFunc: () => {
searchInfo.modelId = '';
},
},
useSearchForm: true,
showTableSetting: false,
bordered: true,
showIndexColumn: false,
handleSearchInfoFn(info) {
return info;
},
actionColumn: {
width: 150,
title: '操作',
dataIndex: 'action',
},
});
/** 新增元模型*/
function handleCreateModel() {
openModal(true, {
isUpdate: false,
});
}
/** 新建分层*/
function handleCreateFile() {
openModal(true, {
isUpdate: false,
});
}
/** 部门树的select*/
function handleSelect(modelId = '') {
searchInfo.modelId = modelId;
reload();
}
<style scoped>
/** 移动按钮*/
function handleMove(record: Recordable) {
openMoveUserModal(true, {
record,
isMove: true,
});
}
</style>
/** 编辑按钮*/
function handleEdit(record: Recordable) {
openModal(true, {
record,
isUpdate: true,
});
}
/** 删除按钮*/
function handleDelete(record: Recordable) {
tableData.value.splice(
tableData.value.findIndex((item) => item.businessId === record.businessId),
1,
);
createMessage.success('删除成功!');
reload();
}
/** 新增/编辑成功*/
function handleSuccess({ isUpdate, values }) {
if (isUpdate) {
// 注意:updateTableDataRecord要求表格的rowKey属性为string并且存在于每一行的record的keys中
//修改表单的值
const result = updateTableDataRecord(values.businessId, values);
reload();
} else {
tableData.value.push(values);
reload();
}
}
/** 移动*/
function handleMoveSuccess({ isMove, values }) {
const rowSelection = getRowSelection().selectedRowKeys;
if (rowSelection.length > 0) {
//批量移动
for (let i = 0; i < rowSelection.length; i++) {
const result = updateTableDataRecord(values[i].institutionId, values[i]);
}
} else {
//单个移动
const result = updateTableDataRecord(values.businessId, values);
}
reload();
}
function handleView(record: Recordable) {
go('/system/account_detail/' + record.id);
}
onMounted(() => {
tableData.value = TreeData;
const path = route.path;
if (filterStore.getSearchParams[path]) {
if (JSON.parse(filterStore.getSearchParams[path] !== {})) {
const params = JSON.parse(filterStore.getSearchParams[path]);
getForm().setFieldsValue({
page: params.page,
pageSize: params.pageSize,
username: params.username,
flag: params.flag,
});
searchInfo.institutionId = params.institutionId;
}
}
});
onBeforeRouteLeave((to, from, next) => {
const params = Object.assign({}, getSearchInfo(), getForm().getFieldsValue());
filterStore.setSearchParams({
path: from.path,
param: {
...params,
},
});
next(); // 允许导航
});
</script>
import { getAllRoleList } from '@/api/system/role/role';
import { BasicColumn, FormSchema } from '@/components/Table';
import { h } from 'vue';
import { Tag, Switch } from 'ant-design-vue';
import { useMessage } from '@/hooks/web/useMessage';
import { changeFlagApi } from '@/api/system/user/user';
import { update } from 'lodash-es';
// 引入开关组件
type CheckedType = boolean | string | number;
export const TreeData: any[] = [
{
tireName: '分层1',
themeEngName: 'theme1',
description: '描述1',
creator: '创建人1',
createTime: '2024-10-27 10:04:04',
updateTime: '2024-10-27 10:04:04',
businessId: 401,
institutionId: null,
},
{
tireName: '分层2',
themeEngName: 'theme1',
description: '',
creator: '创建人1',
createTime: '2024-10-27 10:04:04',
updateTime: '2024-10-27 10:04:04',
businessId: 402,
institutionId: null,
},
{
tireName: '分层1',
themeEngName: 'theme1',
description: '描述1',
creator: '创建人1',
createTime: '2024-10-27 10:04:04',
updateTime: '2024-10-27 10:04:04',
businessId: 403,
institutionId: null,
},
{
tireName: '分层1',
themeEngName: 'theme1',
description: '描述1',
creator: '创建人1',
createTime: '2024-10-27 10:04:04',
updateTime: '2024-10-27 10:04:04',
businessId: 404,
institutionId: null,
},
{
tireName: '分层1',
themeEngName: 'theme1',
description: '',
creator: '创建人1',
createTime: '2024-10-27 10:04:04',
updateTime: '2024-10-27 10:04:04',
businessId: 405,
institutionId: null,
},
{
tireName: '分层1',
themeEngName: 'theme1',
description: '描述1',
creator: '创建人1',
createTime: '2024-10-27 10:04:04',
updateTime: '2024-10-27 10:04:04',
businessId: 406,
institutionId: null,
},
{
tireName: '分层1',
themeEngName: 'theme1',
description: '描述1',
creator: '创建人1',
createTime: '2024-10-27 10:04:04',
updateTime: '2024-10-27 10:04:04',
businessId: 407,
institutionId: null,
},
];
export const modelData: any[] = [
{
delFlag: '0',
flag: '1',
businessId: 309,
username: 'yonghu1',
nickName: '测试用户1',
userType: '1',
name: '测试用户1',
createDate: '2024-10-24 10:04:04',
institutionId: 105,
institutionName: '财务部门',
code: '123f',
identity: '1',
roleIds: null,
roleNames: '三级用户',
roleList: null,
menuList: [],
},
{
delFlag: '0',
flag: '1',
businessId: 310,
username: 'yonghu2',
nickName: '测试用户2',
userType: '1',
name: '测试用户2',
createDate: '2024-10-25 10:05:05',
sex: '0',
institutionId: 105,
institutionName: '财务部门',
code: '123a',
identity: '1',
roleIds: null,
roleNames: null,
roleList: null,
menuList: [],
},
{
delFlag: '0',
flag: '1',
businessId: 317,
username: 'yonghu3',
nickName: '测试用户3',
userType: '1',
name: '测试用户3',
createDate: '2024-10-26 10:06:06',
sex: '1',
institutionId: 102,
institutionName: '研发部门',
code: '123c',
identity: '1',
roleIds: null,
roleNames: '超级管理员',
roleList: null,
menuList: [],
},
{
delFlag: '0',
flag: '1',
businessId: 318,
username: 'yonghu4',
nickName: '测试用户4',
userType: '1',
name: '测试用户4',
createDate: '2024-10-26 10:06:06',
sex: '1',
institutionId: 102,
institutionName: '研发部门',
code: '123b',
identity: '1',
roleIds: null,
roleNames: '超级管理员',
roleList: null,
menuList: [],
},
{
delFlag: '0',
flag: '1',
businessId: 319,
username: 'yonghu5',
nickName: '测试用户5',
userType: '1',
name: '测试用户5',
createDate: '2024-10-26 10:06:06',
sex: '1',
institutionId: 102,
institutionName: '研发部门',
code: '123x',
identity: '1',
roleIds: null,
roleNames: '超级管理员',
roleList: null,
menuList: [],
},
];
export const editTableData: any[] = [
{
businessId: 1,
name: '数据源',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '库名',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '表名',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '资产类型',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '表类型',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '表注释',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '存储类型',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '是否为事务表',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '创建时间',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '创建者',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '发布时间',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '发布者',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
];
export const editColumnData: any[] = [
{
businessId: 1,
name: '列名',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '字段类型',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '字段类型参数',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '长度',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '精度',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '是否可为空',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '字段注释',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
];
export const editBucketData: any[] = [
{
businessId: 1,
name: '分桶数',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '分桶字段',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '排序字段',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '排序方式',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
];
export const editAreaData: any[] = [
{
businessId: 1,
name: '分区类型',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '分区字段',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '分区名',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
{
businessId: 1,
name: '分区值',
description: '',
englishName: '',
isWrite: 0,
isShow: 0,
type: '',
},
];
import { getAllRoleList } from '@/api/system/role/role';
import { BasicColumn, FormSchema } from '@/components/Table';
import { h } from 'vue';
import { Tag, Switch } from 'ant-design-vue';
import { useMessage } from '@/hooks/web/useMessage';
import { changeFlagApi } from '@/api/system/user/user';
// 引入开关组件
type CheckedType = boolean | string | number;
export const columns: BasicColumn[] = [
{
title: '分层名称',
dataIndex: 'tireName',
width: 150,
// onEditRow:true
},
{
title: '英文名称',
dataIndex: 'themeEngName',
width: 150,
// onEditRow:true
},
{
title: '描述',
dataIndex: 'description',
width: 150,
customRender: (text) => text || '-',
// onEditRow:true
},
{
title: '创建人',
dataIndex: 'creator',
width: 150,
// onEditRow:true
},
{
title: '创建时间',
dataIndex: 'createTime',
width: 150,
// onEditRow:true
},
{
title: '更新时间',
dataIndex: 'updateTime',
width: 150,
// onEditRow:true
},
];
export const searchFormSchema: FormSchema[] = [
{
field: 'name',
label: ' ',
component: 'Input',
componentProps: {
placeholder: '请输入分层名称/英文名称',
},
colProps: { span: 5 },
},
];
export const physicalModelFormSchema: any[] = [
{
field: 'tireName',
label: '分层名称',
component: 'Input',
required: true,
colProps: { span: 24 },
},
{
field: 'themeEngName',
label: '英文名称',
component: 'Input',
required: true,
colProps: { span: 24 },
},
{
field: 'description',
label: '描述',
component: 'InputTextArea',
required: false,
colProps: { span: 24 },
},
{
field: 'tireBgColor',
label: '分层背景色',
colProps: { span: 24 },
component: 'RadioGroup',
required: true,
componentProps: {
options: [
{ label: '灰色', value: '#808080' },
{ label: '绿色', value: '#00FF00' },
{ label: '红色', value: '#FF0000' },
{ label: '蓝色', value: '#0000FF' },
{ label: '紫色', value: '#FF00FF' },
{ label: '黄色', value: '#FFFF00' },
{ label: '橙色', value: '#FFA500' },
],
},
},
];
/**移动*/
export const MoveFormSchema: any[] = [
{
field: 'institutionId',
label: '所属机构',
component: 'TreeSelect',
colProps: { lg: 24, md: 24 },
componentProps: {
fieldNames: {
label: 'institutionName',
value: 'businessId',
},
getPopupContainer: () => document.body,
},
required: true,
},
];
<template>
<BasicModal
width="40%"
v-bind="$attrs"
@register="registerModal"
:title="getTitle"
@ok="handleSubmit"
>
<BasicForm @register="registerForm" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref, computed, unref, reactive } from 'vue';
import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form';
import { physicalModelFormSchema } from './model.data';
import { getDeptList } from '@/api/system/dept/dept';
import { addUserApi, UserDetailApi, UserUpdataApi } from '@/api/system/user/user';
import { encryptTwo } from '../../../../src/utils/jsencrypt.js';
import { useMessage } from '@/hooks/web/useMessage';
import { TreeData } from '@/views/ArchitecturePlan/dataTiering/mock';
import { router } from '@/router';
defineOptions({ name: 'ModelModal' });
const emit = defineEmits(['success', 'register']);
const { createMessage } = useMessage();
const isUpdate = ref(true);
const isMove = ref(false);
const rowId = ref('');
//获取接口数据并放在下拉框里(这里是打开了一个弹框)
//初始化表单
const [registerForm, { setFieldsValue, updateSchema, resetFields, validate }] = useForm({
labelWidth: 100,
schemas: physicalModelFormSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23,
},
});
//初始化弹框
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
resetFields();
setModalProps({ confirmLoading: false });
isUpdate.value = !!data?.isUpdate;
isMove.value = !!data?.isMove;
if (unref(isUpdate)) {
// 获取行数据的id
rowId.value = data.record.businessId;
// 塞值
setFieldsValue({
...data.record,
});
}
const treeList = handleTree(TreeData, 'businessId', undefined, undefined, undefined);
console.log('treeList', treeList);
updateSchema([
{
field: 'modelId',
componentProps: {
treeData: treeList,
},
},
]);
});
const getTitle = computed(() => (!unref(isUpdate) ? '新建分层' : '编辑分层'));
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;
}
/**确定按钮*/
async function handleSubmit() {
const values = await validate();
router.push({
path: '/metaModel/physicsModel/EditRowTable',
query: {},
});
closeModal();
}
</script>
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