'系统菜单功能添加,误上传的备份文件删除'

This commit is contained in:
duyufeng
2024-08-23 16:34:59 +08:00
parent 9f9982b04a
commit 9ff820af25
857 changed files with 175 additions and 2698 deletions

View File

@@ -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,