Browse Source

菜单管理setup改造完成

main
piexlmax 3 years ago
parent
commit
26066ce7bc
  1. 1
      web/src/view/superAdmin/authority/authority.vue
  2. 2
      web/src/view/superAdmin/authority/components/datas.vue
  3. 32
      web/src/view/superAdmin/menu/icon.vue
  4. 303
      web/src/view/superAdmin/menu/menu.vue

1
web/src/view/superAdmin/authority/authority.vue

@ -179,7 +179,6 @@ const datas = ref(null)
const autoEnter = (activeName, oldActiveName) => {
const paneArr = [menus, apis, datas]
if (oldActiveName) {
console.log(paneArr[oldActiveName].value.needConfirm)
if (paneArr[oldActiveName].value.needConfirm) {
paneArr[oldActiveName].value.enterAndNext()
paneArr[oldActiveName].value.needConfirm = false

2
web/src/view/superAdmin/authority/components/datas.vue

@ -67,7 +67,6 @@ init()
// 使
const enterAndNext = () => {
console.log(123)
authDataEnter()
}
@ -97,7 +96,6 @@ const getChildrenId = (row, arrBox) => {
}
//
const authDataEnter = async() => {
console.log(123, props.row)
const res = await setDataAuthority(props.row)
if (res.code === 0) {
ElMessage({ type: 'success', message: '资源设置成功' })

32
web/src/view/superAdmin/menu/icon.vue

@ -18,22 +18,18 @@
</div>
</template>
<script>
export default {
name: 'Icon',
props: {
<script setup>
import { defineProps, ref, reactive } from 'vue'
const props = defineProps({
meta: {
default: function() {
return {}
},
type: Object
}
},
data() {
return {
input: '',
metaData: {},
options: [
})
const options = reactive([
{
'key': 'aim',
'label': 'aim'
@ -1154,14 +1150,14 @@ export default {
'key': 'wind-power',
'label': 'wind-power'
}
],
value: ''
}
},
created() {
this.metaData = this.meta
},
methods: {}
])
const metaData = ref(props.meta)
</script>
<script>
export default {
name: 'Icon',
}
</script>

303
web/src/view/superAdmin/menu/menu.vue

@ -188,9 +188,7 @@
</div>
</template>
<script>
// mixins getTableData
<script setup>
import {
updateBaseMenu,
getMenuList,
@ -198,45 +196,12 @@ import {
deleteBaseMenu,
getBaseMenuById
} from '@/api/menu'
import infoList from '@/mixins/infoList'
import icon from '@/view/superAdmin/menu/icon.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' }],
component: [
{ required: true, message: '请输入文件路径', trigger: 'blur' }
@ -244,74 +209,69 @@ export default {
'meta.title': [
{ 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) {
this.form.parameters = []
form.value.parameters = []
}
form.parameters.push({
type: 'query',
key: '',
value: ''
})
},
deleteParameter(parameters, index) {
}
//
const deleteParameter = (parameters, index) => {
parameters.splice(index, 1)
}
const form = ref({
ID: 0,
path: '',
name: '',
hidden: '',
parentId: '',
component: '',
meta: {
title: '',
icon: '',
defaultMenu: false,
closeTab: false,
keepAlive: false
},
changeName() {
this.form.path = this.form.name
},
setOptions() {
this.menuOption = [
{
ID: '0',
title: '根目录'
}
]
this.setMenuOptions(this.tableData, this.menuOption, 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)
}
})
},
handleClose(done) {
this.initForm()
parameters: []
})
const changeName = () => {
form.value.path = form.value.name
}
const handleClose = (done) => {
initForm()
done()
},
//
deleteMenu(ID) {
this.$confirm('此操作将永久删除所有角色下该菜单, 是否继续?', '提示', {
}
//
const deleteMenu = (ID) => {
ElMessageBox.confirm('此操作将永久删除所有角色下该菜单, 是否继续?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
@ -319,28 +279,30 @@ export default {
.then(async() => {
const res = await deleteBaseMenu({ ID })
if (res.code === 0) {
this.$message({
ElMessage({
type: 'success',
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(() => {
this.$message({
ElMessage({
type: 'info',
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,
path: '',
name: '',
@ -354,51 +316,108 @@ export default {
keepAlive: ''
}
}
},
//
closeDialog() {
this.initForm()
this.dialogFormVisible = false
},
// menu
async enterDialog() {
this.$refs.menuForm.validate(async valid => {
}
//
const dialogFormVisible = ref(false)
const closeDialog = () => {
initForm()
dialogFormVisible.value = false
}
// menu
const enterDialog = async() => {
menuForm.value.validate(async valid => {
if (valid) {
let res
if (this.isEdit) {
res = await updateBaseMenu(this.form)
if (isEdit.value) {
res = await updateBaseMenu(form.value)
} else {
res = await addBaseMenu(this.form)
res = await addBaseMenu(form.value)
}
if (res.code === 0) {
this.$message({
ElMessage({
type: 'success',
message: this.isEdit ? '编辑成功' : '添加成功!'
message: isEdit.value ? '编辑成功' : '添加成功!'
})
this.getTableData()
getTableData()
}
this.initForm()
this.dialogFormVisible = false
initForm()
dialogFormVisible.value = false
}
})
},
// id 0
addMenu(id) {
this.dialogTitle = '新增菜单'
this.form.parentId = String(id)
this.isEdit = false
this.setOptions()
this.dialogFormVisible = true
},
//
async editMenu(id) {
this.dialogTitle = '编辑菜单'
const res = await getBaseMenuById({ id })
this.form = res.data.menu
this.isEdit = true
this.setOptions()
this.dialogFormVisible = true
}
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
const isEdit = ref(false)
const dialogTitle = ref('新增菜单')
const addMenu = (id) => {
dialogTitle.value = '新增菜单'
form.value.parentId = String(id)
isEdit.value = false
setOptions()
dialogFormVisible.value = true
}
//
const editMenu = async(id) => {
dialogTitle.value = '编辑菜单'
const res = await getBaseMenuById({ id })
form.value = res.data.menu
isEdit.value = true
setOptions()
dialogFormVisible.value = true
}
</script>
<script>
// mixins getTableData
export default {
name: 'Menus',
methods: {
}
}
</script>

Loading…
Cancel
Save