refactor(AppRoleRightsManager):优化角色标记选择和编辑功能- 在编辑角色时添加 type 参数,确保角色类型正确保存

- 在新增角色页面将角色标记设置为必选项,提高数据完整性- 优化角色保存逻辑,移除冗余的 if 语句
- 重构 back 方法,增加可选参数以提高灵活性
This commit is contained in:
aixianling
2025-01-07 09:20:48 +08:00
parent 532ceeb5e7
commit 385447d3b4
2 changed files with 15 additions and 16 deletions

View File

@@ -319,6 +319,7 @@ export default {
params: {
roleName: this.editName,
appId: this.row.appId,
type: this.row.type
},
})
.then((res) => {

View File

@@ -9,7 +9,7 @@
<el-form-item label="应用角色名称" prop="roleName">
<el-input v-model="form.roleName" placeholder="请输入应用角色名称" clearable/>
</el-form-item>
<el-form-item label="角色标记" prop="type">
<el-form-item label="角色标记" prop="type" :rules="{required:true,message:'请选择角色标记'}">
<ai-select v-model="form.type" dict="roleType" placeholder="请选择角色标记" clearable/>
</el-form-item>
</div>
@@ -132,24 +132,22 @@ export default {
},
//保存提交
confirm() {
this.$refs.rightsForm.validate(v => {
if (v) {
let menus = [this.$refs.roleTree?.getHalfCheckedKeys(), this.$refs.roleTree?.getCheckedKeys()]?.flat()?.toString()
this.instance.post(this.top.actions.modify, null, {
params: {...this.form, menus}
}).then(res => {
if (res?.msg == "success") {
this.$message.success(`${this.msgTitle}应用角色成功`)
this.back()
this.top.searchList()
}
})
}
this.$refs.rightsForm.validate().then(() => {
let menus = [this.$refs.roleTree?.getHalfCheckedKeys(), this.$refs.roleTree?.getCheckedKeys()]?.flat()?.toString()
this.instance.post(this.top.actions.modify, null, {
params: {...this.form, menus}
}).then(res => {
if (res?.msg == "success") {
this.$message.success(`${this.msgTitle}应用角色成功`)
this.back()
this.top.searchList()
}
})
})
},
//取消 返回
back() {
this.$router.push({})
back(params = {}) {
this.$router.push(params)
}
},
}