|
@ -188,9 +188,7 @@ |
|
|
</div> |
|
|
</div> |
|
|
</template> |
|
|
</template> |
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
|
// 获取列表内容封装在mixins内部 getTableData方法 初始化已封装完成 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<script setup> |
|
|
import { |
|
|
import { |
|
|
updateBaseMenu, |
|
|
updateBaseMenu, |
|
|
getMenuList, |
|
|
getMenuList, |
|
@ -198,45 +196,12 @@ import { |
|
|
deleteBaseMenu, |
|
|
deleteBaseMenu, |
|
|
getBaseMenuById |
|
|
getBaseMenuById |
|
|
} from '@/api/menu' |
|
|
} from '@/api/menu' |
|
|
import infoList from '@/mixins/infoList' |
|
|
|
|
|
import icon from '@/view/superAdmin/menu/icon.vue' |
|
|
import icon from '@/view/superAdmin/menu/icon.vue' |
|
|
import warningBar from '@/components/warningBar/warningBar.vue' |
|
|
import warningBar from '@/components/warningBar/warningBar.vue' |
|
|
export default { |
|
|
|
|
|
name: 'Menus', |
|
|
|
|
|
components: { |
|
|
|
|
|
icon, |
|
|
|
|
|
warningBar |
|
|
|
|
|
}, |
|
|
|
|
|
mixins: [infoList], |
|
|
|
|
|
data() { |
|
|
|
|
|
return { |
|
|
|
|
|
checkFlag: false, |
|
|
|
|
|
listApi: getMenuList, |
|
|
|
|
|
dialogFormVisible: false, |
|
|
|
|
|
dialogTitle: '新增菜单', |
|
|
|
|
|
menuOption: [ |
|
|
|
|
|
{ |
|
|
|
|
|
ID: '0', |
|
|
|
|
|
title: '根菜单' |
|
|
|
|
|
} |
|
|
|
|
|
], |
|
|
|
|
|
form: { |
|
|
|
|
|
ID: 0, |
|
|
|
|
|
path: '', |
|
|
|
|
|
name: '', |
|
|
|
|
|
hidden: '', |
|
|
|
|
|
parentId: '', |
|
|
|
|
|
component: '', |
|
|
|
|
|
meta: { |
|
|
|
|
|
title: '', |
|
|
|
|
|
icon: '', |
|
|
|
|
|
defaultMenu: false, |
|
|
|
|
|
closeTab: false, |
|
|
|
|
|
keepAlive: false |
|
|
|
|
|
}, |
|
|
|
|
|
parameters: [] |
|
|
|
|
|
}, |
|
|
|
|
|
rules: { |
|
|
|
|
|
|
|
|
import { reactive, ref } from 'vue' |
|
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus' |
|
|
|
|
|
|
|
|
|
|
|
const rules = reactive({ |
|
|
path: [{ required: true, message: '请输入菜单name', trigger: 'blur' }], |
|
|
path: [{ required: true, message: '请输入菜单name', trigger: 'blur' }], |
|
|
component: [ |
|
|
component: [ |
|
|
{ required: true, message: '请输入文件路径', trigger: 'blur' } |
|
|
{ required: true, message: '请输入文件路径', trigger: 'blur' } |
|
@ -244,74 +209,69 @@ export default { |
|
|
'meta.title': [ |
|
|
'meta.title': [ |
|
|
{ required: true, message: '请输入菜单展示名称', trigger: 'blur' } |
|
|
{ required: true, message: '请输入菜单展示名称', trigger: 'blur' } |
|
|
] |
|
|
] |
|
|
}, |
|
|
|
|
|
isEdit: false, |
|
|
|
|
|
test: '' |
|
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
const page = ref(1) |
|
|
|
|
|
const total = ref(0) |
|
|
|
|
|
const pageSize = ref(999) |
|
|
|
|
|
const tableData = ref([]) |
|
|
|
|
|
const searchInfo = ref({}) |
|
|
|
|
|
// 查询 |
|
|
|
|
|
const getTableData = async() => { |
|
|
|
|
|
const table = await getMenuList({ page: page.value, pageSize: pageSize.value, ...searchInfo.value }) |
|
|
|
|
|
if (table.code === 0) { |
|
|
|
|
|
tableData.value = table.data.list |
|
|
|
|
|
total.value = table.data.total |
|
|
|
|
|
page.value = table.data.page |
|
|
|
|
|
pageSize.value = table.data.pageSize |
|
|
} |
|
|
} |
|
|
}, |
|
|
|
|
|
async created() { |
|
|
|
|
|
this.pageSize = 999 |
|
|
|
|
|
await this.getTableData() |
|
|
|
|
|
}, |
|
|
|
|
|
methods: { |
|
|
|
|
|
addParameter(form) { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
getTableData() |
|
|
|
|
|
|
|
|
|
|
|
// 新增参数 |
|
|
|
|
|
const addParameter = (form) => { |
|
|
if (!form.parameters) { |
|
|
if (!form.parameters) { |
|
|
this.form.parameters = [] |
|
|
|
|
|
|
|
|
form.value.parameters = [] |
|
|
} |
|
|
} |
|
|
form.parameters.push({ |
|
|
form.parameters.push({ |
|
|
type: 'query', |
|
|
type: 'query', |
|
|
key: '', |
|
|
key: '', |
|
|
value: '' |
|
|
value: '' |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
|
|
|
deleteParameter(parameters, index) { |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
// 删除参数 |
|
|
|
|
|
const deleteParameter = (parameters, index) => { |
|
|
parameters.splice(index, 1) |
|
|
parameters.splice(index, 1) |
|
|
}, |
|
|
|
|
|
changeName() { |
|
|
|
|
|
this.form.path = this.form.name |
|
|
|
|
|
}, |
|
|
|
|
|
setOptions() { |
|
|
|
|
|
this.menuOption = [ |
|
|
|
|
|
{ |
|
|
|
|
|
ID: '0', |
|
|
|
|
|
title: '根目录' |
|
|
|
|
|
} |
|
|
} |
|
|
] |
|
|
|
|
|
this.setMenuOptions(this.tableData, this.menuOption, false) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const form = ref({ |
|
|
|
|
|
ID: 0, |
|
|
|
|
|
path: '', |
|
|
|
|
|
name: '', |
|
|
|
|
|
hidden: '', |
|
|
|
|
|
parentId: '', |
|
|
|
|
|
component: '', |
|
|
|
|
|
meta: { |
|
|
|
|
|
title: '', |
|
|
|
|
|
icon: '', |
|
|
|
|
|
defaultMenu: false, |
|
|
|
|
|
closeTab: false, |
|
|
|
|
|
keepAlive: false |
|
|
}, |
|
|
}, |
|
|
setMenuOptions(menuData, optionsData, disabled) { |
|
|
|
|
|
menuData && |
|
|
|
|
|
menuData.forEach(item => { |
|
|
|
|
|
if (item.children && item.children.length) { |
|
|
|
|
|
const option = { |
|
|
|
|
|
title: item.meta.title, |
|
|
|
|
|
ID: String(item.ID), |
|
|
|
|
|
disabled: disabled || item.ID === this.form.ID, |
|
|
|
|
|
children: [] |
|
|
|
|
|
} |
|
|
|
|
|
this.setMenuOptions( |
|
|
|
|
|
item.children, |
|
|
|
|
|
option.children, |
|
|
|
|
|
disabled || item.ID === this.form.ID |
|
|
|
|
|
) |
|
|
|
|
|
optionsData.push(option) |
|
|
|
|
|
} else { |
|
|
|
|
|
const option = { |
|
|
|
|
|
title: item.meta.title, |
|
|
|
|
|
ID: String(item.ID), |
|
|
|
|
|
disabled: disabled || item.ID === this.form.ID |
|
|
|
|
|
} |
|
|
|
|
|
optionsData.push(option) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
parameters: [] |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
|
|
|
handleClose(done) { |
|
|
|
|
|
this.initForm() |
|
|
|
|
|
|
|
|
const changeName = () => { |
|
|
|
|
|
form.value.path = form.value.name |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const handleClose = (done) => { |
|
|
|
|
|
initForm() |
|
|
done() |
|
|
done() |
|
|
}, |
|
|
|
|
|
|
|
|
} |
|
|
// 删除菜单 |
|
|
// 删除菜单 |
|
|
deleteMenu(ID) { |
|
|
|
|
|
this.$confirm('此操作将永久删除所有角色下该菜单, 是否继续?', '提示', { |
|
|
|
|
|
|
|
|
const deleteMenu = (ID) => { |
|
|
|
|
|
ElMessageBox.confirm('此操作将永久删除所有角色下该菜单, 是否继续?', '提示', { |
|
|
confirmButtonText: '确定', |
|
|
confirmButtonText: '确定', |
|
|
cancelButtonText: '取消', |
|
|
cancelButtonText: '取消', |
|
|
type: 'warning' |
|
|
type: 'warning' |
|
@ -319,28 +279,30 @@ export default { |
|
|
.then(async() => { |
|
|
.then(async() => { |
|
|
const res = await deleteBaseMenu({ ID }) |
|
|
const res = await deleteBaseMenu({ ID }) |
|
|
if (res.code === 0) { |
|
|
if (res.code === 0) { |
|
|
this.$message({ |
|
|
|
|
|
|
|
|
ElMessage({ |
|
|
type: 'success', |
|
|
type: 'success', |
|
|
message: '删除成功!' |
|
|
message: '删除成功!' |
|
|
}) |
|
|
}) |
|
|
if (this.tableData.length === 1 && this.page > 1) { |
|
|
|
|
|
this.page-- |
|
|
|
|
|
|
|
|
if (tableData.value.length === 1 && page.value > 1) { |
|
|
|
|
|
page.value-- |
|
|
} |
|
|
} |
|
|
this.getTableData() |
|
|
|
|
|
|
|
|
getTableData() |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
.catch(() => { |
|
|
.catch(() => { |
|
|
this.$message({ |
|
|
|
|
|
|
|
|
ElMessage({ |
|
|
type: 'info', |
|
|
type: 'info', |
|
|
message: '已取消删除' |
|
|
message: '已取消删除' |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
|
|
|
|
|
|
} |
|
|
// 初始化弹窗内表格方法 |
|
|
// 初始化弹窗内表格方法 |
|
|
initForm() { |
|
|
|
|
|
this.checkFlag = false |
|
|
|
|
|
this.$refs.menuForm.resetFields() |
|
|
|
|
|
this.form = { |
|
|
|
|
|
|
|
|
const menuForm = ref(null) |
|
|
|
|
|
const checkFlag = ref(false) |
|
|
|
|
|
const initForm = () => { |
|
|
|
|
|
checkFlag.value = false |
|
|
|
|
|
menuForm.value.resetFields() |
|
|
|
|
|
form.value = { |
|
|
ID: 0, |
|
|
ID: 0, |
|
|
path: '', |
|
|
path: '', |
|
|
name: '', |
|
|
name: '', |
|
@ -354,51 +316,108 @@ export default { |
|
|
keepAlive: '' |
|
|
keepAlive: '' |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
}, |
|
|
|
|
|
|
|
|
} |
|
|
// 关闭弹窗 |
|
|
// 关闭弹窗 |
|
|
closeDialog() { |
|
|
|
|
|
this.initForm() |
|
|
|
|
|
this.dialogFormVisible = false |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const dialogFormVisible = ref(false) |
|
|
|
|
|
const closeDialog = () => { |
|
|
|
|
|
initForm() |
|
|
|
|
|
dialogFormVisible.value = false |
|
|
|
|
|
} |
|
|
// 添加menu |
|
|
// 添加menu |
|
|
async enterDialog() { |
|
|
|
|
|
this.$refs.menuForm.validate(async valid => { |
|
|
|
|
|
|
|
|
const enterDialog = async() => { |
|
|
|
|
|
menuForm.value.validate(async valid => { |
|
|
if (valid) { |
|
|
if (valid) { |
|
|
let res |
|
|
let res |
|
|
if (this.isEdit) { |
|
|
|
|
|
res = await updateBaseMenu(this.form) |
|
|
|
|
|
|
|
|
if (isEdit.value) { |
|
|
|
|
|
res = await updateBaseMenu(form.value) |
|
|
} else { |
|
|
} else { |
|
|
res = await addBaseMenu(this.form) |
|
|
|
|
|
|
|
|
res = await addBaseMenu(form.value) |
|
|
} |
|
|
} |
|
|
if (res.code === 0) { |
|
|
if (res.code === 0) { |
|
|
this.$message({ |
|
|
|
|
|
|
|
|
ElMessage({ |
|
|
type: 'success', |
|
|
type: 'success', |
|
|
message: this.isEdit ? '编辑成功' : '添加成功!' |
|
|
|
|
|
|
|
|
message: isEdit.value ? '编辑成功' : '添加成功!' |
|
|
}) |
|
|
}) |
|
|
this.getTableData() |
|
|
|
|
|
|
|
|
getTableData() |
|
|
} |
|
|
} |
|
|
this.initForm() |
|
|
|
|
|
this.dialogFormVisible = false |
|
|
|
|
|
|
|
|
initForm() |
|
|
|
|
|
dialogFormVisible.value = false |
|
|
} |
|
|
} |
|
|
}) |
|
|
}) |
|
|
}, |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const menuOption = ref([ |
|
|
|
|
|
{ |
|
|
|
|
|
ID: '0', |
|
|
|
|
|
title: '根菜单' |
|
|
|
|
|
} |
|
|
|
|
|
]) |
|
|
|
|
|
const setOptions = () => { |
|
|
|
|
|
menuOption.value = [ |
|
|
|
|
|
{ |
|
|
|
|
|
ID: '0', |
|
|
|
|
|
title: '根目录' |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
|
|
|
setMenuOptions(tableData.value, menuOption.value, false) |
|
|
|
|
|
} |
|
|
|
|
|
const setMenuOptions = (menuData, optionsData, disabled) => { |
|
|
|
|
|
menuData && |
|
|
|
|
|
menuData.forEach(item => { |
|
|
|
|
|
if (item.children && item.children.length) { |
|
|
|
|
|
const option = { |
|
|
|
|
|
title: item.meta.title, |
|
|
|
|
|
ID: String(item.ID), |
|
|
|
|
|
disabled: disabled || item.ID === form.value.ID, |
|
|
|
|
|
children: [] |
|
|
|
|
|
} |
|
|
|
|
|
setMenuOptions( |
|
|
|
|
|
item.children, |
|
|
|
|
|
option.children, |
|
|
|
|
|
disabled || item.ID === form.value.ID |
|
|
|
|
|
) |
|
|
|
|
|
optionsData.push(option) |
|
|
|
|
|
} else { |
|
|
|
|
|
const option = { |
|
|
|
|
|
title: item.meta.title, |
|
|
|
|
|
ID: String(item.ID), |
|
|
|
|
|
disabled: disabled || item.ID === form.value.ID |
|
|
|
|
|
} |
|
|
|
|
|
optionsData.push(option) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 添加菜单方法,id为 0则为添加根菜单 |
|
|
// 添加菜单方法,id为 0则为添加根菜单 |
|
|
addMenu(id) { |
|
|
|
|
|
this.dialogTitle = '新增菜单' |
|
|
|
|
|
this.form.parentId = String(id) |
|
|
|
|
|
this.isEdit = false |
|
|
|
|
|
this.setOptions() |
|
|
|
|
|
this.dialogFormVisible = true |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
const isEdit = ref(false) |
|
|
|
|
|
const dialogTitle = ref('新增菜单') |
|
|
|
|
|
const addMenu = (id) => { |
|
|
|
|
|
dialogTitle.value = '新增菜单' |
|
|
|
|
|
form.value.parentId = String(id) |
|
|
|
|
|
isEdit.value = false |
|
|
|
|
|
setOptions() |
|
|
|
|
|
dialogFormVisible.value = true |
|
|
|
|
|
} |
|
|
// 修改菜单方法 |
|
|
// 修改菜单方法 |
|
|
async editMenu(id) { |
|
|
|
|
|
this.dialogTitle = '编辑菜单' |
|
|
|
|
|
|
|
|
const editMenu = async(id) => { |
|
|
|
|
|
dialogTitle.value = '编辑菜单' |
|
|
const res = await getBaseMenuById({ id }) |
|
|
const res = await getBaseMenuById({ id }) |
|
|
this.form = res.data.menu |
|
|
|
|
|
this.isEdit = true |
|
|
|
|
|
this.setOptions() |
|
|
|
|
|
this.dialogFormVisible = true |
|
|
|
|
|
|
|
|
form.value = res.data.menu |
|
|
|
|
|
isEdit.value = true |
|
|
|
|
|
setOptions() |
|
|
|
|
|
dialogFormVisible.value = true |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
|
|
|
|
|
|
|
|
<script> |
|
|
|
|
|
// 获取列表内容封装在mixins内部 getTableData方法 初始化已封装完成 |
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
|
|
name: 'Menus', |
|
|
|
|
|
methods: { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
</script> |
|
|
</script> |
|
|