refactor(系统设置): 操作日志操作人搜索项搜索时显示用户名

--bug=1014108 --user=李玉号 【系统设置】操作日志-操作人搜索提示输入ID,但是列表操作人是name,建议改为一致的
https://www.tapd.cn/55049933/s/1184925
This commit is contained in:
shiziyuan9527 2022-06-17 11:22:27 +08:00 committed by f2c-ci-robot[bot]
parent 4e7016ad39
commit 084035fe37
5 changed files with 245 additions and 196 deletions

View File

@ -23,21 +23,28 @@
</el-col>
<el-col :span="4">
<el-form-item :label="$t('operating_log.user')" prop="user">
<el-autocomplete
class="input-with-autocomplete"
<el-select
v-model="condition.operUser"
:placeholder="$t('member.input_id_or_email')"
:trigger-on-focus="false"
:fetch-suggestions="querySearch"
filterable
remote
clearable
size="small"
highlight-first-item
value-key="email"
@select="handleSelect">
<template v-slot:default="scope">
<span class="ws-member-name">{{ scope.item.name }}</span>
<span class="ws-member-email">{{ scope.item.email }}</span>
</template>
</el-autocomplete>
style="width: 100%"
@visible-change="visibleChange"
reserve-keyword
:placeholder="$t('member.input_id_or_email_or_name')"
:remote-method="querySearch"
@clear="initTableData"
:loading="selectLoading">
<el-option
v-for="item in options"
:key="item.id"
:label="item.name"
:value="item.id">
<span class="ws-member-name">{{ item.name }} &nbsp;&nbsp;</span>
<span class="ws-member-email">{{ item.email }}</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
@ -170,6 +177,8 @@ export default {
LOG_TYPE_MAP: new LOG_TYPE_MAP(this),
LOG_MODULE_MAP: new LOG_MODULE_MAP(this),
sysList: new PROJECTSYSLIST(),
options: [],
selectLoading: false
}
},
mounted() {
@ -231,14 +240,26 @@ export default {
},
createFilter(queryString) {
return (user) => {
return (user.email.indexOf(queryString.toLowerCase()) === 0 || user.id.indexOf(queryString.toLowerCase()) === 0);
return (user.email.indexOf(queryString.toLowerCase()) === 0
|| user.id.indexOf(queryString.toLowerCase()) === 0
|| (user.name && user.name.indexOf(queryString) === 0));
};
},
querySearch(queryString, cb) {
let userList = this.userList;
let results = queryString ? userList.filter(this.createFilter(queryString)) : userList;
// callback
cb(results);
querySearch(query) {
if (query !== '') {
this.selectLoading = true;
setTimeout(() => {
this.selectLoading = false;
this.options = this.userList.filter(this.createFilter(query));
}, 300);
} else {
this.options = [];
}
},
visibleChange(val) {
if (!val) {
this.querySearch('');
}
},
initTableData() {
if (this.condition.operModules && this.condition.operModules.length > 0) {

View File

@ -23,21 +23,28 @@
</el-col>
<el-col :span="8">
<el-form-item :label="$t('operating_log.user')" prop="user">
<el-autocomplete
class="input-with-autocomplete"
<el-select
v-model="condition.operUser"
:placeholder="$t('member.input_id_or_email')"
:trigger-on-focus="false"
:fetch-suggestions="querySearch"
filterable
remote
clearable
size="small"
highlight-first-item
value-key="email"
@select="handleSelect" style="width: 95%">
<template v-slot:default="scope">
<span class="ws-member-name">{{ scope.item.name }}</span>
<span class="ws-member-email">{{ scope.item.email }}</span>
</template>
</el-autocomplete>
style="width: 95%"
@visible-change="visibleChange"
reserve-keyword
:placeholder="$t('member.input_id_or_email_or_name')"
:remote-method="querySearch"
@clear="initTableData"
:loading="selectLoading">
<el-option
v-for="item in options"
:key="item.id"
:label="item.name"
:value="item.id">
<span class="ws-member-name">{{ item.name }} &nbsp;&nbsp;</span>
<span class="ws-member-email">{{ item.email }}</span>
</el-option>
</el-select>
</el-form-item>
</el-col>
@ -63,7 +70,8 @@
<el-row>
<el-col :span="8">
<el-form-item :label="$t('operating_log.type')" prop="type">
<el-select size="small" v-model="condition.operType" clearable @change="initTableData" style="width: 95%">
<el-select size="small" v-model="condition.operType" clearable @change="initTableData"
style="width: 95%">
<el-option v-for="o in LOG_TYPE" :key="o.id" :label="$t(o.label)" :value="o.id"/>
</el-select>
</el-form-item>
@ -83,7 +91,7 @@
<el-col :span="8">
<div style="float: right">
<el-button type="primary" size="small" @click="search">
<el-button type="primary" size="small" @click="search">
{{ $t('commons.adv_search.search') }}
</el-button>
<el-button size="small" @click="reset">
@ -145,38 +153,53 @@ import {getUrl, LOG_MODULE_MAP, LOG_TYPE, LOG_TYPE_MAP, SYSLIST, WORKSYSLIST} fr
import MsLogDetail from "./LogDetail";
export default {
name: "OperatingLog",
components: {
MsTablePagination, MsTableOperator, MsLogDetail
},
data() {
return {
props: {
multiple: false,
},
result: {},
form: {},
currentPage: 0,
pageSize: 10,
total: 0,
items: [],
workspaceList: [],
isSystem: false,
condition: {
times: [new Date().getTime() - 3600 * 1000 * 24 * 7, new Date().getTime()],
},
tableData: [],
userList: [],
screenHeight: 'calc(100vh - 270px)',
LOG_TYPE: new LOG_TYPE(this),
LOG_TYPE_MAP: new LOG_TYPE_MAP(this),
LOG_MODULE_MAP: new LOG_MODULE_MAP(this),
sysList: new SYSLIST(),
loading: false,
}
},
mounted() {
switch (this.$route.name) {
name: "OperatingLog",
components: {
MsTablePagination, MsTableOperator, MsLogDetail
},
data() {
return {
props: {
multiple: false,
},
result: {},
form: {},
currentPage: 0,
pageSize: 10,
total: 0,
items: [],
workspaceList: [],
isSystem: false,
condition: {
times: [new Date().getTime() - 3600 * 1000 * 24 * 7, new Date().getTime()],
},
tableData: [],
userList: [],
screenHeight: 'calc(100vh - 270px)',
LOG_TYPE: new LOG_TYPE(this),
LOG_TYPE_MAP: new LOG_TYPE_MAP(this),
LOG_MODULE_MAP: new LOG_MODULE_MAP(this),
sysList: new SYSLIST(),
loading: false,
options: [],
selectLoading: false
}
},
mounted() {
switch (this.$route.name) {
case "system":
this.getWorkSpaceList();
this.getMember();
break;
case "workspace":
this.initProject("/project/listAll/" + getCurrentWorkspaceId());
this.getMember('/user/ws/current/member/list');
break;
}
},
watch: {
'$route'(to) {
switch (to.name) {
case "system":
this.getWorkSpaceList();
this.getMember();
@ -187,35 +210,22 @@ export default {
break;
}
},
watch: {
'$route'(to) {
switch (to.name) {
case "system":
this.getWorkSpaceList();
this.getMember();
break;
case "workspace":
this.initProject("/project/listAll/" + getCurrentWorkspaceId());
this.getMember('/user/ws/current/member/list');
break;
'$route.path': {
handler(toPath) {
if (toPath === '/setting/operatingLog/workspace') {
this.isSystem = false;
this.sysList = new WORKSYSLIST();
this.condition.workspaceId = getCurrentWorkspaceId();
} else {
this.isSystem = true;
this.sysList = new SYSLIST();
this.condition.workspaceId = '';
}
},
'$route.path': {
handler(toPath) {
if (toPath === '/setting/operatingLog/workspace') {
this.isSystem = false;
this.sysList = new WORKSYSLIST();
this.condition.workspaceId = getCurrentWorkspaceId();
} else {
this.isSystem = true;
this.sysList = new SYSLIST();
this.condition.workspaceId = '';
}
},
deep: true,
immediate: true
},
deep: true,
immediate: true
},
},
methods: {
isLink(row) {
let uri = getUrl(row, this);
@ -227,88 +237,103 @@ export default {
clickResource(resource) {
let uri = getUrl(resource, this);
if (!resource.sourceId) {
this.toPage(uri);
this.toPage(uri);
}
let operModule = resource.operModule;
let module = this.getLogModule(operModule);
if (module === "系统-系统参数设置" || module === "系统-系統參數設置" || module === "System parameter setting") {
this.toPage(uri);
} else {
let resourceId = resource.sourceId;
if (resourceId && resourceId.startsWith("\"" || resourceId.startsWith("["))) {
resourceId = JSON.parse(resource.sourceId);
}
let operModule = resource.operModule;
let module = this.getLogModule(operModule);
if (module === "系统-系统参数设置" || module === "系统-系統參數設置" || module === "System parameter setting") {
if (resourceId instanceof Array) {
resourceId = resourceId[0];
}
if (!this.isSystem) {
let user = getCurrentUser();
let permission = user.userGroups.filter(ug => ug.sourceId === resource.projectId);
if (!permission || (Array.isArray(permission) && permission.length === 0)) {
this.$warning(this.$t("commons.no_operation_permission"));
return;
}
}
this.$get('/user/update/currentByResourceId/' + resourceId, () => {
this.toPage(uri);
} else {
let resourceId = resource.sourceId;
if (resourceId && resourceId.startsWith("\"" || resourceId.startsWith("["))) {
resourceId = JSON.parse(resource.sourceId);
}
if (resourceId instanceof Array) {
resourceId = resourceId[0];
}
if (!this.isSystem) {
let user = getCurrentUser();
let permission = user.userGroups.filter(ug => ug.sourceId === resource.projectId);
if (!permission || (Array.isArray(permission) && permission.length === 0)) {
this.$warning(this.$t("commons.no_operation_permission"));
return;
}
}
this.$get('/user/update/currentByResourceId/' + resourceId, () => {
this.toPage(uri);
});
}
},
toPage(uri) {
let id = "new_a";
let a = document.createElement("a");
a.setAttribute("href", uri);
a.setAttribute("target", "_blank");
a.setAttribute("id", id);
document.body.appendChild(a);
a.click();
let element = document.getElementById(id);
element.parentNode.removeChild(element);
},
handleSelect(item) {
this.$set(this.condition, "operUser", item.id);
},
getMember(url) {
if (!url) {
url = '/user/list';
}
this.result = this.$get(url, response => {
this.userList = response.data;
});
},
createFilter(queryString) {
return (user) => {
return (user.email.indexOf(queryString.toLowerCase()) === 0 || user.id.indexOf(queryString.toLowerCase()) === 0);
};
},
querySearch(queryString, cb) {
let userList = this.userList;
let results = queryString ? userList.filter(this.createFilter(queryString)) : userList;
// callback
cb(results);
},
initTableData() {
if (this.condition.operModules && this.condition.operModules.length > 0) {
this.condition.operModule = this.condition.operModules[1];
}
if (this.isSystem) {
this.condition.projectIds = [];
} else {
this.condition.workspaceIds = [];
}
let url = "/operating/log/list/" + this.currentPage + "/" + this.pageSize;
this.loading = true;
this.$post(url, this.condition, response => {
this.tableData = response.data.listObject;
this.total = response.data.itemCount;
this.loading = false;
})
}
},
toPage(uri) {
let id = "new_a";
let a = document.createElement("a");
a.setAttribute("href", uri);
a.setAttribute("target", "_blank");
a.setAttribute("id", id);
document.body.appendChild(a);
a.click();
},
let element = document.getElementById(id);
element.parentNode.removeChild(element);
},
handleSelect(item) {
this.$set(this.condition, "operUser", item.id);
},
getMember(url) {
if (!url) {
url = '/user/list';
}
this.result = this.$get(url, response => {
this.userList = response.data;
});
},
createFilter(queryString) {
return (user) => {
return (user.email.indexOf(queryString.toLowerCase()) === 0
|| user.id.indexOf(queryString.toLowerCase()) === 0
|| (user.name && user.name.indexOf(queryString) === 0));
};
},
querySearch(query) {
if (query !== '') {
this.selectLoading = true;
setTimeout(() => {
this.selectLoading = false;
this.options = this.userList.filter(this.createFilter(query));
}, 300);
} else {
this.options = [];
}
},
visibleChange(val) {
if (!val) {
this.querySearch('');
}
},
initTableData() {
if (this.condition.operModules && this.condition.operModules.length > 0) {
this.condition.operModule = this.condition.operModules[1];
}
if (this.isSystem) {
this.condition.projectIds = [];
} else {
this.condition.workspaceIds = [];
}
let url = "/operating/log/list/" + this.currentPage + "/" + this.pageSize;
this.loading = true;
this.$post(url, this.condition, response => {
this.tableData = response.data.listObject;
this.total = response.data.itemCount;
this.loading = false;
})
},
reset() {
let projectIds = this.condition.projectIds;
this.condition = {projectIds: projectIds, times: [new Date().getTime() - 3600 * 1000 * 24 * 7, new Date().getTime()]};
this.condition = {
projectIds: projectIds,
times: [new Date().getTime() - 3600 * 1000 * 24 * 7, new Date().getTime()]
};
this.initTableData();
},
getWorkSpaceList() {
@ -337,36 +362,36 @@ export default {
let data = {id: item.id, label: item.name};
this.items.push(data);
projectIds.push(item.id);
})
}
this.condition.projectIds = projectIds;
this.initTableData();
})
},
getProject() {
this.condition.projectIds = [];
this.result = this.$get("/project/get/" + getCurrentProjectID(), response => {
let project = response.data;
this.items = [{id: project.id, label: project.name}];
this.condition.projectIds = [project.id];
this.condition.projectId = project.id;
this.initTableData();
});
},
getType(type) {
return this.LOG_TYPE_MAP.get(type);
},
getLogModule(val) {
return this.LOG_MODULE_MAP.get(val) ? this.LOG_MODULE_MAP.get(val) : val;
},
search() {
})
}
this.condition.projectIds = projectIds;
this.initTableData();
},
openDetail(row) {
this.$refs.logDetail.open(row.id);
},
}
})
},
getProject() {
this.condition.projectIds = [];
this.result = this.$get("/project/get/" + getCurrentProjectID(), response => {
let project = response.data;
this.items = [{id: project.id, label: project.name}];
this.condition.projectIds = [project.id];
this.condition.projectId = project.id;
this.initTableData();
});
},
getType(type) {
return this.LOG_TYPE_MAP.get(type);
},
getLogModule(val) {
return this.LOG_MODULE_MAP.get(val) ? this.LOG_MODULE_MAP.get(val) : val;
},
search() {
this.initTableData();
},
openDetail(row) {
this.$refs.logDetail.open(row.id);
},
}
}
</script>
<style scoped>

View File

@ -848,6 +848,7 @@ export default {
remove_member: 'Are you sure you want to remove this member',
org_remove_member: 'Removing the user from the organization will also remove permissions from all workspaces under the organization. Are you sure you want to remove the member ?',
input_id_or_email: 'Please enter user ID, or user Email',
input_id_or_email_or_name: 'Please enter User ID, Username, or User Email',
no_such_user: 'Without this user information, please enter the correct user ID or user Email!',
},
user: {

View File

@ -855,6 +855,7 @@ export default {
remove_member: '确定要移除该成员吗',
org_remove_member: '将该用户从组织中移除,将同时移除该组织下所有工作空间的权限,确定要移除该成员吗?',
input_id_or_email: '请输入用户 ID, 或者 用户邮箱',
input_id_or_email_or_name: '请输入用户 ID, 用户名, 或者 用户邮箱',
no_such_user: '无此用户信息, 请输入正确的用户 ID 或者 用户邮箱!',
},
user: {

View File

@ -852,6 +852,7 @@ export default {
remove_member: '確定要移除該成員嗎',
org_remove_member: '將該用戶從組織中移除,將同時移除該組織下所有工作空間的權限,確定要移除該成員嗎?',
input_id_or_email: '請輸入用戶 ID, 或者 用戶郵箱',
input_id_or_email_or_name: '請輸入用戶 ID, 用戶名, 或者 用戶郵箱',
no_such_user: '無此用戶信息, 請輸入正確的用戶 ID 或者 用戶郵箱!',
},
user: {