-
-
{{ item.name }}
-
{{ '(' + item.count + `)` }}
-
+
+
+
+ {{ item.name }}
+
+ {{
+ '(' + item.count + `)`
+ }}
+
+
+
- {{ item.username }}({{ item.name }})
+ {{ item.username }}({{ item.name }})
-
+
+
@@ -242,7 +335,7 @@
-
-
+
{{ $t(`m.common['全员']`) }}
- {{ $t(`m.common['下一步']`) }}
+ {{
+ $t(`m.common['下一步']`)
+ }}
{{ $t(`m.common['上一步']`) }}
- {{ $t(`m.common['确定']`) }}
+ {{ $t(`m.common['确定']`) }}
- {{ $t(`m.common['确定']`) }}
+ {{ $t(`m.common['确定']`) }}
-
{{ $t(`m.common['取消']`) }}
+
{{
+ $t(`m.common['取消']`)
+ }}
@@ -286,7 +394,7 @@
// 去除()以及之间的字符
const getUsername = (str) => {
const array = str.split('');
- const index = array.findIndex(item => item === '(');
+ const index = array.findIndex((item) => item === '(');
if (index !== -1) {
return array.splice(0, index).join('');
}
@@ -416,7 +524,18 @@
text: '',
tip: '',
tipType: ''
- }
+ },
+ emptyTableData: {
+ type: 'empty',
+ text: '请先从左侧输入并解析',
+ tip: '',
+ tipType: ''
+ },
+ tableKeyWord: '',
+ manualTableList: [],
+ manualTableListStorage: [],
+ hasSelectedManualDepartments: [],
+ hasSelectedManualUsers: []
};
},
computed: {
@@ -437,8 +556,12 @@
return !this.treeLoading && this.isShowTooMuch;
},
isSearchResultEmpty () {
- return this.searchedDepartment.length < 1
- && this.searchedUsers.length < 1 && !this.treeLoading && !this.isShowTooMuch;
+ return (
+ this.searchedDepartment.length < 1
+ && this.searchedUsers.length < 1
+ && !this.treeLoading
+ && !this.isShowTooMuch
+ );
},
isShowSelectedText () {
return this.hasSelectedDepartments.length > 0 || this.hasSelectedUsers.length > 0;
@@ -462,7 +585,8 @@
if (this.showExpiredAt) {
if (this.isPrev) {
return {
- height: this.curLanguageIsCn ? '383px' : '400px'
+ // height: this.curLanguageIsCn ? '383px' : '400px'
+ height: this.curLanguageIsCn ? '510px' : '527px'
};
}
return {
@@ -470,7 +594,8 @@
};
}
return {
- height: '383px'
+ // height: '383px'
+ height: '510px'
};
},
isOrganization () {
@@ -481,7 +606,7 @@
return false;
}
const MAX_LEN = 100;
- return this.manualValue.split(';').filter(item => item !== '').length > MAX_LEN;
+ return this.manualValue.split(';').filter((item) => item !== '').length > MAX_LEN;
},
isManualDisabled () {
return this.manualValue === '' || this.isManualInputOverLimit;
@@ -518,6 +643,11 @@
};
return typeMap[type] ? typeMap[type]() : typeMap['user']();
};
+ },
+ formatUserName () {
+ return (payload) => {
+ return ['depart', 'department'].includes(payload.type) ? payload.name : `${payload.username}(${payload.name})`;
+ };
}
},
watch: {
@@ -568,6 +698,11 @@
}
},
methods: {
+ getDefaultSelect () {
+ const list = [...this.hasSelectedManualDepartments, this.hasSelectedManualUsers];
+ return list.length > 0;
+ },
+
fetchInitData () {
if (this.showExpiredAt) {
if (this.isBatch) {
@@ -585,6 +720,23 @@
}
},
+ fetchManualTableData () {
+ this.$nextTick(() => {
+ this.manualTableList.forEach((item) => {
+ if (this.$refs.manualTableRef) {
+ const hasSelectedUsers = [...this.hasSelectedUsers, ...this.hasSelectedManualUsers].map((v) => `${v.username}${v.name}`);
+ const hasSelectedDepartments = [...this.hasSelectedDepartments, ...this.hasSelectedManualDepartments]
+ .map((v) => String(v.id));
+ this.$refs.manualTableRef.toggleRowSelection(
+ item,
+ (hasSelectedUsers.includes(`${item.username}${item.name}`))
+ || (['depart', 'department'].includes(item.type) && hasSelectedDepartments.includes(String(item.id)))
+ );
+ }
+ });
+ });
+ },
+
handleSearchInput () {
this.isSearchFocus = true;
},
@@ -608,24 +760,28 @@
handleTabChange ({ name }) {
this.tabActive = name;
// 已选择的需要从输入框中去掉
- if (this.tabActive === 'manual'
- && (this.hasSelectedUsers.length > 0
- || this.hasSelectedDepartments.length > 0)
- && this.manualValue !== '') {
+ if (
+ this.tabActive === 'manual'
+ && (this.hasSelectedUsers.length > 0 || this.hasSelectedDepartments.length > 0)
+ && this.manualValue !== ''
+ ) {
this.fetchRegOrgData();
const templateArr = [];
- const usernameList = this.hasSelectedUsers.map(item => item.username);
- const manualValueBackup = this.filterUserList.filter(item => item !== '');
- manualValueBackup.forEach(item => {
+ const usernameList = this.hasSelectedUsers.map((item) => item.username);
+ const manualValueBackup = this.filterUserList.filter((item) => item !== '');
+ manualValueBackup.forEach((item) => {
const name = getUsername(item);
if (!usernameList.includes(name)) {
templateArr.push(item);
}
});
// 处理切换tab后按原有的格式回显
- const hasSelectedData = this.manualValueActual.split(';').filter(item => templateArr.includes(item) || this.filterDepartList.includes(item));
+ const hasSelectedData = this.manualValueActual
+ .split(';')
+ .filter((item) => templateArr.includes(item) || this.filterDepartList.includes(item));
this.manualValue = hasSelectedData.join('\n');
}
+ this.fetchManualTableData();
},
handleManualInput (value) {
@@ -633,15 +789,16 @@
this.manualUserList = [];
if (value) {
const inputValue = _.cloneDeep(value.split()[0]);
- if (inputValue.indexOf('{') > -1
+ if (
+ inputValue.indexOf('{') > -1
&& inputValue.indexOf('}') > -1
- && (inputValue.includes('&type=department')
- || inputValue.includes('&type=user'))) {
+ && (inputValue.includes('&type=department') || inputValue.includes('&type=user'))
+ ) {
this.$nextTick(() => {
this.manualValue = '';
this.$refs.manualInputRef.curValue = '';
});
- const splitValue = value.split(/\n/).map(item => {
+ const splitValue = value.split(/\n/).map((item) => {
const str = item.slice(item.indexOf('{') + 1, item.indexOf('}'));
if (item.indexOf('{') > -1 && item.indexOf('}') > -1) {
if (item.includes('&type=user')) {
@@ -667,8 +824,8 @@
},
fetchRegOrgData () {
- const manualList = this.manualValueActual.split(';').filter(item => item !== '');
- this.filterDepartList = manualList.filter(item => {
+ const manualList = this.manualValueActual.split(';').filter((item) => item !== '');
+ this.filterDepartList = manualList.filter((item) => {
if (item.indexOf('{') > -1 && item.indexOf('}') > -1) {
const str = item.slice(item.indexOf('{') + 1, item.indexOf('}'));
if (/^[+-]?\d*(\.\d*)?(e[+-]?\d+)?$/.test(str)) {
@@ -676,7 +833,97 @@
}
}
});
- this.filterUserList = manualList.filter(item => !this.filterDepartList.includes(item));
+ this.filterUserList = manualList.filter((item) => !this.filterDepartList.includes(item));
+ },
+
+ handleClearManualUser () {
+ this.manualValue = '';
+ this.manualInputError = false;
+ },
+
+ async handleSearchOrgAndUser () {
+ let manualInputValue = _.cloneDeep(this.manualValue.split(/;|\n|\s/));
+ manualInputValue = manualInputValue.filter((item) => item !== '');
+ for (let i = 0; i < manualInputValue.length; i++) {
+ const params = {
+ keyword: manualInputValue[i],
+ is_exact: false
+ };
+ try {
+ const { data } = await this.$store.dispatch('organization/getSearchOrganizations', params);
+ const { users, departments } = data;
+ if (users && users.length) {
+ users.forEach((item) => {
+ item.type = 'user';
+ });
+ const result = await this.fetchSubjectScopeCheck(users, 'user');
+ if (result && result.length) {
+ const hasSelectedUsers = [...this.hasSelectedUsers, ...this.hasSelectedManualUsers];
+ const userTemp = result.filter((item) => {
+ return !hasSelectedUsers.map((subItem) =>
+ `${subItem.username}&${subItem.name}`).includes(`${item.username}&${item.name}`);
+ });
+ this.hasSelectedUsers.push(...userTemp);
+ this.hasSelectedManualUsers.push(...userTemp);
+ // 保存原有格式
+ let formatStr = _.cloneDeep(this.manualValue);
+ const usernameList = result.map((item) => item.username);
+ usernameList.forEach((item) => {
+ // 处理既有部门又有用户且不连续相同类型的展示数据
+ formatStr = formatStr
+ .replace(this.evil('/' + item + '(;\\n|\\s\\n|)/'), '')
+ .replace(/(\s*\r?\n\s*)+/g, '\n')
+ .replace(';;', '');
+ // 处理复制全部用户不相连的两个不在授权范围内的用户存在空字符
+ formatStr = formatStr
+ .split(/;|\n|\s/)
+ .filter((item) => item !== '' && item !== manualInputValue[i])
+ .join('\n');
+ });
+ // 处理只选择全部符合条件的用户,还存在特殊符号的情况
+ if (formatStr === '\n' || formatStr === '\s' || formatStr === ';') {
+ formatStr = '';
+ }
+ this.manualValue = _.cloneDeep(formatStr);
+ this.manualInputError = !!this.manualValue.length;
+ } else {
+ this.manualInputError = true;
+ }
+ }
+ if (departments && departments.length) {
+ departments.forEach((item) => {
+ item.type = 'depart';
+ });
+ const result = await this.fetchSubjectScopeCheck(departments, 'depart');
+ if (result && result.length) {
+ const hasSelectedDepartments = [...this.hasSelectedDepartments, ...this.hasSelectedManualDepartments];
+ const departTemp = result.filter((item) => {
+ return !hasSelectedDepartments.map((subItem) =>
+ subItem.id.toString()).includes(item.id.toString());
+ });
+ this.hasSelectedManualDepartments.push(...departTemp);
+ this.hasSelectedDepartments.push(...departTemp);
+ // 备份一份粘贴板里的内容,清除组织的数据,在过滤掉组织的数据
+ let clipboardValue = _.cloneDeep(this.manualValue);
+ // 处理不相连的数据之间存在特殊符号的情况
+ clipboardValue = clipboardValue
+ .split(/;|\n|\s/)
+ .filter((item) => item !== '' && item !== manualInputValue[i])
+ .join('\n');
+ this.manualValue = _.cloneDeep(clipboardValue);
+ this.manualInputError = !!this.manualValue.length;
+ } else {
+ this.manualInputError = true;
+ }
+ }
+ } catch (e) {
+ console.error(e);
+ this.messageAdvancedError(e);
+ }
+ }
+ if (!this.manualValue) {
+ this.manualInputError = false;
+ }
},
async handleAddManualUser () {
@@ -685,19 +932,19 @@
try {
const url = this.isRatingManager ? 'role/queryRolesUsers' : 'organization/verifyManualUser';
const res = await this.$store.dispatch(url, {
- usernames: this.filterUserList.map(item => {
+ usernames: this.filterUserList.map((item) => {
return getUsername(item);
})
});
- const temps = res.data.filter(
- item => {
- this.$set(item, 'full_name', item.departments && item.departments.length ? item.departments.join(';') : '');
- return !this.hasSelectedUsers.map(subItem => subItem.username).includes(item.username);
- }
- );
+ const temps = res.data.filter((item) => {
+ this.$set(item, 'type', 'user');
+ this.$set(item, 'full_name', item.departments && item.departments.length ? item.departments.join(';') : '');
+ return !this.hasSelectedUsers.map((subItem) => subItem.username).includes(item.username);
+ });
this.hasSelectedUsers.push(...temps);
+ this.hasSelectedManualUsers.push(...temps);
if (res.data.length) {
- this.usernameList = res.data.map(item => item.username);
+ this.usernameList = res.data.map((item) => item.username);
// 分号拼接
// const templateArr = [];
// this.manualValueBackup = this.manualValueActual.split(';').filter(item => item !== '');
@@ -711,18 +958,22 @@
// 保存原有格式
let formatStr = _.cloneDeep(this.manualValue);
- this.usernameList.forEach(item => {
+ this.usernameList.forEach((item) => {
// 去掉之前有查全局的写法, 如果username有多个重复的item, 比如shengjieliu03@shengjietest.com、shengjieliu05的时候/g就会有问题
// formatStr = formatStr.replace(this.evil('/' + item + '(;\\n|\\s\\n|)/g'), '');
// 处理既有部门又有用户且不连续相同类型的展示数据
formatStr = formatStr
.replace(this.evil('/' + item + '(;\\n|\\s\\n|)/'), '')
- .replace('\n\n', '\n')
- .replace('\s\s', '\s')
+ // .replace('\n\n', '\n')
+ // .replace('\s\s', '\s')
+ .replace(/(\s*\r?\n\s*)+/g, '\n')
.replace(';;', '');
// 处理复制全部用户不相连的两个不在授权范围内的用户存在空字符
- formatStr = formatStr.split(/;|\n|\s/).filter(item => item !== '').join('\n');
+ formatStr = formatStr
+ .split(/;|\n|\s/)
+ .filter((item) => item !== '')
+ .join('\n');
});
// 处理只选择全部符合条件的用户,还存在特殊符号的情况
if (formatStr === '\n' || formatStr === '\s' || formatStr === ';') {
@@ -735,13 +986,7 @@
}
} catch (e) {
console.error(e);
- const { response } = e;
- // 处理如果是前端校验为空导致的报错,使用前端自定义提示
- if (response && [400].includes(response.status)) {
- this.messageWarn(this.$t(`m.verify['用户名输入格式错误']`), 3000);
- } else {
- this.messageAdvancedError(e);
- }
+ this.messageAdvancedError(e);
} finally {
this.manualAddLoading = false;
}
@@ -752,7 +997,7 @@
if (this.manualValue) {
// 校验查验失败的数据是不是属于部门
const departData = _.cloneDeep(this.manualValue.split(/;|\n|\s/));
- const departGroups = this.filterDepartList.filter(item => departData.includes(item));
+ const departGroups = this.filterDepartList.filter((item) => departData.includes(item));
if (departGroups.length && this.getGroupAttributes) {
if (this.getGroupAttributes().source_from_role) {
this.messageWarn(this.$t(`m.common['管理员组不能添加部门']`), 3000);
@@ -760,7 +1005,7 @@
return;
}
// 重新组装粘贴的部门数据
- const list = this.manualOrgList.map(item => {
+ const list = this.manualOrgList.map((item) => {
return {
id: Number(item.slice(item.indexOf('{') + 1, item.indexOf('}'))),
name: item.slice(item.indexOf('}') + 1, item.indexOf('&') > -1 ? item.indexOf('&') : item.length),
@@ -772,21 +1017,32 @@
});
const result = await this.fetchSubjectScopeCheck(list);
if (result && result.length) {
- const departTemp = result.filter(item => {
- return !this.hasSelectedDepartments.map(subItem => subItem.id.toString()).includes(item.id.toString());
+ const hasSelectedDepartments = [...this.hasSelectedDepartments, ...this.hasSelectedManualDepartments];
+ const departTemp = result.filter((item) => {
+ return !hasSelectedDepartments.map((subItem) =>
+ subItem.id.toString()).includes(item.id.toString());
});
+ this.hasSelectedManualDepartments.push(...departTemp);
this.hasSelectedDepartments.push(...departTemp);
// 备份一份粘贴板里的内容,清除组织的数据,在过滤掉组织的数据
let clipboardValue = _.cloneDeep(this.manualValue);
- this.manualOrgList.forEach(item => {
- const displayValue = item.slice(item.indexOf('{'), item.indexOf('&') > -1 ? item.indexOf('&') : item.length);
- const isScopeOrg = result.map(depart => String(depart.id)).includes(item.slice(item.indexOf('{') + 1, item.indexOf('}')));
+ this.manualOrgList.forEach((item) => {
+ const displayValue = item.slice(
+ item.indexOf('{'),
+ item.indexOf('&') > -1 ? item.indexOf('&') : item.length
+ );
+ const isScopeOrg = result
+ .map((depart) => String(depart.id))
+ .includes(item.slice(item.indexOf('{') + 1, item.indexOf('}')));
if (clipboardValue.split(/;|\n|\s/).includes(displayValue) && isScopeOrg) {
clipboardValue = clipboardValue.replace(displayValue, '');
}
});
// 处理不相连的数据之间存在特殊符号的情况
- clipboardValue = clipboardValue.split(/;|\n|\s/).filter(item => item !== '').join('\n');
+ clipboardValue = clipboardValue
+ .split(/;|\n|\s/)
+ .filter((item) => item !== '')
+ .join('\n');
this.manualValue = _.cloneDeep(clipboardValue);
this.manualInputError = !!this.manualValue.length;
} else {
@@ -796,11 +1052,18 @@
this.manualInputError = true;
}
}
+
+ if (this.manualInputError) {
+ await this.handleSearchOrgAndUser();
+ }
+ this.manualTableListStorage = [...this.hasSelectedManualDepartments, ...this.hasSelectedManualUsers];
+ this.manualTableList = _.cloneDeep(this.manualTableListStorage);
+ this.fetchManualTableData();
},
// 校验部门/用户范围是否满足条件
- async fetchSubjectScopeCheck (payload) {
- const subjects = payload.map(item => {
+ async fetchSubjectScopeCheck (payload, mode) {
+ const subjects = payload.map((item) => {
const { id, type, username } = item;
const typeMap = {
depart: () => {
@@ -816,16 +1079,18 @@
};
}
};
- return typeMap[type]();
+ return typeMap[type || mode]();
});
try {
const { code, data } = await this.$store.dispatch('organization/getSubjectScopeCheck', { subjects });
if (code === 0 && data) {
- const result = payload.filter(item => {
+ const idList = data.map((v) => v.id);
+ const result = payload.filter((item) => {
if (item.type === 'depart') {
item.type = 'department';
}
- return data.map(v => v.type).includes(item.type) && data.map(v => v.id).includes(String(item.id));
+ return data.map((v) => v.type).includes(item.type)
+ && (idList.includes(String(item.id)) || idList.includes(item.username));
});
return result;
}
@@ -854,9 +1119,7 @@
}
const len = this.$refs.searchedResultsRef.renderData.length;
this.focusItemIndex++;
- this.focusItemIndex = this.focusItemIndex > len - 1
- ? len
- : this.focusItemIndex;
+ this.focusItemIndex = this.focusItemIndex > len - 1 ? len : this.focusItemIndex;
if (this.focusItemIndex === len) {
this.focusItemIndex = 0;
}
@@ -875,8 +1138,8 @@
};
const res = await this.$store.dispatch('userGroup/getUserGroupMemberList', params);
- this.defaultDepartments = res.data.results.filter(item => item.type === 'department');
- this.defaultUsers = res.data.results.filter(item => item.type === 'user');
+ this.defaultDepartments = res.data.results.filter((item) => item.type === 'department');
+ this.defaultUsers = res.data.results.filter((item) => item.type === 'user');
if (this.isRatingManager) {
this.fetchRoleSubjectScope(false, true);
} else {
@@ -910,13 +1173,13 @@
try {
const { code, data } = await this.$store.dispatch('role/getRoleSubjectScope');
const departments = [...data];
- this.isAllFlag = departments.some(item => item.type === '*' && item.id === '*');
+ this.isAllFlag = departments.some((item) => item.type === '*' && item.id === '*');
if (this.isAllFlag) {
this.fetchCategories(false, true);
return;
}
this.emptyData = formatCodeData(code, this.emptyData, departments.length === 0);
- departments.forEach(child => {
+ departments.forEach((child) => {
child.visiable = true;
child.level = 0;
child.loading = false;
@@ -962,26 +1225,27 @@
if (child.type === 'user') {
child.username = child.id;
if (this.hasSelectedUsers.length > 0) {
- child.is_selected = this.hasSelectedUsers.map(item => item.id).includes(child.id);
+ child.is_selected = this.hasSelectedUsers.map((item) => item.id).includes(child.id);
} else {
child.is_selected = false;
}
- if (this.defaultUsers.length && this.defaultUsers.map(item => item.id).includes(child.id)) {
+ if (this.defaultUsers.length && this.defaultUsers.map((item) => item.id).includes(child.id)) {
child.is_selected = true;
child.disabled = true;
}
}
-
+
if (child.type === 'depart') {
if (this.hasSelectedDepartments.length > 0) {
- child.is_selected = this.hasSelectedDepartments.map(item => item.id).includes(child.id);
+ child.is_selected = this.hasSelectedDepartments.map((item) => item.id).includes(child.id);
} else {
child.is_selected = false;
}
-
- if (this.defaultDepartments.length > 0
- && this.defaultDepartments.map(item => item.id).includes(child.id.toString())
+
+ if (
+ this.defaultDepartments.length > 0
+ && this.defaultDepartments.map((item) => item.id).includes(child.id.toString())
) {
child.is_selected = true;
child.disabled = true;
@@ -1042,15 +1306,14 @@
child.full_name = `${item.name}:${child.name}`;
if (this.hasSelectedDepartments.length) {
- child.is_selected = this.hasSelectedDepartments.map(
- item => item.id
- ).includes(child.id);
+ child.is_selected = this.hasSelectedDepartments.map((item) => item.id).includes(child.id);
} else {
child.is_selected = false;
}
- if (this.defaultDepartments.length > 0
- && this.defaultDepartments.map(item => item.id).includes(child.id.toString())
+ if (
+ this.defaultDepartments.length > 0
+ && this.defaultDepartments.map((item) => item.id).includes(child.id.toString())
) {
child.is_selected = true;
child.disabled = true;
@@ -1082,31 +1345,34 @@
}
} else {
if (node.type === 'user') {
- this.hasSelectedUsers = [
- ...this.hasSelectedUsers.filter(item => item.username !== node.username)
- ];
+ this.hasSelectedUsers = [...this.hasSelectedUsers.filter((item) => item.username !== node.username)];
+ this.hasSelectedManualUsers = [...this.hasSelectedManualUsers
+ .filter((item) => item.username !== node.username)];
} else {
- this.hasSelectedDepartments = [
- ...this.hasSelectedDepartments.filter(item => item.id !== node.id)
- ];
+ this.hasSelectedDepartments = [...this.hasSelectedDepartments.filter((item) => item.id !== node.id)];
+ this.hasSelectedManualDepartments = [...this.hasSelectedManualDepartments
+ .filter((item) => item.id !== node.id)];
}
}
},
handleDeleteAll () {
if (this.searchedUsers.length) {
- this.searchedUsers.forEach(search => {
+ this.searchedUsers.forEach((search) => {
search.is_selected = false;
});
}
if (this.searchedDepartment.length) {
- this.searchedDepartment.forEach(organ => {
+ this.searchedDepartment.forEach((organ) => {
organ.is_selected = false;
});
}
this.hasSelectedUsers.splice(0, this.hasSelectedUsers.length, ...[]);
this.hasSelectedDepartments.splice(0, this.hasSelectedDepartments.length, ...[]);
+ this.hasSelectedManualUsers.splice(0, this.hasSelectedManualUsers.length, ...[]);
+ this.hasSelectedManualDepartments.splice(0, this.hasSelectedManualDepartments.length, ...[]);
this.$refs.memberTreeRef && this.$refs.memberTreeRef.clearAllIsSelectedStatus();
+ this.fetchManualTableData();
},
handleConditionSelcted (payload) {
@@ -1146,10 +1412,10 @@
this.searchedDepartment.splice(0, this.searchedDepartment.length, ...[]);
this.searchedUsers.splice(0, this.searchedUsers.length, ...[]);
- const defaultDepartIds = [...this.defaultDepartments.map(item => item.id)];
- const defaultUserIds = [...this.defaultUsers.map(item => item.id)];
- const departIds = [...this.hasSelectedDepartments.map(item => item.id)];
- const userIds = [...this.hasSelectedUsers.map(item => item.username)];
+ const defaultDepartIds = [...this.defaultDepartments.map((item) => item.id)];
+ const defaultUserIds = [...this.defaultUsers.map((item) => item.id)];
+ const departIds = [...this.hasSelectedDepartments.map((item) => item.id)];
+ const userIds = [...this.hasSelectedUsers.map((item) => item.username)];
const params = {
keyword: this.keyword,
is_exact: this.searchConditionValue === 'exact'
@@ -1163,7 +1429,7 @@
}
this.isShowTooMuch = false;
if (departments.length > 0) {
- data.departments.forEach(depart => {
+ data.departments.forEach((depart) => {
depart.showRadio = true;
depart.type = 'depart';
if (departIds.length && departIds.includes(depart.id)) {
@@ -1181,7 +1447,7 @@
this.searchedDepartment.splice(0, this.searchedDepartment.length, ...data.departments);
}
if (users.length > 0) {
- data.users.forEach(user => {
+ data.users.forEach((user) => {
user.id = guid();
user.showRadio = true;
user.type = 'user';
@@ -1220,13 +1486,13 @@
if (this.isRatingManager && !this.isAllFlag) {
return;
}
- const flag = this.treeList.some(item => item.parentNodeId === payload.id);
+ const flag = this.treeList.some((item) => item.parentNodeId === payload.id);
if (payload.level === 0 && !flag) {
- const curIndex = this.treeList.findIndex(item => item.id === payload.id);
+ const curIndex = this.treeList.findIndex((item) => item.id === payload.id);
if (curIndex !== -1) {
const children = _.cloneDeep(this.treeList[curIndex].children);
if (children && children.length > 0) {
- children.forEach(item => {
+ children.forEach((item) => {
item.visiable = true;
});
this.treeList.splice(curIndex + 1, 0, ...children);
@@ -1249,7 +1515,7 @@
return;
}
- const curIndex = this.treeList.findIndex(item => item.id === payload.id);
+ const curIndex = this.treeList.findIndex((item) => item.id === payload.id);
if (curIndex === -1) {
return;
@@ -1274,13 +1540,14 @@
child.full_name = `${payload.full_name}/${child.name}`;
if (this.hasSelectedDepartments.length > 0) {
- child.is_selected = this.hasSelectedDepartments.map(item => item.id).includes(child.id);
+ child.is_selected = this.hasSelectedDepartments.map((item) => item.id).includes(child.id);
} else {
child.is_selected = false;
}
- if (this.defaultDepartments.length > 0
- && this.defaultDepartments.map(item => item.id).includes(child.id.toString())
+ if (
+ this.defaultDepartments.length > 0
+ && this.defaultDepartments.map((item) => item.id).includes(child.id.toString())
) {
child.is_selected = true;
child.disabled = true;
@@ -1309,21 +1576,21 @@
// parentNodeId + username 组合成id
child.id = `${child.parentNodeId}${child.username}`;
if (this.hasSelectedUsers.length > 0) {
- child.is_selected = this.hasSelectedUsers.map(item => item.id).includes(child.id)
- || this.hasSelectedUsers.map(item => `${child.parentNodeId}${item.username}`).includes(child.id);
+ child.is_selected
+ = this.hasSelectedUsers.map((item) => item.id).includes(child.id)
+ || this.hasSelectedUsers.map((item) => `${child.parentNodeId}${item.username}`).includes(child.id);
} else {
child.is_selected = false;
}
const existSelectedNode = this.treeList.find(
- item => item.is_selected && item.username === child.username
+ (item) => item.is_selected && item.username === child.username
);
if (existSelectedNode) {
child.is_selected = true;
child.disabled = true;
}
- if (this.defaultUsers.length
- && this.defaultUsers.map(item => item.id).includes(child.username)) {
+ if (this.defaultUsers.length && this.defaultUsers.map((item) => item.id).includes(child.username)) {
child.is_selected = true;
child.disabled = true;
}
@@ -1357,14 +1624,14 @@
}
if (this.isBeingSearch) {
if (this.searchedUsers.length) {
- this.searchedUsers.forEach(search => {
+ this.searchedUsers.forEach((search) => {
if (search.username === item.username) {
search.is_selected = false;
}
});
}
if (this.searchedDepartment.length) {
- this.searchedDepartment.forEach(organ => {
+ this.searchedDepartment.forEach((organ) => {
if (organ.id === item.id) {
organ.is_selected = false;
}
@@ -1374,11 +1641,16 @@
this.tabActive === 'organization' && this.$refs.memberTreeRef.setSingleSelectedStatus(item.id, false);
}
if (type === 'user') {
- this.hasSelectedUsers = [...this.hasSelectedUsers.filter(user => user.username !== item.username)];
+ this.hasSelectedUsers = [...this.hasSelectedUsers.filter((user) => user.username !== item.username)];
+ this.hasSelectedManualUsers
+ = [...this.hasSelectedManualUsers.filter((user) => user.username !== item.username)];
} else {
// eslint-disable-next-line max-len
- this.hasSelectedDepartments = [...this.hasSelectedDepartments.filter(organ => organ.id !== item.id)];
+ this.hasSelectedDepartments = [...this.hasSelectedDepartments.filter((organ) => organ.id !== item.id)];
+ this.hasSelectedManualDepartments
+ = [...this.hasSelectedManualDepartments.filter((organ) => organ.id !== item.id)];
}
+ this.fetchManualTableData();
},
async handleSearchResultSelected (newVal, oldVal, localVal, item) {
@@ -1388,7 +1660,9 @@
if (newVal) {
this.hasSelectedDepartments.push(item);
} else {
- this.hasSelectedDepartments = this.hasSelectedDepartments.filter(organ => organ.id !== item.id);
+ this.hasSelectedDepartments = this.hasSelectedDepartments.filter((organ) => organ.id !== item.id);
+ this.hasSelectedManualDepartments
+ = this.hasSelectedManualDepartments.filter((organ) => organ.id !== item.id);
}
}
},
@@ -1397,10 +1671,39 @@
if (newVal) {
this.hasSelectedUsers.push(item);
} else {
- this.hasSelectedUsers = this.hasSelectedUsers.filter(user => user.username !== item.username);
+ this.hasSelectedUsers = this.hasSelectedUsers.filter((user) => user.username !== item.username);
+ this.hasSelectedManualUsers = this.hasSelectedManualUsers.filter((user) => user.username !== item.username);
}
},
+ handleTableSearch () {
+ this.emptyTableData.tipType = 'search';
+ this.manualTableList = this.manualTableListStorage.filter((item) => {
+ return (
+ item.name.indexOf(this.tableKeyWord) > -1
+ || (item.username && item.username.indexOf(this.tableKeyWord) > -1));
+ });
+ if (!this.manualTableList.length) {
+ this.emptyTableData = formatCodeData(0, this.emptyTableData, true);
+ }
+ this.fetchManualTableData();
+ },
+
+ handleClearSearch () {
+ this.tableKeyWord = '';
+ this.manualTableList = _.cloneDeep(this.manualTableListStorage);
+ if (!this.manualTableList.length) {
+ this.emptyTableData = Object.assign({}, {
+ type: 'empty',
+ text: '请先从左侧输入并解析',
+ tip: '',
+ tipType: ''
+ });
+ return;
+ }
+ this.fetchManualTableData();
+ },
+
handleAfterLeave () {
this.isPrev = true;
this.expiredAt = 15552000;
@@ -1422,6 +1725,11 @@
this.manualAddLoading = false;
this.manualInputError = false;
this.manualValueBackup = [];
+ this.manualTableList = [];
+ this.manualTableListStorage = [];
+ this.hasSelectedManualDepartments = [];
+ this.hasSelectedManualUsers = [];
+ this.tableKeyWord = '';
this.$emit('update:show', false);
this.$emit('on-after-leave');
},
@@ -1460,7 +1768,7 @@
const Fn = Function;
return new Fn('return ' + fn)();
},
-
+
async handleSkip () {
// bus.$emit('nav-change', { id: this.$store.getters.navCurRoleId }, 0);
// await this.$store.dispatch('role/updateCurrentRole', { id: 0 });
@@ -1470,297 +1778,522 @@
params: { id: this.$store.getters.curRoleId }
});
window.open(routeData.href, '_blank');
- // this.$router.push({
- // name: 'gradingAdminEdit',
- // params: {
- // id: this.$store.getters.navCurRoleId
- // }
- // });
+ // this.$router.push({
+ // name: 'gradingAdminEdit',
+ // params: {
+ // id: this.$store.getters.navCurRoleId
+ // }
+ // });
+ },
+
+ fetchSelectedGroups (type, payload, row) {
+ const typeMap = {
+ multiple: async () => {
+ const isChecked = payload.length && payload.indexOf(row) !== -1;
+ if (['depart', 'department'].includes(row.type)) {
+ if (isChecked) {
+ const hasSelectedDepart = [...this.hasSelectedDepartments, ...this.hasSelectedManualDepartments];
+ let hasSelectedDepartIds = [];
+ if (hasSelectedDepart.length) {
+ hasSelectedDepartIds = hasSelectedDepart.map((v) => String(v.id));
+ }
+ if (!hasSelectedDepartIds.includes(String(row.id))) {
+ this.hasSelectedDepartments.push(row);
+ this.hasSelectedManualDepartments.push(row);
+ }
+ } else {
+ this.hasSelectedDepartments = this.hasSelectedDepartments.filter(
+ (item) => item.id.toString() !== row.id.toString()
+ );
+ this.hasSelectedManualDepartments = this.hasSelectedManualDepartments.filter(
+ (item) => item.id.toString() !== row.id.toString()
+ );
+ }
+ }
+ if (['user'].includes(row.type)) {
+ if (isChecked) {
+ const hasSelectedUsers = [...this.hasSelectedUsers, ...this.hasSelectedManualUsers];
+ let hasSelectedUsersIds = [];
+ if (hasSelectedUsers.length) {
+ hasSelectedUsersIds = hasSelectedUsers.map((v) => `${v.username}${v.name}`);
+ }
+ if (!hasSelectedUsersIds.includes(`${row.username}${row.name}`)) {
+ this.hasSelectedUsers.push(row);
+ this.hasSelectedManualUsers.push(row);
+ }
+ } else {
+ this.hasSelectedUsers = this.hasSelectedUsers.filter(
+ (item) => `${item.username}${item.name}` !== `${row.username}${row.name}`
+ );
+ this.hasSelectedManualUsers = this.hasSelectedManualUsers.filter(
+ (item) => `${item.username}${item.name}` !== `${row.username}${row.name}`
+ );
+ }
+ }
+ },
+ all: async () => {
+ const isAllCheck = payload.length > 0;
+ this.manualTableList.forEach((item) => {
+ if (['depart', 'department'].includes(item.type)) {
+ if (isAllCheck) {
+ const hasSelectedDepart = [...this.hasSelectedDepartments, ...this.hasSelectedManualDepartments];
+ let hasSelectedDepartIds = [];
+ if (hasSelectedDepart.length) {
+ hasSelectedDepartIds = hasSelectedDepart.map((v) => String(v.id));
+ }
+ if (!hasSelectedDepartIds.includes(String(item.id))) {
+ this.hasSelectedDepartments.push(item);
+ this.hasSelectedManualDepartments.push(item);
+ }
+ } else {
+ this.hasSelectedDepartments = this.hasSelectedDepartments.filter(
+ (v) => item.id.toString() !== v.id.toString()
+ );
+ this.hasSelectedManualDepartments = this.hasSelectedManualDepartments.filter(
+ (v) => item.id.toString() !== v.id.toString()
+ );
+ }
+ }
+ if (['user'].includes(item.type)) {
+ if (isAllCheck) {
+ const hasSelectedUsers = [...this.hasSelectedUsers, ...this.hasSelectedManualUsers];
+ let hasSelectedUsersIds = [];
+ if (hasSelectedUsers.length) {
+ hasSelectedUsersIds = hasSelectedUsers.map((v) => `${v.username}${v.name}`);
+ }
+ if (!hasSelectedUsersIds.includes(`${item.username}${item.name}`)) {
+ this.hasSelectedUsers.push(item);
+ this.hasSelectedManualUsers.push(item);
+ }
+ } else {
+ this.hasSelectedUsers = this.hasSelectedUsers.filter(
+ (v) => `${item.username}${item.name}` !== `${v.username}${v.name}`
+ );
+ this.hasSelectedManualUsers = this.hasSelectedManualUsers.filter(
+ (v) => `${item.username}${item.name}` !== `${v.username}${v.name}`
+ );
+ }
+ }
+ });
+ }
+ };
+ return typeMap[type]();
+ },
+
+ handleSelectChange (selection, row) {
+ this.fetchSelectedGroups('multiple', selection, row);
+ },
+
+ handleSelectAllChange (selection) {
+ this.fetchSelectedGroups('all', selection);
}
}
};
-
diff --git a/frontend/src/views/group/components/member-table.vue b/frontend/src/views/group/components/member-table.vue
index f5990c89d..ecbcc1a58 100644
--- a/frontend/src/views/group/components/member-table.vue
+++ b/frontend/src/views/group/components/member-table.vue
@@ -2,16 +2,66 @@
-
- {{ $t(`m.userGroup['添加成员']`) }}
-
-
+
+ {{ $t(`m.userGroup['添加成员']`) }}
+
+
+
+
+
-
+
@@ -115,7 +168,7 @@
-
+
{{ row.created_time.replace(/T/, ' ') }}
@@ -175,6 +228,7 @@
:show.sync="isShowRenewalDialog"
:data="curData"
:type="curType"
+ :list="currentSelectList"
:loading="renewalLoading"
@on-submit="handleRenewalSubmit" />
@@ -252,6 +306,7 @@
tipType: ''
},
adminGroupTitle: '',
+ renewalGroupTitle: '',
keyword: '',
enableOrganizationCount: window.ENABLE_ORGANIZATION_COUNT.toLowerCase() === 'true',
isDropdownShow: false,
@@ -274,6 +329,20 @@
return !hasData;
};
},
+ isNoBatchRenewal () {
+ return () => {
+ const hasData = this.tableList.length > 0 && this.currentSelectList.length > 0;
+ if (hasData) {
+ this.selectNoRenewalList = this.currentSelectList.filter(
+ (item) => item.expired_at === PERMANENT_TIMESTAMP);
+ if (this.currentSelectList.length === this.selectNoRenewalList.length) {
+ this.renewalGroupTitle = this.$t(`m.userGroup['已选择的用户组成员不需要续期']`);
+ return true;
+ }
+ }
+ return !hasData;
+ };
+ },
isRatingManager () {
return ['rating_manager', 'subset_manager'].includes(this.user.role.type);
},
@@ -335,24 +404,28 @@
return '';
},
- async handleKeyWordEnter () {
- this.emptyData.tipType = 'search';
- this.pagination = Object.assign(this.pagination, { current: 1, limit: 10 });
- this.fetchMemberList();
- },
-
async fetchMemberList () {
this.tableLoading = true;
try {
+ const { current, limit } = this.pagination;
const params = {
id: this.id,
- limit: this.pagination.limit,
- offset: this.pagination.limit * (this.pagination.current - 1),
+ limit,
+ offset: limit * (current - 1),
keyword: this.keyword
};
const { code, data } = await this.$store.dispatch('userGroup/getUserGroupMemberList', params);
this.pagination.count = data.count || 0;
this.tableList.splice(0, this.tableList.length, ...(data.results || []));
+ this.$nextTick(() => {
+ const currentSelectList = this.currentSelectList.map(item => item.id.toString());
+ this.tableList.forEach(item => {
+ if (currentSelectList.includes(item.id.toString())) {
+ this.$refs.groupMemberRef && this.$refs.groupMemberRef.toggleRowSelection(item, true);
+ }
+ });
+ });
+ await this.fetchCustomTotal();
this.emptyData = formatCodeData(code, this.emptyData, this.tableList.length === 0);
} catch (e) {
console.error(e);
@@ -365,8 +438,60 @@
}
},
+ async handleKeyWordEnter () {
+ this.emptyData.tipType = 'search';
+ this.pagination = Object.assign(this.pagination, { current: 1, limit: 10 });
+ this.fetchMemberList();
+ },
+
+ async handleKeyWordClear () {
+ await this.handleEmptyRefresh();
+ },
+
+ fetchCustomTotal () {
+ this.$nextTick(() => {
+ const selectionCount = document.getElementsByClassName('bk-page-selection-count');
+ if (this.$refs.groupMemberRef && selectionCount && selectionCount.length) {
+ selectionCount[0].children[0].innerHTML = this.currentSelectList.length;
+ }
+ });
+ },
+
+ fetchSelectedGroups (type, payload, row) {
+ const typeMap = {
+ multiple: async () => {
+ const isChecked = payload.length && payload.indexOf(row) !== -1;
+ if (isChecked) {
+ this.currentSelectList.push(row);
+ } else {
+ this.currentSelectList = this.currentSelectList.filter(
+ (item) => item.id.toString() !== row.id.toString()
+ );
+ }
+ await this.fetchCustomTotal();
+ },
+ all: async () => {
+ const tableList = _.cloneDeep(this.tableList);
+ const selectGroups = this.currentSelectList.filter(item =>
+ !tableList.map(v => v.id.toString()).includes(item.id.toString()));
+ this.currentSelectList = [...selectGroups, ...payload];
+ await this.fetchCustomTotal();
+ }
+ };
+ return typeMap[type]();
+ },
+
+ handlerAllChange (selection) {
+ this.fetchSelectedGroups('all', selection);
+ },
+
+ handlerChange (selection, row) {
+ this.fetchSelectedGroups('multiple', selection, row);
+ },
+
handleDropdownShow () {
this.isDropdownShow = true;
+ this.$refs.copyCascade.$refs.cascadeDropdown.hideHandler();
},
handleDropdownHide () {
@@ -400,6 +525,23 @@
});
},
+ handleBatchProcess (type) {
+ const typeMap = {
+ remove: () => {
+ if (!this.isNoBatchDelete()) {
+ this.handleBatchDelete();
+ }
+ },
+ renewal: () => {
+ if (!this.isNoBatchRenewal()) {
+ this.isShowRenewalDialog = true;
+ this.curData = {};
+ }
+ }
+ };
+ return typeMap[type]();
+ },
+
async handleTriggerCopy (event, payload) {
if (payload.id) {
this.curCopyCascade = Object.assign({}, payload);
@@ -505,9 +647,9 @@
handleResetCascade () {
this.$nextTick(() => {
this.copyValue = [];
- if (this.$refs.copyCascade) {
- this.$refs.copyCascade.value = [];
- }
+ // if (this.$refs.copyCascade) {
+ // this.$refs.copyCascade.value = [];
+ // }
});
},
@@ -628,14 +770,6 @@
this.fetchMemberList();
},
- handlerAllChange (selection) {
- this.currentSelectList = [...selection];
- },
-
- handlerChange (selection, row) {
- this.currentSelectList = [...selection];
- },
-
handleAfterDeleteLeave () {
this.deleteDialog.subTitle = '';
this.curMember = {};
@@ -663,7 +797,7 @@
window.parent.postMessage({ type: 'IAM', data: externalParams, code: 'remove_user_confirm' }, '*');
this.messageSuccess(this.$t(`m.info['移除成功']`), 3000);
this.currentSelectList = [];
- this.pagination.current = 1;
+ this.pagination = Object.assign(this.pagination, { current: 1, limit: 10 });
this.fetchMemberList();
}
} catch (e) {
@@ -677,19 +811,22 @@
async handleRenewalSubmit (payload) {
this.renewalLoading = true;
- const { id, type } = this.curData;
const params = {
- groupId: this.id,
- members: [{
- expired_at: payload,
- id,
- type
- }]
+ groupId: this.id
};
+ if (Object.keys(this.curData).length) {
+ const { id, type } = this.curData;
+ this.$set(params, 'members', [{ expired_at: payload, id, type }]);
+ } else {
+ this.$set(params, 'members', payload);
+ }
try {
await this.$store.dispatch('renewal/groupMemberPermRenewal', params);
this.messageSuccess(this.$t(`m.renewal['续期成功']`), 3000);
this.isShowRenewalDialog = false;
+ this.currentSelectList = [];
+ this.$refs.groupMemberRef && this.$refs.groupMemberRef.clearSelection();
+ this.pagination = Object.assign(this.pagination, { current: 1, limit: 10 });
this.fetchMemberList();
} catch (e) {
console.error(e);
@@ -703,35 +840,35 @@
diff --git a/frontend/src/views/my-manage-space/index.vue b/frontend/src/views/my-manage-space/index.vue
index 12d6ae327..052c238cc 100644
--- a/frontend/src/views/my-manage-space/index.vue
+++ b/frontend/src/views/my-manage-space/index.vue
@@ -895,7 +895,7 @@
},
handleOpenDocu () {
const GRADE_DOCU_LINK = '/权限中心/产品白皮书/场景案例/GradingManager.md';
- window.open(`${window.PRODUCT_DOC_URL_PREFIX}${GRADE_DOCU_LINK}`);
+ window.open(`${window.BK_DOCS_URL_PREFIX}${GRADE_DOCU_LINK}`);
}
}
};
diff --git a/frontend/src/views/perm-apply/apply-custom-perm/index.vue b/frontend/src/views/perm-apply/apply-custom-perm/index.vue
index e4bf11e2b..7c92dbd61 100644
--- a/frontend/src/views/perm-apply/apply-custom-perm/index.vue
+++ b/frontend/src/views/perm-apply/apply-custom-perm/index.vue
@@ -52,6 +52,7 @@