From 66b4c21343c0b6e746d8e199f86fe3ae3821deaa Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Tue, 12 Nov 2024 17:18:55 +0800 Subject: [PATCH] fix --- src/views/course/AddCurriculum.vue | 56 ++++++++++++++---------------- src/views/review/index.vue | 4 +-- 2 files changed, 28 insertions(+), 32 deletions(-) diff --git a/src/views/course/AddCurriculum.vue b/src/views/course/AddCurriculum.vue index 951fc84..af07f6d 100644 --- a/src/views/course/AddCurriculum.vue +++ b/src/views/course/AddCurriculum.vue @@ -415,7 +415,6 @@ export default { systemChecked: [], curSystem: '', projects: [], - projectAll: [], projectKeyword: '', checkedKeyword: '', checkeds: [], @@ -442,7 +441,7 @@ export default { projectKeyword: function (val) { clearTimeout(this.searchTimer); this.searchTimer = setTimeout(() => { - this.filterProject(); + this.getProject(); }, 500); }, checkedKeyword: function (val) { @@ -577,6 +576,7 @@ export default { this.pageNo = 1; this.getConfig(); this.checkeds = JSON.parse(JSON.stringify(type == 1 ? this.assessmentData : type == 2 ? this.matches : this.practiceData)) + this.checkedAll = JSON.parse(JSON.stringify(this.checkeds)) }, // 获取系统 getConfig () { @@ -609,26 +609,23 @@ export default { }).catch(err => { }) }, // 获取项目列表 - getProject (item) { + async getProject (item, fromSystemChange) { const checked = this.checkeds - this.curSystem = item.systemId - this.$get(`${this.api.getInternalProjectBySystemId}?permissions=${this.permissions}&systemId=${item.systemId}`).then(res => { - this.projectAll = JSON.parse(JSON.stringify(res)) // 全部项目,另外保存 - const result = [] - res.map(e => { - // 如果选择了该项目,则禁用并选中 - const include = checked.some(n => n.projectId == e.projectId && n.systemId == e.systemId) - e.check = include - result.push(e) - }) - this.checkAll = !result.filter(e => !e.check).length - this.projects = result - }).catch(err => { }) - }, - // 项目模糊查询 - filterProject () { - const val = this.projectKeyword - this.projects = this.projectAll.filter(e => e.projectName.includes(val)) + if (item) this.curSystem = item.systemId + let res + if (!fromSystemChange) { + res = await this.$get(`${this.api.getInternalProjectBySystemId}?permissions=${this.permissions}&systemId=${this.curSystem}&keyword=${this.projectKeyword}`) + } + const result = [] + const projects = fromSystemChange ? this.projects : res + projects.map(e => { + // 如果选择了该项目,则禁用并选中 + const include = checked.some(n => (e.projectId && n.projectId == e.projectId && n.systemId == e.systemId) || (e.paperId && n.paperId == e.paperId)) + e.check = include + result.push(e) + }) + this.checkAll = !result.filter(e => !e.check).length + this.projects = result }, // 系统选择回调 systemChange (val, item) { @@ -640,7 +637,7 @@ export default { }) } this.projectKeyword = '' - this.$get(`${this.api.getInternalProjectBySystemId}?permissions=${this.permissions}&systemId=${item.systemId}`).then(res => { + this.$get(`${this.api.getInternalProjectBySystemId}?permissions=${this.permissions}&systemId=${item.systemId}&keyword=${this.projectKeyword}`).then(res => { if (val) { // 如果不支持多选系统,选中后全部取消选中再选中当前系统 if (!this.mulSystem) { @@ -648,18 +645,18 @@ export default { item.check = true } res.map(e => { - if (!checkeds.find(n => n.projectId == e.projectId && n.systemId == e.systemId)) { + if (!checkeds.find(n => (e.projectId && n.projectId == e.projectId && n.systemId == e.systemId) || (e.paperId && e.paperId == n.paperId))) { checkeds.push(e) } }) } else { res.map(e => { - const i = checkeds.findIndex(n => n.projectId == e.projectId && n.systemId == e.systemId) + const i = checkeds.findIndex(n => (e.projectId && n.projectId == e.projectId && n.systemId == e.systemId) || (e.paperId && e.paperId == n.paperId)) i === -1 || checkeds.splice(i, 1) }) } this.checkedAll = JSON.parse(JSON.stringify(checkeds)) // 全部已选项目,另外保存 - this.getProject(item) + this.getProject(item, 1) }).catch(err => { }) }, // 项目全选回调 @@ -672,7 +669,7 @@ export default { // 项目选择回调 projectChange (val, item) { const { systemId, paperId } = item - const i = this.checkeds.findIndex(e => (e.projectId == item.projectId && e.systemId == systemId) || e.paperId == paperId) + const i = this.checkeds.findIndex(e => (item.projectId && e.projectId == item.projectId && e.systemId == systemId) || (paperId && paperId == e.paperId)) // 选中,则push,否则移除 if (val) { this.checkeds.push(item) @@ -685,12 +682,11 @@ export default { }) this.checkAll = !this.projects.find(e => !e.check) // 同步全选框 this.checkedAll = JSON.parse(JSON.stringify(this.checkeds)) // 全部已选项目,另外保存 - console.log("🚀 ~ file: AddCurriculum.vue ~ line 728 ~ projectChange ~ checkedAll", this.checkeds, item) }, // 已选择项目模糊查询 filterChecked () { const val = this.checkedKeyword - this.checkeds = this.checkedAll.filter(e => e.projectName.includes(val)) + this.checkeds = this.checkedAll.filter(e => (e.projectName && e.projectName.includes(val)) || (e.paperName && e.paperName.includes(val))) }, // 删除已选项目 delProject (i, e) { @@ -701,9 +697,9 @@ export default { this.checkeds.splice(i, 1) // 如果当前展示的项目列表跟删掉的项目是同个系统,则找到项目列表里删掉的该项目,重置check和disabled if (e.systemId == this.curSystem) { - const { projectId } = e + const { projectId, paperId } = e this.projects.map(n => { - if (n.projectId == projectId) { + if ((projectId && n.projectId == projectId) || (paperId && n.paperId == paperId)) { n.check = false } }) diff --git a/src/views/review/index.vue b/src/views/review/index.vue index 8dfca48..0e7a430 100644 --- a/src/views/review/index.vue +++ b/src/views/review/index.vue @@ -17,9 +17,9 @@ export default { let url = `${location.origin}/reviewCenter/` if (Setting.isDev) url = `http://192.168.31.125:8099/` if (cache) { - url += `#${cache}${cache.includes('?') ? `&` : '?'}token=${sessionStorage.getItem('token')}` + url += `#${cache}${cache.includes('?') ? `&` : '?'}token=${sessionStorage.getItem('token')}&nakadai=1` } else { - url += `#/myReview?token=${sessionStorage.getItem('token')}` + url += `#/myReview?token=${sessionStorage.getItem('token')}&nakadai=1` } url += `&v=${Date.now()}` localStorage.setItem('review_token', sessionStorage.getItem('token'))