判断字段为空问题

规则与参考答案其中一个存在数据就可以保存
master
e 3 years ago
parent 3fb67521fb
commit 7b22f92776
  1. 89
      src/views/Program.vue
  2. 36
      src/views/Transaction.vue

@ -260,10 +260,6 @@ export default {
}
},
saveAll() { //
if (!this.formData.points.name) {
this.$message.warning(`判分点名称不能为空`);
return;
}
if (this.isNameRepeat) {
this.$message.warning(`当前判分点名称已存在`);
return;
@ -272,20 +268,13 @@ export default {
this.$message.warning(`实验要求不能为空`);
return;
}
if (!this.formData.points.experimentCode) {
this.$message.warning(`实验代码不能为空`);
return;
}
if (!this.tableData.length) {
this.$message.warning(`请添加判分规则`);
return;
} else {
for (let i = 0; i < this.tableData.length; i++) {
if (this.tableData[i].isSubject && !this.tableData[i].required) {
this.$message.warning(`${i + 1}项,规则要求不能为空`);
return;
} else if (this.tableData[i].isSubject && !this.tableData[i].result) {
this.$message.warning(`${i + 1}项,规则结果不能为空`);
if ((this.tableData[i].isSubject && !this.tableData[i].required) && (this.tableData[i].isSubject && !this.tableData[i].result)) {
this.$message.warning(`${i + 1}项,规则与结果至少填写一个`);
return;
} else if (this.tableData[i].isSubject && !this.tableData[i].isSave) {
this.$message.warning(`${i + 1}项,未保存`);
@ -293,9 +282,10 @@ export default {
}
}
}
let tempArr = [];
this.tableData.forEach(i => {
if (i.isSubject) {
if (this.formData.points.name || this.formData.points.experimentCode){
let tempArr = [];
this.tableData.forEach(i => {
if (i.isSubject) {
let obj = {
id: i.id ? i.id : "",
bcId: i.bcId,
@ -305,31 +295,42 @@ export default {
ruleOperation: i.ruleOperation
};
tempArr.push(obj)
}
});
this.formData.bcJudgmentRuleList = tempArr;
if (this.isAdd) { //
this.$post(this.api.addBcJudgmentPoint, this.formData).then(res => {
if (res.status === 200) {
this.$message.success("新增判分点成功");
this.Back();
} else {
this.$message.warning(res.message);
}
}).catch(err => {
console.log(err)
})
} else if (this.isEdit) { //
this.$post(this.api.updateBcJudgmentPoint, this.formData).then(res => {
if (res.status === 200) {
this.$message.success("更新判分点成功");
this.Back();
} else {
this.$message.warning(res.message);
}
}).catch(err => {
console.log(err)
})
});
this.formData.bcJudgmentRuleList = tempArr;
if (this.isAdd) { //
this.$post(this.api.addBcJudgmentPoint, this.formData).then(res => {
if (res.status === 200) {
this.$message.success("新增判分点成功");
this.Back();
} else {
this.$message.warning(res.message);
}
}).catch(err => {
console.log(err)
})
} else if (this.isEdit) { //
this.$post(this.api.updateBcJudgmentPoint, this.formData).then(res => {
if (res.status === 200) {
this.$message.success("更新判分点成功");
this.Back();
} else {
this.$message.warning(res.message);
}
}).catch(err => {
console.log(err)
})
}
}else{
this.$message.warning(`实验代码与判分点名称至少填写一个`);
// if (!this.formData.points.name) {
// this.$message.warning(``);
// return;
// }
// if (!this.formData.points.experimentCode) {
//
// return;
// }
}
},
addRule() { //
@ -385,12 +386,8 @@ export default {
row.isDisabled = false;
},
handleSave(row) { //
if (!row.required) {
this.$message.warning(`规则要求不能为空`);
return;
}
if (!row.result) {
this.$message.warning(`规则结果不能为空`);
if (!row.required && !row.result) {
this.$message.warning(`规则与结果至少填写一个`);
return;
}
row.isSave = true;

@ -393,9 +393,7 @@ export default {
token: atob(decodeURI(this.$route.query.token))
});
this.checkChange.push(false)
console.log('remounted')
this.getTreeData();
console.log(this.treeData)
if (this.$route.query.systemId) {
this.formData.lcJudgmentPoint.systemId = this.$route.query.systemId;
}
@ -415,16 +413,6 @@ export default {
if (item.operationIds) {
this.$nextTick(() => {
this.$refs[`tree-${index}`].setCheckedKeys([item.operationIds]);
// let currentNode = this.$refs[`tree-${index}`].getNode([item]);
// while ( parentLevel>0)//while ( 1!=parentLevel)
// let dom = document.querySelector("#divTree")
// let dom1 = document.querySelector("#depTree")
// //26px,
// let nodeHight =26
// dom1.style.height = (nodeCount * nodeHight) + "px"
// let contHeight=(nodeIndex * nodeHight)+topHeight-300//,
// dom.scrollTo(0, contHeight)
// this.scrollToDepTree(item.operationIds)
})
}
// id,
@ -445,7 +433,6 @@ export default {
},
currentChecked (nodeObj, SelectedObj) {
this.SelectedObj = SelectedObj
},
handleConfirm(){
let list = []
@ -474,7 +461,6 @@ export default {
this.tableData.forEach(async (item, index) => {
//
item.operationIds = item.id
// console.log(item)
if (item.id) {
this.$nextTick(() => {
this.$refs[`tree-${index}`].setCheckedKeys([item.id]);
@ -493,8 +479,6 @@ export default {
isDisabled: false, //
isSave: false //
};
console.log(item)
if(item.type == undefined){
item.operationIds = item.id
item.type = null
@ -591,29 +575,19 @@ export default {
});
},
handleCheckChange(data, checked, indeterminate, row, index) { //
// console.log(checked)
// if (checked){
// }else{
// this.tableData[index].operationIds= null
// this.tableData[index].operationIds= null
// }
// console.log(this.tableData[index].operationIds)
if (checked && data.isNode === 1) {
console.log('123')
this.tableData[index].operationIds = data.id; // id
row.value1 = "";
row.value2 = "";
row.value3 = "";
row.value4 = "";
row.value5 = "";
// console.log(data)
if (data.subjectId) { // id
this.currentNodeData = data;
this.$refs[`tree-${index}`].setCheckedNodes([data]);
this.getSubjectData(data.subjectId, index);
} else {
row.type = null;
// console.log(row.type)
this.currentNodeData = {};
this.$refs[`tree-${index}`].setCheckedNodes([data]);
}
@ -649,7 +623,6 @@ export default {
let result = [];
data.forEach(item => {
if (item.isNode === 0) {
// item.disabled = true;
item.showCheckbox = false;
} else {
item.showCheckbox = true;
@ -781,7 +754,6 @@ export default {
this.checkChange.push(false)
if(!this.isAddRule) {
this.isAddRule = true;
// this.tableData.length && this.tableData.push({ruleOperation: 0, indexNo: ""});
if (this.tableData.length > 0){
this.tableData.push({
ruleOperation: 0
@ -820,7 +792,6 @@ export default {
}else {
this.$message('请保存当前判分规则再新增!');
}
// anewPosttingData(judgmentRuleList)
},
changeResult(row) { // (0 1 0)
row.resultOperation = row.resultOperation === 0 ? 1 : 0;
@ -837,8 +808,6 @@ export default {
},
handleSave(row, index) { //
let keys = this.$refs[`tree-${index}`].getCheckedKeys();
console.log(keys)
console.log(row)
if(!row.operationIds){
row.operationIds = keys[0]
}
@ -899,8 +868,6 @@ export default {
}else{
this.tableData.splice(index,2);
}
// this.tableData.splice(index-1, 2);
// index ? this.tableData.splice(index - 1, 1) : this.tableData.splice(0, 1);
this.isAddRule = false;
}
},
@ -911,9 +878,6 @@ export default {
type: "warning",
center: true
}).then(() => {
// if(index+1 == this.tableData.length){
// index = index-1
// }
if (index+1 == this.tableData.length){
this.tableData.splice(index - 1, 2)
}else{

Loading…
Cancel
Save