|
@@ -9,19 +9,36 @@
|
|
|
<!-- 搜索 -->
|
|
|
<el-form inline :model="searchForm">
|
|
|
<el-form-item v-if="isSuperAdmin" label="学校">
|
|
|
- <SchoolSelectForRoot
|
|
|
+ <el-select
|
|
|
v-model="searchForm.rootOrgId"
|
|
|
+ placeholder="请选择"
|
|
|
+ :disabled="!isSuperAdmin"
|
|
|
class="input_width"
|
|
|
- @change="() => (searchForm.roleId = '')"
|
|
|
- />
|
|
|
+ filterable
|
|
|
+ @change="rootOrgChanged4Search"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in rootSchoolSelect"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="角色">
|
|
|
- <RoleSelect
|
|
|
+ <el-select
|
|
|
v-model="searchForm.roleId"
|
|
|
- :school-id="searchForm.rootOrgId"
|
|
|
- :enable-super="isSuperAdmin"
|
|
|
+ clearable
|
|
|
+ placeholder="请选择"
|
|
|
class="input_width"
|
|
|
- />
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in roleList4Search"
|
|
|
+ :key="item.roleId"
|
|
|
+ :label="item.roleName"
|
|
|
+ :value="item.roleId"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="登录名">
|
|
|
<el-input
|
|
@@ -74,7 +91,6 @@
|
|
|
</el-button>
|
|
|
|
|
|
<el-button
|
|
|
- v-if="rolePrivileges.user_data_rule_setting"
|
|
|
size="small"
|
|
|
type="primary"
|
|
|
icon="el-icon-plus"
|
|
@@ -101,13 +117,13 @@
|
|
|
type="danger"
|
|
|
icon="el-icon-close"
|
|
|
:disabled="noBatchSelected"
|
|
|
- @click="disableUsers"
|
|
|
+ @click="disableByIds"
|
|
|
>禁用
|
|
|
</el-button>
|
|
|
|
|
|
<div class="block-seperator"></div>
|
|
|
<!-- 添加用户信息弹出框 -->
|
|
|
- <el-dialog title="新增用户" width="520px" :visible.sync="addingDialog">
|
|
|
+ <el-dialog title="新增用户" width="450px" :visible.sync="addingDialog">
|
|
|
<el-form
|
|
|
ref="addingForm"
|
|
|
:inline="true"
|
|
@@ -159,22 +175,41 @@
|
|
|
</el-row>
|
|
|
<el-row>
|
|
|
<el-form-item v-if="isSuperAdmin" label="学校" prop="rootOrgId">
|
|
|
- <SchoolSelectForRoot
|
|
|
+ <el-select
|
|
|
v-model="userForm.rootOrgId"
|
|
|
class="input_width_lg"
|
|
|
- @change="() => (userForm.roleIds = '')"
|
|
|
- />
|
|
|
+ placeholder="请选择"
|
|
|
+ :disabled="!isSuperAdmin"
|
|
|
+ filterable
|
|
|
+ @change="rootOrgChanged4InsertOrUpdate"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in rootSchoolSelect"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
</el-row>
|
|
|
<el-row>
|
|
|
<el-form-item label="角色" prop="roleIds">
|
|
|
- <RoleSelect
|
|
|
+ <el-select
|
|
|
v-model="userForm.roleIds"
|
|
|
- :school-id="userForm.rootOrgId"
|
|
|
- multiple
|
|
|
class="input_width_lg"
|
|
|
- @change="selectRoleChanged"
|
|
|
- />
|
|
|
+ multiple
|
|
|
+ placeholder="请选择"
|
|
|
+ @change="rolesChanged"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in roleList4InsertOrUpdateWithoutSuperAdmin"
|
|
|
+ :key="item.roleId"
|
|
|
+ :label="item.roleName"
|
|
|
+ :value="item.roleId"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
</el-row>
|
|
|
<el-row>
|
|
@@ -216,7 +251,7 @@
|
|
|
</el-dialog>
|
|
|
|
|
|
<!-- 修改用户信息弹出框 -->
|
|
|
- <el-dialog title="编辑用户" width="520px" :visible.sync="updateDialog">
|
|
|
+ <el-dialog title="编辑用户" width="450px" :visible.sync="updateDialog">
|
|
|
<el-form
|
|
|
ref="updateForm"
|
|
|
:inline="true"
|
|
@@ -267,22 +302,41 @@
|
|
|
</el-row>
|
|
|
<el-row>
|
|
|
<el-form-item v-if="isSuperAdmin" label="学校" prop="rootOrgId">
|
|
|
- <SchoolSelectForRoot
|
|
|
+ <el-select
|
|
|
v-model="userForm.rootOrgId"
|
|
|
class="input_width_lg"
|
|
|
- @change="() => (userForm.roleIds = '')"
|
|
|
- />
|
|
|
+ placeholder="请选择"
|
|
|
+ :disabled="true"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in rootSchoolSelect"
|
|
|
+ :key="item.id"
|
|
|
+ :label="item.name"
|
|
|
+ :value="item.id"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
</el-row>
|
|
|
<el-row>
|
|
|
<el-form-item label="角色" prop="roleIds">
|
|
|
- <RoleSelect
|
|
|
+ <el-select
|
|
|
v-model="userForm.roleIds"
|
|
|
- :school-id="userForm.rootOrgId"
|
|
|
- multiple
|
|
|
class="input_width_lg"
|
|
|
- @change="selectRoleChanged"
|
|
|
- />
|
|
|
+ multiple
|
|
|
+ placeholder="请选择"
|
|
|
+ :disabled="rowIsSuperAdmin"
|
|
|
+ @change="rolesChanged"
|
|
|
+ >
|
|
|
+ <el-option
|
|
|
+ v-for="item in roleList4InsertOrUpdate"
|
|
|
+ :key="item.roleId"
|
|
|
+ :label="item.roleName"
|
|
|
+ :disabled="item.roleCode == 'SUPER_ADMIN'"
|
|
|
+ :value="item.roleId"
|
|
|
+ >
|
|
|
+ </el-option>
|
|
|
+ </el-select>
|
|
|
</el-form-item>
|
|
|
</el-row>
|
|
|
<el-row>
|
|
@@ -342,6 +396,7 @@
|
|
|
<el-table-column prop="name" width="120" label="姓名" />
|
|
|
<el-table-column prop="loginName" width="100" label="登录名" />
|
|
|
<el-table-column prop="rootOrgName" label="学校" />
|
|
|
+ <!-- <el-table-column prop="roleNamesStr" width="110" label="角色" /> -->
|
|
|
<el-table-column width="120" label="角色">
|
|
|
<span
|
|
|
slot-scope="scope"
|
|
@@ -396,7 +451,7 @@
|
|
|
size="mini"
|
|
|
type="danger"
|
|
|
icon="el-icon-close"
|
|
|
- @click="disableTheUser(scope.row)"
|
|
|
+ @click="disableById(scope.row)"
|
|
|
>
|
|
|
禁用
|
|
|
</el-button>
|
|
@@ -492,13 +547,22 @@ export default {
|
|
|
callback();
|
|
|
}
|
|
|
};
|
|
|
+ var validateRoles = (rule, value, callback) => {
|
|
|
+ if (value.length == 0) {
|
|
|
+ callback(new Error("请选择角色"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ };
|
|
|
return {
|
|
|
rolePrivileges: {
|
|
|
user_data_rule_setting: false,
|
|
|
},
|
|
|
loading: false,
|
|
|
orgLoading4InsertOrUpdate: false,
|
|
|
+ roleList4Search: [],
|
|
|
roleList4InsertOrUpdate: [],
|
|
|
+ rootOrgList: [],
|
|
|
orgList4InsertOrUpdate: [],
|
|
|
searchForm: {
|
|
|
name: "",
|
|
@@ -553,23 +617,24 @@ export default {
|
|
|
trigger: "blur",
|
|
|
},
|
|
|
],
|
|
|
+ phoneNumber: [
|
|
|
+ // {
|
|
|
+ // message: "请输入联系方式",
|
|
|
+ // trigger: "blur"
|
|
|
+ // }
|
|
|
+ ],
|
|
|
rootOrgId: [
|
|
|
{
|
|
|
validator: validateRootOrg,
|
|
|
trigger: "blur",
|
|
|
},
|
|
|
],
|
|
|
- orgId: [
|
|
|
- {
|
|
|
- required: "", // changed by role
|
|
|
- message: "学习中心用户必须选择子机构",
|
|
|
- },
|
|
|
- ],
|
|
|
+ orgId: [],
|
|
|
roleIds: [
|
|
|
{
|
|
|
required: true,
|
|
|
- message: "请选择角色",
|
|
|
- trigger: "blur",
|
|
|
+ validator: validateRoles,
|
|
|
+ trigger: ["blur", "change"],
|
|
|
},
|
|
|
],
|
|
|
},
|
|
@@ -593,19 +658,24 @@ export default {
|
|
|
noBatchSelected() {
|
|
|
return this.selectedUserIds.length === 0;
|
|
|
},
|
|
|
+ roleList4InsertOrUpdateWithoutSuperAdmin() {
|
|
|
+ return this.roleList4InsertOrUpdate.filter(
|
|
|
+ (item) => item.roleCode != "SUPER_ADMIN"
|
|
|
+ );
|
|
|
+ },
|
|
|
isSuperAdmin() {
|
|
|
return this.user.roleList.some((role) => role.roleCode == "SUPER_ADMIN");
|
|
|
},
|
|
|
- isOrgAdminNotSuperAdmin() {
|
|
|
- return (
|
|
|
- this.user.roleList.some((role) => role.roleCode == "ORG_ADMIN") &&
|
|
|
- !this.user.roleList.some((role) => role.roleCode == "SUPER_ADMIN")
|
|
|
- );
|
|
|
- },
|
|
|
- isSuperAdminOrOrgAdmin() {
|
|
|
- return this.user.roleList.some(
|
|
|
- (role) => role.roleCode == "SUPER_ADMIN" || role.roleCode == "ORG_ADMIN"
|
|
|
- );
|
|
|
+ rootSchoolSelect() {
|
|
|
+ let rootSchools = [];
|
|
|
+ for (let i = 0; i < this.rootOrgList.length; i++) {
|
|
|
+ let info = {
|
|
|
+ name: this.rootOrgList[i].name + "(" + this.rootOrgList[i].id + ")",
|
|
|
+ id: this.rootOrgList[i].id,
|
|
|
+ };
|
|
|
+ rootSchools.push(info);
|
|
|
+ }
|
|
|
+ return rootSchools;
|
|
|
},
|
|
|
},
|
|
|
//初始化查询
|
|
@@ -614,14 +684,6 @@ export default {
|
|
|
this.init();
|
|
|
},
|
|
|
methods: {
|
|
|
- selectRoleChanged(selectRoles, roleList) {
|
|
|
- const isLCUser = selectRoles.includes(
|
|
|
- roleList.filter((v) => v.roleCode === "LC_USER").map((v) => v.roleId)[0]
|
|
|
- );
|
|
|
- this.rules.orgId[0].required = isLCUser;
|
|
|
- this.$refs.addingForm && this.$refs.addingForm.validateField("orgId");
|
|
|
- this.$refs.updateForm && this.$refs.updateForm.validateField("orgId");
|
|
|
- },
|
|
|
resetEcsFormSearch() {
|
|
|
this.searchForm = Object.assign(this.searchForm, {
|
|
|
roleId: "",
|
|
@@ -635,6 +697,71 @@ export default {
|
|
|
this.pageSize = val;
|
|
|
this.search();
|
|
|
},
|
|
|
+ validateOrg(rule, value, callback) {
|
|
|
+ if (0 != value && !value) {
|
|
|
+ callback(new Error("请选择子机构"));
|
|
|
+ } else {
|
|
|
+ callback();
|
|
|
+ }
|
|
|
+ },
|
|
|
+ rolesChanged() {
|
|
|
+ var isLC = false;
|
|
|
+ for (let cur of this.roleList4InsertOrUpdate) {
|
|
|
+ if (
|
|
|
+ cur.roleCode == "LC_USER" &&
|
|
|
+ this.userForm.roleIds.includes(cur.roleId)
|
|
|
+ ) {
|
|
|
+ isLC = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log("rolesChanged(); isLC:", isLC);
|
|
|
+ if (isLC) {
|
|
|
+ this.rules.orgId = [
|
|
|
+ {
|
|
|
+ validator: this.validateOrg,
|
|
|
+ trigger: ["blur", "change"],
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ } else {
|
|
|
+ this.rules.orgId = [];
|
|
|
+ if (this.updateDialog) {
|
|
|
+ this.$refs.updateForm && this.$refs.updateForm.clearValidate("orgId");
|
|
|
+ } else if (this.addingDialog) {
|
|
|
+ this.$refs.addingForm && this.$refs.addingForm.clearValidate("orgId");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (this.updateDialog) {
|
|
|
+ this.$refs.updateForm && this.$refs.updateForm.validateField("orgId");
|
|
|
+ } else if (this.addingDialog) {
|
|
|
+ this.$refs.addingForm && this.$refs.addingForm.validateField("orgId");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ rootOrgChanged4Search() {
|
|
|
+ var url =
|
|
|
+ CORE_API +
|
|
|
+ "/rolePrivilege/getRoles?includeSuperAdmin=" +
|
|
|
+ true +
|
|
|
+ "&rootOrgId=" +
|
|
|
+ this.searchForm.rootOrgId;
|
|
|
+ this.$httpWithMsg.post(url).then((response) => {
|
|
|
+ this.roleList4Search = response.data;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ rootOrgChanged4InsertOrUpdate() {
|
|
|
+ this.orgList4InsertOrUpdate = [];
|
|
|
+
|
|
|
+ var url =
|
|
|
+ CORE_API +
|
|
|
+ "/rolePrivilege/getRoles?includeSuperAdmin=" +
|
|
|
+ true +
|
|
|
+ "&rootOrgId=" +
|
|
|
+ this.userForm.rootOrgId;
|
|
|
+ this.$httpWithMsg.post(url).then((response) => {
|
|
|
+ this.roleList4InsertOrUpdate = response.data;
|
|
|
+ this.rolesChanged();
|
|
|
+ });
|
|
|
+ },
|
|
|
getOrgList4InsertOrUpdate(query) {
|
|
|
this.orgLoading4InsertOrUpdate = true;
|
|
|
var url =
|
|
@@ -654,6 +781,22 @@ export default {
|
|
|
this.orgLoading4InsertOrUpdate = false;
|
|
|
});
|
|
|
},
|
|
|
+ getTag(status) {
|
|
|
+ if (status == true) {
|
|
|
+ return "success";
|
|
|
+ } else if (status == false) {
|
|
|
+ return "danger";
|
|
|
+ }
|
|
|
+ return status;
|
|
|
+ },
|
|
|
+ getLevel(level) {
|
|
|
+ if (level == "ZSB") {
|
|
|
+ return "专升本";
|
|
|
+ } else if (level == "GQZ") {
|
|
|
+ return "高起专";
|
|
|
+ }
|
|
|
+ return level;
|
|
|
+ },
|
|
|
handleSearchBtn() {
|
|
|
this.currentPage = 1;
|
|
|
this.search();
|
|
@@ -666,11 +809,6 @@ export default {
|
|
|
}
|
|
|
}, 500);
|
|
|
var param = new URLSearchParams(this.searchForm);
|
|
|
- if (!this.isSuperAdminOrOrgAdmin)
|
|
|
- param.append("ignoreRoleCodes", "SUPER_ADMIN,ORG_ADMIN");
|
|
|
- else if (this.isOrgAdminNotSuperAdmin) {
|
|
|
- param.append("ignoreRoleCodes", "SUPER_ADMIN");
|
|
|
- }
|
|
|
var url =
|
|
|
CORE_API +
|
|
|
"/user/all/" +
|
|
@@ -704,14 +842,11 @@ export default {
|
|
|
},
|
|
|
//新增
|
|
|
openAddingDialog() {
|
|
|
- this.rules.orgId[0].required = false;
|
|
|
if (this.$refs.addingForm) {
|
|
|
this.$refs.addingForm.resetFields();
|
|
|
- this.$refs.addingForm.clearValidate();
|
|
|
}
|
|
|
if (this.$refs.updateForm) {
|
|
|
this.$refs.updateForm.resetFields();
|
|
|
- this.$refs.updateForm.clearValidate();
|
|
|
}
|
|
|
this.addingDialog = true;
|
|
|
this.userForm.name = "";
|
|
@@ -722,10 +857,10 @@ export default {
|
|
|
this.userForm.orgId = null;
|
|
|
this.enableStr = "true";
|
|
|
this.orgList4InsertOrUpdate = [];
|
|
|
+ this.rolesChanged();
|
|
|
},
|
|
|
//修改
|
|
|
openUpdateDialog(row) {
|
|
|
- this.rules.orgId[0].required = row.roleCodes.includes("LC_USER");
|
|
|
if (this.$refs.updateForm) {
|
|
|
this.$refs.updateForm.resetFields();
|
|
|
}
|
|
@@ -750,9 +885,14 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ this.rootOrgChanged4InsertOrUpdate();
|
|
|
this.orgList4InsertOrUpdate = [{ id: row.orgId, name: row.orgName }];
|
|
|
this.userForm.orgId = row.orgId;
|
|
|
},
|
|
|
+ exportUser() {
|
|
|
+ var param = new URLSearchParams(this.searchForm);
|
|
|
+ window.open(CORE_API + "/user/export?" + param);
|
|
|
+ },
|
|
|
//保存
|
|
|
add() {
|
|
|
var url = CORE_API + "/user";
|
|
@@ -891,27 +1031,38 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
- disableUsers() {
|
|
|
+ //禁用
|
|
|
+ disableByIds() {
|
|
|
if (this.selectedUserIds.length === 0) {
|
|
|
this.$notify({
|
|
|
type: "warning",
|
|
|
message: "请选择要禁用的用户",
|
|
|
});
|
|
|
} else {
|
|
|
- this.disableByIds(this.userIds);
|
|
|
+ this.$confirm("是否禁用这些用户?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "error",
|
|
|
+ }).then(() => {
|
|
|
+ var url = CORE_API + "/user/disable/" + this.userIds;
|
|
|
+ this.$httpWithMsg.put(url, {}).then(() => {
|
|
|
+ this.$notify({
|
|
|
+ type: "success",
|
|
|
+ message: "禁用成功!",
|
|
|
+ });
|
|
|
+ this.search();
|
|
|
+ });
|
|
|
+ });
|
|
|
}
|
|
|
},
|
|
|
- disableTheUser(user) {
|
|
|
- this.disableByIds(user.id);
|
|
|
- },
|
|
|
//禁用
|
|
|
- disableByIds(ids) {
|
|
|
- this.$confirm("是否禁用用户?", "提示", {
|
|
|
+ disableById(row) {
|
|
|
+ this.$confirm("是否禁用该用户?", "提示", {
|
|
|
confirmButtonText: "确定",
|
|
|
cancelButtonText: "取消",
|
|
|
type: "error",
|
|
|
}).then(() => {
|
|
|
- var url = CORE_API + "/user/disable/" + ids;
|
|
|
+ var url = CORE_API + "/user/disable/" + row.id;
|
|
|
this.$httpWithMsg.put(url, {}).then(() => {
|
|
|
this.$notify({
|
|
|
type: "success",
|
|
@@ -926,7 +1077,21 @@ export default {
|
|
|
this.searchForm.rootOrgId = this.user.rootOrgId;
|
|
|
this.userForm.rootOrgId = this.user.rootOrgId;
|
|
|
|
|
|
- this.search();
|
|
|
+ var url1 = CORE_API + "/org/getRootOrgList";
|
|
|
+ var url2 =
|
|
|
+ CORE_API +
|
|
|
+ "/rolePrivilege/getRoles?includeSuperAdmin=true&rootOrgId=" +
|
|
|
+ this.user.rootOrgId;
|
|
|
+
|
|
|
+ Promise.all([
|
|
|
+ this.$httpWithMsg.get(url1),
|
|
|
+ this.$httpWithMsg.post(url2),
|
|
|
+ ]).then(([resp1, resp2]) => {
|
|
|
+ this.rootOrgList = resp1.data;
|
|
|
+ this.roleList4Search = resp2.data;
|
|
|
+ this.roleList4InsertOrUpdate = resp2.data;
|
|
|
+ this.search();
|
|
|
+ });
|
|
|
},
|
|
|
initPrivileges() {
|
|
|
let params = new URLSearchParams();
|
|
@@ -944,24 +1109,26 @@ export default {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
- const isSuperOrOrgAdmin = row.roleCodes.includes((v) =>
|
|
|
- ["SUPER_ADMIN", "ORG_ADMIN"].includes(v)
|
|
|
- );
|
|
|
+ let roleCodes = row.roleCodes;
|
|
|
+ // console.log(JSON.stringify(roleCodes));
|
|
|
|
|
|
- return !isSuperOrOrgAdmin;
|
|
|
+ for (let n = 0; n < roleCodes.length; n++) {
|
|
|
+ let roleCode = roleCodes[n];
|
|
|
+ if (roleCode == "SUPER_ADMIN" || roleCode == "ORG_ADMIN") {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
},
|
|
|
copyPrevillegeDialog() {
|
|
|
const refIds = this.$refs.table.selection;
|
|
|
- if (refIds.length === 0 || refIds.length > 1) {
|
|
|
+ if (refIds.length === 0 || refIds > 1) {
|
|
|
this.$notify({ type: "warning", message: "请先选择一行" });
|
|
|
return;
|
|
|
}
|
|
|
this.selectedUserToCopy = refIds[0];
|
|
|
- if (this.showUserDataRuleSetting(this.selectedUserToCopy)) {
|
|
|
- this.$refs.copyPrevillegeDialog.openDialog();
|
|
|
- } else {
|
|
|
- this.$notify({ type: "warning", message: "当前行无权限复制" });
|
|
|
- }
|
|
|
+ this.$refs.copyPrevillegeDialog.openDialog();
|
|
|
},
|
|
|
},
|
|
|
};
|