fix: tenant package menu
parent
fe8e0a25ae
commit
1d07574df8
|
@ -4,12 +4,11 @@
|
||||||
<template #menuIds="{ model, field }">
|
<template #menuIds="{ model, field }">
|
||||||
<BasicTree
|
<BasicTree
|
||||||
v-model:value="model[field]"
|
v-model:value="model[field]"
|
||||||
:treeData="menuTree"
|
:treeData="treeData"
|
||||||
:fieldNames="{ title: 'name', key: 'id' }"
|
:fieldNames="{ title: 'name', key: 'id' }"
|
||||||
:checkStrictly="false"
|
:checkStrictly="true"
|
||||||
checkable
|
checkable
|
||||||
toolbar
|
toolbar
|
||||||
@check="menuCheck"
|
|
||||||
title="菜单分配"
|
title="菜单分配"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
@ -28,9 +27,7 @@ import { handleTree } from '@/utils/tree'
|
||||||
|
|
||||||
const emit = defineEmits(['success', 'register'])
|
const emit = defineEmits(['success', 'register'])
|
||||||
const isUpdate = ref(true)
|
const isUpdate = ref(true)
|
||||||
const menuTree = ref<TreeItem[]>([])
|
const treeData = ref<TreeItem[]>([])
|
||||||
const menuKeys = ref<(string | number)[]>([])
|
|
||||||
const menuHalfKeys = ref<(string | number)[]>([])
|
|
||||||
|
|
||||||
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
|
const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
|
||||||
labelWidth: 120,
|
labelWidth: 120,
|
||||||
|
@ -41,29 +38,24 @@ const [registerForm, { setFieldsValue, resetFields, validate }] = useForm({
|
||||||
})
|
})
|
||||||
|
|
||||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
menuKeys.value = []
|
|
||||||
menuHalfKeys.value = []
|
|
||||||
resetFields()
|
resetFields()
|
||||||
setModalProps({ confirmLoading: false })
|
setModalProps({ confirmLoading: false })
|
||||||
|
if (unref(treeData).length === 0) {
|
||||||
|
const res = await listSimpleMenus()
|
||||||
|
treeData.value = handleTree(res, 'id')
|
||||||
|
}
|
||||||
isUpdate.value = !!data?.isUpdate
|
isUpdate.value = !!data?.isUpdate
|
||||||
|
|
||||||
if (unref(isUpdate)) {
|
if (unref(isUpdate)) {
|
||||||
const res = await getTenantPackage(data.record.id)
|
const res = await getTenantPackage(data.record.id)
|
||||||
const menus = await listSimpleMenus()
|
|
||||||
menuTree.value = handleTree(menus, 'id')
|
|
||||||
setFieldsValue({ ...res })
|
setFieldsValue({ ...res })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
function menuCheck(checkedKeys, e) {
|
|
||||||
menuKeys.value = checkedKeys as (string | number)[]
|
|
||||||
menuHalfKeys.value = e.halfCheckedKeys as (string | number)[]
|
|
||||||
}
|
|
||||||
|
|
||||||
async function handleSubmit() {
|
async function handleSubmit() {
|
||||||
try {
|
try {
|
||||||
const values = await validate()
|
const values = await validate()
|
||||||
setModalProps({ confirmLoading: true })
|
setModalProps({ confirmLoading: true })
|
||||||
values.menuIds = menuKeys.value.concat(menuHalfKeys.value)
|
|
||||||
if (unref(isUpdate)) {
|
if (unref(isUpdate)) {
|
||||||
await updateTenantPackage(values)
|
await updateTenantPackage(values)
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue