判断字段为空问题

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

@ -260,10 +260,6 @@ export default {
} }
}, },
saveAll() { // saveAll() { //
if (!this.formData.points.name) {
this.$message.warning(`判分点名称不能为空`);
return;
}
if (this.isNameRepeat) { if (this.isNameRepeat) {
this.$message.warning(`当前判分点名称已存在`); this.$message.warning(`当前判分点名称已存在`);
return; return;
@ -272,20 +268,13 @@ export default {
this.$message.warning(`实验要求不能为空`); this.$message.warning(`实验要求不能为空`);
return; return;
} }
if (!this.formData.points.experimentCode) {
this.$message.warning(`实验代码不能为空`);
return;
}
if (!this.tableData.length) { if (!this.tableData.length) {
this.$message.warning(`请添加判分规则`); this.$message.warning(`请添加判分规则`);
return; return;
} else { } else {
for (let i = 0; i < this.tableData.length; i++) { for (let i = 0; i < this.tableData.length; i++) {
if (this.tableData[i].isSubject && !this.tableData[i].required) { if ((this.tableData[i].isSubject && !this.tableData[i].required) && (this.tableData[i].isSubject && !this.tableData[i].result)) {
this.$message.warning(`${i + 1}项,规则要求不能为空`); this.$message.warning(`${i + 1}项,规则与结果至少填写一个`);
return;
} else if (this.tableData[i].isSubject && !this.tableData[i].result) {
this.$message.warning(`${i + 1}项,规则结果不能为空`);
return; return;
} else if (this.tableData[i].isSubject && !this.tableData[i].isSave) { } else if (this.tableData[i].isSubject && !this.tableData[i].isSave) {
this.$message.warning(`${i + 1}项,未保存`); this.$message.warning(`${i + 1}项,未保存`);
@ -293,6 +282,7 @@ export default {
} }
} }
} }
if (this.formData.points.name || this.formData.points.experimentCode){
let tempArr = []; let tempArr = [];
this.tableData.forEach(i => { this.tableData.forEach(i => {
if (i.isSubject) { if (i.isSubject) {
@ -331,6 +321,17 @@ export default {
console.log(err) console.log(err)
}) })
} }
}else{
this.$message.warning(`实验代码与判分点名称至少填写一个`);
// if (!this.formData.points.name) {
// this.$message.warning(``);
// return;
// }
// if (!this.formData.points.experimentCode) {
//
// return;
// }
}
}, },
addRule() { // addRule() { //
if(!this.isAddRule) { if(!this.isAddRule) {
@ -385,12 +386,8 @@ export default {
row.isDisabled = false; row.isDisabled = false;
}, },
handleSave(row) { // handleSave(row) { //
if (!row.required) { if (!row.required && !row.result) {
this.$message.warning(`规则要求不能为空`); this.$message.warning(`规则与结果至少填写一个`);
return;
}
if (!row.result) {
this.$message.warning(`规则结果不能为空`);
return; return;
} }
row.isSave = true; row.isSave = true;

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

Loading…
Cancel
Save