REVIEW 租户套餐

This commit is contained in:
YunaiV 2023-03-30 09:35:35 +08:00
parent 216ad84938
commit 84ab75b475

View File

@ -33,7 +33,6 @@
<el-tree <el-tree
ref="treeRef" ref="treeRef"
node-key="id" node-key="id"
:check-strictly="!menuCheckStrictly"
show-checkbox show-checkbox
:props="defaultProps" :props="defaultProps"
:data="menuOptions" :data="menuOptions"
@ -91,7 +90,6 @@ const formRules = reactive({
}) })
const formRef = ref() // Ref const formRef = ref() // Ref
const menuOptions = ref<any[]>([]) // const menuOptions = ref<any[]>([]) //
const menuCheckStrictly = ref(false) // true
const menuExpand = ref(false) // / const menuExpand = ref(false) // /
const treeRef = ref<InstanceType<typeof ElTree>>() // Ref const treeRef = ref<InstanceType<typeof ElTree>>() // Ref
const treeNodeAll = ref(false) // / const treeNodeAll = ref(false) // /
@ -102,6 +100,8 @@ const open = async (type: string, id?: number) => {
modelTitle.value = t('action.' + type) modelTitle.value = t('action.' + type)
formType.value = type formType.value = type
resetForm() resetForm()
// Menu setChecked
menuOptions.value = handleTree(await MenuApi.getSimpleMenusList())
// //
if (id) { if (id) {
formLoading.value = true formLoading.value = true
@ -110,15 +110,13 @@ const open = async (type: string, id?: number) => {
// //
formData.value = res formData.value = res
// //
res.menuIds?.forEach((item: any) => { res.menuIds.forEach((menuId: number) => {
treeRef.value?.setChecked(item, true, false) treeRef.value.setChecked(menuId, true, false)
}) })
} finally { } finally {
formLoading.value = false formLoading.value = false
} }
} }
// Menu
menuOptions.value = handleTree(await MenuApi.getSimpleMenusList())
} }
defineExpose({ open }) // open defineExpose({ open }) // open
@ -134,8 +132,8 @@ const submitForm = async () => {
try { try {
const data = formData.value as unknown as TenantPackageApi.TenantPackageVO const data = formData.value as unknown as TenantPackageApi.TenantPackageVO
data.menuIds = [ data.menuIds = [
...(treeRef.value!.getCheckedKeys(false) as unknown as Array<number>), ...(treeRef.value!.getCheckedKeys(false) as unknown as Array<number>), //
...(treeRef.value!.getHalfCheckedKeys() as unknown as Array<number>) ...(treeRef.value!.getHalfCheckedKeys() as unknown as Array<number>) //
] ]
if (formType.value === 'create') { if (formType.value === 'create') {
await TenantPackageApi.createTenantPackage(data) await TenantPackageApi.createTenantPackage(data)
@ -154,6 +152,10 @@ const submitForm = async () => {
/** 重置表单 */ /** 重置表单 */
const resetForm = () => { const resetForm = () => {
//
treeNodeAll.value = false
menuExpand.value = false
//
formData.value = { formData.value = {
id: null, id: null,
name: null, name: null,
@ -162,10 +164,6 @@ const resetForm = () => {
status: CommonStatusEnum.ENABLE status: CommonStatusEnum.ENABLE
} }
treeRef.value?.setCheckedNodes([]) treeRef.value?.setCheckedNodes([])
treeNodeAll.value = false
menuExpand.value = false
// 使
menuCheckStrictly.value = false
formRef.value?.resetFields() formRef.value?.resetFields()
} }
@ -173,6 +171,7 @@ const resetForm = () => {
const handleCheckedTreeNodeAll = () => { const handleCheckedTreeNodeAll = () => {
treeRef.value!.setCheckedNodes(treeNodeAll.value ? menuOptions.value : []) treeRef.value!.setCheckedNodes(treeNodeAll.value ? menuOptions.value : [])
} }
// /TODO:for // /TODO:for
const handleCheckedTreeExpand = () => { const handleCheckedTreeExpand = () => {
const nodes = treeRef.value?.store.nodesMap const nodes = treeRef.value?.store.nodesMap