优化菜单、租户

This commit is contained in:
zjl 2024-12-11 15:57:54 +08:00
parent 1b77f96704
commit 62bcc3c098
6 changed files with 76 additions and 40 deletions

View File

@ -11,7 +11,7 @@ export const columns: BasicColumn[] = [
{ {
title: '菜单名称', title: '菜单名称',
key: 'name', key: 'name',
width: 150, width: 200,
align: 'left', align: 'left',
}, },
{ {

View File

@ -128,6 +128,7 @@
import { useMessage, useDialog } from 'naive-ui'; import { useMessage, useDialog } from 'naive-ui';
import { useModal } from '@/components/Modal'; import { useModal } from '@/components/Modal';
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
/** /**
* 定义接收的参数 * 定义接收的参数
*/ */
@ -146,7 +147,6 @@
/** /**
* 定义参数变量 * 定义参数变量
*/ */
const [modalRegister, { openModal, setSubLoading }] = useModal({ const [modalRegister, { openModal, setSubLoading }] = useModal({
title: props.menuId ? '编辑菜单' : '添加菜单', title: props.menuId ? '编辑菜单' : '添加菜单',
subBtuText: '确定', subBtuText: '确定',
@ -275,7 +275,10 @@
formData.parentId = props.pid; formData.parentId = props.pid;
} }
}); });
//
/**
* 定义函数
*/
defineExpose({ defineExpose({
openModal, openModal,
}); });

View File

@ -64,26 +64,19 @@
const menuId = ref(0); const menuId = ref(0);
const pid = ref(0); const pid = ref(0);
/**
* 定义操作栏
*/
const actionColumn = reactive({ const actionColumn = reactive({
width: 220, width: 250,
title: '操作', title: '操作',
align: 'center', align: 'left',
key: 'action', key: 'action',
fixed: 'right', fixed: 'right',
render(record) { render(record) {
return h(TableAction as any, { return h(TableAction as any, {
style: 'button', style: 'button',
actions: [ actions: [
{
label: '新增',
type: 'info',
icon: renderIcon(PlusOutlined),
auth: ['sys:menu:add'],
ifShow: () => {
return record.type !== 1;
},
onclick: handleAdd.bind(null, record),
},
{ {
label: '编辑', label: '编辑',
type: 'warning', type: 'warning',
@ -98,6 +91,16 @@
auth: ['sys:menu:delete'], auth: ['sys:menu:delete'],
onclick: handleDelete.bind(null, record), onclick: handleDelete.bind(null, record),
}, },
{
label: '新增',
type: 'info',
icon: renderIcon(PlusOutlined),
auth: ['sys:menu:add'],
ifShow: () => {
return record.type !== 1;
},
onclick: handleAdd.bind(null, record),
},
], ],
}); });
}, },

View File

@ -218,6 +218,10 @@
subBtuText: '确定', subBtuText: '确定',
width: 800, width: 800,
}); });
/**
* 定义表单参数
*/
const formData = reactive({ const formData = reactive({
id: 0, id: 0,
code: '', code: '',
@ -275,6 +279,7 @@
setSubLoading(false); setSubLoading(false);
}); });
}; };
/** /**
* 定义选项数据 * 定义选项数据
*/ */
@ -285,10 +290,19 @@
positionList: [], positionList: [],
}); });
/**
* 上传发生变化
* @param data 参数
*/
function uploadChange(data: string[]) { function uploadChange(data: string[]) {
formData.avatar = data.fileUrl; formData.avatar = data.fileUrl;
formData.avatarName = data.fileName; formData.avatarName = data.fileName;
} }
/**
* 执行删除文件
* @param file 文件参数
*/
const handleDelete = async (file) => { const handleDelete = async (file) => {
console.log(file); console.log(file);
}; };
@ -316,7 +330,10 @@
setFormData({ tenantId: props.tenantId }); setFormData({ tenantId: props.tenantId });
} }
}); });
//
/**
* 定义函数
*/
defineExpose({ defineExpose({
openModal, openModal,
}); });

View File

@ -27,7 +27,6 @@
</template> </template>
新建 新建
</n-button> </n-button>
<n-button <n-button
type="error" type="error"
@click="handleDelete" @click="handleDelete"
@ -68,13 +67,9 @@
} from '@/api/system/tenant'; } from '@/api/system/tenant';
import { columns } from './columns'; import { columns } from './columns';
import { PlusOutlined, DeleteOutlined, FormOutlined } from '@vicons/antd'; import { PlusOutlined, DeleteOutlined, FormOutlined } from '@vicons/antd';
import CreateModal from './CreateModal.vue';
import editDialog from './edit.vue'; import editDialog from './edit.vue';
import { basicModal, useModal } from '@/components/Modal';
import { downloadByData } from '@/utils/file/download';
import { schemas } from './querySchemas'; import { schemas } from './querySchemas';
import { renderIcon } from '@/utils'; import { renderIcon } from '@/utils';
import printJS from 'print-js';
const message = useMessage(); const message = useMessage();
const dialog = useDialog(); const dialog = useDialog();
@ -83,15 +78,23 @@
const editVisible = ref(false); const editVisible = ref(false);
const tenantId = ref(0); const tenantId = ref(0);
const rowKeys = ref([]); const rowKeys = ref([]);
const showModal = ref(false); const showModal = ref(false);
/**
* 定义查询参数
*/
const formParams = reactive({ const formParams = reactive({
//
name: '', name: '',
//
status: '', status: '',
}); });
/**
* 定义操作栏
*/
const actionColumn = reactive({ const actionColumn = reactive({
width: 200, width: 320,
title: '操作', title: '操作',
align: 'center', align: 'center',
key: 'action', key: 'action',
@ -119,24 +122,36 @@
}, },
}); });
function addTable() { /**
showModal.value = true; * 加载数据列表
} * @param res 参数
*/
const loadDataTable = async (res) => { const loadDataTable = async (res) => {
rowKeys.value = []; rowKeys.value = [];
const result = await getTenantList({ ...formParams, ...res }); const result = await getTenantList({ ...formParams, ...res });
return result; return result;
}; };
/**
* 数据行选中事件
* @param keys 参数
*/
function onCheckedRow(keys) { function onCheckedRow(keys) {
rowKeys.value = keys; rowKeys.value = keys;
} }
/**
* 刷新数据列表
* @param noRefresh 参数
*/
function reloadTable(noRefresh = '') { function reloadTable(noRefresh = '') {
basicTableRef.value.reload(noRefresh ? {} : { pageNo: 1 }); basicTableRef.value.reload(noRefresh ? {} : { pageNo: 1 });
} }
/**
* 执行提交表单
* @param values 参数
*/
function handleSubmit(values: Recordable) { function handleSubmit(values: Recordable) {
for (const key in formParams) { for (const key in formParams) {
formParams[key] = ''; formParams[key] = '';
@ -147,6 +162,10 @@
reloadTable(); reloadTable();
} }
/**
* 执行重置
* @param values 参数
*/
function handleReset(values: Recordable) { function handleReset(values: Recordable) {
for (const key in formParams) { for (const key in formParams) {
formParams[key] = ''; formParams[key] = '';
@ -157,11 +176,15 @@
reloadTable(); reloadTable();
} }
/**
* 执行注册
*/
const [register, {}] = useForm({ const [register, {}] = useForm({
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' }, gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
labelWidth: 80, labelWidth: 80,
schemas, schemas,
}); });
/** /**
* 执行添加 * 执行添加
*/ */
@ -171,6 +194,7 @@
await nextTick(); await nextTick();
createModalRef.value.openModal(); createModalRef.value.openModal();
}; };
/** /**
* 执行编辑 * 执行编辑
*/ */
@ -180,6 +204,7 @@
await nextTick(); await nextTick();
createModalRef.value.openModal(); createModalRef.value.openModal();
} }
/** /**
* 执行删除 * 执行删除
* @param id 参数 * @param id 参数

View File

@ -1,16 +1,4 @@
import { FormSchema } from '@/components/Form/index'; import { FormSchema } from '@/components/Form/index';
import { getRoleAllList } from '@/api/system/role';
export const loadSelectData = async (res) => {
//这里可以进行数据转换处理
return (await getRoleAllList({ ...res })).map((item, index) => {
return {
...item,
label: item.name,
value: item.id,
index,
};
});
};
export const schemas: FormSchema[] = [ export const schemas: FormSchema[] = [
{ {
field: 'realname', field: 'realname',