优化部门、角色

This commit is contained in:
zjl 2024-12-11 15:47:34 +08:00
parent 3811a5c8a8
commit 1b77f96704
7 changed files with 80 additions and 21 deletions

View File

@ -5,7 +5,7 @@ export const columns = [
{
title: '部门名称',
key: 'name',
width: 150,
width: 250,
align: 'left',
},
{
@ -54,7 +54,7 @@ export const columns = [
{
title: '部门备注',
key: 'note',
width: 100,
width: 200,
},
{
title: '创建人',

View File

@ -135,13 +135,18 @@
sort: 0,
note: '',
});
/**
* 定义模态
*/
const [modalRegister, { openModal, setSubLoading }] = useModal({
title: props.deptId ? '编辑部门' : '添加部门',
subBtuText: '确定',
width: 600,
});
/**
* 关闭窗体
* 执行关闭窗体
*/
const handleClose = () => {
emit('update:visible', false);
@ -208,7 +213,10 @@
formData.parentId = props.pid;
}
});
//
/**
* 定义函数
*/
defineExpose({
openModal,
});

View File

@ -64,8 +64,11 @@
const deptId = ref(0);
const pid = ref(0);
/**
* 定义操作栏
*/
const actionColumn = reactive({
width: 220,
width: 250,
title: '操作',
align: 'center',
key: 'action',

View File

@ -22,7 +22,7 @@
children-field="children"
cascade
virtual-scroll
style="height: 350px"
style="height: 450px"
:checked-keys="checkedKeys"
:expanded-keys="expandedKeys"
:indeterminate-keys="halfCheckedIds"
@ -42,7 +42,6 @@
import { useMessage } from 'naive-ui';
import { onMounted, ref } from 'vue';
import { useModal } from '@/components/Modal';
import { isArray } from '@/utils/is';
/**
* 定义接收的参数
@ -75,11 +74,15 @@
const menuArray = ref<any[]>([]);
const menuTree = ref<any[]>([]);
/**
* 定义模态
*/
const [modalRegister, { openModal, setSubLoading }] = useModal({
title: '分配权限',
subBtuText: '确定',
width: 600,
});
/**
* 执行扩展收缩
*/
@ -102,7 +105,9 @@
}
};
//
/**
* 获取所有选择的节点
*/
const getDeptAllCheckedKeys = () => {
const checkedKeys = treeRef.value?.getCheckedData().keys;
const halfCheckedKeys = treeRef.value?.getIndeterminateData().keys;
@ -137,6 +142,10 @@
checkedKeys.value = node;
};
/**
* 执行收缩展开
* @param node 参数
*/
const handleExpands = (node) => {
expandedKeys.value = node;
};
@ -155,6 +164,7 @@
checkedKeys.value = keys.checkedIds;
halfCheckedIds.value = keys.halfCheckedIds;
};
/**
* 选中树结构
* @param nodes 节点
@ -210,6 +220,10 @@
onMounted(() => {
setFormData();
});
/**
* 定义函数
*/
defineExpose({
openModal,
});

View File

@ -79,13 +79,18 @@
default: 0,
},
});
/**
* 定义模态
*/
const [modalRegister, { openModal, setSubLoading }] = useModal({
title: props.roleId ? '编辑角色' : '添加角色',
subBtuText: '确定',
width: 600,
});
/**
* 执行提交
* 执行提交表单
*/
const handleSubmit = async () => {
formRef.value
@ -129,7 +134,10 @@
setFormData();
}
});
//
/**
* 定义函数
*/
defineExpose({
openModal,
});

View File

@ -27,7 +27,6 @@
</template>
新建
</n-button>
<n-button
type="error"
@click="handleDelete"
@ -45,6 +44,7 @@
</template>
</BasicTable>
</n-card>
<!-- 编辑弹窗 -->
<editDialog
ref="createModalRef"
:roleId="roleId"
@ -52,6 +52,7 @@
v-model:visible="editVisible"
@success="reloadTable('noRefresh')"
/>
<!-- 权限设置弹窗 -->
<authDialog
ref="authRef"
v-if="authVisible"
@ -70,10 +71,8 @@
import { getRoleList, roleDelete, roleBatchDelete } from '@/api/system/role';
import { columns } from './columns';
import { PlusOutlined, DeleteOutlined, FormOutlined, SettingOutlined } from '@vicons/antd';
import CreateModal from './CreateModal.vue';
import editDialog from './edit.vue';
import authDialog from './auth.vue';
import { basicModal, useModal } from '@/components/Modal';
import { schemas } from './querySchemas';
import { renderIcon } from '@/utils';
@ -86,15 +85,20 @@
const authVisible = ref(false);
const roleId = ref(0);
const rowKeys = ref([]);
const exportLoading = ref(false);
const showModal = ref(false);
/**
* 定义查询参数
*/
const formParams = reactive({
name: '',
});
/**
* 定义操作栏
*/
const actionColumn = reactive({
width: 250,
width: 300,
title: '操作',
align: 'center',
key: 'action',
@ -129,24 +133,36 @@
},
});
function addTable() {
showModal.value = true;
}
/**
* 加载数据列表
* @param res 参数
*/
const loadDataTable = async (res) => {
rowKeys.value = [];
const result = await getRoleList({ ...formParams, ...res });
return result;
};
/**
* 数据行选中事件
* @param keys 参数
*/
function onCheckedRow(keys) {
rowKeys.value = keys;
}
/**
* 刷新数据列表
* @param noRefresh 参数
*/
function reloadTable(noRefresh = '') {
basicTableRef.value.reload(noRefresh ? {} : { pageNo: 1 });
}
/**
* 执行提交表单
* @param values 参数
*/
function handleSubmit(values: Recordable) {
for (const key in formParams) {
formParams[key] = '';
@ -157,6 +173,10 @@
reloadTable();
}
/**
* 执行重置
* @param values 参数
*/
function handleReset(values: Recordable) {
for (const key in formParams) {
formParams[key] = '';
@ -167,6 +187,9 @@
reloadTable();
}
/**
* 执行注册
*/
const [register, {}] = useForm({
gridProps: { cols: '1 s:1 m:2 l:3 xl:4 2xl:4' },
labelWidth: 80,
@ -182,6 +205,7 @@
await nextTick();
createModalRef.value.openModal();
};
/**
* 执行编辑
*/
@ -191,6 +215,7 @@
await nextTick();
createModalRef.value.openModal();
}
/**
* 执行分配权限
*/
@ -200,6 +225,7 @@
await nextTick();
authRef.value.openModal();
}
/**
* 执行删除
* @param id 参数

View File

@ -131,7 +131,7 @@
* 定义操作栏
*/
const actionColumn = reactive({
width: 400,
width: 380,
title: '操作',
align: 'center',
key: 'action',