|
@@ -20,10 +20,11 @@ export function useUser() {
|
|
|
path: "", //路由路径
|
|
|
parentId: "-1", //父菜单ID
|
|
|
icon: "", //菜单图标
|
|
|
- sortOrder: "0", //排序值,越小越靠前
|
|
|
+ sortOrder: "", //排序值,越小越靠前
|
|
|
embedded: "0", //是否内嵌,0否,1是
|
|
|
menuType: "0" //菜单类型,0菜单,1按钮
|
|
|
});
|
|
|
+ const UpdateFormRef = ref()
|
|
|
const dialogType = ref(1);
|
|
|
const dataList = ref([]);
|
|
|
const menuList = ref([]);
|
|
@@ -31,9 +32,10 @@ export function useUser() {
|
|
|
const dialogUpdateVisible = ref(false);
|
|
|
const pagination = reactive<PaginationProps>({
|
|
|
total: 0,
|
|
|
- pageSize: 10,
|
|
|
+ pageSize: 30,
|
|
|
currentPage: 1,
|
|
|
- background: true
|
|
|
+ background: true,
|
|
|
+ pageSizes: [10, 30, 50, 100]
|
|
|
});
|
|
|
const columns: TableColumnList = [
|
|
|
{
|
|
@@ -115,7 +117,9 @@ export function useUser() {
|
|
|
// 获取全部菜单列表
|
|
|
async function Menu() {
|
|
|
const { data } = await getMenuList({});
|
|
|
+ console.log(data);
|
|
|
menuList.value = TreeFormatter(data);
|
|
|
+ console.log(menuList.value);
|
|
|
menuList.value.unshift({
|
|
|
label: "作为顶级菜单",
|
|
|
value: "-1"
|
|
@@ -123,70 +127,80 @@ export function useUser() {
|
|
|
}
|
|
|
Menu();
|
|
|
async function UpdateFormSubmit() {
|
|
|
- if (dialogType.value == 1) {
|
|
|
- const { status, msg } = await postMenuList({
|
|
|
- name: UpdateForm.value.name,
|
|
|
- enName: UpdateForm.value.enName,
|
|
|
- permission: UpdateForm.value.permission,
|
|
|
- path: UpdateForm.value.path,
|
|
|
- parentId:
|
|
|
- UpdateForm.value.parentId === "null"
|
|
|
- ? null
|
|
|
- : UpdateForm.value.parentId,
|
|
|
- icon: UpdateForm.value.icon,
|
|
|
- visible: visibleswitchvalue.value,
|
|
|
- sortOrder: UpdateForm.value.sortOrder,
|
|
|
- keepAlive: keepAliveswitchvalue.value,
|
|
|
- embedded: UpdateForm.value.embedded,
|
|
|
- menuType: UpdateForm.value.menuType
|
|
|
- });
|
|
|
- if (status == 1) {
|
|
|
- ElMessage({
|
|
|
- message: "新增菜单成功",
|
|
|
- type: "success"
|
|
|
- });
|
|
|
- dialogUpdateVisible.value = false;
|
|
|
- onSearch();
|
|
|
- Menu();
|
|
|
+ UpdateFormRef.value.validate(async (valid, fields) => {
|
|
|
+ if (valid) {
|
|
|
+ if (dialogType.value == 1) {
|
|
|
+ const { status, msg } = await postMenuList({
|
|
|
+ name: UpdateForm.value.name,
|
|
|
+ enName: UpdateForm.value.enName,
|
|
|
+ permission: UpdateForm.value.permission,
|
|
|
+ path: UpdateForm.value.path,
|
|
|
+ parentId:
|
|
|
+ UpdateForm.value.parentId === "null"
|
|
|
+ ? null
|
|
|
+ : UpdateForm.value.parentId,
|
|
|
+ icon: UpdateForm.value.icon,
|
|
|
+ visible: visibleswitchvalue.value,
|
|
|
+ sortOrder: UpdateForm.value.sortOrder,
|
|
|
+ keepAlive: keepAliveswitchvalue.value,
|
|
|
+ embedded: UpdateForm.value.embedded,
|
|
|
+ menuType: UpdateForm.value.menuType
|
|
|
+ });
|
|
|
+ if (status == 1) {
|
|
|
+ ElMessage({
|
|
|
+ message: "新增菜单成功",
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
+ dialogUpdateVisible.value = false;
|
|
|
+ onSearch();
|
|
|
+ Menu();
|
|
|
+ } else {
|
|
|
+ ElMessageBox.alert(msg, "提示", {
|
|
|
+ confirmButtonText: "关闭",
|
|
|
+ type: "warning"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ const { status, msg } = await putMenuList({
|
|
|
+ name: UpdateForm.value.name,
|
|
|
+ enName: UpdateForm.value.enName,
|
|
|
+ permission: UpdateForm.value.permission,
|
|
|
+ path: UpdateForm.value.path,
|
|
|
+ parentId:
|
|
|
+ UpdateForm.value.parentId === "null"
|
|
|
+ ? null
|
|
|
+ : UpdateForm.value.parentId,
|
|
|
+ icon: UpdateForm.value.icon,
|
|
|
+ visible: visibleswitchvalue.value,
|
|
|
+ sortOrder: UpdateForm.value.sortOrder,
|
|
|
+ keepAlive: keepAliveswitchvalue.value,
|
|
|
+ embedded: UpdateForm.value.embedded,
|
|
|
+ menuType: UpdateForm.value.menuType,
|
|
|
+ menuId: UpdateForm.value.menuId
|
|
|
+ });
|
|
|
+ if (status == 1) {
|
|
|
+ ElMessage({
|
|
|
+ message: "菜单修改成功",
|
|
|
+ type: "success"
|
|
|
+ });
|
|
|
+ dialogUpdateVisible.value = false;
|
|
|
+ onSearch();
|
|
|
+ Menu();
|
|
|
+ } else {
|
|
|
+ ElMessageBox.alert(msg, "提示", {
|
|
|
+ confirmButtonText: "关闭",
|
|
|
+ type: "warning"
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
- ElMessageBox.alert(msg, "提示", {
|
|
|
- confirmButtonText: "关闭",
|
|
|
- type: "warning"
|
|
|
- });
|
|
|
- }
|
|
|
- } else {
|
|
|
- const { status, msg } = await putMenuList({
|
|
|
- name: UpdateForm.value.name,
|
|
|
- enName: UpdateForm.value.enName,
|
|
|
- permission: UpdateForm.value.permission,
|
|
|
- path: UpdateForm.value.path,
|
|
|
- parentId:
|
|
|
- UpdateForm.value.parentId === "null"
|
|
|
- ? null
|
|
|
- : UpdateForm.value.parentId,
|
|
|
- icon: UpdateForm.value.icon,
|
|
|
- visible: visibleswitchvalue.value,
|
|
|
- sortOrder: UpdateForm.value.sortOrder,
|
|
|
- keepAlive: keepAliveswitchvalue.value,
|
|
|
- embedded: UpdateForm.value.embedded,
|
|
|
- menuType: UpdateForm.value.menuType,
|
|
|
- menuId: UpdateForm.value.menuId
|
|
|
- });
|
|
|
- if (status == 1) {
|
|
|
+ //表单校验失败回调
|
|
|
ElMessage({
|
|
|
- message: "菜单修改成功",
|
|
|
- type: "success"
|
|
|
- });
|
|
|
- dialogUpdateVisible.value = false;
|
|
|
- onSearch();
|
|
|
- Menu();
|
|
|
- } else {
|
|
|
- ElMessageBox.alert(msg, "提示", {
|
|
|
- confirmButtonText: "关闭",
|
|
|
- type: "warning"
|
|
|
+ message: "请输入完整信息",
|
|
|
+ type: "error"
|
|
|
});
|
|
|
}
|
|
|
- }
|
|
|
+ })
|
|
|
}
|
|
|
function handleDelete(row) {
|
|
|
ElMessageBox.confirm(`是否删除名称为:${row.name}的菜单? `, "提示", {
|
|
@@ -218,16 +232,22 @@ export function useUser() {
|
|
|
path: "", //路由路径
|
|
|
parentId: "", //父菜单ID
|
|
|
icon: "", //菜单图标
|
|
|
- sortOrder: "0", //排序值,越小越靠前
|
|
|
+ sortOrder: "", //排序值,越小越靠前
|
|
|
embedded: "0", //是否内嵌,0否,1是
|
|
|
menuType: "0" //菜单类型,0菜单,1按钮
|
|
|
};
|
|
|
+ visibleswitchvalue.value = "1"
|
|
|
+ keepAliveswitchvalue.value = "1"
|
|
|
dialogType.value = 1;
|
|
|
dialogUpdateVisible.value = true;
|
|
|
+ UpdateFormRef.value && UpdateFormRef.value.resetFields()
|
|
|
}
|
|
|
function handleUpdate(row) {
|
|
|
dialogType.value = 2;
|
|
|
dialogUpdateVisible.value = true;
|
|
|
+ UpdateFormRef.value && UpdateFormRef.value.resetFields()
|
|
|
+ visibleswitchvalue.value = row.meta.isHide ? "0" : "1"
|
|
|
+ keepAliveswitchvalue.value = row.meta.isKeepAlive ? "1" : "0"
|
|
|
UpdateForm.value = {
|
|
|
menuId: row.id ? row.id : "",
|
|
|
name: row.name ? row.name : "", //菜单名称
|
|
@@ -238,7 +258,7 @@ export function useUser() {
|
|
|
icon: row.meta.icon ? row.meta.icon : "", //菜单图标
|
|
|
sortOrder: row.sortOrder, //排序值,越小越靠前
|
|
|
embedded: row.embedded ? row.embedded : "0", //是否内嵌,0否,1是
|
|
|
- menuType: row.menuType ? row.menuType : "" //菜单类型,0菜单,1按钮
|
|
|
+ menuType: row.menuType ? row.menuType : "", //菜单类型,0菜单,1按钮
|
|
|
};
|
|
|
}
|
|
|
|
|
@@ -269,7 +289,6 @@ export function useUser() {
|
|
|
async function onSearch() {
|
|
|
loading.value = true;
|
|
|
const { data } = await getMenuList({});
|
|
|
- console.log('testlog', data);
|
|
|
dataList.value = data;
|
|
|
pagination.total = data.length;
|
|
|
setTimeout(() => {
|
|
@@ -292,6 +311,7 @@ export function useUser() {
|
|
|
UpdateFormSubmit,
|
|
|
submit,
|
|
|
UpdateForm,
|
|
|
+ UpdateFormRef,
|
|
|
menuList,
|
|
|
dialogType,
|
|
|
AddUser,
|