Copyright © 2021 - 2024 youlai.tech All Rights Reserved. 有来技术
版权所有
@@ -114,35 +114,48 @@
-
+
diff --git a/src/views/system/dept/index.vue b/src/views/system/dept/index.vue
index c1d6f002..ec6722ca 100644
--- a/src/views/system/dept/index.vue
+++ b/src/views/system/dept/index.vue
@@ -38,7 +38,7 @@
新增
+
正常
@@ -76,7 +77,7 @@
type="primary"
link
size="small"
- @click.stop="openDialog(scope.row.id, undefined)"
+ @click.stop="handleOpenDialog(scope.row.id, undefined)"
>新增
编辑
+
+
+
@@ -158,8 +162,7 @@ defineOptions({
inheritAttrs: false,
});
-import DeptAPI from "@/api/dept";
-import { DeptVO, DeptForm, DeptQuery } from "@/api/dept/model";
+import DeptAPI, { DeptVO, DeptForm, DeptQuery } from "@/api/dept";
const queryFormRef = ref(ElForm);
const deptFormRef = ref(ElForm);
@@ -183,12 +186,15 @@ const formData = reactive({
});
const rules = reactive({
- parentId: [{ required: true, message: "上级部门不能为空", trigger: "blur" }],
+ parentId: [
+ { required: true, message: "上级部门不能为空", trigger: "change" },
+ ],
name: [{ required: true, message: "部门名称不能为空", trigger: "blur" }],
+ code: [{ required: true, message: "部门编号不能为空", trigger: "blur" }],
sort: [{ required: true, message: "显示排序不能为空", trigger: "blur" }],
});
-/** 查询 */
+/** 查询部门 */
function handleQuery() {
loading.value = true;
DeptAPI.getList(queryParams).then((data) => {
@@ -197,7 +203,7 @@ function handleQuery() {
});
}
-/**重置查询 */
+/** 重置查询 */
function handleResetQuery() {
queryFormRef.value.resetFields();
handleQuery();
@@ -208,27 +214,23 @@ function handleSelectionChange(selection: any) {
ids.value = selection.map((item: any) => item.id);
}
-/** 获取部门下拉数据 */
-async function loadDeptOptions() {
- DeptAPI.getOptions().then((data) => {
- deptOptions.value = [
- {
- value: 0,
- label: "顶级部门",
- children: data,
- },
- ];
- });
-}
-
/**
- * 打开弹窗
+ * 打开部门弹窗
*
* @param parentId 父部门ID
* @param deptId 部门ID
*/
-async function openDialog(parentId?: number, deptId?: number) {
- await loadDeptOptions();
+async function handleOpenDialog(parentId?: number, deptId?: number) {
+ // 加载部门下拉数据
+ const data = await DeptAPI.getOptions();
+ deptOptions.value = [
+ {
+ value: 0,
+ label: "顶级部门",
+ children: data,
+ },
+ ];
+
dialog.visible = true;
if (deptId) {
dialog.title = "修改部门";
@@ -241,17 +243,17 @@ async function openDialog(parentId?: number, deptId?: number) {
}
}
-/** 表单提交 */
+/** 提交部门表单 */
function handleSubmit() {
deptFormRef.value.validate((valid: any) => {
if (valid) {
- const deptId = formData.id;
loading.value = true;
+ const deptId = formData.id;
if (deptId) {
DeptAPI.update(deptId, formData)
.then(() => {
ElMessage.success("修改成功");
- closeDialog();
+ handleCloseDialog();
handleQuery();
})
.finally(() => (loading.value = false));
@@ -259,7 +261,7 @@ function handleSubmit() {
DeptAPI.add(formData)
.then(() => {
ElMessage.success("新增成功");
- closeDialog();
+ handleCloseDialog();
handleQuery();
})
.finally(() => (loading.value = false));
@@ -281,22 +283,26 @@ function handleDelete(deptId?: number) {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
- }).then(() => {
- DeptAPI.deleteByIds(deptIds).then(() => {
- ElMessage.success("删除成功");
- handleResetQuery();
- });
- });
+ }).then(
+ () => {
+ loading.value = true;
+ DeptAPI.deleteByIds(deptIds)
+ .then(() => {
+ ElMessage.success("删除成功");
+ handleResetQuery();
+ })
+ .finally(() => (loading.value = false));
+ },
+ () => {
+ ElMessage.info("已取消删除");
+ }
+ );
}
/** 关闭弹窗 */
-function closeDialog() {
+function handleCloseDialog() {
dialog.visible = false;
- resetForm();
-}
-/** 重置表单 */
-function resetForm() {
deptFormRef.value.resetFields();
deptFormRef.value.clearValidate();
diff --git a/src/views/system/dict/components/dict-item.vue b/src/views/system/dict/components/dict-item.vue
deleted file mode 100644
index 547ea3a3..00000000
--- a/src/views/system/dict/components/dict-item.vue
+++ /dev/null
@@ -1,308 +0,0 @@
-
-
-
-
-
-
-
-
-
-
- 搜索
- 重置
-
-
-
-
-
- 新增
- 删除
-
-
-
-
-
-
-
-
-
- 启用
- 禁用
-
-
-
-
- 编辑
- 删除
-
-
-
-
-
-
-
-
-
-
- {{ typeName }}
-
-
-
-
-
-
-
-
-
-
-
- 正常
- 停用
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/views/system/dict/index.vue b/src/views/system/dict/index.vue
index 65cfd16d..273560ce 100644
--- a/src/views/system/dict/index.vue
+++ b/src/views/system/dict/index.vue
@@ -1,5 +1,4 @@
-
-
+
@@ -7,7 +6,7 @@
@@ -16,19 +15,16 @@
搜索
- 重置
-
-
-
+
+ 新增
删除
-
+
+
-
-
-
-
- 启用
- 禁用
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ scope.row.status === 1 ? "启用" : "禁用" }}
+
-
字典数据
- 编辑
-
+
-
-
-
-
-
-
-
-
- 正常
- 停用
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+ 启用
+ 禁用
+
+
+
+
+
+
+
+ 字典项
+ 新增字典
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 删除
+
+
+
+
+
-
-
-
-
-
-
+
+
+
diff --git a/src/views/system/menu/index.vue b/src/views/system/menu/index.vue
index f818fc01..d4dbace2 100644
--- a/src/views/system/menu/index.vue
+++ b/src/views/system/menu/index.vue
@@ -27,7 +27,7 @@
新增
+
+
新增
@@ -132,7 +139,7 @@
type="primary"
link
size="small"
- @click.stop="handleDialogOpen(undefined, scope.row.id)"
+ @click.stop="handleOpenDialog(undefined, scope.row.id)"
>
编辑
@@ -150,19 +157,17 @@
-
-
+
+
+
+
+
+
+ 路由名称
+
+
+ 如果需要开启缓存,需保证页面 defineOptions 中的 name
+ 与此处一致,建议使用驼峰。
+
+
+
+
+
+
@@ -222,10 +248,10 @@
-
+
-
+
@@ -418,8 +444,7 @@ defineOptions({
inheritAttrs: false,
});
-import MenuAPI from "@/api/menu";
-import { MenuQuery, MenuForm, MenuVO } from "@/api/menu/model";
+import MenuAPI, { MenuQuery, MenuForm, MenuVO } from "@/api/menu";
import { MenuTypeEnum } from "@/enums/MenuTypeEnum";
const queryFormRef = ref(ElForm);
@@ -458,7 +483,8 @@ const rules = reactive({
parentId: [{ required: true, message: "请选择顶级菜单", trigger: "blur" }],
name: [{ required: true, message: "请输入菜单名称", trigger: "blur" }],
type: [{ required: true, message: "请选择菜单类型", trigger: "blur" }],
- path: [{ required: true, message: "请输入路由路径", trigger: "blur" }],
+ routeName: [{ required: true, message: "请输入路由名称", trigger: "blur" }],
+ routePath: [{ required: true, message: "请输入路由路径", trigger: "blur" }],
component: [{ required: true, message: "请输入组件路径", trigger: "blur" }],
visible: [{ required: true, message: "请输入路由路径", trigger: "blur" }],
});
@@ -496,7 +522,7 @@ function handleRowClick(row: MenuVO) {
* @param parentId 父菜单ID
* @param menuId 菜单ID
*/
-function handleDialogOpen(parentId?: number, menuId?: number) {
+function handleOpenDialog(parentId?: number, menuId?: number) {
MenuAPI.getOptions()
.then((data) => {
menuOptions.value = [{ value: 0, label: "顶级菜单", children: data }];
@@ -541,13 +567,13 @@ function submitForm() {
if (menuId) {
MenuAPI.update(menuId, formData.value).then(() => {
ElMessage.success("修改成功");
- closeDialog();
+ handleCloseDialog();
handleQuery();
});
} else {
MenuAPI.add(formData.value).then(() => {
ElMessage.success("新增成功");
- closeDialog();
+ handleCloseDialog();
handleQuery();
});
}
@@ -566,18 +592,26 @@ function handleDelete(menuId: number) {
confirmButtonText: "确定",
cancelButtonText: "取消",
type: "warning",
- })
- .then(() => {
- MenuAPI.deleteById(menuId).then(() => {
- ElMessage.success("删除成功");
- handleQuery();
- });
- })
- .catch(() => ElMessage.info("已取消删除"));
+ }).then(
+ () => {
+ loading.value = true;
+ MenuAPI.deleteById(menuId)
+ .then(() => {
+ ElMessage.success("删除成功");
+ handleQuery();
+ })
+ .finally(() => {
+ loading.value = false;
+ });
+ },
+ () => {
+ ElMessage.info("已取消删除");
+ }
+ );
}
// 关闭弹窗
-function closeDialog() {
+function handleCloseDialog() {
dialog.visible = false;
menuFormRef.value.resetFields();
menuFormRef.value.clearValidate();
diff --git a/src/views/system/role/index.vue b/src/views/system/role/index.vue
index 388f4b43..daec88ba 100644
--- a/src/views/system/role/index.vue
+++ b/src/views/system/role/index.vue
@@ -22,7 +22,7 @@
- 新增
分配权限
@@ -68,12 +68,12 @@
type="primary"
size="small"
link
- @click="openDialog(scope.row.id)"
+ @click="handleOpenDialog(scope.row.id)"
>
编辑
-
-
+
-
-
+
-
- {{ data.label }}
+
+
-
-
+
+
+
+ {{ isExpanded ? "收缩" : "展开" }}
+ 父子联动
+
+
+
+
+ 如果只需勾选菜单权限,不需要勾选子菜单或者按钮权限,请关闭父子联动
+
+
+
+
+