Commit 729e4758 authored by 罗林杰's avatar 罗林杰

修改元模型模块

parent 8b53d033
<template> <template>
<PageWrapper dense contentFullHeight fixedHeight contentClass="flex"> <PageWrapper style="height: 100%">
<ModelTree class="w-1/4 xl:w-1/5" @select="handleSelect" /> <Row>
<BasicTable @register="registerTable" class="w-3/4 xl:w-4/5" :searchInfo="searchInfo"> <Col :span="24" style="height: 800px">
<Card>
<BasicTable @register="registerTable" minheight:600px style="height: 800px">
<template #toolbar> <template #toolbar>
<a-button type="primary" @click="handleCreateFile">新建文件夹</a-button> <a-button type="primary" @click="handleCreateFile">新建文件夹</a-button>
<a-button type="primary" @click="handleCreateModel">新建元模型</a-button> <a-button type="primary" @click="handleCreateModel">新建元模型</a-button>
</template> </template>
<template #bodyCell="{ column, record }"> </BasicTable>
<template v-if="column.key === 'action'"> </Card>
<TableAction </Col>
:actions="[ </Row>
{ <Row>
// icon: 'clarity:note-edit-line', <Col :span="24" style="height: 800px">
label: '编辑', <Card>
onClick: handleEdit.bind(null, record), <BasicTable @register="registerTable" class="height" style="height: 800px">
}, <template #toolbar>
{ <a-button type="primary" @click="handleCreateFile">新建文件夹</a-button>
color: 'error', <a-button type="primary" @click="handleCreateModel">新建元模型</a-button>
label: '删除',
popConfirm: {
title: '是否确认删除',
placement: 'left',
confirm: handleDelete.bind(null, record),
},
},
{
label: '移动',
onClick: handleMove.bind(null, record),
},
]"
/>
</template> </template>
</BasicTable>
</Card>
</Col>
</Row>
<Row>
<Col :span="24" style="height: 800px">
<Card>
<BasicTable @register="registerTable" class="height" minheight:600px style="height: 800px">
<template #toolbar>
<a-button type="primary" @click="handleCreateFile">新建文件夹</a-button>
<a-button type="primary" @click="handleCreateModel">新建元模型</a-button>
</template> </template>
</BasicTable> </BasicTable>
</Card>
</Col>
</Row>
<ModelModal @register="registerModal" @success="handleSuccess" /> <ModelModal @register="registerModal" @success="handleSuccess" />
</PageWrapper> </PageWrapper>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
import { reactive, onMounted, ref } from 'vue'; import { reactive, onMounted, ref } from 'vue';
import { BasicTable, useTable, TableAction } from '@/components/Table'; import { BasicTable, useTable } from '@/components/Table';
import { PageWrapper } from '@/components/Page'; import { PageWrapper } from '@/components/Page';
import ModelTree from './ModelTree.vue'; import { useMessage } from '@/hooks/web/useMessage';
import { useMessage } from '@/hooks/web/useMessage'; import { useModal } from '@/components/Modal';
import { useModal } from '@/components/Modal'; import ModelModal from './modelModal.vue';
import ModelModal from './modelModal.vue'; import { columns, searchFormSchema } from './editModel.data';
import { columns, searchFormSchema } from './model.data'; import { useGo } from '@/hooks/web/usePage';
import { useGo } from '@/hooks/web/usePage'; 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 { editTableData } from '@/views/metaModel/knowledgeModel/modelData';
import { TreeData } from '@/views/metaModel/knowledgeModel/modelData'; import { Col, Row, Card } from 'ant-design-vue';
defineOptions({ name: 'AccountManagement' }); defineOptions({ name: 'AccountManagement' });
const { createMessage } = useMessage(); const { createMessage } = useMessage();
const filterStore = useFilterStore(); const filterStore = useFilterStore();
const route = useRoute(); const route = useRoute();
const go = useGo(); const go = useGo();
const [registerModal, { openModal }] = useModal(); const [registerModal, { openModal }] = useModal();
const [registerAddUserModal, { openModal: addUserModal }] = useModal(); const [registerAddUserModal, { openModal: addUserModal }] = useModal();
const [registerMoveUser, { openModal: openMoveUserModal }] = useModal(); const [registerMoveUser, { openModal: openMoveUserModal }] = useModal();
const searchInfo = reactive<Recordable>({}); const searchInfo = reactive<Recordable>({});
const tableData = ref([]); const tableData = ref([]);
const [ const [
registerTable, registerTable,
{ reload, updateTableDataRecord, getSearchInfo, getForm, getRowSelection }, { reload, updateTableDataRecord, getSearchInfo, getForm, getRowSelection },
] = useTable({ ] = useTable({
title: '', title: '',
api: async (params) => { api: async (params) => {
console.log('params:', params); console.log('params:', params);
...@@ -85,17 +88,16 @@ const [ ...@@ -85,17 +88,16 @@ const [
}, },
rowKey: 'businessId', rowKey: 'businessId',
columns, columns,
rowSelection: true, rowSelection: false,
formConfig: { formConfig: {
labelWidth: 120, labelWidth: 120,
schemas: searchFormSchema, schemas: searchFormSchema,
autoSubmitOnEnter: true, autoSubmitOnEnter: true,
resetFunc: () => {
searchInfo.modelId = '';
}, },
}, useSearchForm: false,
useSearchForm: true,
showTableSetting: false, showTableSetting: false,
showIndexColumn: false,
pagination: false,
bordered: true, bordered: true,
handleSearchInfoFn(info) { handleSearchInfoFn(info) {
return info; return info;
...@@ -105,50 +107,50 @@ const [ ...@@ -105,50 +107,50 @@ const [
title: '操作', title: '操作',
dataIndex: 'action', dataIndex: 'action',
}, },
}); });
/** 新增元模型*/ /** 新增元模型*/
function handleCreateModel() { function handleCreateModel() {
openModal(true, { openModal(true, {
isUpdate: false, isUpdate: false,
}); });
} }
/** 新增文件夹*/ /** 新增文件夹*/
function handleCreateFile() { function handleCreateFile() {
openModal(true, { openModal(true, {
isUpdate: false, isUpdate: false,
}); });
} }
/** 移动按钮*/ /** 移动按钮*/
function handleMove(record: Recordable) { function handleMove(record: Recordable) {
openMoveUserModal(true, { openMoveUserModal(true, {
record, record,
isMove: true, isMove: true,
}); });
} }
/** 编辑按钮*/ /** 编辑按钮*/
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {
openModal(true, { openModal(true, {
record, record,
isUpdate: true, isUpdate: true,
}); });
} }
/** 删除按钮*/ /** 删除按钮*/
function handleDelete(record: Recordable) { function handleDelete(record: Recordable) {
tableData.value.splice( tableData.value.splice(
tableData.value.findIndex((item) => item.businessId === record.businessId), tableData.value.findIndex((item) => item.businessId === record.businessId),
1, 1,
); );
createMessage.success('删除成功!'); createMessage.success('删除成功!');
reload(); reload();
} }
/** 新增/编辑成功*/ /** 新增/编辑成功*/
function handleSuccess({ isUpdate, values }) { function handleSuccess({ isUpdate, values }) {
if (isUpdate) { if (isUpdate) {
// 注意:updateTableDataRecord要求表格的rowKey属性为string并且存在于每一行的record的keys中 // 注意:updateTableDataRecord要求表格的rowKey属性为string并且存在于每一行的record的keys中
//修改表单的值 //修改表单的值
...@@ -158,10 +160,10 @@ function handleSuccess({ isUpdate, values }) { ...@@ -158,10 +160,10 @@ function handleSuccess({ isUpdate, values }) {
tableData.value.push(values); tableData.value.push(values);
reload(); reload();
} }
} }
/** 移动*/ /** 移动*/
function handleMoveSuccess({ isMove, values }) { function handleMoveSuccess({ isMove, values }) {
const rowSelection = getRowSelection().selectedRowKeys; const rowSelection = getRowSelection().selectedRowKeys;
if (rowSelection.length > 0) { if (rowSelection.length > 0) {
//批量移动 //批量移动
...@@ -173,35 +175,22 @@ function handleMoveSuccess({ isMove, values }) { ...@@ -173,35 +175,22 @@ function handleMoveSuccess({ isMove, values }) {
const result = updateTableDataRecord(values.businessId, values); const result = updateTableDataRecord(values.businessId, values);
} }
reload(); reload();
} }
/** 部门树的select*/ /** 部门树的select*/
function handleSelect(modelId = '') { function handleSelect(modelId = '') {
searchInfo.modelId = modelId; searchInfo.modelId = modelId;
reload(); reload();
} }
function handleView(record: Recordable) { function handleView(record: Recordable) {
go('/system/account_detail/' + record.id); go('/system/account_detail/' + record.id);
} }
onMounted(() => { onMounted(() => {
tableData.value = TreeData; tableData.value = editTableData;
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) => {
}
}
});
onBeforeRouteLeave((to, from, next) => {
const params = Object.assign({}, getSearchInfo(), getForm().getFieldsValue()); const params = Object.assign({}, getSearchInfo(), getForm().getFieldsValue());
filterStore.setSearchParams({ filterStore.setSearchParams({
path: from.path, path: from.path,
...@@ -210,5 +199,15 @@ onBeforeRouteLeave((to, from, next) => { ...@@ -210,5 +199,15 @@ onBeforeRouteLeave((to, from, next) => {
}, },
}); });
next(); // 允许导航 next(); // 允许导航
}); });
</script> </script>
<style>
.height {
.ant-table-container {
.ant-table-body {
min-height: 1000px;
}
}
}
</style>
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