From 4a10986a2f4cbe761062829eea016f71dd953df2 Mon Sep 17 00:00:00 2001 From: e <2432808546@qq.com> Date: Sat, 9 Oct 2021 16:34:50 +0800 Subject: [PATCH] =?UTF-8?q?=E6=95=99=E5=B8=88=E7=AB=AF=E8=81=8C=E7=AB=99?= =?UTF-8?q?=E5=AE=9E=E9=AA=8C=E9=A1=B9=E7=9B=AE=E7=AE=A1=E7=90=86=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E5=AE=8C=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 6 +- package.json | 1 + src/api/index.js | 11 +- src/pages/project/add/index.vue | 284 ++++++++++++++++++++++---------- 4 files changed, 209 insertions(+), 93 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1436688..3bac6d9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11394,9 +11394,9 @@ } }, "sortablejs": { - "version": "1.10.1", - "resolved": "https://registry.npmjs.org/sortablejs/-/sortablejs-1.10.1.tgz", - "integrity": "sha512-N6r7GrVmO8RW1rn0cTdvK3JR0BcqecAJ0PmYMCL3ZuqTH3pY+9QyqkmJSkkLyyDvd+AJnwaxTP22Ybr/83V9hQ==" + "version": "1.14.0", + "resolved": "https://registry.nlark.com/sortablejs/download/sortablejs-1.14.0.tgz", + "integrity": "sha1-bS4XzL2yX0ZHNN9iHU811Ks1s9g=" }, "source-list-map": { "version": "2.0.1", diff --git a/package.json b/package.json index b47557d..eb0a836 100644 --- a/package.json +++ b/package.json @@ -17,6 +17,7 @@ "mavon-editor": "^2.6.17", "postcss-px2rem": "^0.3.0", "px2rem-loader": "^0.1.9", + "sortablejs": "^1.14.0", "vue": "^2.6.10", "vue-cropperjs": "^3.0.0", "vue-i18n": "^8.10.0", diff --git a/src/api/index.js b/src/api/index.js index befa64e..59352c8 100644 --- a/src/api/index.js +++ b/src/api/index.js @@ -1,7 +1,7 @@ import Setting from "@/setting"; // let host = Setting.apiBaseURL -let host = "http://192.168.31.151:9000/"; // 榕 -// let host = 'http://192.168.31.125:9000/'; // 坤 +// let host = "http://192.168.31.151:9000/"; // 榕 +let host = 'http://192.168.31.125:9000/'; // 坤 let xsHost = "http://39.108.250.202:9000/"; // 线上 @@ -84,10 +84,17 @@ export default { addProjectManage: `${host}occupationlab/projectManage/addProjectManage`, // 新增项目管理 updateProjectManage: `${host}occupationlab/projectManage/updateProjectManage`, // 修改项目管理 copyProjectManage: `${host}occupationlab/projectManage/copyProjectManage`, // 复制项目管理 + // 判分点 getBcJudgmentPoint: `${host}judgment/bcJudgmentPoint/getBcJudgmentPoint`, // 获取编程类判分点列表(分页) getLcJudgmentPoint: `${host}judgment/lcJudgmentPoint/queryAllJudgmentPoint`, // 获取流程类判分点列表(分页) + addProjectJudgment: `${host}occupationlab/projectJudgment/addProjectJudgment`, // 添加项目管理、判分点中间表 + updateProjectJudgment: `${host}occupationlab/projectJudgment/updateProjectJudgment`, // 判分点中间表批量更新 + deleteProjectJudgment: `${host}occupationlab/projectJudgment/deleteProjectJudgment`, // 判分点中间表批量删除 + + + // 赛事管理 addContest: `${host}occupationlab/enterprise/match/contest/addContest`, diff --git a/src/pages/project/add/index.vue b/src/pages/project/add/index.vue index 1b76356..a4ac9c8 100644 --- a/src/pages/project/add/index.vue +++ b/src/pages/project/add/index.vue @@ -75,7 +75,6 @@
项目总分值:100分
-
平均分配分值 手动分配分值 @@ -84,61 +83,43 @@
判分点 批量删除 - - - - - - - - - - - - - - - - - - - - +
+ + + + + + + + + + + + + + + + + +
@@ -160,13 +141,12 @@ - +
- { + e.sort = i+1 + }) } else { util.warningMsg(res.message); } @@ -410,7 +395,8 @@ export default { let obj = { projectId: this.projectId ? this.projectId : "", judgmentId: i.judgmentId, - score: i.score + score: i.score, + sort:i.sort }; return obj; }); @@ -475,24 +461,28 @@ export default { }); } }, - handleMoveUp(index) { // 处理上移 - let x = index; - let y = index + 1; - this.projectJudgmentData.splice(x - 1, 1, ...this.projectJudgmentData.splice(y - 1, 1, this.projectJudgmentData[x - 1])); - }, - handleMoveDown(index) { // 处理下移 - let x = index + 1; - let y = index + 2; - this.projectJudgmentData.splice(x - 1, 1, ...this.projectJudgmentData.splice(y - 1, 1, this.projectJudgmentData[x - 1])); - }, - scoreChange(row, index) { // 暂时解决,输入分数,页面没有更新 + // handleMoveUp(index) { // 处理上移 + // let x = index; + // let y = index + 1; + // this.projectJudgmentData.splice(x - 1, 1, ...this.projectJudgmentData.splice(y - 1, 1, this.projectJudgmentData[x - 1])); + // }, + // handleMoveDown(index) { // 处理下移 + // let x = index + 1; + // let y = index + 2; + // this.projectJudgmentData.splice(x - 1, 1, ...this.projectJudgmentData.splice(y - 1, 1, this.projectJudgmentData[x - 1])); + // }, + scoreChange(row, index,val) { // 暂时解决,输入分数,页面没有更新 this.projectJudgmentData.splice(index, 1, row); }, delJudgePoint(index) { // 删除判分点 this.$confirm("确定要删除吗?", "提示", { type: "warning" }).then(() => { - this.projectJudgmentData.splice(index, 1); + if(this.projectId){ + this.deleteProjectJudgment([this.projectJudgmentData[index].id]) + }else{ + this.projectJudgmentData.splice(index, 1); + } }).catch(() => { }); }, @@ -505,12 +495,17 @@ export default { type: "warning" }).then(() => { // this.projectJudgmentData.splice(index, 1); - let list = this.projectJudgmentData; - let result = []; - list.map(i => { - this.selectedProjectJudgment.find(j => j.judgmentId === i.judgmentId) || result.push(i); - }); - this.projectJudgmentData = result; + if(this.projectId){// 编辑项目的时候 + let param = this.selectedProjectJudgment.map(e=>e.id) + this.deleteProjectJudgment(param)// 调删除接口 + }else{ + let list = this.projectJudgmentData; + let result = []; + list.map(i => { + this.selectedProjectJudgment.find(j => j.judgmentId === i.judgmentId) || result.push(i); + }); + this.projectJudgmentData = result; + } }).catch(() => { }); } else { @@ -542,6 +537,7 @@ export default { } }, getProcessClassData(params) { // 获取流程类判分点列表数据 + this.visibleLoading = true this.$post(`${this.api.getLcJudgmentPoint}`, params).then(res => { if (res.status === 200) { let list = res.message.records; @@ -550,6 +546,7 @@ export default { i.judgmentId = i.lcId; this.projectJudgmentData.find(j => j.judgmentId === i.judgmentId) || result.push(i); }); + this.visibleLoading = false this.judgementData = result; } }).catch(err => { @@ -557,6 +554,7 @@ export default { }); }, getProgrammingClassData(params) { // 获取编程类判分点列表数据 + this.visibleLoading = true this.$post(this.api.getBcJudgmentPoint, params).then(res => { if (res.status === 200) { let list = res.message.records; @@ -565,7 +563,10 @@ export default { i.judgmentId = i.bcId; this.projectJudgmentData.find(j => j.judgmentId === i.judgmentId) || result.push(i); }); + this.visibleLoading = false this.judgementData = result; + console.log(res,'res') + console.log(this.projectJudgmentData,'projectJudgmentData') } }).catch(err => { @@ -577,15 +578,24 @@ export default { }, addJudgment() { // 确认选择判分点 if (this.selectedJudgment.length) { + console.log(this.selectedJudgment,'queren') this.dialogVisible = false; - let tempArr = this.selectedJudgment.map(i => { - i.score = 0; - return i; - }); - this.projectJudgmentData = this.projectJudgmentData.concat(tempArr); - this.$nextTick(() => { - this.$refs.projectJudgementTable.clearSelection(); - }); + if(this.projectId){ // 编辑的时候,新增调接口 + this.addProjectJudgment() + }else{ + // 新增时,假添加 + let tempArr = this.selectedJudgment.map(i => { + i.score = 0; + return i; + }); + this.projectJudgmentData = this.projectJudgmentData.concat(tempArr); + this.projectJudgmentData.map((e,i)=>{ + e.sort = i+1 + }) + this.$nextTick(() => { + this.$refs.projectJudgementTable.clearSelection(); + }); + } } else { util.warningMsg("请选择判分点"); } @@ -635,7 +645,105 @@ export default { } } location.href = href; - } + }, + // 行拖拽 + rowDrop() { + // 此时找到的元素是要拖拽元素的父容器 + const tbody = document.querySelector('.draggable .el-table__body-wrapper tbody'); + const _this = this; + Sortable.create(tbody, { + // 指定父元素下可被拖拽的子元素 + draggable: ".draggable .el-table__row", + onEnd({newIndex, oldIndex}) { + let newItem = _this.projectJudgmentData[newIndex] + _this.projectJudgmentData[newIndex] = _this.projectJudgmentData[oldIndex] + _this.projectJudgmentData[oldIndex] = newItem + // 循环,重新赋值排序赋值 + _this.projectJudgmentData.forEach((e,i)=>{ + _this.$set(e,'sort',i+1)// 不更新 + _this.$set(e,'name',e.name+"?") + _this.$set(e,'name',e.name.slice(0,e.name.length-1)) // 不更新的解决方案 + }) + // 调修改接口,更新列表 + if(_this.projectId){// 如果是编辑项目,则调编辑接口 + _this.updateProjectJudgment() + } + } + }); + }, + // 添加判分点中间表 + addProjectJudgment(){ + let param = this.selectedJudgment.map((e,i)=>{ + let obj = { + judgmentId:e.judgmentId, + projectId:this.projectId||'', + score:0, + sort:i+1 + } + return obj + }) + console.log(param,'param',this.projectId,) + this.$post(this.api.addProjectJudgment,param).then(res => { + // 重新调接口 + console.log('添加成功',res) + if(this.projectId){ // 有项目id,调接口,没有项目id,手动更新 + this.listAgain() + } + }).catch(err => { + console.log(err); + }); + + }, + // 修改判分点中间表 + updateProjectJudgment(){ + // 直接传data回去 + let param = this.projectJudgmentData.map((e,i)=>{ + let obj = { + judgmentId:e.judgmentId, + projectId:this.projectId||'', + score:0, + sort:i+1, + id:e.id + } + return obj + }) + this.$post(this.api.updateProjectJudgment, param).then(res => { + + // 重新调接口 + if(this.projectId){ // 有项目id,调接口,没有项目id,手动更新 + this.listAgain() + } + }).catch(err => { + console.log(err); + }); + }, + // 批量删除判分点中间表 + deleteProjectJudgment(values){ + if(values&&values.length>0){ + this.$post(this.api.deleteProjectJudgment+"?projectJudgmentIds="+`${values}`).then(res => { + + // 重新调接口 + if(this.projectId){ // 有项目id,调接口,没有项目id,手动更新 + this.listAgain() + } + }).catch(err => { + + }); + } + }, + // 重新调接口,专门赋值列表 + listAgain(){ + this.$get(`${this.api.getProjectDetail}?projectId=${this.projectId}`).then(res => { + let { projectManage, projectJudgmentVos } = res; + this.projectJudgmentData = projectJudgmentVos; + this.projectJudgmentData.map((e,i)=>{ + e.sort = i+1 + }) + }) + }, + + + } };