fix: 项目电价合同 阶梯计价 渲染问题

This commit is contained in:
nieli 2022-11-28 11:46:33 +08:00
parent 6c9a1f83c2
commit 64f8a09543
2 changed files with 19 additions and 26 deletions

View File

@ -164,11 +164,11 @@
<el-form-item label="合同规则:" prop> <el-form-item label="合同规则:" prop>
<el-button size="mini" type="primary" @click="handelAddRule">添加规则</el-button> <el-button size="mini" type="primary" @click="handelAddRule">添加规则</el-button>
<div class="contract-gz-wrap" v-for="(item, index) in form.priceContractRuleList" :key="item.guid"> <div class="contract-gz-wrap" v-for="(item, index) in form.priceContractRuleList" :key="item.ruleId">
<time-picker-wrap <time-picker-wrap
:priceList="item" :priceList="item"
:contractType="form.contractType" :contractType="form.contractType"
:tempIndex="item.guid" :tempIndex="item.ruleId"
:delshow="form.priceContractRuleList.length >= 2" :delshow="form.priceContractRuleList.length >= 2"
:nodeMaxTime="returnMinTime(index)" :nodeMaxTime="returnMinTime(index)"
:nodeMaxVal="returnMaxVal(index)" :nodeMaxVal="returnMaxVal(index)"
@ -297,8 +297,9 @@ export default {
return row.status === "0" ? "启用" : "禁用"; return row.status === "0" ? "启用" : "禁用";
}, },
resultEvent(data) { resultEvent(data) {
console.log('resultEvent--', JSON.stringify(data))
for (var i = 0; i < this.form.priceContractRuleList.length; i++) { for (var i = 0; i < this.form.priceContractRuleList.length; i++) {
if (this.form.priceContractRuleList[i]["guid"] === data.index) { if (this.form.priceContractRuleList[i]["ruleId"] === data.index) {
this.form.priceContractRuleList[i] = data.result; this.form.priceContractRuleList[i] = data.result;
this.$forceUpdate(); this.$forceUpdate();
} }
@ -320,7 +321,7 @@ export default {
}, },
delEvent(data) { delEvent(data) {
for (var i = 0; i < this.form.priceContractRuleList.length; i++) { for (var i = 0; i < this.form.priceContractRuleList.length; i++) {
if (this.form.priceContractRuleList[i]["guid"] === data.index) { if (this.form.priceContractRuleList[i]["ruleId"] === data.index) {
this.form.priceContractRuleList.splice(i, 1); this.form.priceContractRuleList.splice(i, 1);
this.$forceUpdate(); this.$forceUpdate();
break; break;
@ -336,7 +337,7 @@ export default {
ruleName: "", ruleName: "",
ruleNum: null, ruleNum: null,
unitPrice: "", unitPrice: "",
guid: this.getGuid() ruleId: this.getGuid()
}); });
}, },
contractTypeChange(val) { contractTypeChange(val) {
@ -349,7 +350,7 @@ export default {
ruleName: "", ruleName: "",
ruleNum: null, ruleNum: null,
unitPrice: "", unitPrice: "",
guid: this.getGuid() ruleId: this.getGuid()
}); });
}, },
indexFormatter(val) { indexFormatter(val) {
@ -415,7 +416,7 @@ export default {
ruleName: "", ruleName: "",
ruleNum: null, ruleNum: null,
unitPrice: "", unitPrice: "",
guid: this.getGuid() ruleId: this.getGuid()
}); });
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
@ -424,14 +425,10 @@ export default {
const contractId = row.contractId || this.ids; const contractId = row.contractId || this.ids;
getContract(contractId).then(response => { getContract(contractId).then(response => {
this.form = response.data; this.form = response.data;
var arr = [];
response.data.priceContractRuleList.forEach(v => {
arr.push(Object.assign(v, { guid: this.getGuid() }));
});
this.form.priceContractRuleList = arr || [];
this.open = true; this.open = true;
this.tempType = 'update' this.tempType = 'update'
this.title = "修改电价合同"; this.title = "修改电价合同";
this.$forceUpdate();
}); });
}, },
handleDestail(row) { handleDestail(row) {
@ -439,11 +436,6 @@ export default {
const contractId = row.contractId || this.ids; const contractId = row.contractId || this.ids;
getContract(contractId).then(response => { getContract(contractId).then(response => {
this.form = response.data; this.form = response.data;
var arr = [];
response.data.priceContractRuleList.forEach(v => {
arr.push(Object.assign(v, { guid: this.getGuid() }));
});
this.form.priceContractRuleList = arr || [];
this.tempType = 'destail' this.tempType = 'destail'
this.open = true; this.open = true;
this.title = "电价合同详情"; this.title = "电价合同详情";

View File

@ -34,7 +34,6 @@
v-model="form.maxVal" v-model="form.maxVal"
:precision="2" :precision="2"
class="form-input" class="form-input"
:min="form.minVal"
label="最大值" label="最大值"
></el-input-number> ></el-input-number>
</el-col> </el-col>
@ -88,7 +87,7 @@ export default {
created() { created() {
this.form = this.priceList; this.form = this.priceList;
if (this.contractType === "LADDER") { if (this.contractType === "LADDER") {
this.valSet(this.nodeMaxVal); this.handleUpdateValue(this.nodeMaxVal);
} else { } else {
this.timtSet(this.nodeMaxTime); this.timtSet(this.nodeMaxTime);
} }
@ -96,13 +95,13 @@ export default {
watch: { watch: {
form: { form: {
handler(val, oldVal) { handler(val, oldVal) {
this.reultEventFu();
if ( if (
this.contractType === "LADDER" && this.contractType === "LADDER" &&
this.form.minVal >= this.form.maxVal this.form.minVal >= this.form.maxVal
) { ) {
this.form.maxVal = this.form.minVal; this.form.maxVal = this.form.minVal;
} }
this.reultEventFu();
}, },
deep: true deep: true
}, },
@ -113,13 +112,13 @@ export default {
}, },
nodeMaxVal(val) { nodeMaxVal(val) {
if (val || val === 0) { if (val || val === 0) {
this.valSet(val); this.handleUpdateValue(val);
} }
}, },
contractType(val) { contractType(val) {
this.form = this.priceList; this.form = this.priceList;
if (val === "LADDER") { if (val === "LADDER") {
this.valSet(this.nodeMaxVal); this.handleUpdateValue(this.nodeMaxVal);
} else { } else {
this.timtSet(this.nodeMaxTime); this.timtSet(this.nodeMaxTime);
} }
@ -140,11 +139,13 @@ export default {
this.times = [this.form.minTime, this.form.maxTime]; this.times = [this.form.minTime, this.form.maxTime];
this.$forceUpdate(); this.$forceUpdate();
}, },
valSet(val) { handleUpdateValue(val) {
this.form.minVal = this.priceList.minVal || 0; this.form.minVal = this.priceList.minVal || 0;
if (val === "" || val === 0) { this.form.maxVal = this.priceList.maxVal
this.form.minVal = 0; if ((val === "" || val === 0)) {
this.form.maxVal = this.form.minVal + 1; this.form.minVal = this.priceList.minVal || 0;
this.form.maxVal = this.priceList.maxVal || this.form.minVal + 1;
} else { } else {
this.form.minVal = val; this.form.minVal = val;
if (this.form.minVal >= this.form.maxVal) { if (this.form.minVal >= this.form.maxVal) {