From 084035fe3780ec7bfbecfb53a57e713b179b605d Mon Sep 17 00:00:00 2001 From: shiziyuan9527 Date: Fri, 17 Jun 2022 11:22:27 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):?= =?UTF-8?q?=20=E6=93=8D=E4=BD=9C=E6=97=A5=E5=BF=97=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E4=BA=BA=E6=90=9C=E7=B4=A2=E9=A1=B9=E6=90=9C=E7=B4=A2=E6=97=B6?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E7=94=A8=E6=88=B7=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1014108 --user=李玉号 【系统设置】操作日志-操作人搜索提示输入ID,但是列表操作人是name,建议改为一致的 https://www.tapd.cn/55049933/s/1184925 --- .../business/components/project/menu/Log.vue | 59 ++- .../settings/operatinglog/OperatingLog.vue | 379 ++++++++++-------- frontend/src/i18n/en-US.js | 1 + frontend/src/i18n/zh-CN.js | 1 + frontend/src/i18n/zh-TW.js | 1 + 5 files changed, 245 insertions(+), 196 deletions(-) diff --git a/frontend/src/business/components/project/menu/Log.vue b/frontend/src/business/components/project/menu/Log.vue index 120f528040..aa86fe5bba 100644 --- a/frontend/src/business/components/project/menu/Log.vue +++ b/frontend/src/business/components/project/menu/Log.vue @@ -23,21 +23,28 @@ - - - + style="width: 100%" + @visible-change="visibleChange" + reserve-keyword + :placeholder="$t('member.input_id_or_email_or_name')" + :remote-method="querySearch" + @clear="initTableData" + :loading="selectLoading"> + + {{ item.name }}    + {{ item.email }} + + @@ -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) { diff --git a/frontend/src/business/components/settings/operatinglog/OperatingLog.vue b/frontend/src/business/components/settings/operatinglog/OperatingLog.vue index 5f846a029f..b1da1481fe 100644 --- a/frontend/src/business/components/settings/operatinglog/OperatingLog.vue +++ b/frontend/src/business/components/settings/operatinglog/OperatingLog.vue @@ -23,21 +23,28 @@ - - - + style="width: 95%" + @visible-change="visibleChange" + reserve-keyword + :placeholder="$t('member.input_id_or_email_or_name')" + :remote-method="querySearch" + @clear="initTableData" + :loading="selectLoading"> + + {{ item.name }}    + {{ item.email }} + + @@ -63,7 +70,8 @@ - + @@ -83,7 +91,7 @@
- + {{ $t('commons.adv_search.search') }} @@ -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); + }, } +}