角色添加启用、停用功能
continuous-integration/drone/push Build is passing Details

uat
wangxiaoshuang 2025-02-24 14:20:31 +08:00
parent e7dcdb33c4
commit 2575e27d22
2 changed files with 186 additions and 105 deletions

View File

@ -29,7 +29,18 @@
> >
</el-radio-group> </el-radio-group>
</el-form-item> </el-form-item>
<el-form-item :label="$t('system:role:form:IsEnable')" prop="IsEnable">
<el-switch
v-model="form.IsEnable"
active-color="#13ce66"
inactive-color="#dcdfe6"
:active-value="true"
:inactive-value="false"
:active-text="$fd('IsEnable', true)"
:inactive-text="$fd('IsEnable', false)"
>
</el-switch>
</el-form-item>
<el-form-item label="Group: " prop="UserTypeGroupIdList"> <el-form-item label="Group: " prop="UserTypeGroupIdList">
<el-select v-model="form.UserTypeGroupIdList" multiple> <el-select v-model="form.UserTypeGroupIdList" multiple>
<el-option <el-option
@ -69,18 +80,18 @@
<el-checkbox <el-checkbox
v-model="menuExpand" v-model="menuExpand"
@change="handleCheckedTreeExpand($event)" @change="handleCheckedTreeExpand($event)"
>{{ $t("system:role:form:checkbox:menuExpand") }}</el-checkbox >{{ $t('system:role:form:checkbox:menuExpand') }}</el-checkbox
> >
<el-checkbox <el-checkbox
v-model="menuNodeAll" v-model="menuNodeAll"
@change="handleCheckedTreeNodeAll($event)" @change="handleCheckedTreeNodeAll($event)"
>{{ $t("system:role:form:checkbox:menuNodeAll") }}</el-checkbox >{{ $t('system:role:form:checkbox:menuNodeAll') }}</el-checkbox
> >
<el-checkbox <el-checkbox
v-model="form.menuCheckStrictly" v-model="form.menuCheckStrictly"
@change="handleCheckedTreeConnect($event)" @change="handleCheckedTreeConnect($event)"
>{{ >{{
$t("system:role:form:checkbox:menuCheckStrictly") $t('system:role:form:checkbox:menuCheckStrictly')
}}</el-checkbox }}</el-checkbox
> >
<el-tree <el-tree
@ -116,30 +127,31 @@
</base-model> </base-model>
</template> </template>
<script> <script>
import { addOrUpdateUserType } from "@/api/admin"; import { addOrUpdateUserType } from '@/api/admin'
// import { addOrUpdateUserType } from '@/api/system/role' // import { addOrUpdateUserType } from '@/api/system/role'
// import { getMenuList } from '@/api/system/menu' // import { getMenuList } from '@/api/system/menu'
import { getMenuList } from "@/api/system/menu"; import { getMenuList } from '@/api/system/menu'
import { model_cfg } from "../role"; import { model_cfg } from '../role'
import BaseModel from "@/components/BaseModel"; import BaseModel from '@/components/BaseModel'
export default { export default {
components: { BaseModel }, components: { BaseModel },
dicts: ["UserTypeGroup"], dicts: ['UserTypeGroup'],
props: { props: {
data: { data: {
type: Object, type: Object,
default() { default() {
return { return {
Id: "", Id: '',
UserTypeName: "", UserTypeName: '',
IsInternal: true, IsInternal: true,
UserTypeShortName: "", UserTypeShortName: '',
Order: "", Order: '',
Description: "", Description: '',
PermissionStr: "", PermissionStr: '',
UserTypeEnum: null, UserTypeEnum: null,
}; IsEnable: true,
}
}, },
}, },
}, },
@ -148,136 +160,137 @@ export default {
menuExpand: false, menuExpand: false,
menuNodeAll: false, menuNodeAll: false,
userTypeGroupOptions: [ userTypeGroupOptions: [
{ value: 1, label: "Trial" }, { value: 1, label: 'Trial' },
{ value: 2, label: "Reviewer" }, { value: 2, label: 'Reviewer' },
{ value: 3, label: "Other" }, { value: 3, label: 'Other' },
], ],
model_cfg, model_cfg,
defaultProps: { defaultProps: {
children: "Children", children: 'Children',
label: "MenuName", label: 'MenuName',
}, },
form: { form: {
Id: "", Id: '',
UserType: "", UserType: '',
IsInternal: true, IsInternal: true,
UserTypeShortName: "", UserTypeShortName: '',
Type: null, Type: null,
Description: "", Description: '',
UserTypeGroupIdList: [], UserTypeGroupIdList: [],
menuCheckStrictly: true, menuCheckStrictly: true,
IsEnable: true,
}, },
rules: { rules: {
UserTypeName: [ UserTypeName: [
{ required: true, message: "Please specify", trigger: "blur" }, { required: true, message: 'Please specify', trigger: 'blur' },
{ {
max: 50, max: 50,
message: "The maximum length is 50", message: 'The maximum length is 50',
}, },
], ],
UserTypeShortName: [ UserTypeShortName: [
{ required: true, message: "Please specify", trigger: "blur" }, { required: true, message: 'Please specify', trigger: 'blur' },
{ {
max: 50, max: 50,
message: "The maximum length is 50", message: 'The maximum length is 50',
trigger: "blur", trigger: 'blur',
}, },
], ],
Description: [{ max: 500, message: "The maximum length is 500" }], Description: [{ max: 500, message: 'The maximum length is 500' }],
UserTypeGroupIdList: [ UserTypeGroupIdList: [
{ required: true, message: "Please specify", trigger: "blur" }, { required: true, message: 'Please specify', trigger: 'blur' },
], ],
UserTypeEnum: [ UserTypeEnum: [
{ required: true, message: "Please select", trigger: "blur" }, { required: true, message: 'Please select', trigger: 'blur' },
], ],
}, },
menuOptions: [], menuOptions: [],
btnLoading: false, btnLoading: false,
}; }
}, },
mounted() { mounted() {
this.getMenuList(); this.getMenuList()
if (Object.keys(this.data).length && this.data.Id) { if (Object.keys(this.data).length && this.data.Id) {
this.form = { ...this.data }; this.form = { ...this.data }
} }
}, },
methods: { methods: {
handleCheckedTreeConnect(value) { handleCheckedTreeConnect(value) {
this.form.menuCheckStrictly = !!value; this.form.menuCheckStrictly = !!value
}, },
getMenuAllCheckedKeys() { getMenuAllCheckedKeys() {
// //
const checkedKeys = this.$refs.menu.getCheckedKeys(); const checkedKeys = this.$refs.menu.getCheckedKeys()
// //
const halfCheckedKeys = this.$refs.menu.getHalfCheckedKeys(); const halfCheckedKeys = this.$refs.menu.getHalfCheckedKeys()
checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys); checkedKeys.unshift.apply(checkedKeys, halfCheckedKeys)
return checkedKeys; return checkedKeys
}, },
handleCheckedTreeExpand(value) { handleCheckedTreeExpand(value) {
const treeList = this.menuOptions; const treeList = this.menuOptions
for (let i = 0; i < treeList.length; i++) { for (let i = 0; i < treeList.length; i++) {
this.$refs.menu.store.nodesMap[treeList[i].MenuId].expanded = value; this.$refs.menu.store.nodesMap[treeList[i].MenuId].expanded = value
} }
}, },
handleCheckedTreeNodeAll(value, type) { handleCheckedTreeNodeAll(value, type) {
this.$refs.menu.setCheckedNodes(value ? this.menuOptions : []); this.$refs.menu.setCheckedNodes(value ? this.menuOptions : [])
}, },
toTree(arr, ParentId) { toTree(arr, ParentId) {
function loop(ParentId) { function loop(ParentId) {
const res = []; const res = []
for (let i = 0; i < arr.length; i++) { for (let i = 0; i < arr.length; i++) {
const item = arr[i]; const item = arr[i]
item.hasChildren = false; item.hasChildren = false
if (item.ParentId !== ParentId) { if (item.ParentId !== ParentId) {
continue; continue
} }
item.Children = loop(item.MenuId); item.Children = loop(item.MenuId)
res.push(item); res.push(item)
} }
return res; return res
} }
return loop(ParentId); return loop(ParentId)
}, },
getMenuList() { getMenuList() {
getMenuList({}) getMenuList({})
.then((res) => { .then((res) => {
const menu = this.toTree( const menu = this.toTree(
res.Result, res.Result,
"00000000-0000-0000-0000-000000000000" '00000000-0000-0000-0000-000000000000'
); )
this.menuOptions = menu; this.menuOptions = menu
console.log(this.menuOptions); console.log(this.menuOptions)
this.$nextTick(() => { this.$nextTick(() => {
this.form.MenuIds.forEach((v) => { this.form.MenuIds.forEach((v) => {
this.$refs.menu.setChecked(v, true, false); this.$refs.menu.setChecked(v, true, false)
}); })
}); })
}) })
.catch(function () {}); .catch(function () {})
}, },
handleSave() { handleSave() {
this.$refs.roleForm.validate((valid) => { this.$refs.roleForm.validate((valid) => {
if (!valid) return; if (!valid) return
this.btnLoading = true; this.btnLoading = true
this.model_cfg.showClose = false; this.model_cfg.showClose = false
this.form.MenuIds = this.getMenuAllCheckedKeys(); this.form.MenuIds = this.getMenuAllCheckedKeys()
console.log(this.form.MenuIds); console.log(this.form.MenuIds)
addOrUpdateUserType(this.form) addOrUpdateUserType(this.form)
.then((res) => { .then((res) => {
this.btnLoading = false; this.btnLoading = false
this.$refs["roleForm"].resetFields(); this.$refs['roleForm'].resetFields()
this.$emit("close"); this.$emit('close')
this.model_cfg.showClose = true; this.model_cfg.showClose = true
this.$message.success("Saved successfully!"); this.$message.success('Saved successfully!')
}) })
.catch(() => { .catch(() => {
this.btnLoading = false; this.btnLoading = false
this.model_cfg.showClose = true; this.model_cfg.showClose = true
}); })
}); })
}, },
}, },
}; }
</script> </script>

View File

@ -21,26 +21,90 @@
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="getList">{{ $t('common:button:search') }}</el-button> <el-button
<el-button v-hasPermi="['system:role:add']" type="primary" icon="el-icon-plus" size="mini" @click="handleAddRole">{{ $t('common:button:add') }}</el-button> type="primary"
icon="el-icon-search"
size="mini"
@click="getList"
>{{ $t('common:button:search') }}</el-button
>
<el-button
v-hasPermi="['system:role:add']"
type="primary"
icon="el-icon-plus"
size="mini"
@click="handleAddRole"
>{{ $t('common:button:add') }}</el-button
>
</el-form-item> </el-form-item>
</el-form> </el-form>
<el-table v-loading="loading" v-adaptive="{bottomOffset:30}" size="small" height="100" :data="list" class="table"> <el-table
v-loading="loading"
v-adaptive="{ bottomOffset: 30 }"
size="small"
height="100"
:data="list"
class="table"
>
<el-table-column type="index" width="50" /> <el-table-column type="index" width="50" />
<el-table-column :label="$t('system:role:table:User Type')" prop="UserTypeName" min-width="220" show-overflow-tooltip /> <el-table-column
<el-table-column :label="$t('system:role:table:Shortname')" prop="UserTypeShortName" min-width="120" show-overflow-tooltip /> :label="$t('system:role:table:User Type')"
<el-table-column :label="$t('system:role:table:Group')" prop="Note" min-width="80" show-overflow-tooltip> prop="UserTypeName"
min-width="220"
show-overflow-tooltip
/>
<el-table-column
:label="$t('system:role:table:Shortname')"
prop="UserTypeShortName"
min-width="120"
show-overflow-tooltip
/>
<el-table-column
:label="$t('system:role:table:Group')"
prop="Note"
min-width="80"
show-overflow-tooltip
>
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.UserTypeGroupList.map(v => {return v.GroupName}).toString() }} {{
scope.row.UserTypeGroupList.map((v) => {
return v.GroupName
}).toString()
}}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('system:role:table:PermissionStr')" prop="PermissionStr" min-width="100" show-overflow-tooltip /> <el-table-column
<el-table-column :label="$t('system:role:table:User Type Enum')" prop="UserTypeEnum" min-width="100" show-overflow-tooltip> :label="$t('system:role:table:PermissionStr')"
prop="PermissionStr"
min-width="100"
show-overflow-tooltip
/>
<el-table-column
:label="$t('system:role:table:User Type Enum')"
prop="UserTypeEnum"
min-width="100"
show-overflow-tooltip
>
<template slot-scope="scope"> <template slot-scope="scope">
{{ $fd('UserType',scope.row.UserTypeEnum) }} {{ $fd('UserType', scope.row.UserTypeEnum) }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column :label="$t('system:role:table:Description')" prop="Description" min-width="220" show-overflow-tooltip /> <el-table-column
:label="$t('system:role:table:IsEnable')"
prop="IsEnable"
min-width="100"
show-overflow-tooltip
>
<template slot-scope="scope">
{{ $fd('IsEnable', scope.row.IsEnable) }}
</template>
</el-table-column>
<el-table-column
:label="$t('system:role:table:Description')"
prop="Description"
min-width="220"
show-overflow-tooltip
/>
<el-table-column :label="$t('common:action:action')" width="280"> <el-table-column :label="$t('common:action:action')" width="280">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
@ -49,14 +113,16 @@
type="text" type="text"
icon="el-icon-edit" icon="el-icon-edit"
@click="handleEditRole(scope.row)" @click="handleEditRole(scope.row)"
>{{ $t('common:button:edit') }}</el-button> >{{ $t('common:button:edit') }}</el-button
>
<el-button <el-button
v-hasPermi="['system:role:delete']" v-hasPermi="['system:role:delete']"
size="mini" size="mini"
type="text" type="text"
icon="el-icon-delete" icon="el-icon-delete"
@click="handleDeleteRole(scope.row)" @click="handleDeleteRole(scope.row)"
>{{ $t('common:button:delete') }}</el-button> >{{ $t('common:button:delete') }}</el-button
>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -87,36 +153,36 @@ export default {
treeData: [], treeData: [],
defaultProps: { defaultProps: {
label: 'MenuName', label: 'MenuName',
children: 'Children' children: 'Children',
}, },
// //
queryParams: { queryParams: {
GroupId: undefined, GroupId: undefined,
SearchFilter: undefined SearchFilter: undefined,
}, },
dialogVisible: false, dialogVisible: false,
editRow: {}, editRow: {},
expandedKeys: [], expandedKeys: [],
treeLoading: false, treeLoading: false,
funcListLoading: false, funcListLoading: false,
funcList: [] funcList: [],
} }
}, },
mounted() { mounted() {
this.getList() this.getList()
}, },
methods: { methods: {
getDictionary() { getDictionary() {},
},
getList() { getList() {
this.loading = true this.loading = true
getUserTypeRoleList(this.queryParams).then((res) => { getUserTypeRoleList(this.queryParams)
this.loading = false .then((res) => {
this.list = res.Result this.loading = false
}).catch(() => { this.list = res.Result
this.loading = false })
}) .catch(() => {
this.loading = false
})
}, },
handleAddRole() { handleAddRole() {
this.editRow = {} this.editRow = {}
@ -139,11 +205,13 @@ export default {
this.$confirm(this.$t('trials:uploadedDicoms:message:deleteMes'), { this.$confirm(this.$t('trials:uploadedDicoms:message:deleteMes'), {
type: 'warning', type: 'warning',
distinguishCancelAndClose: true, distinguishCancelAndClose: true,
}).then(() => { }).then(() => {
deleteUserTypeRole(row.Id).then((res) => { deleteUserTypeRole(row.Id).then((res) => {
if (res.IsSuccess) { if (res.IsSuccess) {
this.list.splice(this.list.findIndex((item) => item.Id === row.Id), 1) this.list.splice(
this.list.findIndex((item) => item.Id === row.Id),
1
)
this.$message.success(this.$t('common:message:deletedSuccessfully')) this.$message.success(this.$t('common:message:deletedSuccessfully'))
} }
}) })
@ -152,8 +220,8 @@ export default {
closeModal() { closeModal() {
this.model_cfg.visible = false this.model_cfg.visible = false
this.getList() this.getList()
} },
} },
} }
</script> </script>
<style lang="scss"> <style lang="scss">
@ -188,7 +256,7 @@ export default {
overflow-y: auto; overflow-y: auto;
border-right: 1px solid #ccc; border-right: 1px solid #ccc;
} }
.selected-row{ .selected-row {
background-color: cadetblue; background-color: cadetblue;
} }
} }