|
|
@@ -3,7 +3,7 @@
|
|
|
<ele-modal
|
|
|
width="720px"
|
|
|
:visible="visible"
|
|
|
- :close-on-click-modal="true"
|
|
|
+ :close-on-click-modal="false"
|
|
|
custom-class="ele-dialog-form"
|
|
|
:title="isUpdate ? '修改菜单' : '添加菜单'"
|
|
|
@update:visible="updateVisible"
|
|
|
@@ -41,6 +41,15 @@
|
|
|
/>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
+ <el-col :span="12">
|
|
|
+ <el-form-item label="组件地址:" prop="component">
|
|
|
+ <el-input
|
|
|
+ clearable
|
|
|
+ v-model="form.component"
|
|
|
+ placeholder="请输入路由地址"
|
|
|
+ />
|
|
|
+ </el-form-item>
|
|
|
+ </el-col>
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="菜单图标:">
|
|
|
<ele-icon-picker
|
|
|
@@ -85,7 +94,7 @@
|
|
|
|
|
|
<script>
|
|
|
import { EleIconPicker } from 'ele-admin';
|
|
|
- import { saveOrUpdate } from '@/api/system/menu';
|
|
|
+ import { saveOrUpdate } from '@/api/system/menu';
|
|
|
|
|
|
export default {
|
|
|
components: { EleIconPicker },
|
|
|
@@ -95,11 +104,11 @@
|
|
|
// 修改回显的数据
|
|
|
data: Object,
|
|
|
// 上级菜单id
|
|
|
- parentId: [Number,String],
|
|
|
+ parentId: [Number, String],
|
|
|
// 全部菜单数据
|
|
|
menuList: Array
|
|
|
},
|
|
|
- data() {
|
|
|
+ data () {
|
|
|
const defaultForm = {
|
|
|
id: null,
|
|
|
parentId: '',
|
|
|
@@ -107,8 +116,9 @@
|
|
|
type: 1,
|
|
|
icon: '',
|
|
|
url: '',
|
|
|
+ component: '',
|
|
|
sort: null,
|
|
|
- permissionCode:1
|
|
|
+ permissionCode: 1
|
|
|
};
|
|
|
return {
|
|
|
defaultForm,
|
|
|
@@ -116,10 +126,12 @@
|
|
|
form: { ...defaultForm },
|
|
|
// 表单验证规则
|
|
|
rules: {
|
|
|
- name: [{required: true,message: '请输入菜单名称',trigger: 'blur'}],
|
|
|
- sort: [{required: true,message: '请输入排序号', trigger: 'blur'}],
|
|
|
- url: [{required: true,message: '请输入菜单路由', trigger: 'blur'}],
|
|
|
- type: [{required: true,message: '请选择菜单类型', trigger: 'blur'}],
|
|
|
+ name: [
|
|
|
+ { required: true, message: '请输入菜单名称', trigger: 'blur' }
|
|
|
+ ],
|
|
|
+ sort: [{ required: true, message: '请输入排序号', trigger: 'blur' }],
|
|
|
+ url: [{ required: true, message: '请输入菜单路由', trigger: 'blur' }],
|
|
|
+ type: [{ required: true, message: '请选择菜单类型', trigger: 'blur' }]
|
|
|
},
|
|
|
// 提交状态
|
|
|
loading: false,
|
|
|
@@ -141,7 +153,7 @@
|
|
|
},
|
|
|
methods: {
|
|
|
/* 保存编辑 */
|
|
|
- save() {
|
|
|
+ save () {
|
|
|
this.$refs.form.validate((valid) => {
|
|
|
if (!valid) {
|
|
|
return false;
|
|
|
@@ -154,15 +166,15 @@
|
|
|
parentId: this.form.parentId || 0
|
|
|
};
|
|
|
// const saveOrUpdate = this.isUpdate ? updateMenu : addMenu;
|
|
|
- if(!this.isUpdate){
|
|
|
- delete data.id
|
|
|
+ if (!this.isUpdate) {
|
|
|
+ delete data.id;
|
|
|
}
|
|
|
saveOrUpdate(data)
|
|
|
- .then(res => {
|
|
|
+ .then((res) => {
|
|
|
this.loading = false;
|
|
|
- if(this.isUpdate){
|
|
|
+ if (this.isUpdate) {
|
|
|
this.$message.success('菜单编辑成功');
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
this.$message.success('菜单新增成功');
|
|
|
}
|
|
|
this.updateVisible(false);
|
|
|
@@ -175,11 +187,11 @@
|
|
|
});
|
|
|
},
|
|
|
/* 更新visible */
|
|
|
- updateVisible(value) {
|
|
|
+ updateVisible (value) {
|
|
|
this.$emit('update:visible', value);
|
|
|
},
|
|
|
/* menuType选择改变 */
|
|
|
- onMenuTypeChange() {
|
|
|
+ onMenuTypeChange () {
|
|
|
// if (this.form.menuType === 0) {
|
|
|
// this.form.authority = null;
|
|
|
// this.form.openType = 0;
|
|
|
@@ -197,12 +209,12 @@
|
|
|
// }
|
|
|
},
|
|
|
/* openType选择改变 */
|
|
|
- onOpenTypeChange() {
|
|
|
+ onOpenTypeChange () {
|
|
|
if (this.form.openType === 2) {
|
|
|
this.form.component = null;
|
|
|
this.form.authority = null;
|
|
|
}
|
|
|
- },
|
|
|
+ }
|
|
|
/* 判断是否是外链 */
|
|
|
// isUrl(url) {
|
|
|
// return !!(
|
|
|
@@ -218,7 +230,7 @@
|
|
|
// }
|
|
|
},
|
|
|
watch: {
|
|
|
- visible(visible) {
|
|
|
+ visible (visible) {
|
|
|
if (visible) {
|
|
|
if (this.data) {
|
|
|
// const isInnerLink = this.isUrl(this.data.component) ? 1 : 0;
|