|
|
@ -43,6 +43,49 @@
|
|
|
|
<el-form-item label="备注" prop="remark">
|
|
|
|
<el-form-item label="备注" prop="remark">
|
|
|
|
<el-input v-model="form.remark" type="textarea" />
|
|
|
|
<el-input v-model="form.remark" type="textarea" />
|
|
|
|
</el-form-item>
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
<el-form-item label="账号角色" prop="roleIds">
|
|
|
|
|
|
|
|
<div class="role-list">
|
|
|
|
|
|
|
|
<div v-for="(item, index) in opts.system" :key="index" class="system">
|
|
|
|
|
|
|
|
<h3 class="system-header">
|
|
|
|
|
|
|
|
{{ item.systemName }}
|
|
|
|
|
|
|
|
</h3>
|
|
|
|
|
|
|
|
<div class="flex">
|
|
|
|
|
|
|
|
<el-tag
|
|
|
|
|
|
|
|
v-for="(role, j) in handleSystemRole(item.id)"
|
|
|
|
|
|
|
|
:key="index + '' + j"
|
|
|
|
|
|
|
|
closable
|
|
|
|
|
|
|
|
size="large"
|
|
|
|
|
|
|
|
@close="handleDelRole(role.id)"
|
|
|
|
|
|
|
|
>
|
|
|
|
|
|
|
|
{{ role.roleName }}
|
|
|
|
|
|
|
|
</el-tag>
|
|
|
|
|
|
|
|
<el-button @click="handleAddRole(item.id)">添加角色</el-button>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<el-dialog v-model="roleVisible" title="添加角色">
|
|
|
|
|
|
|
|
<el-form v-loading="loading2">
|
|
|
|
|
|
|
|
<el-form-item>
|
|
|
|
|
|
|
|
<el-select
|
|
|
|
|
|
|
|
v-model="checkedRole"
|
|
|
|
|
|
|
|
:config="{
|
|
|
|
|
|
|
|
label: 'roleName',
|
|
|
|
|
|
|
|
value: 'id',
|
|
|
|
|
|
|
|
disabled: (item) =>
|
|
|
|
|
|
|
|
handleSystemRole(currentSystemId).findIndex((role) => role.id === item.id) !==
|
|
|
|
|
|
|
|
-1,
|
|
|
|
|
|
|
|
}"
|
|
|
|
|
|
|
|
multiple
|
|
|
|
|
|
|
|
:opts="systemRoleList"
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
|
|
|
|
</el-form>
|
|
|
|
|
|
|
|
<template #footer>
|
|
|
|
|
|
|
|
<el-button @click="roleVisible = false">取消</el-button>
|
|
|
|
|
|
|
|
<el-button :loading="loading2" type="primary" @click="handleSaveRole">确定</el-button>
|
|
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
</el-dialog>
|
|
|
|
|
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</el-form>
|
|
|
|
<div class="form-footer">
|
|
|
|
<div class="form-footer">
|
|
|
|
<el-button @click="handleCancel">取消</el-button>
|
|
|
|
<el-button @click="handleCancel">取消</el-button>
|
|
|
@ -71,13 +114,17 @@
|
|
|
|
phone: '',
|
|
|
|
phone: '',
|
|
|
|
remark: '',
|
|
|
|
remark: '',
|
|
|
|
userName: '',
|
|
|
|
userName: '',
|
|
|
|
|
|
|
|
roleIds: [],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
const permissionList = reactive([]);
|
|
|
|
|
|
|
|
const handleSystemRole = (systemId) => permissionList.filter((item) => item.systemId === systemId);
|
|
|
|
const rules = reactive({
|
|
|
|
const rules = reactive({
|
|
|
|
departmentId: [{ required: unref(computed(() => !form.id)), message: '所在组织不能为空' }],
|
|
|
|
departmentId: [{ required: unref(computed(() => !form.id)), message: '所在组织不能为空' }],
|
|
|
|
userName: [{ required: true, message: '用户名不能为空' }],
|
|
|
|
userName: [{ required: true, message: '用户名不能为空' }],
|
|
|
|
phone: [{ required: true, message: '手机号码不能为空' }],
|
|
|
|
phone: [{ required: true, message: '手机号码不能为空' }],
|
|
|
|
email: [{ required: true, message: '邮箱地址不能为空' }],
|
|
|
|
email: [{ required: true, message: '邮箱地址不能为空' }],
|
|
|
|
employeeName: [{ required: true, message: '员工姓名不能为空' }],
|
|
|
|
employeeName: [{ required: true, message: '员工姓名不能为空' }],
|
|
|
|
|
|
|
|
roleIds: [{ required: true, message: '账号角色不能为空' }],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
const opts = computed(() => store.state.employee.opts);
|
|
|
|
const opts = computed(() => store.state.employee.opts);
|
|
|
|
if (!unref(opts).init) {
|
|
|
|
if (!unref(opts).init) {
|
|
|
@ -91,6 +138,9 @@
|
|
|
|
let res = await store.dispatch('employee/detail', id);
|
|
|
|
let res = await store.dispatch('employee/detail', id);
|
|
|
|
Object.assign(form, res);
|
|
|
|
Object.assign(form, res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
permissionList.splice(0);
|
|
|
|
|
|
|
|
permissionList.push(...(await store.dispatch('employee/permission', id)));
|
|
|
|
|
|
|
|
form.roleIds = permissionList.map((item) => item.id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
onActivated(handleLoad);
|
|
|
|
onActivated(handleLoad);
|
|
|
@ -125,6 +175,50 @@
|
|
|
|
const handleClose = () => {
|
|
|
|
const handleClose = () => {
|
|
|
|
router.push({ name: 'EmployeeManagement' });
|
|
|
|
router.push({ name: 'EmployeeManagement' });
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
const loading2 = ref(false);
|
|
|
|
|
|
|
|
const roleVisible = ref(false);
|
|
|
|
|
|
|
|
const currentSystemId = ref(null);
|
|
|
|
|
|
|
|
const checkedRole = ref([]);
|
|
|
|
|
|
|
|
const systemRoleList = ref([]);
|
|
|
|
|
|
|
|
const handleAddRole = async (id) => {
|
|
|
|
|
|
|
|
loading2.value = true;
|
|
|
|
|
|
|
|
currentSystemId.value = id;
|
|
|
|
|
|
|
|
checkedRole.value = [];
|
|
|
|
|
|
|
|
roleVisible.value = true;
|
|
|
|
|
|
|
|
systemRoleList.value = await store.dispatch('deptRole/role', id);
|
|
|
|
|
|
|
|
loading2.value = false;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleDelRole = (id) => {
|
|
|
|
|
|
|
|
form.roleIds.splice(form.roleIds.findIndex(id), 1);
|
|
|
|
|
|
|
|
permissionList.splice(
|
|
|
|
|
|
|
|
permissionList.findIndex((item) => item.id === id),
|
|
|
|
|
|
|
|
1
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleSaveRole = async () => {
|
|
|
|
|
|
|
|
form.roleIds.push(...unref(checkedRole));
|
|
|
|
|
|
|
|
permissionList.push(...unref(systemRoleList).filter((item) => unref(checkedRole).indexOf(item.id) !== -1));
|
|
|
|
|
|
|
|
roleVisible.value = false;
|
|
|
|
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<style lang="less" scoped></style>
|
|
|
|
<style lang="less" scoped>
|
|
|
|
|
|
|
|
.role-list {
|
|
|
|
|
|
|
|
.system {
|
|
|
|
|
|
|
|
& + .system {
|
|
|
|
|
|
|
|
margin-top: @layout-space;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.system-header {
|
|
|
|
|
|
|
|
margin-bottom: @layout-space;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.flex {
|
|
|
|
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
align-items: center;
|
|
|
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.el-tag {
|
|
|
|
|
|
|
|
margin: @layout-space-small @layout-space @layout-space-small 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
</style>
|
|
|
|