更新判分点中间表接口添加projectId参数

dev
yujialong 3 years ago
parent 29180b5c69
commit 51f5c50b5e
  1. 30
      src/utils/util.js
  2. 131
      src/views/serve/projectAdd.vue

@ -0,0 +1,30 @@
const util = {
deepCopy(obj) { // 深拷贝
if (obj == null) {
return null;
}
if (typeof obj !== "object") return obj;
let result;
if (Array.isArray(obj)) {
result = [];
obj.forEach(item => {
result.push(
typeof item === "object" && !(item instanceof Date)
? util.deepCopy(item)
: item
);
});
} else {
result = {};
Object.keys(obj).forEach(key => {
result[key] =
typeof obj[key] === "object" && !(obj[key] instanceof Date)
? util.deepCopy(obj[key])
: obj[key];
});
}
return result;
}
};
export default util;

@ -143,9 +143,8 @@
</el-table-column> </el-table-column>
<el-table-column prop="score" label="分数" align="center" width="120"> <el-table-column prop="score" label="分数" align="center" width="120">
<template slot-scope="scope"> <template slot-scope="scope">
<!--type="number"--> <!--type="number" @blur="updateProjectJudgment"-->
<el-input :disabled="isDetail" v-model.trim="scope.row.score" <el-input :disabled="isDetail" v-model.trim="scope.row.score"
@blur="updateProjectJudgment"
@input="scoreChange(scope.row, scope.$index,$event)"></el-input> @input="scoreChange(scope.row, scope.$index,$event)"></el-input>
</template> </template>
</el-table-column> </el-table-column>
@ -429,6 +428,19 @@ export default {
} }
this.$store.dispatch("setSystemId", this.projectManage.systemId); this.$store.dispatch("setSystemId", this.projectManage.systemId);
this.projectManage.state = state; this.projectManage.state = state;
let { systemId } = this.projectManage;
if (this.projectId) {
if (systemId == 2 || systemId == 3) {
console.log("系统id:", systemId);
} else {
//
this.updateProjectJudgment();
}
} else {
if (systemId == 2 || systemId == 3) {
console.log("系统id:", systemId);
} else {
//
let tempArr = this.projectJudgmentData.map(i => { let tempArr = this.projectJudgmentData.map(i => {
let obj = { let obj = {
projectId: this.projectId ? this.projectId : "", projectId: this.projectId ? this.projectId : "",
@ -443,20 +455,6 @@ export default {
projectManage: this.projectManage, projectManage: this.projectManage,
projectJudgmentList: tempArr projectJudgmentList: tempArr
}; };
let { systemId } = this.projectManage;
if (this.projectId) {
if (systemId == 2 || systemId == 3) {
console.log("系统id:", systemId);
} else {
//
this.updateProject(params);
}
} else {
if (systemId == 2 || systemId == 3) {
console.log("系统id:", systemId);
} else {
//
this.addProject(params); this.addProject(params);
} }
} }
@ -495,6 +493,7 @@ export default {
item.score = res.data[index]; item.score = res.data[index];
return item; return item;
}); });
// this.updateProjectJudgment();
} }
}); });
} }
@ -613,10 +612,6 @@ export default {
if (this.selectedJudgment.length) { if (this.selectedJudgment.length) {
this.judgementpointsquery = ""; this.judgementpointsquery = "";
this.dialogVisible = false; this.dialogVisible = false;
if (this.projectId) { //
this.addProjectJudgment();
} else {
//
let tempArr = this.selectedJudgment.map(i => { let tempArr = this.selectedJudgment.map(i => {
i.score = 0; i.score = 0;
return i; return i;
@ -628,7 +623,6 @@ export default {
this.$nextTick(() => { this.$nextTick(() => {
this.$refs.projectJudgementTable.clearSelection(); this.$refs.projectJudgementTable.clearSelection();
}); });
}
} else { } else {
this.$message.warning("请选择判分点"); this.$message.warning("请选择判分点");
} }
@ -642,48 +636,23 @@ export default {
// //
draggable: ".draggable .el-table__row", draggable: ".draggable .el-table__row",
onEnd({ newIndex, oldIndex }) { onEnd({ newIndex, oldIndex }) {
let newItem = _this.projectJudgmentData[newIndex]; // : vue$nextTick
_this.projectJudgmentData[newIndex] = _this.projectJudgmentData[oldIndex]; _this.projectJudgmentData.splice(newIndex, 0, _this.projectJudgmentData.splice(oldIndex, 1)[0]);
_this.projectJudgmentData[oldIndex] = newItem; let newArray = _this.projectJudgmentData.slice(0);
// _this.projectJudgmentData = [];
_this.projectJudgmentData.forEach((e, i) => { _this.$nextTick(function () {
newArray.forEach((e, i) => {
_this.$set(e, "sort", i + 1);// _this.$set(e, "sort", i + 1);//
_this.$set(e, "name", e.name + "?"); _this.$set(e, "name", e.name + "?");
_this.$set(e, "name", e.name.slice(0, e.name.length - 1)); // _this.$set(e, "name", e.name.slice(0, e.name.length - 1)); //
}); });
// _this.projectJudgmentData = newArray;
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) { // idid
this.listAgain();
} }
}).catch(err => {
console.log(err);
}); });
}, },
// //
updateProjectJudgment() { async updateProjectJudgment() {
// data
let param = this.projectJudgmentData.map((e, i) => { let param = this.projectJudgmentData.map((e, i) => {
let obj = { let obj = {
judgmentId: e.judgmentId, judgmentId: e.judgmentId,
@ -694,48 +663,24 @@ export default {
}; };
return obj; return obj;
}); });
this.$post(this.api.updateProjectJudgment, param).then(res => { await this.$post(`${this.api.updateProjectJudgment}?projectId=${this.projectId}`, param).then(res => {
let tempArr = this.projectJudgmentData.map(i => {
// let obj = {
if (this.projectId) { // idid projectId: this.projectId ? this.projectId : "",
this.listAgain(); judgmentId: i.judgmentId,
} score: i.score,
}).catch(err => { sort: i.sort
console.log(err); };
return obj;
}); });
}, let params = {
// projectManage: this.projectManage,
deleteProjectJudgment(values) { projectJudgmentList: tempArr
if (values && values.length > 0) { };
this.$post(this.api.deleteProjectJudgment + "?projectJudgmentIds=" + `${values}`).then(res => { this.updateProject(params);
//
if (this.projectId) { // idid
this.listAgain();
}
}).catch(err => { }).catch(err => {
console.log(err);
});
}
},
// ,
listAgain() {
this.listLoading = true
let scrollTop = this.$refs.main.scrollTop
this.projectJudgmentData = []
this.$refs.main.scrollTop = scrollTop
this.$get(`${this.api.getProjectDetail}?projectId=${this.projectId}`).then(res => {
let { projectManage, projectJudgmentVos } = res;
projectJudgmentVos.map((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)) //
}); });
this.projectJudgmentData = projectJudgmentVos;
this.listLoading = false
}).catch(()=>{
this.listLoading = false
})
}, },
handleCacheData() { // handleCacheData() { //
this.isToPoint = true; this.isToPoint = true;

Loading…
Cancel
Save