|
@@ -24,6 +24,7 @@ export default {
|
|
|
curObj: Object,
|
|
|
curType: String,
|
|
|
},
|
|
|
+ inject: ['parentData'],
|
|
|
mixins,
|
|
|
data() {
|
|
|
return {
|
|
@@ -34,20 +35,62 @@ export default {
|
|
|
watch: {
|
|
|
isShow: function(val) {
|
|
|
if (val) {
|
|
|
- let params = {...this.curObj}
|
|
|
- if (this.curType === 'edit') params = {...this.curObj}
|
|
|
- if (this.curType === 'add') params = {}
|
|
|
- this.formData = [
|
|
|
- {label: '菜单名称', key: 'name', rules: 1},
|
|
|
- {label: '类型', key: 'perm_type', type: 'select', options: this.$dictData.perm_type, rules: 1},
|
|
|
- {label: '路径', key: 'path', rules: 1},
|
|
|
- {label: '状态', key: 'perm_status', type: 'select', options: this.$dictData.perm_status, rules: 1},
|
|
|
- ]
|
|
|
- this.setDefaultValue(params)
|
|
|
+ let params = {}
|
|
|
+ if (this.curType === 'edit') {
|
|
|
+ params = {...this.curObj}
|
|
|
+ let parentIdArr = JSON.parse(JSON.stringify(params.ids))
|
|
|
+ if (params.ids && params.ids.length > 1) {
|
|
|
+ parentIdArr.pop()
|
|
|
+ params.parentIdArr = parentIdArr
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (this.curType === 'add') {
|
|
|
+ params = {
|
|
|
+ parentName: this.curObj.name,
|
|
|
+ perm_status: '1',
|
|
|
+ perm_type: '2',
|
|
|
+ parentIdArr: this.curObj.ids
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.getDef(params)
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
methods: {
|
|
|
+ typeChange () {
|
|
|
+ let params = {...this.$refs.ruleForm.baseForm}
|
|
|
+ this.getDef(params)
|
|
|
+ },
|
|
|
+ getDef (params) {
|
|
|
+ if (params.perm_type && params.perm_type === '1') {
|
|
|
+ this.formData = [
|
|
|
+ {label: '上级节点', key: 'parentIdArr', type: 'cascader', options: this.parentData.curData, props: { checkStrictly: true }},
|
|
|
+ {label: '节点类型', key: 'perm_type', type: 'select', options: this.$dictData.perm_type, rules: 1, changeHandle: this.typeChange},
|
|
|
+ {label: '目录名称', key: 'name', rules: 1},
|
|
|
+ {label: '目录路径', key: 'path', rules: 1},
|
|
|
+ {label: '目录排序', key: 'sort'},
|
|
|
+ {label: '状态', key: 'perm_status', type: 'select', clearable: false, options: this.$dictData.perm_status},
|
|
|
+ ]
|
|
|
+ } else if (params.perm_type && params.perm_type === '2') {
|
|
|
+ this.formData = [
|
|
|
+ {label: '上级节点', key: 'parentIdArr', type: 'cascader', options: this.parentData.curData, props: { checkStrictly: true }},
|
|
|
+ {label: '节点类型', key: 'perm_type', type: 'select', options: this.$dictData.perm_type, rules: 1, changeHandle: this.typeChange},
|
|
|
+ {label: '菜单名称', key: 'name', rules: 1},
|
|
|
+ {label: '菜单路径', key: 'path', rules: 1},
|
|
|
+ {label: '菜单排序', key: 'sort'},
|
|
|
+ {label: '菜单栏', key: 'menu_hidden', type: 'select', clearable: false, options: this.$dictData.show_hidden},
|
|
|
+ {label: '状态', key: 'perm_status', type: 'select', clearable: false, options: this.$dictData.perm_status},
|
|
|
+ ]
|
|
|
+ } else {
|
|
|
+ this.formData = [
|
|
|
+ {label: '上级节点', key: 'parentIdArr', type: 'cascader', options: this.parentData.curData, props: { checkStrictly: true }},
|
|
|
+ {label: '节点名称', key: 'name', rules: 1},
|
|
|
+ {label: '节点类型', key: 'perm_type', type: 'select', options: this.$dictData.perm_type, rules: 1, changeHandle: this.typeChange},
|
|
|
+ {label: '状态', key: 'perm_status', type: 'select', clearable: false, options: this.$dictData.perm_status},
|
|
|
+ ]
|
|
|
+ }
|
|
|
+ this.setDefaultValue(params)
|
|
|
+ },
|
|
|
close (str) {
|
|
|
if (str === 'confirm') {
|
|
|
this.$refs['ruleForm'].$refs['baseForm'].validate((valid) => {
|
|
@@ -55,9 +98,12 @@ export default {
|
|
|
const oldform = this.$refs.ruleForm.baseForm
|
|
|
let params = {...oldform}
|
|
|
let str = 'admpermissionsadd'
|
|
|
- params.p_id = this.curObj.p_id
|
|
|
+ params.p_id = params.parentIdArr[params.parentIdArr.length - 1]
|
|
|
+ delete params.parentIdArr
|
|
|
+ if (!params.sort) delete params.sort
|
|
|
if(this.curType === 'edit') {
|
|
|
- params.dict_id = this.curObj.id
|
|
|
+ // params.p_id = this.curObj.p_id
|
|
|
+ params.id = this.curObj.id
|
|
|
str = 'admpermissionsedit'
|
|
|
}
|
|
|
this.$api.base[str](params).then(data => {
|