|
@@ -36,14 +36,17 @@
|
|
|
<operate-bar :pageOptList="userOptList" @submitPageOpt="receviceOpt"></operate-bar>
|
|
|
<!-- 角色列表 -->
|
|
|
<dg-table
|
|
|
- ref="userConditionTable"
|
|
|
- :data="persionListData"
|
|
|
+ ref="userTable"
|
|
|
+ :condition="userCondition"
|
|
|
+ :url="userTableUrl"
|
|
|
row-key="id"
|
|
|
- :pagination-total="total"
|
|
|
+ border
|
|
|
@selection-change="handleSelectChange"
|
|
|
+ :before-quest="handleBeforeQuest"
|
|
|
+ lazyLoad
|
|
|
>
|
|
|
- <dg-table-column type="selection" width="50"></dg-table-column>
|
|
|
- <dg-table-column type="index" label="序号" width="70"></dg-table-column>
|
|
|
+ <dg-table-column type="selection" reserve-selection width="50"></dg-table-column>
|
|
|
+ <!-- <dg-table-column type="index" label="序号" width="70"></dg-table-column> -->
|
|
|
<dg-table-column prop="name" align="center" width="120" label="姓名"></dg-table-column>
|
|
|
<dg-table-column prop="idcard" align="center" label="身份证号码"></dg-table-column>
|
|
|
<dg-table-column prop="orgName" align="center" label="单位名称"></dg-table-column>
|
|
@@ -152,7 +155,8 @@ export default {
|
|
|
op: 'like'
|
|
|
}
|
|
|
},
|
|
|
- checkedPersionData: [],
|
|
|
+ userTableUrl: roleAuthApi.userTableUrl,
|
|
|
+ checkUserList: [],
|
|
|
deleteIds: [],
|
|
|
|
|
|
// 点击动作object
|
|
@@ -167,7 +171,8 @@ export default {
|
|
|
},
|
|
|
page: 0,
|
|
|
size: 10,
|
|
|
- total: 0
|
|
|
+ total: 0,
|
|
|
+ updateUsers: []
|
|
|
};
|
|
|
},
|
|
|
// 计算属性
|
|
@@ -194,135 +199,143 @@ export default {
|
|
|
}
|
|
|
this.saveRoleAuthParams.orgId = this.userCondition.orgId.value;
|
|
|
},
|
|
|
+ loadUserTable() {
|
|
|
+ this.selectUserList = [];
|
|
|
+ this.$refs.userTable.searchForm();
|
|
|
+
|
|
|
+ },
|
|
|
receiveUserSearch(val) {
|
|
|
for (const key in val) {
|
|
|
this.userCondition[key].value = val[key].value;
|
|
|
}
|
|
|
this.saveRoleAuthParams.orgId = this.userCondition.orgId.value;
|
|
|
- this.handleUserSearch();
|
|
|
+ if (!this.handleValid()) return;
|
|
|
+ this.loadUserTable();
|
|
|
+
|
|
|
},
|
|
|
- handleRoleRowClick({ id, appId }) {
|
|
|
+ async handleRoleRowClick({ id, appId }) {
|
|
|
this.saveRoleAuthParams.roleId = this.userCondition.roleId.value = id;
|
|
|
this.saveRoleAuthParams.appId = appId;
|
|
|
- // 如果选择机构
|
|
|
- if (this.saveRoleAuthParams.orgId) {
|
|
|
- this.handleUserSearch(); // 人员列表查询
|
|
|
- }
|
|
|
+ await this.getUserChecked();
|
|
|
+ this.loadUserTable();
|
|
|
+ },
|
|
|
+
|
|
|
+ getUserChecked() {
|
|
|
+ return new Promise((resolve) => {
|
|
|
+ const { orgId, roleId, appId } = this.saveRoleAuthParams;
|
|
|
+ // 获取人员列表选中记录
|
|
|
+ const queryCheckedParams = {
|
|
|
+ orgId,
|
|
|
+ roleId,
|
|
|
+ appId,
|
|
|
+ type: 'role'
|
|
|
+ };
|
|
|
+ roleAuthApi.getChecked(queryCheckedParams).then((res) => {
|
|
|
+ this.checkUserList = res;
|
|
|
+ resolve(res);
|
|
|
+ });
|
|
|
+ });
|
|
|
},
|
|
|
handleValid() {
|
|
|
- if (!this.saveRoleAuthParams.appId) {
|
|
|
- this.$message.warning('请先选择应用系统名称');
|
|
|
- return false;
|
|
|
- }
|
|
|
if (!this.saveRoleAuthParams.roleId) {
|
|
|
- this.$message.warning('请选择角色名称');
|
|
|
+ this.$message.warning('请选择角色!');
|
|
|
return false;
|
|
|
}
|
|
|
if (!this.saveRoleAuthParams.orgId) {
|
|
|
- this.$message.warning('请选择单位名称');
|
|
|
+ this.$message.warning('请选择单位名称!');
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
},
|
|
|
+ // 用户列表数据渲染前整合数据
|
|
|
+ handleBeforeQuest(res) {
|
|
|
+ const { content, totalElements } = res.data;
|
|
|
+ let _content = content.map((item) => {
|
|
|
+ return {
|
|
|
+ ...item,
|
|
|
+ activeTime: '长期'
|
|
|
+ };
|
|
|
+ });
|
|
|
+ this.currentPageContent = _content;
|
|
|
+ if (this.checkUserList.length > 0) {
|
|
|
+ let rowKeys = [];
|
|
|
+ for (let j = 0; j < _content.length; j++) {
|
|
|
+ const cItem = _content[j];
|
|
|
+ const index = this.checkUserList.findIndex((item) => item.id == cItem.id);
|
|
|
+ if (index > -1) {
|
|
|
+ _content[j].activeTime = this.checkUserList[index].activeTime;
|
|
|
+ rowKeys.push(this.checkUserList[index].id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ setTimeout(() => {
|
|
|
+ this.$refs.userTable.setCheck(rowKeys);
|
|
|
+ }, 500);
|
|
|
+ }
|
|
|
+ this.Usertotal = totalElements;
|
|
|
|
|
|
- // 人员列表查询
|
|
|
- handleUserSearch() {
|
|
|
- if (!this.handleValid()) return;
|
|
|
- const that = this;
|
|
|
- const { orgId, roleId, appId } = this.saveRoleAuthParams;
|
|
|
- // 获取人员列表选中记录
|
|
|
- const queryCheckedParams = {
|
|
|
- orgId,
|
|
|
- roleId,
|
|
|
- appId,
|
|
|
- type: 'role'
|
|
|
- };
|
|
|
- const userParams = {
|
|
|
- page: this.page,
|
|
|
- size: this.size,
|
|
|
- searchCondition: this.userCondition
|
|
|
- };
|
|
|
-
|
|
|
- that.persionListData = [];
|
|
|
- that.checkedPersionData = [];
|
|
|
- that.deleteIds = [];
|
|
|
- // 人员列表和选中人员
|
|
|
- Promise.all([roleAuthApi.persionListByOrgRole(userParams), roleAuthApi.getChecked(queryCheckedParams)]).then(
|
|
|
- (res) => {
|
|
|
- // console.log(res);
|
|
|
- const { content, totalElements } = res[0].data;
|
|
|
- that.persionListData = content;
|
|
|
- that.total = totalElements;
|
|
|
- that.persionListData.map((item) => {
|
|
|
- that.$set(item, 'activeTime', '长期');
|
|
|
- // item["activeTime"] = "长期"; //列表一开始写死
|
|
|
- });
|
|
|
- let checkeds = res[1];
|
|
|
- that.$nextTick(() => {
|
|
|
- for (let k = 0; k < checkeds.length; k++) {
|
|
|
- for (let m = 0; m < that.persionListData.length; m++) {
|
|
|
- if (that.persionListData[m].id == checkeds[k].staffId) {
|
|
|
- that.$refs.userConditionTable.toggleRowSelection(that.persionListData[m], true);
|
|
|
- that.persionListData[m].activeTime = checkeds[k].activeTime;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
+ const result = {
|
|
|
+ data: {
|
|
|
+ content: _content,
|
|
|
+ totalElements
|
|
|
}
|
|
|
- );
|
|
|
+ };
|
|
|
+ return result;
|
|
|
},
|
|
|
handleSelectChange(selection) {
|
|
|
- this.checkedPersionData = selection;
|
|
|
- this.deleteIds = [];
|
|
|
+ this.selectUserList = this.$lodash.cloneDeep(selection);
|
|
|
},
|
|
|
handleSave() {
|
|
|
if (!this.handleValid()) return;
|
|
|
- const that = this;
|
|
|
- let saveParams = {
|
|
|
- ...that.saveRoleAuthParams
|
|
|
- };
|
|
|
- saveParams.staffJson = JSON.stringify(that.checkedPersionData); // 已勾选
|
|
|
- that.checkedPersionData.forEach((cc) => {
|
|
|
- saveParams.staffList += cc.id + ',';
|
|
|
- });
|
|
|
- saveParams.staffList = saveParams.staffList.substr(0, saveParams.staffList.length - 1); // 已勾选id
|
|
|
+ if (this.Usertotal == 0) {
|
|
|
+ this.$message.warning("没有可保存的数据!");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const { roleId, orgId } = this.saveRoleAuthParams;
|
|
|
|
|
|
- // 未勾选
|
|
|
- if (this.checkedPersionData.length == 0) {
|
|
|
- this.persionListData.forEach((dd) => {
|
|
|
- this.deleteIds.push({
|
|
|
- id: dd.id,
|
|
|
- orgId: dd.orgId
|
|
|
- });
|
|
|
- });
|
|
|
- } else {
|
|
|
- for (let i = 0; i < this.persionListData.length; i++) {
|
|
|
- let flag = true;
|
|
|
- for (let j = 0; j < this.checkedPersionData.length; j++) {
|
|
|
- if (this.persionListData[i].id == this.checkedPersionData[j].id) {
|
|
|
- flag = false;
|
|
|
- break;
|
|
|
+ const delUserIds = this.checkUserList
|
|
|
+ .filter((item) => !this.selectUserList.map((sItem) => sItem.id).includes(item.id))
|
|
|
+ .map((item) => item.id);
|
|
|
+
|
|
|
+ const addUserIds = this.selectUserList
|
|
|
+ .filter((item) => !this.checkUserList.map((cItem) => cItem.id).includes(item.id))
|
|
|
+ .map((item) => item.id);
|
|
|
+
|
|
|
+ // 剔除掉被删除的再过滤出修改过的,与check接口比较
|
|
|
+ const updateUserIncludeDel = this.updateUsers.filter((item) => !delUserIds.includes(item.id));
|
|
|
+
|
|
|
+ const updateUsers = updateUserIncludeDel
|
|
|
+ .filter((item) => {
|
|
|
+ const index = this.selectUserList.findIndex((sItem) => sItem.id == item.id);
|
|
|
+ if (index > -1) {
|
|
|
+ if (item.activeTime !== this.selectUserList[index].activeTime) {
|
|
|
+ return item;
|
|
|
}
|
|
|
}
|
|
|
- if (flag) {
|
|
|
- this.deleteIds.push({
|
|
|
- id: this.persionListData[i].id,
|
|
|
- orgId: this.persionListData[i].orgId
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- saveParams.delStaffJson = JSON.stringify(this.deleteIds);
|
|
|
+ })
|
|
|
+ .map((item) => {
|
|
|
+ return {
|
|
|
+ id: item.id,
|
|
|
+ activeTime: item.activeTime
|
|
|
+ };
|
|
|
+ });
|
|
|
+
|
|
|
+ const saveParams = {
|
|
|
+ roleId,
|
|
|
+ orgId,
|
|
|
+ addUserIds,
|
|
|
+ delUserIds,
|
|
|
+ updateUsers: updateUsers
|
|
|
+ };
|
|
|
+
|
|
|
|
|
|
// 保存
|
|
|
roleAuthApi
|
|
|
.savePersion(saveParams)
|
|
|
.then(() => {
|
|
|
- that.$message.success('保存成功');
|
|
|
+ this.$message.success('保存成功');
|
|
|
})
|
|
|
.catch((err) => {
|
|
|
- that.$message.error(err);
|
|
|
+ this.$message.error(err);
|
|
|
});
|
|
|
},
|
|
|
// 有效期选择
|
|
@@ -337,10 +350,15 @@ export default {
|
|
|
operatorRow: row
|
|
|
},
|
|
|
on: {
|
|
|
- success: function (newRow) {
|
|
|
+ success: function (res) {
|
|
|
layer.closeAll(layer.dialogIndex);
|
|
|
- row.activeTime = newRow;
|
|
|
- // that.handleUserSearch();
|
|
|
+ row.activeTime = res.activeTime;
|
|
|
+ const index = that.updateUsers.findIndex((item) => item.id == res.id);
|
|
|
+ if (index > -1) {
|
|
|
+ that.updateUsers[index] = res;
|
|
|
+ } else {
|
|
|
+ that.updateUsers.push(res);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
});
|