Commit 9e792693 authored by hubaoshan's avatar hubaoshan

商城管理-编目管理和资源管理

parent 48538796
...@@ -941,6 +941,25 @@ export const SyncMaintenanceRoute: AppRouteRecordRaw = { ...@@ -941,6 +941,25 @@ export const SyncMaintenanceRoute: AppRouteRecordRaw = {
}, },
], ],
}; };
/**实时同步-任务运维*/
export const ResourceRoute: AppRouteRecordRaw = {
path: '/dataSharingAndExchange',
name: 'dataSharingAndExchange',
component: LAYOUT,
meta: {
title: '资源管理',
icon: '',
hidden: true,
currentActiveMenu: '/dataSharingAndExchange',
},
children: [
{
path: 'dataSharingAndExchange/resourceManagement/detail',
name: 'detail',
component: () => import('@/views/dataSharingAndExchange/resourceManagement/detail/index.vue'),
},
],
};
// Basic routing without permission // Basic routing without permission
// 没有权限要求的基本路由 // 没有权限要求的基本路由
export const basicRoutes = [ export const basicRoutes = [
...@@ -967,5 +986,6 @@ export const basicRoutes = [ ...@@ -967,5 +986,6 @@ export const basicRoutes = [
DataWarehousephysicalModelRoute, DataWarehousephysicalModelRoute,
PAGE_NOT_FOUND_ROUTE, PAGE_NOT_FOUND_ROUTE,
QualityRuleRoute, QualityRuleRoute,
ResourceRoute,
processCenterRoute, processCenterRoute,
]; ];
<template>
<PageWrapper
:title="`用户` + userId + `的资料`"
content="这是用户资料详情页面。本页面仅用于演示相同路由在tab中打开多个页面并且显示不同的数据"
contentBackground
@back="goBack"
>
<template #extra>
<a-button type="primary" danger> 禁用账号 </a-button>
<a-button type="primary"> 修改密码 </a-button>
</template>
<template #footer>
<a-tabs default-active-key="detail" v-model:activeKey="currentKey">
<a-tab-pane key="detail" tab="用户资料" />
<a-tab-pane key="logs" tab="操作日志" />
</a-tabs>
</template>
<div class="pt-4 m-4 desc-wrap">
<template v-if="currentKey == 'detail'">
<div v-for="i in 10" :key="i">这是用户{{ userId }}资料Tab</div>
</template>
<template v-if="currentKey == 'logs'">
<div v-for="i in 10" :key="i">这是用户{{ userId }}操作日志Tab</div>
</template>
</div>
</PageWrapper>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { useRoute } from 'vue-router';
import { PageWrapper } from '@/components/Page';
import { useGo } from '@/hooks/web/usePage';
import { useTabs } from '@/hooks/web/useTabs';
import { Tabs } from 'ant-design-vue';
defineOptions({ name: 'AccountDetail' });
const ATabs = Tabs;
const ATabPane = Tabs.TabPane;
const route = useRoute();
const go = useGo();
// 此处可以得到用户ID
const userId = ref(route.params?.id);
const currentKey = ref('detail');
const { setTitle } = useTabs();
// TODO
// 本页代码仅作演示,实际应当通过userId从接口获得用户的相关资料
// 设置Tab的标题(不会影响页面标题)
setTitle('详情:用户' + userId.value);
// 页面左侧点击返回链接时的操作
function goBack() {
// 本例的效果时点击返回始终跳转到账号列表页,实际应用时可返回上一页
go('/system/account');
}
</script>
<style></style>
...@@ -12,7 +12,7 @@ import {ref, computed, unref, reactive} from 'vue'; ...@@ -12,7 +12,7 @@ import {ref, computed, unref, reactive} from 'vue';
import {addUserApi,UserDetailApi,UserUpdataApi} from '@/api/system/user/user' import {addUserApi,UserDetailApi,UserUpdataApi} from '@/api/system/user/user'
import { encryptTwo } from '../../../../src/utils/jsencrypt.js' import { encryptTwo } from '../../../../src/utils/jsencrypt.js'
import { useMessage } from '@/hooks/web/useMessage'; import { useMessage } from '@/hooks/web/useMessage';
import {TreeData} from "@/views/system/institution/institutionData"; import {TreeData} from "@/views/dataSharingAndExchange/catalogingManagement/institutionData";
defineOptions({ name: 'AccountModal' }); defineOptions({ name: 'AccountModal' });
const emit = defineEmits(['success', 'register']); const emit = defineEmits(['success', 'register']);
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
import { useRoute,onBeforeRouteLeave } from 'vue-router'; import { useRoute,onBeforeRouteLeave } from 'vue-router';
import { useFilterStore } from '@/store/modules/filterData'; import { useFilterStore } from '@/store/modules/filterData';
import {useUserStore} from "@/store/modules/user"; import {useUserStore} from "@/store/modules/user";
import { userData } from "@/views/system/institution/institutionData"; import { userData } from "@/views/dataSharingAndExchange/catalogingManagement/institutionData";
defineOptions({ name: 'AccountManagement' }); defineOptions({ name: 'AccountManagement' });
const { createMessage } = useMessage(); const { createMessage } = useMessage();
...@@ -29,7 +29,7 @@ const emit = defineEmits(['success', 'register']); ...@@ -29,7 +29,7 @@ const emit = defineEmits(['success', 'register']);
const tableData = ref([]) const tableData = ref([])
const isAdd = ref(true) const isAdd = ref(true)
const [registerTable, { reload, updateTableDataRecord, getSearchInfo,getForm,getRowSelection }] = useTable({ const [registerTable, { reload, updateTableDataRecord, getSearchInfo,getForm,getRowSelection }] = useTable({
title: '添加用户', title: '添加编目',
api: async (params) => { api: async (params) => {
const response = { const response = {
pageNu: "1", pageNu: "1",
......
...@@ -22,7 +22,7 @@ import {h, nextTick, onMounted, ref, unref} from 'vue'; ...@@ -22,7 +22,7 @@ import {h, nextTick, onMounted, ref, unref} from 'vue';
import {BasicTree, TreeActionItem, TreeActionType, TreeItem} from '@/components/Tree'; import {BasicTree, TreeActionItem, 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 { TreeData } from "@/views/system/institution/institutionData"; import { TreeData } from "@/views/dataSharingAndExchange/catalogingManagement/institutionData";
import {DeleteOutlined, PlusOutlined,EditOutlined,FolderOutlined } from "@ant-design/icons-vue"; import {DeleteOutlined, PlusOutlined,EditOutlined,FolderOutlined } from "@ant-design/icons-vue";
import {Modal} from "ant-design-vue"; import {Modal} from "ant-design-vue";
import { useMessage } from '@/hooks/web/useMessage'; import { useMessage } from '@/hooks/web/useMessage';
......
...@@ -9,7 +9,7 @@ import { BasicModal, useModalInner } from '@/components/Modal'; ...@@ -9,7 +9,7 @@ import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form'; import { BasicForm, useForm } from '@/components/Form';
import {AddTreeSchema, MoveFormSchema} from './institution.data'; import {AddTreeSchema, MoveFormSchema} from './institution.data';
import { useMessage } from '@/hooks/web/useMessage'; import { useMessage } from '@/hooks/web/useMessage';
import {TreeData} from "@/views/system/institution/institutionData"; import {TreeData} from "@/views/dataSharingAndExchange/catalogingManagement/institutionData";
defineOptions({ name: 'AccountModal' }); defineOptions({ name: 'AccountModal' });
const emit = defineEmits(['success', 'register']); const emit = defineEmits(['success', 'register']);
......
...@@ -9,7 +9,7 @@ import { BasicModal, useModalInner } from '@/components/Modal'; ...@@ -9,7 +9,7 @@ import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form'; import { BasicForm, useForm } from '@/components/Form';
import {AddTreeSchema} from './institution.data'; import {AddTreeSchema} from './institution.data';
import { useMessage } from '@/hooks/web/useMessage'; import { useMessage } from '@/hooks/web/useMessage';
import {TreeData} from "@/views/system/institution/institutionData"; import {TreeData} from "@/views/dataSharingAndExchange/catalogingManagement/institutionData";
defineOptions({ name: 'AccountModal' }); defineOptions({ name: 'AccountModal' });
const emit = defineEmits(['success', 'register']); const emit = defineEmits(['success', 'register']);
...@@ -66,7 +66,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data ...@@ -66,7 +66,7 @@ const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data
]); ]);
}); });
const getTitle = computed(() => (!unref(isUpdate) ? '新增机构' : '编辑机构')); const getTitle = computed(() => (!unref(isUpdate) ? '新增编目' : '编辑编目'));
function handleTree(data, id, parentId, children, rootId) { function handleTree(data, id, parentId, children, rootId) {
id = id || 'id' id = id || 'id'
......
...@@ -3,14 +3,21 @@ ...@@ -3,14 +3,21 @@
<DeptTree class="w-1/4 xl:w-1/5" @select="handleSelect" /> <DeptTree class="w-1/4 xl:w-1/5" @select="handleSelect" />
<BasicTable @register="registerTable" class="w-3/4 xl:w-4/5" :searchInfo="searchInfo"> <BasicTable @register="registerTable" class="w-3/4 xl:w-4/5" :searchInfo="searchInfo">
<template #toolbar> <template #toolbar>
<a-button type="primary" @click="handleCreate">新增</a-button> <a-button type="primary" @click="updateData">更新</a-button>
<a-button type="primary" @click="handleDeleteBatch">批量删除</a-button> <!-- <a-button type="primary" @click="handleCreate">新增</a-button>-->
<a-button type="primary" @click="handleAdd">新增</a-button>
<!-- <a-button type="primary" @click="handleDeleteBatch">批量删除</a-button>-->
<a-button type="primary" @click="handleMoveBatch">批量移动</a-button> <a-button type="primary" @click="handleMoveBatch">批量移动</a-button>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'"> <template v-if="column.key === 'action'">
<TableAction <TableAction
:actions="[ :actions="[
{
// icon: 'clarity:note-edit-line',
label: '新建',
onClick: handleAdd.bind(null, record),
},
{ {
// icon: 'clarity:note-edit-line', // icon: 'clarity:note-edit-line',
label: '编辑', label: '编辑',
...@@ -57,7 +64,7 @@ ...@@ -57,7 +64,7 @@
import { useFilterStore } from '@/store/modules/filterData'; import { useFilterStore } from '@/store/modules/filterData';
import {useUserStore} from "@/store/modules/user"; import {useUserStore} from "@/store/modules/user";
import {getMenuListByPage} from "@/api/system/menu/menu"; import {getMenuListByPage} from "@/api/system/menu/menu";
import { userData } from "@/views/system/institution/institutionData"; import { userData } from "@/views/dataSharingAndExchange/catalogingManagement/institutionData";
import AddUserModal from './AddUserModal.vue'; import AddUserModal from './AddUserModal.vue';
import user from "../../../../mock/sys/user"; import user from "../../../../mock/sys/user";
import {forEach} from "lodash-es"; import {forEach} from "lodash-es";
...@@ -73,7 +80,7 @@ ...@@ -73,7 +80,7 @@
const searchInfo = reactive<Recordable>({}); const searchInfo = reactive<Recordable>({});
const tableData = ref([]) const tableData = ref([])
const [registerTable, { reload, updateTableDataRecord, getSearchInfo,getForm,getRowSelection }] = useTable({ const [registerTable, { reload, updateTableDataRecord, getSearchInfo,getForm,getRowSelection }] = useTable({
title: '用户管理列表', title: '编目管理列表',
api: async (params) => { api: async (params) => {
console.log(params) console.log(params)
const response = { const response = {
...@@ -120,7 +127,7 @@ ...@@ -120,7 +127,7 @@
return info; return info;
}, },
actionColumn: { actionColumn: {
width: 150, width: 200,
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
}, },
...@@ -132,7 +139,9 @@ ...@@ -132,7 +139,9 @@
isAdd: true, isAdd: true,
}); });
} }
function updateData(){
console.log()
}
/**批量移动*/ /**批量移动*/
function handleMoveBatch() { function handleMoveBatch() {
const rowSelection = getRowSelection().selectedRowKeys; const rowSelection = getRowSelection().selectedRowKeys;
...@@ -150,6 +159,13 @@ ...@@ -150,6 +159,13 @@
}); });
} }
/** 新增按钮*/
function handleAdd(record: Recordable) {
openModal(true, {
record,
isAdd: true,
});
}
/** 编辑按钮*/ /** 编辑按钮*/
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
openModal(true, { openModal(true, {
......
...@@ -10,13 +10,23 @@ type CheckedType = boolean | string | number; ...@@ -10,13 +10,23 @@ type CheckedType = boolean | string | number;
export const columns: BasicColumn[] = [ export const columns: BasicColumn[] = [
{ {
title: '姓名', title: '名称',
dataIndex: 'name', dataIndex: 'name',
width: 150, width: 150,
}, },
{ {
title: '登录名', title: '描述',
dataIndex: 'username', dataIndex: 'describe',
width: 150,
},
{
title: '可见范围',
dataIndex: 'visibleRange',
width: 150,
},
{
title: '资源数',
dataIndex: 'resourceNum',
width: 150, width: 150,
}, },
{ {
...@@ -25,38 +35,35 @@ export const columns: BasicColumn[] = [ ...@@ -25,38 +35,35 @@ export const columns: BasicColumn[] = [
width: 150, width: 150,
}, },
{ {
title: '所属机构', title: '更新时间',
dataIndex: 'institutionName', dataIndex: 'updateDate',
width: 150, width: 150,
// customRender: ({ value }) => {
// return deptMap[value];
// },
}, },
]; ];
export const searchFormSchema: FormSchema[] = [ export const searchFormSchema: FormSchema[] = [
{ {
field: 'name', field: 'name',
label: '姓名', // label: '姓名',
component: 'Input', component: 'Input',
componentProps: { componentProps: {
placeholder: '请输入姓名', placeholder: '输入关键字搜索',
},
colProps: { span: 7 },
},
{
field: 'username',
label: '登录名',
component: 'Input',
componentProps: {
placeholder: '请输入登录名',
}, },
colProps: { span: 7 }, colProps: { span: 7 },
}, },
// {
// field: 'username',
// label: '登录名',
// component: 'Input',
// componentProps: {
// placeholder: '请输入登录名',
// },
// colProps: { span: 7 },
// },
]; ];
export const accountFormSchema: any[] = [ export const accountFormSchema: any[] = [
{ {
field: 'name', field: 'name',
label: '姓名', label: '名称',
component: 'Input', component: 'Input',
colProps: { lg: 24, md: 24 }, colProps: { lg: 24, md: 24 },
rules: [ rules: [
...@@ -67,21 +74,28 @@ export const accountFormSchema: any[] = [ ...@@ -67,21 +74,28 @@ export const accountFormSchema: any[] = [
], ],
}, },
{ {
field: 'username', field: 'describe',
label: '登录名', label: '描述',
component: 'Input', component: 'Input',
colProps: { lg: 24, md: 24 }, colProps: { lg: 24, md: 24 },
rules: [ rules: [
{ {
required: true, required: true,
message: '请输入登录名', message: '请输入描述',
}, },
], ],
}, },
{ {
field: 'username', field: 'visibleRange',
label: '用户名称', label: '可见范围',
component: 'Input', component: 'Select',
componentProps: {
options: [
{ label: '所有人', value: '所有人' },
{ label: '用户1', value: '用户1' },
{ label: '用户2', value: '用户2' },
],
},
colProps: { lg: 24, md: 24 }, colProps: { lg: 24, md: 24 },
rules: [ rules: [
{ {
...@@ -90,9 +104,21 @@ export const accountFormSchema: any[] = [ ...@@ -90,9 +104,21 @@ export const accountFormSchema: any[] = [
}, },
], ],
}, },
{
field: 'resourceNum',
label: '可见资源数',
component: 'InputNumber',
colProps: { lg: 24, md: 24 },
rules: [
{
required: true,
message: '请输入',
},
],
},
{ {
field: 'institutionId', field: 'institutionId',
label: '所属机构', label: '所属编目',
component: 'TreeSelect', component: 'TreeSelect',
colProps: { lg: 24, md: 24 }, colProps: { lg: 24, md: 24 },
componentProps: { componentProps: {
...@@ -110,7 +136,7 @@ export const accountFormSchema: any[] = [ ...@@ -110,7 +136,7 @@ export const accountFormSchema: any[] = [
export const MoveFormSchema: any[] = [ export const MoveFormSchema: any[] = [
{ {
field: 'institutionId', field: 'institutionId',
label: '目标机构', label: '目标编目',
component: 'TreeSelect', component: 'TreeSelect',
colProps: { lg: 24, md: 24 }, colProps: { lg: 24, md: 24 },
componentProps: { componentProps: {
...@@ -128,19 +154,19 @@ export const MoveFormSchema: any[] = [ ...@@ -128,19 +154,19 @@ export const MoveFormSchema: any[] = [
export const AddTreeSchema: any[] = [ export const AddTreeSchema: any[] = [
{ {
field: 'institutionName', field: 'institutionName',
label: '机构名称', label: '编目名称',
component: 'Input', component: 'Input',
colProps: { lg: 24, md: 24 }, colProps: { lg: 24, md: 24 },
rules: [ rules: [
{ {
required: true, required: true,
message: '请输入姓名', message: '请输入编目名称',
}, },
], ],
}, },
{ {
field: 'institutionId', field: 'institutionId',
label: '上级机构', label: '上级编目',
component: 'TreeSelect', component: 'TreeSelect',
colProps: { lg: 24, md: 24 }, colProps: { lg: 24, md: 24 },
componentProps: { componentProps: {
...@@ -152,17 +178,17 @@ export const AddTreeSchema: any[] = [ ...@@ -152,17 +178,17 @@ export const AddTreeSchema: any[] = [
}, },
required: true, required: true,
}, },
{ // {
field: 'code', // field: 'code',
label: '机构编码', // label: '机构编码',
component: 'Input', // component: 'Input',
colProps: { lg: 24, md: 24 }, // colProps: { lg: 24, md: 24 },
rules: [ // rules: [
{ // {
required: true, // required: true,
message: '请输入机构编码', // message: '请输入机构编码',
}, // },
], // ],
}, // },
] ]
...@@ -10,9 +10,9 @@ import { BasicForm, useForm } from '@/components/Form'; ...@@ -10,9 +10,9 @@ import { BasicForm, useForm } from '@/components/Form';
import {accountFormSchema, MoveFormSchema, resetPasswordFormSchema} from './institution.data'; import {accountFormSchema, MoveFormSchema, resetPasswordFormSchema} from './institution.data';
import { getDeptList } from '@/api/system/dept/dept'; import { getDeptList } from '@/api/system/dept/dept';
import {resetUserPwd} from '@/api/system/user/user' import {resetUserPwd} from '@/api/system/user/user'
import { encryptTwo } from '../../../../src/utils/jsencrypt.js' import { encryptTwo } from '@/utils/jsencrypt'
import { useMessage } from '@/hooks/web/useMessage'; import { useMessage } from '@/hooks/web/useMessage';
import {TreeData, userData} from "@/views/system/institution/institutionData"; import {TreeData, userData} from "@/views/dataSharingAndExchange/catalogingManagement/institutionData";
defineOptions({ name: 'AccountModal' }); defineOptions({ name: 'AccountModal' });
const emit = defineEmits(['success', 'register']); const emit = defineEmits(['success', 'register']);
......
<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 { accountFormSchema } from './institution.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/dataSharingAndExchange/catalogingManagement/institutionData";
defineOptions({ name: 'AccountModal' });
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,
baseColProps: { lg: 12, md: 24 },
schemas: accountFormSchema,
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)
updateSchema([
{
field: 'institutionId',
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() {
try {
//拿到表单内容
const values = await validate();
//通过表单获取的institutionId去查找相同TreeData中的institutionId的institutionName
const institutionName = TreeData.find(item => item.businessId === values.institutionId).institutionName
values.institutionName = institutionName
setModalProps({ confirmLoading: true });
// 编辑
if(unref(isUpdate)) {
values.businessId = rowId.value
//修改列表值
emit('success', { isUpdate: unref(isUpdate), values: { ...values, id: rowId.value } });
createMessage.success('编辑成功');
closeModal();
}else {
//根据institutionId去查找相同TreeData中的institutionId的institutionName
const institutionName = TreeData.find(item => item.businessId === values.institutionId).institutionName
const paramsAdd = {
username: values.username,
name: values.name,
institutionId: values.institutionId,
institutionName: institutionName,
createDate: formatDate(new Date())
}
emit('success', { isUpdate: unref(isUpdate), values: { ...paramsAdd } });
createMessage.success('新增成功');
closeModal();
}
} finally {
setModalProps({ confirmLoading: false });
}
}
// 格式化日期
function formatDate(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
</script>
<template>
<BasicModal width="50%" v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit">
<BasicTable @register="registerTable"></BasicTable>
</BasicModal>
</template>
<script lang="ts" setup>
import { BasicModal, useModalInner } from '@/components/Modal';
import { BasicForm, useForm } from '@/components/Form';
import { reactive,unref,onDeactivated,onMounted,ref } from 'vue';
import { BasicTable, useTable, TableAction } from '@/components/Table';
import { useMessage } from '@/hooks/web/useMessage';
import { useModal } from '@/components/Modal';
import {addUserData, columns, searchFormSchema, TreeData} from './institutionData';
import { useGo } from '@/hooks/web/usePage';
import { downloadByData } from '@/utils/file/download';
import { useRoute,onBeforeRouteLeave } from 'vue-router';
import { useFilterStore } from '@/store/modules/filterData';
import {useUserStore} from "@/store/modules/user";
import { userData } from "@/views/dataSharingAndExchange/catalogingManagement/institutionData";
defineOptions({ name: 'AccountManagement' });
const { createMessage } = useMessage();
const filterStore = useFilterStore();
const route = useRoute();
const go = useGo();
const [registerMoveUser, { openModal: openMoveUserModal }] = useModal();
const searchInfo = reactive<Recordable>({});
const emit = defineEmits(['success', 'register']);
const tableData = ref([])
const isAdd = ref(true)
const [registerTable, { reload, updateTableDataRecord, getSearchInfo,getForm,getRowSelection }] = useTable({
title: '添加编目',
api: async (params) => {
const response = {
pageNu: "1",
pageSize: "10",
pages: "1",
total: tableData.value.length,
code:'',
message:'',
data: [],
};
var data = []
data = tableData.value
if (params.name != undefined && params.name != '' && params.name != null){
//过滤出名字包含params.name的数据
data = data.filter((item) => item.name.includes(params.name));
}
if (params.username != undefined && params.username != '' && params.username != null){
data = data.filter((item) => item.username.includes(params.username));
}
return { ...response, data: data };
},
rowKey: 'businessId',
columns,
rowSelection: true,
formConfig: {
labelWidth: 100,
schemas: searchFormSchema,
autoSubmitOnEnter: true,
},
useSearchForm: true,
showTableSetting: false,
bordered: true,
handleSearchInfoFn(info) {
return info;
},
});
//初始化弹框
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
setModalProps({ confirmLoading: false });
isAdd.value = !!data?.isAdd;
});
/** 新增成功*/
function handleSubmit() {
const rowSelection = getRowSelection().selectedRowKeys;
if (rowSelection.length>0){
//已选中
//根据选中的查询用户 然后进行添加
let data = []
data = tableData.value.filter((item) => rowSelection.includes(item.businessId));
emit('success', { isAdd: unref(isAdd), values: { ...data },length: rowSelection.length });
closeModal();
}
}
onMounted(() => {
tableData.value = addUserData
});
</script>
<template>
<div class="m-4 mr-0 overflow-hidden bg-white">
<BasicTree
title="部门列表"
ref="treeRef"
toolbar
search
treeWrapperClassName="h-[calc(100%-35px)] overflow-auto"
:clickRowToExpand="false"
:defaultExpandAll="true"
:treeData="treeData"
:fieldNames="{ key: 'businessId', title: 'institutionName' }"
@select="handleSelect"
:actionList="actionList"
/>
</div>
<MoveTreeModal @register="registerMoveTreeModel" @success="handleSuccess" />
<UpdateTreeModal @register="registerModal" @success="handleSuccess" />
</template>
<script lang="ts" setup>
import {h, nextTick, onMounted, ref, unref} from 'vue';
import {BasicTree, TreeActionItem, TreeActionType, TreeItem} from '@/components/Tree';
import { getDeptList } from '@/api/system/dept/dept';
import {Nullable} from "@vben/types";
import { TreeData } from "@/views/dataSharingAndExchange/catalogingManagement/institutionData";
import {DeleteOutlined, PlusOutlined,EditOutlined,FolderOutlined } from "@ant-design/icons-vue";
import {Modal} from "ant-design-vue";
import { useMessage } from '@/hooks/web/useMessage';
import MoveTreeModal from './MoveTreeModal.vue';
import UpdateTreeModal from './UpdateTreeModal.vue';
import {useModal} from "@/components/Modal";
defineOptions({ name: 'DeptTree' });
const emit = defineEmits(['select']);
const { createMessage } = useMessage();
const treeData = ref<TreeItem[]>([]);
const treeRef = ref<Nullable<TreeActionType>>(null);
const [registerModal, { openModal }] = useModal();
const [registerMoveTreeModel, { openModal:openMoveTreeModel }] = useModal();
function getTree() {
const tree = unref(treeRef);
if (!tree) {
throw new Error('tree is null!');
}
return tree;
}
async function fetch() {
const data = TreeData
treeData.value = handleTree(data, 'businessId',undefined,undefined,undefined)
await nextTick(() => {
getTree().expandAll(true)
})
}
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]);
}
onMounted(() => {
fetch();
});
/** 成功回调函数*/
function handleSuccess() {
}
// 树的操作列表
const actionList = [
{
//新增
render: (node) => {
return h(PlusOutlined, {
class: 'ml-2',
onClick: () => {
handleAdd(node);
},
});
},
},
{
//修改
render: (node) => {
return h(EditOutlined, {
class: 'ml-2',
onClick: () => {
handleUpdate(node);
},
});
},
},
{
//删除
render: (node) => {
return h(DeleteOutlined, {
class: 'ml-2',
onClick: () => {
handleDelete(node);
},
});
},
},
{
//移动
render: (node) => {
return h(FolderOutlined, {
class: 'ml-2',
onClick: () => {
handleMove(node);
},
});
},
},
];
// 新增节点
const handleAdd = (node) => {
openModal(true, {
isAdd: true,
record: node,
});
};
// 修改节点
const handleUpdate = (node) => {
openModal(true, {
isUpdate: true,
record: node,
});
};
// 移动节点
const handleMove = (node) => {
openMoveTreeModel(true, {
isMove: true,
record: node,
});
};
// 删除节点
const handleDelete = (node) => {
Modal.confirm({
title: '确认删除',
content: '确定要删除此节点吗?',
okText: '确认',
cancelText: '取消',
onOk() {
// 执行删除逻辑
createMessage.success('删除成功!')
},
onCancel() {
console.log('取消删除');
createMessage.info('取消删除')
},
});
};
</script>
<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 {AddTreeSchema, MoveFormSchema} from './institution.data';
import { useMessage } from '@/hooks/web/useMessage';
import {TreeData} from "@/views/dataSharingAndExchange/catalogingManagement/institutionData";
defineOptions({ name: 'AccountModal' });
const emit = defineEmits(['success', 'register']);
const { createMessage } = useMessage();
const isUpdate = ref(true);
const isMove = ref(false);
const rowId = ref('')
const form = ref([])
//获取接口数据并放在下拉框里(这里是打开了一个弹框)
//初始化表单
const [registerForm, { setFieldsValue, updateSchema, resetFields, validate }] = useForm({
labelWidth: 100,
baseColProps: { lg: 12, md: 24 },
schemas: MoveFormSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23,
},
});
//初始化弹框
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
resetFields();
setModalProps({ confirmLoading: false });
form.value = data.record
const formData = {
institutionId: data.record.parentId,
}
// 塞值
setFieldsValue({
...formData,
});
const treeList = handleTree(TreeData, 'businessId',undefined,undefined,undefined)
updateSchema([
{
field: 'institutionId',
componentProps: {
treeData: treeList
},
},
]);
});
const getTitle = computed(() => ('移动'));
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();
createMessage.success('移动成功')
closeModal()
}
// 格式化日期
function formatDate(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
</script>
<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 {AddTreeSchema} from './institution.data';
import { useMessage } from '@/hooks/web/useMessage';
import {TreeData} from "@/views/dataSharingAndExchange/catalogingManagement/institutionData";
defineOptions({ name: 'AccountModal' });
const emit = defineEmits(['success', 'register']);
const { createMessage } = useMessage();
const isUpdate = ref(true);
const isMove = ref(false);
const isAdd = ref(false);
const rowId = ref('');
//获取接口数据并放在下拉框里(这里是打开了一个弹框)
//初始化表单
const [registerForm, { setFieldsValue, updateSchema, resetFields, validate }] = useForm({
labelWidth: 100,
baseColProps: { lg: 12, md: 24 },
schemas: AddTreeSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23,
},
});
//初始化弹框
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
resetFields();
setModalProps({ confirmLoading: false });
//修改
isAdd.value = !!data?.isAdd;
//修改
isUpdate.value = !!data?.isUpdate;
if (unref(isUpdate)) {
//修改
// 获取行数据的id
rowId.value = data.record.businessId;
const formData = {
institutionId: data.record.parentId,
institutionName: data.record.anotherName,
code:data.record.code
}
// 塞值
setFieldsValue({
...formData,
});
}else if (unref(isAdd)){
//新增
}
const treeList = handleTree(TreeData, 'businessId',undefined,undefined,undefined)
updateSchema([
{
field: 'institutionId',
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();
if (unref(isUpdate)){
createMessage.success('修改成功')
closeModal()
}else if (!unref(isUpdate)){
createMessage.success('新增成功')
closeModal()
}
}
// 格式化日期
function formatDate(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0'); // 月份从0开始,需要加1
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
</script>
<template>
<PageWrapper dense contentFullHeight fixedHeight contentClass="flex">
<!-- <DeptTree class="w-1/4 xl:w-1/5" @select="handleSelect" class="w-3/4 xl:w-4/5" />-->
<BasicTable @register="registerTable" :searchInfo="searchInfo">
<template #toolbar>
</template>
<template #name="{ text, record }">
<a @click="showDetails(record)"> {{ text }}</a>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
// 详情按钮
{
// icon: 'clarity:note-edit-line',
label: '详情',
onClick: handleDetails.bind(null, record),
},
// {
// // icon: 'clarity:note-edit-line',
// label: '新建',
// onClick: handleAdd.bind(null, record),
// },
// {
// // icon: 'clarity:note-edit-line',
// label: '编辑',
// onClick: handleEdit.bind(null, record),
// },
// {
// color: 'error',
// label: '删除',
// popConfirm: {
// title: '是否确认删除',
// placement: 'left',
// confirm: handleDelete.bind(null, record),
// },
// },
// {
// label: '移动',
// onClick: handleMove.bind(null, record),
// },
]"
/>
</template>
</template>
</BasicTable>
<AccountModal @register="registerModal" @success="handleSuccess" />
<MoveUser @register="registerMoveUser" @success="handleMoveSuccess" />
<AddUserModal @register="registerAddUserModal" @success="handleAddSuccess" />
</PageWrapper>
</template>
<script lang="ts" setup>
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 AccountModal from './AccountModal.vue';
import importModal from './importModal.vue';
import MoveUser from './moveUser.vue';
import { columns, searchFormSchema } from './institution.data';
import { useGo } from '@/hooks/web/usePage';
import { downloadByData } from '@/utils/file/download';
import { useRoute,onBeforeRouteLeave,useRouter } from 'vue-router';
import { useFilterStore } from '@/store/modules/filterData';
import {useUserStore} from "@/store/modules/user";
import {getMenuListByPage} from "@/api/system/menu/menu";
import { userData } from "@/views/dataSharingAndExchange/resourceManagement/institutionData";
import AddUserModal from './AddUserModal.vue';
import user from "../../../../mock/sys/user";
import {forEach} from "lodash-es";
defineOptions({ name: 'AccountManagement' });
const { createMessage, createConfirm } = 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)
const response = {
pageNu: "1",
pageSize: "10",
pages: "1",
total: tableData.value.length,
code:'',
message:'',
data: [],
};
//过滤data中的数据,取出等于params.deptId的数据
var data = []
//按照部门筛选 如果有进行过滤相应部门的 没有就赋值全部
if (params.institutionId != undefined && params.institutionId != ''){
data = tableData.value.filter((item) => item.institutionId === params.institutionId);
} else {
data = tableData.value
}
if (params.name != undefined && params.name != '' && params.name != null){
//过滤出名字包含params.name的数据
data = data.filter((item) => item.name.includes(params.name));
}
if (params.username != undefined && params.username != '' && params.username != null){
data = data.filter((item) => item.username.includes(params.username));
}
return { ...response, data: data };
},
rowKey: 'businessId',
columns,
rowSelection: true,
formConfig: {
labelWidth: 120,
schemas: searchFormSchema,
autoSubmitOnEnter: true,
resetFunc: () => {
searchInfo.institutionId=''
},
},
useSearchForm: true,
showTableSetting: false,
bordered: true,
handleSearchInfoFn(info) {
return info;
},
actionColumn: {
width: 100,
title: '操作',
dataIndex: 'action',
},
});
const { push } = useRouter();
/** 新增按钮*/
function handleCreate() {
addUserModal(true, {
isAdd: true,
});
}
function updateData(){
console.log()
}
/**批量移动*/
function handleMoveBatch() {
const rowSelection = getRowSelection().selectedRowKeys;
openMoveUserModal(true, {
idList:rowSelection,
isMove: true,
});
}
/** 移动按钮*/
function handleMove(record: Recordable) {
openMoveUserModal(true, {
record,
isMove: true,
});
}
/** 新增按钮*/
function handleAdd(record: Recordable) {
openModal(true, {
record,
isAdd: true,
});
}
/** 编辑按钮*/
function handleEdit(record: Recordable) {
openModal(true, {
record,
isUpdate: true,
});
}/** 详情按钮*/
function handleDetails(record: Recordable) {
push({
path: '/dataSharingAndExchange/resourceManagement/detail',
// path: '/dataWarehousePlanning/physicalModel/detail',
query: record,
});
}
/** 删除按钮*/
function handleDelete(record: Recordable) {
tableData.value.splice(tableData.value.findIndex(item => item.businessId === record.businessId), 1);
createMessage.success('删除成功!');
reload();
}
/** 导入成功*/
function handleImportSuccess() {
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 handleAddSuccess({ isAdd, values,length }) {
if (length > 0){
//批量添加
for (let i = 0; i < length; i++){
tableData.value.push(values[i])
}
}
reload();
}
/** 部门树的select*/
function handleSelect(institutionId = '') {
searchInfo.institutionId = institutionId;
reload();
}
function handleView(record: Recordable) {
go('/system/account_detail/' + record.id);
}
onMounted(() => {
tableData.value = userData
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} from "ant-design-vue";
import { 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: 'name',
width: 150,
},
{
title: '项目',
dataIndex: 'project',
width: 150,
},
{
title: '权属机构',
dataIndex: 'ownerInstitution',
width: 150,
},
{
title: '创建者',
dataIndex: 'creator',
width: 150,
},
{
title: '创建时间',
dataIndex: 'createDate',
width: 150,
},
{
title: '发布状态',
dataIndex: 'releaseStatus',
width: 150,
},
{
title: '发布者',
dataIndex: 'releaser',
width: 150,
},
{
title: '发布时间',
dataIndex: 'releaseDate',
width: 150,
},
];
export const searchFormSchema: FormSchema[] = [
{
field: 'name',
label: '资源名称',
component: 'Input',
componentProps: {
placeholder: '搜索资源名称',
},
colProps: { span: 5 },
},
{
field: 'project',
label: '项目',
component: 'Input',
componentProps: {
placeholder: '搜索项目',
},
colProps: { span: 5 },
},
{
field: 'ownerInstitution',
label: '权属机构',
component: 'Select',
componentProps: {
placeholder: '权属机构',
options: [
{ label: 'test1', value: 'test1' },
{ label: 'test2', value: 'test2' },
{ label: 'test3', value: 'test3' },
{ label: 'test4', value: 'test4' },
]
},
colProps: { span: 5 },
},
{
field: 'releaseStatus',
label: '发布状态',
component: 'Select',
componentProps: {
placeholder: '发布状态',
options: [
{ label: '已发布', value: '已发布' },
{ label: '发布审批中', value: '发布审批中' },
{ label: '未发布', value: '未发布' },
],
},
colProps: { span: 5 },
},
];
export const accountFormSchema: any[] = [
{
field: 'name',
label: '名称',
component: 'Input',
colProps: { lg: 24, md: 24 },
rules: [
{
required: true,
message: '请输入姓名',
},
],
},
{
field: 'describe',
label: '描述',
component: 'Input',
colProps: { lg: 24, md: 24 },
rules: [
{
required: true,
message: '请输入描述',
},
],
},
{
field: 'visibleRange',
label: '可见范围',
component: 'Select',
componentProps: {
options: [
{ label: '所有人', value: '所有人' },
{ label: '用户1', value: '用户1' },
{ label: '用户2', value: '用户2' },
],
},
colProps: { lg: 24, md: 24 },
rules: [
{
required: true,
message: '请输入登录名',
},
],
},
{
field: 'resourceNum',
label: '可见资源数',
component: 'InputNumber',
colProps: { lg: 24, md: 24 },
rules: [
{
required: true,
message: '请输入',
},
],
},
{
field: 'institutionId',
label: '所属编目',
component: 'TreeSelect',
colProps: { lg: 24, md: 24 },
componentProps: {
fieldNames: {
label: 'institutionName',
value: 'businessId',
},
getPopupContainer: () => document.body,
},
required: true,
},
];
/**移动*/
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,
},
]
/**新增*/
export const AddTreeSchema: any[] = [
{
field: 'institutionName',
label: '编目名称',
component: 'Input',
colProps: { lg: 24, md: 24 },
rules: [
{
required: true,
message: '请输入编目名称',
},
],
},
{
field: 'institutionId',
label: '上级编目',
component: 'TreeSelect',
colProps: { lg: 24, md: 24 },
componentProps: {
fieldNames: {
label: 'institutionName',
value: 'businessId',
},
getPopupContainer: () => document.body,
},
required: true,
},
// {
// field: 'code',
// label: '机构编码',
// component: 'Input',
// colProps: { lg: 24, md: 24 },
// rules: [
// {
// required: true,
// message: '请输入机构编码',
// },
// ],
// },
]
import {getAllRoleList} from '@/api/system/role/role';
import { BasicColumn, FormSchema } from '@/components/Table';
import {h} from "vue";
import {Tag} from "ant-design-vue";
import { 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: 'name',
width: 150,
},
{
title: '描述',
dataIndex: 'describe',
width: 150,
},
{
title: '可见范围',
dataIndex: 'visibleRange',
width: 150,
},
{
title: '资源数',
dataIndex: 'resourceNum',
width: 150,
},
{
title: '创建时间',
dataIndex: 'createDate',
width: 150,
},
{
title: '更新时间',
dataIndex: 'updateDate',
width: 150,
},
];
export const searchFormSchema: FormSchema[] = [
{
field: 'name',
label: '姓名',
component: 'Input',
componentProps: {
placeholder: '请输入姓名',
},
colProps: { span: 7 },
},
// {
// field: 'username',
// label: '登录名',
// component: 'Input',
// componentProps: {
// placeholder: '请输入登录名',
// },
// colProps: { span: 7 },
// },
];
export const TreeData: any[] = [
{
"delFlag" : "0",
"flag" : "1",
"businessId" : 100,
"institutionName" : "资源编目管理",
"anotherName":"资源编目管理",
"parentId" : 0,
"code": "DataGovernanceDep_product1",
"ancestors" : "0",
"orderNum" : 0,
"children" : [ ],
"selectType" : null,
icon: 'ion:settings-outline',
},
{
"delFlag" : "0",
"flag" : "1",
"businessId" : 101,
"institutionName" : "一级编目",
"anotherName":"数据平台治理部",
"parentId" : 100,
"code": "DataGovernanceDep_product2",
"ancestors" : "0,100",
"orderNum" : 1,
"children" : [ ],
"selectType" : null,
icon: 'ion:settings-outline',
},
{
"delFlag" : "0",
"flag" : "1",
"businessId" : 102,
"institutionName" : "公共安全",
"anotherName":"数据资源管理部",
"parentId" : 100,
"code": "DataGovernanceDep_product3",
"ancestors" : "0,100",
"orderNum" : 2,
"children" : [ ],
"selectType" : null,
icon: 'ion:settings-outline',
},
{
"delFlag" : "0",
"flag" : "1",
"businessId" : 103,
"institutionName" : "卫生健康",
"anotherName":"数据资源管理部",
"parentId" : 100,
"code": "DataGovernanceDep_product3",
"ancestors" : "0,100",
"orderNum" : 2,
"children" : [ ],
"selectType" : null,
icon: 'ion:settings-outline',
},
{
"delFlag" : "0",
"flag" : "1",
"businessId" : 104,
"institutionName" : "文化休闲",
"anotherName":"数据资源管理部",
"parentId" : 100,
"code": "DataGovernanceDep_product3",
"ancestors" : "0,100",
"orderNum" : 2,
"children" : [ ],
"selectType" : null,
icon: 'ion:settings-outline',
},
{
"delFlag" : "0",
"flag" : "1",
"businessId" : 105,
"institutionName" : "经济建设",
"anotherName":"数据资源管理部",
"parentId" : 100,
"code": "DataGovernanceDep_product3",
"ancestors" : "0,100",
"orderNum" : 2,
"children" : [ ],
"selectType" : null,
icon: 'ion:settings-outline',
},
{
"delFlag" : "0",
"flag" : "1",
"businessId" : 106,
"institutionName" : "科技教育",
"anotherName":"数据资源管理部",
"parentId" : 100,
"code": "DataGovernanceDep_product3",
"ancestors" : "0,100",
"orderNum" : 2,
"children" : [ ],
"selectType" : null,
icon: 'ion:settings-outline',
},
];
export const userData: any[] = [
{
"delFlag" : "0",
"flag" : "1",
"businessId" : 309,
"username" : "一级编目",
"nickName" : "一级编目",
"userType" : "1",
"creator" : "monkey",
"releaser" : "duck",
"name" : "一级资源",
"project" : "一级编目",
"releaseStatus" : "已发布",
"ownerInstitution" : "test1",
"resourceNum" : 3,
"institutionId": 101,
"createDate": "2024-10-24 10:04:04",
"releaseDate": "2024-10-25 10:04:04",
},
{
"delFlag" : "0",
"flag" : "1",
"businessId" : 310,
"username" : "公共安全",
"nickName" : "公共安全",
"userType" : "1",
"creator" : "monkey",
"releaser" : "duck",
"name" : "二级资源",
"project" : "公共安全",
"ownerInstitution" : "test2",
"releaseStatus" : "已发布",
"resourceNum" : 4,
"institutionId": 102,
"createDate": "2024-10-24 10:04:04",
"releaseDate": "2024-10-25 10:04:04",
},
{
"delFlag": "0",
"flag": "1",
"businessId": 317,
"username" : "卫生健康",
"nickName" : "卫生健康",
"userType" : "1",
"creator" : "monkey",
"releaser" : "duck",
"name" : "三级资源",
"project" : "卫生健康",
"releaseStatus" : "已发布",
"ownerInstitution" : "test1",
"resourceNum" : 5,
"institutionId": 103,
"createDate": "2024-10-24 10:04:04",
"releaseDate": "2024-10-25 10:04:04",
},
{
"delFlag": "0",
"flag": "1",
"businessId": 318,
"username" : "文化休闲",
"nickName" : "文化休闲",
"userType" : "1",
"creator" : "monkey",
"releaser" : "duck",
"name" : "四级资源",
"project" : "文化休闲",
"releaseStatus" : "已发布",
"ownerInstitution" : "test3",
"resourceNum" : 6,
"institutionId": 104,
"createDate": "2024-10-24 10:04:04",
"releaseDate": "2024-10-25 10:04:04",
},
{
"delFlag": "0",
"flag": "1",
"businessId": 319,
"username" : "经济建设",
"nickName" : "经济建设",
"userType" : "1",
"creator" : "monkey",
"releaser" : "duck",
"name" : "五级资源",
"project" : "经济建设",
"releaseStatus" : "已发布",
"ownerInstitution" : "test1",
"resourceNum" : 7,
"institutionId": 105,
"createDate": "2024-10-24 10:04:04",
"releaseDate": "2024-10-25 10:04:04",
},
{
"delFlag": "0",
"flag": "1",
"businessId": 320,
"username" : "科技教育",
"nickName" : "科技教育",
"userType" : "1",
"creator" : "monkey",
"releaser" : "duck",
"name" : "特级资源",
"project" : "科技教育",
"releaseStatus" : "未发布",
"ownerInstitution" : "test4",
"resourceNum" : 8,
"createDate": "2024-10-24 10:04:04",
"releaseDate": "2024-10-25 10:04:04",
"institutionId": 106,
// "institutionName" : "研发部门",
}
];
export const addUserData: any[] = [
{
"delFlag" : "0",
"flag" : "1",
"businessId" : 400,
"username" : "tianjia1",
"nickName" : "添加用户1",
"userType" : "1",
"name" : "添加用户1",
"roleName":"工作区访客",
"createDate": "2024-10-24 10:04:04",
"institutionId" : null,
"institutionName" : "",
"code":"123f",
"identity" : "1",
"roleIds" : null,
"roleNames" : "三级用户",
"roleList" : null,
"menuList" : [ ]
},
{
"delFlag" : "0",
"flag" : "1",
"businessId" : 402,
"username" : "tianjia2",
"nickName" : "添加用户2",
"userType" : "1",
"name" : "添加用户2",
"roleName":"工作区访客",
"createDate": "2024-10-25 10:05:05",
"sex" : "0",
"institutionId" : null,
"institutionName" : "",
"code":"123a",
"identity" : "1",
"roleIds" : null,
"roleNames" : null,
"roleList" : null,
"menuList" : [ ]
},
{
"delFlag": "0",
"flag": "1",
"businessId": 403,
"username": "tianjia3",
"nickName": "添加用户3",
"userType": "1",
"name": "添加用户3",
"roleName":"工作区访客",
"createDate": "2024-10-26 10:06:06",
"sex": "1",
"institutionId": null,
"institutionName" : "",
"code":"123c",
"identity": "1",
"roleIds": null,
"roleNames": "超级管理员",
"roleList": null,
"menuList": []
},
];
export const accountFormSchema: any[] = [
];
<template>
<BasicModal v-bind="$attrs" @register="registerModal" :title="getTitle" @ok="handleSubmit" minHeight="50">
<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 {accountFormSchema, MoveFormSchema, resetPasswordFormSchema} from './institution.data';
import { getDeptList } from '@/api/system/dept/dept';
import {resetUserPwd} from '@/api/system/user/user'
import { encryptTwo } from '@/utils/jsencrypt'
import { useMessage } from '@/hooks/web/useMessage';
import {TreeData, userData} from "@/views/dataSharingAndExchange/catalogingManagement/institutionData";
defineOptions({ name: 'AccountModal' });
const emit = defineEmits(['success', 'register']);
const { createMessage } = useMessage();
const isUpdate = ref(true);
const rowId = ref('');
const idList = ref([])
const rowData = ref([])
//获取接口数据并放在下拉框里(这里是打开了一个弹框)
//初始化表单
const [registerForm, { setFieldsValue, updateSchema, resetFields, validate }] = useForm({
labelWidth: 100,
baseColProps: { span: 24 },
schemas: MoveFormSchema,
showActionButtonGroup: false,
actionColOptions: {
span: 23,
},
});
//初始化弹框
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
//每次点击弹窗 需要清空存储的数据
rowData.value = []
//重置表单数据
resetFields();
setModalProps({ confirmLoading: false });
if (data.idList != null && data.idList != undefined && data.idList.length > 0){
//批量移动
//根据id查用户信息
idList.value = data.idList;
//过滤出userData中businessId与idList相等的数据
const result = userData.filter(item => data.idList.includes(item.businessId));
result.forEach(item => {
rowData.value.push(item)
})
}else {
rowData.value.push(data.record)
//单个移动
rowId.value = data.record.businessId;
setFieldsValue({
...data.record,
});
}
const treeList = handleTree(TreeData, 'businessId',undefined,undefined,undefined)
updateSchema([
{
field: 'institutionId',
componentProps: {
treeData: treeList
},
},
]);
});
const getTitle = computed(() => ('移动用户'));
/**确定按钮*/
async function handleSubmit() {
try {
//校验并得到表单数据
const values = await validate();
setModalProps({ confirmLoading: true });
//拿到表单里修改后的值 进行修改赋值 传给父组件
console.log('rowData.value:',rowData.value)
rowData.value.forEach(item => {
item.institutionId = values.institutionId
})
emit('success', { values: { ...rowData.value }})
createMessage.success('移动成功');
closeModal();
} finally {
setModalProps({ confirmLoading: false });
}
}
/**数组对象转成树*/
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
}
</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