'系统菜单功能添加,误上传的备份文件删除'
This commit is contained in:
@@ -1,65 +1,9 @@
|
||||
import { http } from '/nerv-lib/util';
|
||||
import { ref } from 'vue';
|
||||
import { menuS } from '/@/api/menuSystem';
|
||||
// interface DataItem {
|
||||
// key: number;
|
||||
// menuName: string;
|
||||
// menuType: number;
|
||||
// menuIcon: string;
|
||||
// menuRouter:string;
|
||||
// children?: DataItem[];
|
||||
// }
|
||||
// const data: DataItem[] = [
|
||||
// {
|
||||
// key: 1,
|
||||
// menuName: 'John Brown sr.',
|
||||
// menuType: 60,
|
||||
// menuIcon:'icon',
|
||||
// menuRouter: '/dashboard',
|
||||
// children: [
|
||||
// {
|
||||
// key: 11,
|
||||
// menuName: 'John Brown',
|
||||
// menuType: 42,
|
||||
// menuIcon:'icon',
|
||||
// menuRouter: '/dashboard1',
|
||||
// },
|
||||
// {
|
||||
// key: 12,
|
||||
// menuName: 'John Brown',
|
||||
// menuType: 42,
|
||||
// menuIcon:'icon',
|
||||
// menuRouter: '/dashboard3',
|
||||
// children: [
|
||||
// {
|
||||
// key: 121,
|
||||
// menuName: 'John Brown',
|
||||
// menuType: 42,
|
||||
// menuIcon:'icon',
|
||||
// menuRouter: '/dashboard4',
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// key: 13,
|
||||
// menuName: 'John Brown sr.',
|
||||
// menuType: 60,
|
||||
// menuIcon:'icon',
|
||||
// menuRouter: '/dashboard',
|
||||
// children: [
|
||||
// ],
|
||||
// },
|
||||
// ],
|
||||
// },
|
||||
// {
|
||||
// key: 2,
|
||||
// menuName: 'John Brown sr.',
|
||||
// menuType: 60,
|
||||
// menuIcon:'icon',
|
||||
// menuRouter: '/dashboard',
|
||||
// },
|
||||
// ];
|
||||
export const tableConfig = (orgId:any,SystemAddEdit:any) => {
|
||||
import { NsMessage } from '/nerv-lib/component';
|
||||
import { resetRouter } from '/nerv-lib/saas/router';
|
||||
export const tableConfig = (orgId:any,SystemAddEdit:any,mainRef:any) => {
|
||||
return ref({
|
||||
title: '系统菜单',
|
||||
api: menuS.queryMenuPage,
|
||||
@@ -72,23 +16,12 @@ export const tableConfig = (orgId:any,SystemAddEdit:any) => {
|
||||
type: 'primary',
|
||||
handle: () => {
|
||||
console.log("12345")
|
||||
SystemAddEdit.value.getMenuList();//请求列表的菜单数据
|
||||
SystemAddEdit.value.toggle(1);
|
||||
// editConfigureDeviceAlarms.value.toggle(null, configureDeviceAlarmsData.value);
|
||||
},
|
||||
},
|
||||
],
|
||||
// rowSelection: {
|
||||
// checkStrictly: false,
|
||||
// onChange: (selectedRowKeys: (string | number)[], selectedRows: DataItem[]) => {
|
||||
// console.log(`selectedRowKeys: ${selectedRowKeys}`, 'selectedRows: ', selectedRows);
|
||||
// },
|
||||
// onSelect: (record: DataItem, selected: boolean, selectedRows: DataItem[]) => {
|
||||
// console.log(record, selected, selectedRows);
|
||||
// },
|
||||
// onSelectAll: (selected: boolean, selectedRows: DataItem[], changeRows: DataItem[]) => {
|
||||
// console.log(selected, selectedRows, changeRows);
|
||||
// },
|
||||
// },
|
||||
columns:[
|
||||
{
|
||||
title: '菜单名称',
|
||||
@@ -112,6 +45,11 @@ export const tableConfig = (orgId:any,SystemAddEdit:any) => {
|
||||
dataIndex: 'backApi',
|
||||
key: 'backApi',
|
||||
},
|
||||
{
|
||||
title: '菜单编码',
|
||||
dataIndex: 'code',
|
||||
key: 'code',
|
||||
},
|
||||
{
|
||||
title: '排序',
|
||||
dataIndex: 'sort',
|
||||
@@ -151,22 +89,28 @@ export const tableConfig = (orgId:any,SystemAddEdit:any) => {
|
||||
label: '编辑',
|
||||
name: 'userEdit',
|
||||
handle: (record: any) => {
|
||||
SystemAddEdit.value.getMenuList();//请求列表的菜单数据
|
||||
SystemAddEdit.value.toggle(2,record);
|
||||
mainRef.value?.nsTableRef.reload();
|
||||
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
name: 'userDelete',
|
||||
dynamicParams: { id: 'id' },
|
||||
dynamicParams: { id: 'permissionId' },
|
||||
confirm: true,
|
||||
isReload: true,
|
||||
handle: (data: any) => {
|
||||
// http.post(energyAlarms.del, { id: data.id, orgId: data.orgId }).then(() => {
|
||||
// NsMessage.success('操作成功');
|
||||
// mainEnergyAlarmConfig.value?.nsTableRef.reload();
|
||||
// mainRef.value?.nsTableRef.reload();
|
||||
// });
|
||||
if(data.children && data.children.length>0){
|
||||
NsMessage.error('当前菜单下存在子菜单,请先删除!');
|
||||
return false
|
||||
}else{
|
||||
http.post(menuS.queryMenuPageDel, { permissionId: data.permissionId, updateUser: data.updateUser }).then(() => {
|
||||
NsMessage.success('操作成功');
|
||||
mainRef.value?.nsTableRef.reload();
|
||||
});
|
||||
}
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@@ -39,12 +39,18 @@
|
||||
>
|
||||
</a-tree-select>
|
||||
</a-form-item>
|
||||
<a-form-item label="菜单路由:" name="routePath">
|
||||
<a-form-item label="菜单路由:" name="routePath" v-if="menuRouteIsshow">
|
||||
<a-input v-model:value="formState.routePath" placeholder="请输入路由地址"/>
|
||||
</a-form-item>
|
||||
<!-- <a-form-item label="跳转地址:" name="menuJumpUrl">
|
||||
<a-input v-model:value="formState.menuJumpUrl" placeholder="请输入跳转地址"/>
|
||||
</a-form-item> -->
|
||||
<!-- 前端组件 component-->
|
||||
<a-form-item label="前端组件:" name="menuJumpUrl" v-if="componentIsshow">
|
||||
<a-input v-model:value="formState.menuJumpUrl" placeholder="请输入前端组件"/>
|
||||
</a-form-item>
|
||||
<!-- 重定向路由 Redirect -->
|
||||
<a-form-item label="重定向路由:" name="menuRedirect" v-if="redirectIsshow">
|
||||
<a-input v-model:value="formState.menuRedirect" placeholder="请输入重定向路由"/>
|
||||
</a-form-item>
|
||||
|
||||
<a-form-item label="菜单图标:" name="menuIcon" class="iconMenu">
|
||||
<a-input v-model:value="formState.menuIcon" placeholder="点击选择菜单图标" />
|
||||
<SlackOutlined @click="showIconMenu"/>
|
||||
@@ -54,7 +60,14 @@
|
||||
</a-form-item>
|
||||
<a-form-item label="排序:" name="menuSort" v-if="sortIsshow">
|
||||
<a-input type="number" v-model:value="formState.menuSort" min="0" maxlength="7" placeholder="请输入排序号" />
|
||||
</a-form-item>
|
||||
</a-form-item>
|
||||
<a-form-item label="是否缓存" v-if="keepAliveIsshow">
|
||||
<a-switch v-model:checked="formState.keepAlive" />
|
||||
</a-form-item>
|
||||
<a-form-item label="是否隐藏子级" v-if="hideChildrenIsshow">
|
||||
<a-switch v-model:checked="formState.hideChildren"/>
|
||||
|
||||
</a-form-item>
|
||||
</a-form>
|
||||
<template #footer>
|
||||
<a-button style="margin-right: 8px" @click="onClose">取消</a-button>
|
||||
@@ -65,7 +78,7 @@
|
||||
<icon-picker :iconHandleOk="getSonData" ref="refIconPicker"></icon-picker>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { ref,toRaw,defineExpose,reactive} from 'vue';
|
||||
import { ref,toRaw,defineExpose,reactive,onBeforeUnmount} from 'vue';
|
||||
import type { Rule } from 'ant-design-vue/es/form';
|
||||
import type { TreeSelectProps } from 'ant-design-vue';
|
||||
import { SlackOutlined } from '@ant-design/icons-vue';
|
||||
@@ -76,6 +89,7 @@
|
||||
const accountNo = sessionStorage.getItem('accountNo')?sessionStorage.getItem('accountNo'):'';
|
||||
const menuRadioType = ref(1);//菜单类型默认值
|
||||
const treeData = ref<TreeSelectProps['treeData']>([]);//存储菜单数据
|
||||
const addOrEditType = ref();//新增、编辑类型,区分调不同接口
|
||||
|
||||
const drawerTitele = ref('');
|
||||
const formRef = ref();
|
||||
@@ -88,6 +102,11 @@
|
||||
const sortIsshow = ref(true);//排序是否显示
|
||||
const menuRouteIsshow = ref(true);//菜单路由是否显示
|
||||
const refIconPicker = ref();
|
||||
const currentLineData = ref();//存储当前行的数据
|
||||
const componentIsshow = ref(false);//前端组件是否显示
|
||||
const redirectIsshow = ref(true);//重定向路由是否显示
|
||||
const keepAliveIsshow = ref(false);//缓存是否显示
|
||||
const hideChildrenIsshow = ref(false);//是否隐藏子级是否显示
|
||||
interface FormState {
|
||||
menuName: string;
|
||||
previousMenu:string;
|
||||
@@ -99,6 +118,9 @@
|
||||
menuCode:string;
|
||||
type:string;//菜单类型
|
||||
menuJumpUrl:string;
|
||||
menuRedirect:string;
|
||||
keepAlive:boolean;
|
||||
hideChildren:boolean
|
||||
}
|
||||
const formState = ref<FormState>({
|
||||
menuName:'',
|
||||
@@ -110,7 +132,10 @@
|
||||
menuIcon:'',
|
||||
menuCode:'',
|
||||
type:'',
|
||||
menuJumpUrl:''
|
||||
menuJumpUrl:'',
|
||||
menuRedirect:'',
|
||||
keepAlive:false,
|
||||
hideChildren:false
|
||||
})
|
||||
const labelCol = { span: 5 };
|
||||
const wrapperCol = { span: 19 };
|
||||
@@ -124,6 +149,14 @@
|
||||
routePath:[{ required: true, message: '请输入菜单路由', trigger: 'change' }],
|
||||
});
|
||||
const emit = defineEmits(['editObject']);
|
||||
//是否缓存-开关
|
||||
// const clickSwitchKeepAlive = () => {
|
||||
// if (formState.value.keepAlive === 1) {
|
||||
// infoObject.value.enableRules = 0;
|
||||
// } else {
|
||||
// infoObject.value.enableRules = 1;
|
||||
// }
|
||||
// };
|
||||
// 关闭新增抽屉
|
||||
const onClose = () => {
|
||||
visible.value = false;
|
||||
@@ -131,7 +164,6 @@
|
||||
};
|
||||
//菜单类型按钮切换
|
||||
const chanageMenuType = (e:any,typeMenu:any)=>{
|
||||
console.log("1444444444444443333333333333333333333333333333333333")
|
||||
let currentType = null;
|
||||
if(e && e.target){
|
||||
currentType = e.target.value;
|
||||
@@ -139,7 +171,6 @@
|
||||
if(typeMenu){
|
||||
currentType = typeMenu;
|
||||
}
|
||||
console.log(currentType);
|
||||
menuRadioType.value = currentType;
|
||||
if(currentType==1){//一级菜单
|
||||
menuNameIsshow.value = true;
|
||||
@@ -149,6 +180,10 @@
|
||||
sortIsshow.value = true;
|
||||
menuCodeIsshow.value = true;
|
||||
menuRouteIsshow.value = true;
|
||||
componentIsshow.value = false;
|
||||
redirectIsshow.value = true;
|
||||
keepAliveIsshow.value = false;
|
||||
hideChildrenIsshow.value = false;
|
||||
}else if(currentType==2){//二级菜单
|
||||
menuNameIsshow.value = true;
|
||||
preMenuIsshow.value = true;
|
||||
@@ -157,6 +192,10 @@
|
||||
sortIsshow.value = true;
|
||||
menuCodeIsshow.value = true;
|
||||
menuRouteIsshow.value = true;
|
||||
componentIsshow.value = true;
|
||||
redirectIsshow.value = true;
|
||||
keepAliveIsshow.value = true;
|
||||
hideChildrenIsshow.value = true;
|
||||
}else{//按钮
|
||||
menuNameIsshow.value = false;
|
||||
preMenuIsshow.value = true;
|
||||
@@ -165,6 +204,10 @@
|
||||
sortIsshow.value = false;
|
||||
menuCodeIsshow.value = false;
|
||||
menuRouteIsshow.value = false;
|
||||
componentIsshow.value = false;
|
||||
redirectIsshow.value = false;
|
||||
keepAliveIsshow.value = false;
|
||||
hideChildrenIsshow.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,11 +216,8 @@
|
||||
formRef.value
|
||||
.validate()
|
||||
.then(() => {
|
||||
console.log('values1111111111111');
|
||||
console.log(formState)
|
||||
console.log(toRaw(formState))
|
||||
//请求添加接口提交数据
|
||||
let params={
|
||||
let params:any={
|
||||
pid:'root',
|
||||
code:formState.value.menuCode,
|
||||
label:formState.value.menuName,
|
||||
@@ -186,30 +226,58 @@
|
||||
sort:formState.value.menuSort,
|
||||
backApi:formState.value.routePath,
|
||||
projectId:null,
|
||||
updateUser:accountNo
|
||||
updateUser:accountNo,
|
||||
redirect:formState.value.menuRedirect,
|
||||
}
|
||||
if(menuRadioType.value==3){
|
||||
params.code = formState.value.authorizationMark;
|
||||
params
|
||||
params.pid = formState.value.previousMenu;//父级id
|
||||
params.label = formState.value.perissionBtn;
|
||||
}
|
||||
if(menuRadioType.value==2){
|
||||
// params.pid = currentLineData.value.code; //父级id
|
||||
params.component = formState.value.menuJumpUrl;
|
||||
params.pid = formState.value.previousMenu;
|
||||
params.keepAlive = formState.value.keepAlive;
|
||||
params.hideChildren = formState.value.hideChildren;//是否隐藏子级
|
||||
}
|
||||
if(menuRadioType.value==1){
|
||||
params.pid = currentLineData.value?currentLineData.value.pid:"root";//一级菜单pid,传'root'
|
||||
}
|
||||
if(addOrEditType.value==1){//新增
|
||||
http.post(menuS.queryMenuPageAdd, params).then(() => {
|
||||
NsMessage.success('操作成功');
|
||||
visible.value = !visible.value;
|
||||
emit("editObject",formState)
|
||||
});
|
||||
}else{
|
||||
params.permissionId = currentLineData.value.permissionId;
|
||||
params.createTime = currentLineData.value.createTime;
|
||||
params.updateTime = currentLineData.value.updateTime;
|
||||
params.isDelete = currentLineData.value.isDelete;
|
||||
http.post(menuS.queryMenuPageEdit, params).then(() => {
|
||||
NsMessage.success('操作成功');
|
||||
visible.value = !visible.value;
|
||||
emit("editObject",formState)
|
||||
});
|
||||
}
|
||||
return
|
||||
http.post(menuS.queryMenuPageAdd, params).then(() => {
|
||||
NsMessage.success('操作成功');
|
||||
});
|
||||
// emit("editObject",formState)
|
||||
})
|
||||
}
|
||||
//获取菜单列表
|
||||
const getMenuList= ()=>{
|
||||
http.post(menuS.queryMenuPage, { label: '',projectId: null}).then((res) => {
|
||||
treeData.value = res.data.records;
|
||||
// treeData.value = res.data.records;
|
||||
treeData.value = res.data.records.map((item:any) => ({
|
||||
value: item.code,
|
||||
label: item.label,
|
||||
children: item.children ? item.children.map((child:any) => ({
|
||||
value: child.code,
|
||||
label:child.label,
|
||||
|
||||
children: child.children ? child.children.map((childchild:any) => ({
|
||||
value: childchild.code,
|
||||
label:childchild.label,
|
||||
|
||||
})) : []
|
||||
})) : []
|
||||
}));
|
||||
});
|
||||
@@ -220,8 +288,6 @@
|
||||
|
||||
}
|
||||
const getSonData = (data:any) => {
|
||||
// formState.icon = data;
|
||||
console.log("子组件中的数据:",data)
|
||||
if(data){
|
||||
formState.value.menuIcon = data;
|
||||
}else{
|
||||
@@ -229,16 +295,59 @@
|
||||
}
|
||||
}
|
||||
const toggle = (type:any,record:any)=>{
|
||||
currentLineData.value = record;
|
||||
visible.value = !visible.value;
|
||||
addOrEditType.value = type;
|
||||
if(type==1){//新增
|
||||
drawerTitele.value = '新增菜单';
|
||||
formState.value = {
|
||||
menuName:'',
|
||||
previousMenu:'',
|
||||
routePath:'',
|
||||
menuSort:'',
|
||||
perissionBtn:'',
|
||||
authorizationMark:'',
|
||||
menuIcon:'',
|
||||
menuCode:'',
|
||||
type:'',
|
||||
menuJumpUrl:'',
|
||||
menuRedirect:''
|
||||
};
|
||||
}else if(type==2){//编辑
|
||||
drawerTitele.value = '编辑菜单';
|
||||
if(record){
|
||||
formState.value.menuName = record.label;
|
||||
if(record.type==1||record.type==2){
|
||||
formState.value.menuCode = record.code;
|
||||
}
|
||||
if(record.type==3){
|
||||
formState.value.authorizationMark = record.code;
|
||||
}
|
||||
formState.value.menuSort = record.sort;
|
||||
formState.value.menuIcon = record.icon;
|
||||
formState.value.routePath = record.backApi;
|
||||
formState.value.type = record.type;
|
||||
formState.value.menuCode = record.code;
|
||||
formState.value.perissionBtn = record.label;
|
||||
formState.value.menuJumpUrl = record.component;
|
||||
formState.value.menuRedirect = record.redirect.name;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
//如果record有值,说明是编辑或者从有数据条目中点击新增编辑过来的
|
||||
if(record){
|
||||
if(record.type==1){//一级菜单
|
||||
if(type==1){
|
||||
formState.value.previousMenu = record.code;
|
||||
}else{
|
||||
if(record.type==1){
|
||||
formState.value.previousMenu = "";
|
||||
}
|
||||
if(record.type==2||record.type==3){
|
||||
formState.value.previousMenu = record.pid;
|
||||
}
|
||||
}
|
||||
if(record.type==1){//一级菜单
|
||||
if(type==1){//新增
|
||||
menuRadioType.value = 2;//如果是一级菜单进来应该是添加子菜单
|
||||
chanageMenuType(null,2);
|
||||
@@ -247,7 +356,6 @@
|
||||
chanageMenuType(null,1);
|
||||
}
|
||||
}else if(record.type==2){//子菜单
|
||||
formState.value.previousMenu = record.code;
|
||||
if(type==1){
|
||||
menuRadioType.value = 2;//如果是一级菜单进来应该是添加子菜单
|
||||
}else{
|
||||
@@ -255,7 +363,6 @@
|
||||
}
|
||||
chanageMenuType(null,2);
|
||||
}else if(record.type==3){//按钮
|
||||
formState.value.previousMenu = record.code;
|
||||
if(type==1){
|
||||
menuRadioType.value = 2;//如果是一级菜单进来应该是添加子菜单
|
||||
chanageMenuType(null,2);
|
||||
@@ -264,9 +371,9 @@
|
||||
chanageMenuType(null,3);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
menuRadioType.value = 1;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
defineExpose({
|
||||
toggle,
|
||||
|
@@ -26,11 +26,12 @@
|
||||
const result = JSON.parse(sessionStorage.getItem('ORGID')!);
|
||||
orgId.value = result;
|
||||
const SystemAddEdit = ref({});
|
||||
const config = tableConfig(orgId.value,SystemAddEdit);
|
||||
|
||||
// 表格相关数据
|
||||
const data = ref([]);//子组件数据修改时,父组件也跟着改变。
|
||||
const mainRef = ref();//可以定义一个函数使用mainRef.value来调用子组件的方法。
|
||||
const config = tableConfig(orgId.value,SystemAddEdit,mainRef);
|
||||
|
||||
|
||||
defineOptions({
|
||||
name: 'systemMenuIndex', // 与页面路由name一致缓存才可生效
|
||||
});
|
||||
|
Reference in New Issue
Block a user