权限增加等级
This commit is contained in:
parent
9cfd62f08b
commit
0f0c98486f
@ -76,6 +76,14 @@
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="等级" prop="level">
|
||||
<el-input
|
||||
v-model="record.level"
|
||||
placeholder="等级"
|
||||
type="number"
|
||||
clearable
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="操作" prop="actions">
|
||||
<el-select
|
||||
v-model="record.actions"
|
||||
@ -124,6 +132,7 @@ export interface ITreeData{
|
||||
id: string
|
||||
label: string
|
||||
actions: string[]
|
||||
level: number
|
||||
children: ITreeData[]
|
||||
}
|
||||
|
||||
@ -143,7 +152,7 @@ export default class extends Vue {
|
||||
private loading = true
|
||||
private dialogType = 'new'
|
||||
private dialogVisible = false
|
||||
private record: ITreeData = { actions: [], id: '', label: '', children: [] }
|
||||
private record: ITreeData = {}
|
||||
private actions = [
|
||||
'read', 'edit', 'delete'
|
||||
]
|
||||
@ -153,12 +162,13 @@ export default class extends Vue {
|
||||
}
|
||||
|
||||
private typeOptions: ITreeData[] = []
|
||||
private initAdmin() {
|
||||
private initData() {
|
||||
return {
|
||||
id: '',
|
||||
label: '',
|
||||
actions: [],
|
||||
children: []
|
||||
children: [],
|
||||
level: 999
|
||||
}
|
||||
}
|
||||
|
||||
@ -179,7 +189,9 @@ export default class extends Vue {
|
||||
pattern: /^[\u4e00-\u9fa5_a-zA-Z0-9.·-]+$/,
|
||||
message: '权限名不支持特殊字符',
|
||||
trigger: 'blur'
|
||||
}]
|
||||
}],
|
||||
|
||||
level: [{ required: true, message: '请输入权限等级', trigger: 'blur' }]
|
||||
|
||||
}
|
||||
|
||||
@ -203,7 +215,7 @@ export default class extends Vue {
|
||||
}
|
||||
|
||||
private append(data: ITreeData) {
|
||||
this.record = this.initAdmin()
|
||||
this.record = this.initData()
|
||||
this.dialogType = 'new'
|
||||
this.dialogVisible = true
|
||||
this.record.actions = this.actions
|
||||
@ -212,7 +224,7 @@ export default class extends Vue {
|
||||
|
||||
private edit(node: TreeNode<any, any>, data: ITreeData) {
|
||||
console.log(data)
|
||||
this.record = this.initAdmin()
|
||||
this.record = this.initData()
|
||||
this.record.idx = node.parent?.data.children.indexOf(data)
|
||||
this.record.actions = data.children?.map(o => o.label)
|
||||
this.record.parent = node.parent?.data
|
||||
@ -220,6 +232,7 @@ export default class extends Vue {
|
||||
this.dialogVisible = true
|
||||
this.record.id = data.id
|
||||
this.record.label = data.label
|
||||
this.record.level = data.level
|
||||
}
|
||||
|
||||
private async remove(node: TreeNode<any, any>, data: ITreeData) {
|
||||
@ -246,7 +259,8 @@ export default class extends Vue {
|
||||
records.push({
|
||||
_id: data.id,
|
||||
name: data.label,
|
||||
actions: data.children?.map(o => o.label)
|
||||
actions: data.children?.map(o => o.label),
|
||||
level: data.level
|
||||
})
|
||||
}
|
||||
const { data } = await savePermission({ datas: records })
|
||||
@ -293,7 +307,8 @@ export default class extends Vue {
|
||||
const data = {
|
||||
id: this.record.id,
|
||||
label: this.record.label,
|
||||
children: subArr
|
||||
children: subArr,
|
||||
level: this.record.level
|
||||
}
|
||||
if (this.dialogType === 'new') {
|
||||
this.record.parent.children.push(data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user