fix 修复菜单编辑
This commit is contained in:
@@ -82,7 +82,7 @@
|
||||
<a-form-model-item label="内外链地址" prop="link" v-if="form.type == 1 && form.openType == 3">
|
||||
<a-input placeholder="请输入内外链地址" v-model="form.link" />
|
||||
</a-form-model-item>
|
||||
<a-form-model-item label="权重" prop="weight">
|
||||
<!-- <a-form-model-item label="权重" prop="weight">
|
||||
<template slot="help">
|
||||
系统权重:菜单可分配给任何角色
|
||||
<br />业务权重:菜单对超级管理员不可见
|
||||
@@ -94,7 +94,7 @@
|
||||
v-for="type in codes.menuWerght"
|
||||
>{{type.value}}</a-radio-button>
|
||||
</a-radio-group>
|
||||
</a-form-model-item>
|
||||
</a-form-model-item>-->
|
||||
<a-form-model-item label="可见性">
|
||||
<a-switch checked-children="可见" un-checked-children="隐藏" v-model="form.visible" />
|
||||
</a-form-model-item>
|
||||
@@ -118,16 +118,22 @@
|
||||
</a-form-model>
|
||||
</template>
|
||||
<script>
|
||||
import { EMPTY_ID } from '@/util/global';
|
||||
|
||||
const defaultValue = {
|
||||
type: '1',
|
||||
openType: '1',
|
||||
weight: '1',
|
||||
visible: true,
|
||||
sort: 100,
|
||||
};
|
||||
|
||||
export default {
|
||||
data() {
|
||||
return {
|
||||
/** 表单数据 */
|
||||
form: {
|
||||
type: '1',
|
||||
openType: '1',
|
||||
weight: '2',
|
||||
visible: true,
|
||||
sort: 100,
|
||||
...defaultValue,
|
||||
},
|
||||
/** 验证格式 */
|
||||
rules: {
|
||||
@@ -168,7 +174,6 @@ export default {
|
||||
...record,
|
||||
/** 在此处添加默认数据转换 */
|
||||
/** ... */
|
||||
visible: record.visible == 'Y',
|
||||
});
|
||||
},
|
||||
|
||||
@@ -184,7 +189,6 @@ export default {
|
||||
|
||||
/** 验证通过后可以对数据进行转换得到想要提交的格式 */
|
||||
/** ... */
|
||||
record.visible = record.visible ? 'Y' : 'N';
|
||||
|
||||
reslove(record);
|
||||
} else {
|
||||
@@ -209,6 +213,9 @@ export default {
|
||||
onResetFields() {
|
||||
setTimeout(() => {
|
||||
this.$refs.form.resetFields();
|
||||
this.form = {
|
||||
...defaultValue,
|
||||
};
|
||||
|
||||
/** 在这里可以初始化当前组件中其他属性 */
|
||||
/** ... */
|
||||
@@ -220,13 +227,26 @@ export default {
|
||||
* 必要方法
|
||||
* 加载当前表单中所需要的异步数据
|
||||
*/
|
||||
async onInit() {
|
||||
async onInit(record) {
|
||||
this.loading = true;
|
||||
|
||||
/** 可以在这里await获取一些异步数据 */
|
||||
/** ...BEGIN */
|
||||
this.codes = await this.onLoadCodes();
|
||||
this.appList = await this.onLoadSysApplist();
|
||||
if (record) {
|
||||
const treeData = await this.onLoadMenuTree(record.application);
|
||||
this.parentTreeData = [
|
||||
{
|
||||
id: EMPTY_ID,
|
||||
parentId: undefined,
|
||||
title: '顶级',
|
||||
value: EMPTY_ID,
|
||||
pid: undefined,
|
||||
children: treeData,
|
||||
},
|
||||
];
|
||||
}
|
||||
/** ...END */
|
||||
this.loading = false;
|
||||
},
|
||||
@@ -255,6 +275,12 @@ export default {
|
||||
});
|
||||
},
|
||||
|
||||
onLoadMenuTree(app) {
|
||||
return this.$api.getMenuTree({ application: app }).then(({ data }) => {
|
||||
return data;
|
||||
});
|
||||
},
|
||||
|
||||
onTypeChangeGroup() {
|
||||
const { type, openType } = this.form;
|
||||
if (type == 1 && openType == 2) {
|
||||
@@ -279,14 +305,14 @@ export default {
|
||||
},
|
||||
|
||||
onChangeApplication(value) {
|
||||
this.$api.getMenuTree({ application: value }).then(({ data }) => {
|
||||
this.onLoadMenuTree(value).then((data) => {
|
||||
this.parentTreeData = [
|
||||
{
|
||||
id: -1,
|
||||
parentId: 0,
|
||||
id: EMPTY_ID,
|
||||
parentId: undefined,
|
||||
title: '顶级',
|
||||
value: 0,
|
||||
pid: 0,
|
||||
value: EMPTY_ID,
|
||||
pid: undefined,
|
||||
children: data,
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user