mirror of
https://github.com/yangzongzhuan/RuoYi-Vue3.git
synced 2025-09-28 15:22:42 +00:00
优化代码
This commit is contained in:
@@ -305,17 +305,20 @@ function getList() {
|
||||
loading.value = false;
|
||||
});
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
function handleQuery() {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
dateRange.value = [];
|
||||
proxy.resetForm("queryRef");
|
||||
handleQuery();
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
function handleDelete(row) {
|
||||
const roleIds = row.roleId || ids.value;
|
||||
@@ -326,18 +329,21 @@ function handleDelete(row) {
|
||||
proxy.$modal.msgSuccess("删除成功");
|
||||
}).catch(() => {});
|
||||
}
|
||||
|
||||
/** 导出按钮操作 */
|
||||
function handleExport() {
|
||||
proxy.download("system/role/export", {
|
||||
...queryParams.value,
|
||||
}, `role_${new Date().getTime()}.xlsx`);
|
||||
}
|
||||
|
||||
/** 多选框选中数据 */
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map(item => item.roleId);
|
||||
single.value = selection.length != 1;
|
||||
multiple.value = !selection.length;
|
||||
}
|
||||
|
||||
/** 角色状态修改 */
|
||||
function handleStatusChange(row) {
|
||||
let text = row.status === "0" ? "启用" : "停用";
|
||||
@@ -349,6 +355,7 @@ function handleStatusChange(row) {
|
||||
row.status = row.status === "0" ? "1" : "0";
|
||||
});
|
||||
}
|
||||
|
||||
/** 更多操作 */
|
||||
function handleCommand(command, row) {
|
||||
switch (command) {
|
||||
@@ -362,16 +369,19 @@ function handleCommand(command, row) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/** 分配用户 */
|
||||
function handleAuthUser(row) {
|
||||
router.push("/system/role-auth/user/" + row.roleId);
|
||||
}
|
||||
|
||||
/** 查询菜单树结构 */
|
||||
function getMenuTreeselect() {
|
||||
menuTreeselect().then(response => {
|
||||
menuOptions.value = response.data;
|
||||
});
|
||||
}
|
||||
|
||||
/** 所有部门节点数据 */
|
||||
function getDeptAllCheckedKeys() {
|
||||
// 目前被选中的部门节点
|
||||
@@ -381,6 +391,7 @@ function getDeptAllCheckedKeys() {
|
||||
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
|
||||
return checkedKeys;
|
||||
}
|
||||
|
||||
/** 重置新增的表单以及其他数据 */
|
||||
function reset() {
|
||||
if (menuRef.value != undefined) {
|
||||
@@ -404,6 +415,7 @@ function reset() {
|
||||
};
|
||||
proxy.resetForm("roleRef");
|
||||
}
|
||||
|
||||
/** 添加角色 */
|
||||
function handleAdd() {
|
||||
reset();
|
||||
@@ -411,6 +423,7 @@ function handleAdd() {
|
||||
open.value = true;
|
||||
title.value = "添加角色";
|
||||
}
|
||||
|
||||
/** 修改角色 */
|
||||
function handleUpdate(row) {
|
||||
reset();
|
||||
@@ -433,6 +446,7 @@ function handleUpdate(row) {
|
||||
title.value = "修改角色";
|
||||
});
|
||||
}
|
||||
|
||||
/** 根据角色ID查询菜单树结构 */
|
||||
function getRoleMenuTreeselect(roleId) {
|
||||
return roleMenuTreeselect(roleId).then(response => {
|
||||
@@ -440,6 +454,7 @@ function getRoleMenuTreeselect(roleId) {
|
||||
return response;
|
||||
});
|
||||
}
|
||||
|
||||
/** 根据角色ID查询部门树结构 */
|
||||
function getDeptTree(roleId) {
|
||||
return deptTreeSelect(roleId).then(response => {
|
||||
@@ -447,6 +462,7 @@ function getDeptTree(roleId) {
|
||||
return response;
|
||||
});
|
||||
}
|
||||
|
||||
/** 树权限(展开/折叠)*/
|
||||
function handleCheckedTreeExpand(value, type) {
|
||||
if (type == "menu") {
|
||||
@@ -461,6 +477,7 @@ function handleCheckedTreeExpand(value, type) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 树权限(全选/全不选) */
|
||||
function handleCheckedTreeNodeAll(value, type) {
|
||||
if (type == "menu") {
|
||||
@@ -469,6 +486,7 @@ function handleCheckedTreeNodeAll(value, type) {
|
||||
deptRef.value.setCheckedNodes(value ? deptOptions.value : []);
|
||||
}
|
||||
}
|
||||
|
||||
/** 树权限(父子联动) */
|
||||
function handleCheckedTreeConnect(value, type) {
|
||||
if (type == "menu") {
|
||||
@@ -477,6 +495,7 @@ function handleCheckedTreeConnect(value, type) {
|
||||
form.value.deptCheckStrictly = value ? true : false;
|
||||
}
|
||||
}
|
||||
|
||||
/** 所有菜单节点数据 */
|
||||
function getMenuAllCheckedKeys() {
|
||||
// 目前被选中的菜单节点
|
||||
@@ -486,6 +505,7 @@ function getMenuAllCheckedKeys() {
|
||||
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys);
|
||||
return checkedKeys;
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
function submitForm() {
|
||||
proxy.$refs["roleRef"].validate(valid => {
|
||||
@@ -508,17 +528,20 @@ function submitForm() {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** 取消按钮 */
|
||||
function cancel() {
|
||||
open.value = false;
|
||||
reset();
|
||||
}
|
||||
|
||||
/** 选择角色权限范围触发 */
|
||||
function dataScopeSelectChange(value) {
|
||||
if (value !== "2") {
|
||||
deptRef.value.setCheckedKeys([]);
|
||||
}
|
||||
}
|
||||
|
||||
/** 分配数据权限操作 */
|
||||
function handleDataScope(row) {
|
||||
reset();
|
||||
@@ -538,6 +561,7 @@ function handleDataScope(row) {
|
||||
title.value = "分配数据权限";
|
||||
});
|
||||
}
|
||||
|
||||
/** 提交按钮(数据权限) */
|
||||
function submitDataScope() {
|
||||
if (form.value.roleId != undefined) {
|
||||
@@ -549,6 +573,7 @@ function submitDataScope() {
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/** 取消按钮(数据权限)*/
|
||||
function cancelDataScope() {
|
||||
openDataScope.value = false;
|
||||
|
Reference in New Issue
Block a user