From 87ab0641ce583cba5f87e11b592b41164bc6a968 Mon Sep 17 00:00:00 2001 From: yujialong <479214531@qq.com> Date: Mon, 11 Jul 2022 18:04:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AF=BE=E7=A8=8B=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/utils/api.js | 1 + src/views/course/AddCurriculum.vue | 336 ++++++++++++++++--------- src/views/match/list/index.vue | 21 ++ src/views/match/manage/matchSignup.vue | 2 + 4 files changed, 242 insertions(+), 118 deletions(-) diff --git a/src/utils/api.js b/src/utils/api.js index 22639f8..63fd01b 100644 --- a/src/utils/api.js +++ b/src/utils/api.js @@ -253,6 +253,7 @@ export default { saveAnnex: `occupationlab/occupationlab/contest/annex/save`, getSchoolsByProvince: `nakadai/nakadai/school/getSchoolsByProvince`, disabledEvents: `occupationlab/occupationlab/enterprise/match/contest/disabledEvents`, + batchDeleteContest: `occupationlab/occupationlab/enterprise/match/contest/batchDeleteContest`, // 竞赛进展 addContestProgress: `occupationlab/occupationlab/enterprise/match/contest-progress/addContestProgress`, diff --git a/src/views/course/AddCurriculum.vue b/src/views/course/AddCurriculum.vue index b3a8197..3f579b4 100644 --- a/src/views/course/AddCurriculum.vue +++ b/src/views/course/AddCurriculum.vue @@ -187,7 +187,7 @@ @@ -237,7 +237,7 @@ @@ -268,19 +268,19 @@ - +
-
+

系统列表
- +
  • - -
    + +
    {{ item.systemName }}
    @@ -288,24 +288,46 @@
-
+

项目列表
- +
    -
  • - -
    - {{ item.systemName }} - -
    +
  • +
+
+
+

+ 已选择项目({{ checkeds.length }}个) +
+ + + + + + + + + + + + + + +
@@ -400,11 +422,10 @@ export default { 0: "运行中", 1: "默认" }, - systems: [], pageNo: 1, pageSize: 10, multipleSelection: [], - configSearch: "", + systemKeyword: "", searchTimer: null, configVisible: false,// 配置弹框 @@ -419,8 +440,15 @@ export default { submiting: false, // 新增编辑防抖标识 loadIns: null, updateTime: 0, + systemAll: [], systems: [], - systemChecked: [] + systemChecked: [], + projects: [], + projectAll: [], + projectKeyword: '', + checkedKeyword: '', + checkeds: [], + checkedAll: [] }; }, watch: { @@ -431,46 +459,34 @@ export default { }, deep:true }, - configSearch: function(val) { + systemKeyword: function(val) { + clearTimeout(this.searchTimer); + this.searchTimer = setTimeout(() => { + this.getConfig(); + }, 500); + }, + projectKeyword: function(val) { clearTimeout(this.searchTimer); this.searchTimer = setTimeout(() => { - this.initData(); + this.filterProject(); + }, 500); + }, + checkedKeyword: function(val) { + clearTimeout(this.searchTimer); + this.searchTimer = setTimeout(() => { + this.filterChecked(); }, 500); } }, created() { - this.getSubject(); - this.getConfig(); + }, mounted() { - // 详情 - if (this.form.cid) { - this.getInfoData(); - } - // this.getSystems() + this.getSubject() + this.getConfig() + this.form.cid && this.getInfoData() }, methods: { - goback() { - const id = this.form.cid - const updateTime = this.updateTime - // 更改了信息才需要提示 - if ((id && updateTime > 1) || (!id && updateTime)) { - this.$confirm(`编辑的内容未保存,是否保存?`, '提示', { - type: 'warning' - }).then(() => { - this.saveAdd(1) - }).catch(() => { - this.backPage() - }) - } else { - this.backPage() - } - }, - // 返回上一页 - backPage() { - this.$router.back() - this.loadIns.close() - }, getInfoData() { this.$post(`${this.api.curriculumDetail}?cid=${this.form.cid}`).then(res => { let { data } = res; @@ -575,82 +591,127 @@ export default { }).catch(err => { }); }, - - handleConfig(type) { // 弹窗 + // 练习考核弹框 + handleConfig(type) { this.permissions = type; this.configVisible = true; this.pageNo = 1; this.getConfig(); - }, - getConfig() { // 获取配置 - let data = { - systemName: this.configSearch, - pageNum: this.pageNo, - pageSize: this.pageSize - }; - this.$post(this.api.queryServiceConfig, data).then(res => { - this.systems = res.serviceList.records; - }).catch(err => { - }); - }, - practiceSelectable(row, index) { // 禁止勾选已经选过的系统 - let boolean = true; - if (this.permissions) { - this.assessmentData.length && this.assessmentData.some(e => { - if (e.systemId == row.systemId) { - boolean = false; - } - }); + this.checkeds = JSON.parse(JSON.stringify(type ? this.assessmentData : this.practiceData)) + }, + // 获取系统 + getConfig() { + const checked = this.permissions ? this.assessmentData : this.practiceData + this.$post(this.api.queryServiceConfig, { + systemName: this.systemKeyword, + pageNum: 1, + pageSize: 1000 + }).then(res => { + const list = res.serviceList.records + this.systemAll = JSON.parse(JSON.stringify(list)) // 全部系统,另外保存 + const result = [] + list.map(e => { + // 如果选中的项目里有该系统的项目,则隐藏 + if (!checked.find(n => n.systemId == e.systemId)) { + e.check = false + result.push(e) + } + }) + this.systems = result + list.length && this.getProject(result[0]) + }).catch(err => {}) + }, + // 获取项目列表 + getProject(item) { + const { check } = item // 项目选中状态跟随系统 + const checked = this.permissions ? this.assessmentData : this.practiceData + 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 => { + // 如果选择了该项目,则隐藏 + if (!checked.find(n => n.projectId == e.projectId && n.systemId == e.systemId)) { + e.type = item.type ? '流程类' : '编程类' + e.check = check + result.push(e) + } + }) + this.projects = result + }).catch(err => {}) + }, + // 项目模糊查询 + filterProject() { + const val = this.projectKeyword + this.projects = this.projectAll.filter(e => e.projectName.includes(val)) + }, + // 系统选择回调 + systemChange(val, item) { + // 项目列表选中状态同步 + const { projects, checkeds } = this + if (projects.length && projects[0].systemId == item.systemId) { + projects.map(e => e.check = val) + } + this.projectKeyword = '' + this.$get(`${this.api.getInternalProjectBySystemId}?permissions=${this.permissions}&systemId=${item.systemId}`).then(res => { + if (val) { + res.map(e => e.type = item.type ? '流程类' : '编程类') + checkeds.push(...res) } else { - this.practiceData.length && this.practiceData.some(e => { - if (e.systemId == row.systemId) { - boolean = false; - } - }); + res.map(e => { + const i = checkeds.findIndex(n => n.projectId == e.projectId && n.systemId == e.systemId) + i === -1 || checkeds.splice(i, 1) + }) } - return boolean; - }, - initData() { - this.$refs.table.clearSelection(); - this.pageNo = 1; - this.getConfig(); - }, - handleSelectionChange(val) { // 系统-多选操作 - this.multipleSelection = val; - }, - handleCurrentChange(val) { // 系统-切换分页 - this.pageNo = val; - this.getConfig(); - }, - handleConfirm() { // 确认系统 - const list = this.multipleSelection - if (!list.length) { - this.$message.warning("请选择系统!"); - return; - } else if (list.find(e => !e.type) && list.find(e => e.type === 1)) { - return this.$message.warning('请勿同时选择编程类和流程类的系统!') + this.checkedAll = JSON.parse(JSON.stringify(checkeds)) // 全部已选项目,另外保存 + }).catch(err => {}) + }, + // 项目选择回调 + projectChange(val, item) { + const { systemId } = item + const i = this.checkeds.findIndex(e => e.projectId == item.projectId && e.systemId == systemId) + // 选中,则push,否则移除 + if (val) { + this.checkeds.push(item) + } else if (i !== -1) { + this.systems.map(e => { + if (e.systemId == systemId) e.check = false + }) + this.checkeds.splice(i, 1) + } + this.checkedAll = JSON.parse(JSON.stringify(this.checkeds)) // 全部已选项目,另外保存 + }, + // 已选择项目模糊查询 + filterChecked() { + const val = this.checkedKeyword + this.checkeds = this.checkedAll.filter(e => e.projectName.includes(val)) + }, + // 删除已选项目 + delProject(i) { + this.$confirm("确定要删除吗?", "提示", { + type: "warning" + }).then(() => { + this.checkeds.splice(i, 1) + }).catch(() => {}) + }, + // 确认系统 + handleConfirm() { + const list = this.checkeds + if (!list.length) { + this.$message.warning("请选择系统!"); + } else { + this.configVisible = false + list.map((e, i) => { + e.isShow = 0; // isShow是否展示(默认0:展示 1:不展示) + e.sort = i + 1; // 排序 + }); + if (this.permissions) { + this.assessmentData = JSON.parse(JSON.stringify(list)) + this.assessmentTotal = this.assessmentData.length; } else { - this.getConfigData(); - this.configVisible = false; + this.practiceData = JSON.parse(JSON.stringify(list)) + this.practiceTotal = this.practiceData.length; } - }, - getConfigData() { // 查询实训配置 - let ids = this.multipleSelection.map(i => i.systemId); - this.$get(`${this.api.getInternalProjectBySystemId}?permissions=${this.permissions}&systemId=${ids.toString()}`).then((res) => { - let data = res.map((e, i) => { - e.isShow = 0; // isShow是否展示(默认0:展示 1:不展示) - e.sort = i + 1; // 排序 - return e; - }); - if (this.permissions) { - this.assessmentData.push(...data) - this.assessmentTotal = this.assessmentData.length; - } else { - this.practiceData.push(...data) - this.practiceTotal = this.practiceData.length; - } - }).catch(err => { - }); + } }, practiceSortChange(row, index) { // 处理排序 this.practiceData.splice(index, 1, row); @@ -794,6 +855,27 @@ export default { return false; } }); + }, + goback() { + const id = this.form.cid + const updateTime = this.updateTime + // 更改了信息才需要提示 + if ((id && updateTime > 1) || (!id && updateTime)) { + this.$confirm(`编辑的内容未保存,是否保存?`, '提示', { + type: 'warning' + }).then(() => { + this.saveAdd(1) + }).catch(() => { + this.backPage() + }) + } else { + this.backPage() + } + }, + // 返回上一页 + backPage() { + this.$router.back() + this.loadIns.close() } } }; @@ -881,10 +963,15 @@ $avatar-width: 104px; .title-wrap { margin-bottom: 15px; } + .item { + max-height: 600px; + margin-right: 20px; + overflow: auto; + } .system { width: 280px; - padding-right: 20px; - // border-right: 1px solid #ccc; + padding: 10px; + background-color: #f9f9f9; } .systems { margin-top: 10px; @@ -905,5 +992,18 @@ $avatar-width: 104px; } } } + .project { + width: 350px; + } + .checked { + flex: 1; + } + .rm { + font-size: 14px; + cursor: pointer; + &:hover { + color: #9076FF; + } + } } \ No newline at end of file diff --git a/src/views/match/list/index.vue b/src/views/match/list/index.vue index b2555c4..c0e7b17 100644 --- a/src/views/match/list/index.vue +++ b/src/views/match/list/index.vue @@ -41,10 +41,12 @@
创建竞赛 + 批量删除
+