py项目增加上下且或判断

master
e 3 years ago
parent 4719526a71
commit cb81102b53
  1. 126
      src/views/Program.vue
  2. 47
      src/views/Transaction.vue

@ -71,7 +71,7 @@
> >
<el-table-column prop="id" type="index" label="序号" width="80"></el-table-column> <el-table-column prop="id" type="index" label="序号" width="80"></el-table-column>
<el-table-column label="编译器中正确答案" align="center"> <el-table-column label="编译器中正确答案" align="center">
<template slot-scope="scope"> <template slot-scope="scope" v-if="scope.row.isSubject">
<p class="p">字段一致性规则用户编辑器中至少出现如下语句</p> <p class="p">字段一致性规则用户编辑器中至少出现如下语句</p>
<el-input <el-input
type="textarea" type="textarea"
@ -84,6 +84,7 @@
<el-table-column label=" " width="150"> <el-table-column label=" " width="150">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
v-if="scope.row.isSubject"
:disabled="isView || scope.row.isDisabled" :disabled="isView || scope.row.isDisabled"
type="primary" circle type="primary" circle
@click="changeResult(scope.row)" @click="changeResult(scope.row)"
@ -91,10 +92,13 @@
> >
{{ scope.row.withOr === 0 ? '且' : '或' }} {{ scope.row.withOr === 0 ? '且' : '或' }}
</el-button> </el-button>
<el-button v-else type="primary" circle @click="changeRule(scope.row, scope.$index)">
{{ scope.row.ruleOperation === 0 ? "且" : "或" }}
</el-button>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="终端中正确答案" align="center"> <el-table-column label="终端中正确答案" align="center">
<template slot-scope="scope"> <template slot-scope="scope" v-if="scope.row.isSubject">
<p class="p">运行结果一致性规则用户运行结果需要与下方代码运行结果一致</p> <p class="p">运行结果一致性规则用户运行结果需要与下方代码运行结果一致</p>
<el-input <el-input
type="textarea" type="textarea"
@ -105,7 +109,7 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" width="300" v-if="!isView"> <el-table-column label="操作" width="300" v-if="!isView">
<template slot-scope="scope"> <template slot-scope="scope" v-if="scope.row.isSubject">
<el-button v-show="scope.row.isDisabled" size="mini" type="text" @click="handleEdit(scope.row)">编辑</el-button> <el-button v-show="scope.row.isDisabled" size="mini" type="text" @click="handleEdit(scope.row)">编辑</el-button>
<el-button v-show="!scope.row.isDisabled" size="mini" type="text" @click="handleSave(scope.row)">保存</el-button> <el-button v-show="!scope.row.isDisabled" size="mini" type="text" @click="handleSave(scope.row)">保存</el-button>
<el-button v-show="!scope.row.isDisabled" size="mini" type="text" @click="handleCancel(scope.row, scope.$index)">取消</el-button> <el-button v-show="!scope.row.isDisabled" size="mini" type="text" @click="handleCancel(scope.row, scope.$index)">取消</el-button>
@ -178,14 +182,15 @@ export default {
bcJudgmentRuleList: judgmentRule bcJudgmentRuleList: judgmentRule
} }
// //
judgmentRule.forEach((item, index) => { this.anewPosttingData(judgmentRule)
this.tableData.push({ // judgmentRule.forEach((item, index) => {
...item, // this.tableData.push({
isSubject: true, // ...item,
isDisabled: true, // isSubject: true,
isSave: true // isDisabled: true,
}); // isSave: true
}) // });
// })
} else { } else {
this.$message.warning(res.message); this.$message.warning(res.message);
} }
@ -193,6 +198,49 @@ export default {
console.log(err) console.log(err)
}); });
}, },
//
anewPosttingData(judgmentRule){
let length = judgmentRule.length;
let tempArr = [];
judgmentRule.forEach((item, index) => {
let obj = {
...item,
isSubject: true,
isDisabled: true, //
isSave: true //
};
//(1 2 3 4 5)
if (item.type == 1 || item.type == 2) {
obj.subjectId = Number(item.emptyOne);
obj.value1 = item.itemId;
} else if (item.type == 3) {
obj.subjectId = Number(item.emptyOne);
obj.value1 = item.emptyTwo;
} else if (item.type == 4) {
// id
if (item.emptyOne === "无限制") {
obj.value1 = item.emptyOne;
obj.value2 = "";
} else {
obj.value1 = item.emptyOne.substring(0, item.emptyOne.indexOf(","));
obj.value2 = item.emptyOne.substring(item.emptyOne.indexOf(",") + 1, item.emptyOne.length);
}
obj.value3 = item.emptyTwo;
} else if (item.type == 5) {
obj.subjectId = Number(item.emptyOne);
obj.value2 = item.emptyTwo[0];
obj.value3 = item.emptyTwo.substring(1, item.emptyTwo.indexOf("~"));
obj.value4 = item.emptyTwo.substring(item.emptyTwo.indexOf("~") + 1, item.emptyTwo.length - 1);
obj.value5 = item.emptyTwo[item.emptyTwo.length - 1];
}
tempArr.push(obj);
if (length > 1 && index !== (length - 1)) {
tempArr.push({ruleOperation: item.ruleOperation});
}
this.tableData = tempArr;
console.log(this.tableData)
});
},
handleBlur() { // / handleBlur() { // /
if (this.formData.points.name) { if (this.formData.points.name) {
let params = { let params = {
@ -281,19 +329,53 @@ export default {
} }
}, },
addRule() { // addRule() { //
if(!this.isAddRule) {
this.isAddRule = true; this.isAddRule = true;
// this.tableData.length && this.tableData.push({ruleOperation: 0, indexNo: ""});
if (this.tableData.length > 0) {
this.tableData.push({ this.tableData.push({
ruleOperation: 0
}, {
indexNo: this.tableData.length + 1,
isSubject: true,
isDisabled: false, // isDisabled: false, //
isSave: false, // isSave: false, //
bcId: this.bcId, lcId: this.lcId,
required: "", resultOperation: 0,
result: "", ruleOperation: 0,
withOr: 0 operationIds: "",
value1: "",
value2: "",
value3: "",
value4: "",
value5: ""
});
} else {
this.tableData.push({
indexNo: this.tableData.length + 1,
isSubject: true,
isDisabled: false, //
isSave: false, //
lcId: this.lcId,
resultOperation: 0,
ruleOperation: 0,
operationIds: "",
value1: "",
value2: "",
value3: "",
value4: "",
value5: ""
}); });
}
}
}, },
changeResult(row) { // (0 1 0) changeResult(row) { // (0 1 0)
row.withOr = row.withOr === 0 ? 1 : 0; row.withOr = row.withOr === 0 ? 1 : 0;
}, },
changeRule(row, index) { // (0 1 0)
row.ruleOperation = row.ruleOperation === 0 ? 1 : 0;
this.tableData[index - 1].ruleOperation = row.ruleOperation;
},
handleEdit(row) { // handleEdit(row) { //
this.tableDataCopy = deepCopy(this.tableData); // this.tableDataCopy = deepCopy(this.tableData); //
row.isDisabled = false; row.isDisabled = false;
@ -315,7 +397,8 @@ export default {
if (row.isSave) { if (row.isSave) {
this.$set(this.tableData, index, this.tableDataCopy[index]); this.$set(this.tableData, index, this.tableDataCopy[index]);
} else { } else {
this.tableData.splice(index, 1); this.tableData.splice(index-1, 2);
// this.tableData.splice(index, 1);
this.isAddRule = false; this.isAddRule = false;
} }
}, },
@ -326,7 +409,16 @@ export default {
type: "warning", type: "warning",
center: true, center: true,
}).then(() => { }).then(() => {
this.tableData.splice(index, 1); // this.tableData.splice(index, 1);
console.log(index)
console.log(this.tableData.length)
if (index+1 == this.tableData.length){
this.tableData.splice(index - 1, 2)
}else{
this.tableData.splice(index,2);
}
this.itemkey = Math.random()
this.isAddRule = false; this.isAddRule = false;
}).catch(() => {}) }).catch(() => {})
}, },

@ -50,8 +50,8 @@
<div>判分规则</div> <div>判分规则</div>
</div> </div>
<div> <div>
<el-button v-if="!isView" type="primary" size="mini" @click="addRules">批量新增</el-button> <el-button v-if="!isView" type="primary" size="mini" @click="addRules">新增</el-button>
<el-button v-if="!isView" type="primary" size="mini" @click="addRule">新增</el-button> <!-- <el-button v-if="!isView" type="primary" size="mini" @click="addRule">新增</el-button>-->
</div> </div>
</div> </div>
<el-dialog :visible.sync="configVisible" width="30%" title="批量新增判分点" center> <el-dialog :visible.sync="configVisible" width="30%" title="批量新增判分点" center>
@ -77,9 +77,7 @@
:data="tableData" :data="tableData"
:stripe="true" :stripe="true"
:key="itemkey" :key="itemkey"
:cell-style="rowClass"
header-align="center" header-align="center"
:header-cell-style="headClass"
> >
<el-table-column prop="indexNo" type="index" label="序号" width="80"> <el-table-column prop="indexNo" type="index" label="序号" width="80">
</el-table-column> </el-table-column>
@ -128,7 +126,7 @@
<p class="p" style="margin-top: 1px">交易结果一致性规则用户交易结果需要与下面设置的交易结果指标要求一致</p> <p class="p" style="margin-top: 1px">交易结果一致性规则用户交易结果需要与下面设置的交易结果指标要求一致</p>
<div class="block"> <div class="block">
<!-- type: 题目类型(1选择 2判断 3填空 4问答 5指标结果) --> <!-- type: 题目类型(1选择 2判断 3填空 4问答 5指标结果) -->
<div v-if="scope.row.operationIds && scope.row.type == null" style="line-height: 65px">需点击</div> <div v-if="scope.row.operationIds && scope.row.type == null" style="line-height: 65px;text-align: center">需点击</div>
<template v-if="scope.row.type == 1"> <template v-if="scope.row.type == 1">
<div class="box"> <div class="box">
<div class="line"> <div class="line">
@ -475,6 +473,7 @@ export default {
this.anewPosttingDatas(list) this.anewPosttingDatas(list)
this.tableData.forEach(async (item, index) => { this.tableData.forEach(async (item, index) => {
// //
item.operationIds = item.id
// console.log(item) // console.log(item)
if (item.id) { if (item.id) {
this.$nextTick(() => { this.$nextTick(() => {
@ -491,9 +490,15 @@ export default {
let obj = { let obj = {
...item, ...item,
isSubject: true, isSubject: true,
isDisabled: true, // isDisabled: false, //
isSave: true // isSave: false //
}; };
console.log(item)
if(item.type == undefined){
item.operationIds = item.id
item.type = null
}
//(1 2 3 4 5) //(1 2 3 4 5)
if (item.type == 1 || item.type == 2) { if (item.type == 1 || item.type == 2) {
obj.subjectId = Number(item.emptyOne); obj.subjectId = Number(item.emptyOne);
@ -586,19 +591,15 @@ export default {
}); });
}, },
handleCheckChange(data, checked, indeterminate, row, index) { // handleCheckChange(data, checked, indeterminate, row, index) { //
// this.changeArr.push(checked) // console.log(checked)
// if(this.changeArr.length === 4) { // if (checked){
// this.checkChange.splice(index, 1, this.changeArr[2]) // }else{
// this.changeArr.splice(0, this.changeArr.length) // this.tableData[index].operationIds= null
// }else if(this.changeArr.length === 2) { // this.tableData[index].operationIds= null
// this.checkChange.splice(index, 1, true)
// } // }
if (checked){ // console.log(this.tableData[index].operationIds)
}else{
row.operationIds = null
row.type = null
}
if (checked && data.isNode === 1) { if (checked && data.isNode === 1) {
console.log('123')
this.tableData[index].operationIds = data.id; // id this.tableData[index].operationIds = data.id; // id
row.value1 = ""; row.value1 = "";
row.value2 = ""; row.value2 = "";
@ -836,6 +837,11 @@ export default {
}, },
handleSave(row, index) { // handleSave(row, index) { //
let keys = this.$refs[`tree-${index}`].getCheckedKeys(); let keys = this.$refs[`tree-${index}`].getCheckedKeys();
console.log(keys)
console.log(row)
if(!row.operationIds){
row.operationIds = keys[0]
}
if (!keys.length || !row.operationIds) { if (!keys.length || !row.operationIds) {
this.$message.warning(`请选择操作点`); this.$message.warning(`请选择操作点`);
return; return;
@ -971,7 +977,10 @@ export default {
margin-left: 20px; margin-left: 20px;
} }
} }
.cell div{
margin: auto;
text-align: center;
}
// //
.form-con { .form-con {
padding-bottom: 24px; padding-bottom: 24px;

Loading…
Cancel
Save