|
|
@@ -177,7 +177,7 @@
|
|
|
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
|
|
|
</el-row>
|
|
|
|
|
|
- <el-table height="500" border v-loading="loading" :data="userList" @selection-change="handleSelectionChange">
|
|
|
+ <el-table ref="userTable" height="500" border v-loading="loading" :data="userList" @selection-change="handleSelectionChange" @select="handleSelect" @select-all="handleSelectAll">
|
|
|
<el-table-column type="selection" width="55" align="center" />
|
|
|
<el-table-column label="ID" align="center" prop="userId" />
|
|
|
<el-table-column label="项目" align="center" prop="projectId">
|
|
|
@@ -555,6 +555,7 @@ export default {
|
|
|
companyOptions: [],
|
|
|
projectOptions: [],
|
|
|
selectedUser: [],
|
|
|
+ restoring: false,
|
|
|
// 转移导入
|
|
|
transferUploadDialog: {
|
|
|
visible: false,
|
|
|
@@ -643,9 +644,28 @@ export default {
|
|
|
getList() {
|
|
|
this.loading = true;
|
|
|
listUserByProject(this.queryParams).then(response => {
|
|
|
- this.userList = response.rows;
|
|
|
+ this.restoring = true;
|
|
|
+ this.userList = (response.rows || []).map(row => {
|
|
|
+ row._rowKey = row.userId + '_' + (row.projectId || 0);
|
|
|
+ return row;
|
|
|
+ });
|
|
|
this.total = response.total;
|
|
|
this.loading = false;
|
|
|
+ this.$nextTick(() => {
|
|
|
+ const table = this.$refs.userTable;
|
|
|
+ if (table) {
|
|
|
+ this.userList.forEach(row => {
|
|
|
+ if (this.ids.includes(row._rowKey)) {
|
|
|
+ table.toggleRowSelection(row, true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.$nextTick(() => {
|
|
|
+ this.restoring = false;
|
|
|
+ });
|
|
|
+ });
|
|
|
+ }).catch(() => {
|
|
|
+ this.loading = false;
|
|
|
});
|
|
|
},
|
|
|
// 取消按钮
|
|
|
@@ -691,6 +711,8 @@ export default {
|
|
|
/** 搜索按钮操作 */
|
|
|
handleQuery() {
|
|
|
this.queryParams.pageNum = 1;
|
|
|
+ this.ids = [];
|
|
|
+ this.selectedUser = [];
|
|
|
this.getList();
|
|
|
},
|
|
|
/** 重置按钮操作 */
|
|
|
@@ -702,6 +724,8 @@ export default {
|
|
|
this.companyQueryUserOptions = null;
|
|
|
this.queryParams.startCreateTime = null
|
|
|
this.queryParams.endCreateTime = null
|
|
|
+ this.ids = [];
|
|
|
+ this.selectedUser = [];
|
|
|
this.handleQuery();
|
|
|
},
|
|
|
/** 处理日期范围变化 */
|
|
|
@@ -716,10 +740,35 @@ export default {
|
|
|
},
|
|
|
// 多选框选中数据
|
|
|
handleSelectionChange(selection) {
|
|
|
- this.ids = selection.map(item => item.userId)
|
|
|
- this.selectedUser = selection.map(item => {return {userId: item.userId, projectId: item.projectId}})
|
|
|
- this.single = selection.length!==1
|
|
|
- this.multiple = !selection.length
|
|
|
+ this.single = selection.length !== 1;
|
|
|
+ this.multiple = !selection.length;
|
|
|
+ },
|
|
|
+ // 单行选中(跨页累积)
|
|
|
+ handleSelect(selection) {
|
|
|
+ if (this.restoring) return;
|
|
|
+ this.updateSelection(selection);
|
|
|
+ },
|
|
|
+ // 全选当前页(跨页累积)
|
|
|
+ handleSelectAll(selection) {
|
|
|
+ if (this.restoring) return;
|
|
|
+ this.updateSelection(selection);
|
|
|
+ },
|
|
|
+ // 更新跨页选中数据
|
|
|
+ updateSelection(selection) {
|
|
|
+ const pageKeys = this.userList.map(row => row._rowKey);
|
|
|
+ const otherIds = this.ids.filter(id => !pageKeys.includes(id));
|
|
|
+ const curIds = selection.map(item => item._rowKey);
|
|
|
+ this.ids = [...otherIds, ...curIds];
|
|
|
+
|
|
|
+ const curUsers = selection.map(item => ({userId: item.userId, projectId: item.projectId}));
|
|
|
+ const otherUsers = this.selectedUser.filter(u => {
|
|
|
+ const key = u.userId + '_' + (u.projectId || 0);
|
|
|
+ return !pageKeys.includes(key);
|
|
|
+ });
|
|
|
+ this.selectedUser = [...otherUsers, ...curUsers];
|
|
|
+
|
|
|
+ this.single = this.ids.length !== 1;
|
|
|
+ this.multiple = !this.ids.length;
|
|
|
},
|
|
|
/** 新增按钮操作 */
|
|
|
handleAdd() {
|