一键保存

master
yujialong 8 months ago
parent 1c4b5c617f
commit b95a3c87c1
  1. 25
      src/views/Program.vue
  2. 41
      src/views/Transaction.vue

@ -14,7 +14,7 @@
<el-button v-if="!isView" <el-button v-if="!isView"
type="primary" type="primary"
size="mini" size="mini"
@click="saveAll">保存</el-button> @click="submit">保存</el-button>
</div> </div>
</div> </div>
@ -76,6 +76,10 @@
type="primary" type="primary"
size="mini" size="mini"
@click="batchDel">批量删除</el-button> @click="batchDel">批量删除</el-button>
<el-button v-if="!isView"
type="primary"
size="mini"
@click="saveAll">一键保存</el-button>
<el-button v-if="!isView" <el-button v-if="!isView"
type="primary" type="primary"
size="mini" size="mini"
@ -320,7 +324,7 @@ export default {
}); });
} }
}, },
saveAll () { // submit () { //
if (this.isNameRepeat) { if (this.isNameRepeat) {
this.$message.warning(`当前判分点名称已存在`); this.$message.warning(`当前判分点名称已存在`);
return; return;
@ -446,14 +450,16 @@ export default {
this.tableDataCopy = deepCopy(this.tableData); // this.tableDataCopy = deepCopy(this.tableData); //
row.isDisabled = false; row.isDisabled = false;
}, },
handleSave (row) { // handleSave (row, i) { //
const pre = typeof i === 'number' ? `${i + 1}项,` : ''
if (!row.required && !row.result) { if (!row.required && !row.result) {
this.$message.warning(`规则与结果至少填写一个`); this.$message.warning(pre + `规则与结果至少填写一个`);
return; return;
} }
row.isSave = true; row.isSave = true;
row.isDisabled = true; row.isDisabled = true;
this.isAddRule = false; this.isAddRule = false;
return true
}, },
handleCancel (row, index) { // handleCancel (row, index) { //
if (row.isSave) { if (row.isSave) {
@ -507,6 +513,17 @@ export default {
this.$message.error('请先选择数据 !') this.$message.error('请先选择数据 !')
} }
}, },
//
saveAll () {
for (const e of this.tableData) {
if (e.isSubject) {
const result = this.handleSave(e, e.index)
if (!result) break
e.isDisabled = true
e.isSave = true
}
}
},
// //
headClass () { headClass () {
return "text-align: center;"; return "text-align: center;";

@ -466,7 +466,7 @@
<el-button v-show="!scope.row.isDisabled" <el-button v-show="!scope.row.isDisabled"
size="mini" size="mini"
type="text" type="text"
@click="handleSave(scope.row, scope.$index)">保存 @click="handleSave(scope.row)">保存
</el-button> </el-button>
<!-- <el-button v-show="!scope.row.isDisabled" <!-- <el-button v-show="!scope.row.isDisabled"
size="mini" size="mini"
@ -1176,53 +1176,51 @@ export default {
row.isDisabled = false; row.isDisabled = false;
row.isSave = false; row.isSave = false;
}, },
handleSave (row, index) { // handleSave (row, i) { //
const pre = typeof i === 'number' ? `${i + 1}项,` : ''
if (!row.operationIds) { if (!row.operationIds) {
this.$message.warning(`请选择操作点`); this.$message.warning(pre + `请选择操作点`);
return; return;
} else { } else {
//(1 2 3 4 5) //(1 2 3 4 5)
if (row.type == 1 || row.type == 2) { if (row.type == 1 || row.type == 2) {
if (row.type == 1 && this.isSt) { if (row.type == 1 && this.isSt) {
if (!row.value1.length) { if (!row.value1.length) {
this.$message.warning(`请选择正确答案`); this.$message.warning(pre + `请选择正确答案`);
return; return;
} }
} else if (!row.value1) { } else if (!row.value1) {
this.$message.warning(`请选择正确答案`); this.$message.warning(pre + `请选择正确答案`);
return; return;
} }
} else if (row.type == 3) { } else if (row.type == 3) {
if (!row.value1) { if (!row.value1) {
this.$message.warning(`请输入字段要求`); this.$message.warning(pre + `请输入字段要求`);
return; return
} }
} else if (row.type == 4) { } else if (row.type == 4) {
if (!row.value1) { if (!row.value1) {
this.$message.warning(`请选择字数要求`); this.$message.warning(pre + `请选择字数要求`);
return; return;
} else if (row.value1 !== "无限制" && !row.value2) { } else if (row.value1 !== "无限制" && !row.value2) {
this.$message.warning(`请输入字数要求`); this.$message.warning(pre + `请输入字数要求`);
return; return;
} else if (!row.value3) { } else if (!row.value3) {
this.$message.warning(`请输入字段要求`); this.$message.warning(pre + `请输入字段要求`);
return; return;
} }
} else if (row.type == 5) { } else if (row.type == 5) {
if ((!row.value2 || !row.value5) && !this.isSt) { if (!row.value2 && !row.value3 && !row.value4 && !row.value5 && !row.value6 && !row.value7) {
this.$message.warning(`请选择交易指标区间`); this.$message.warning(pre + `请输入交易指标区间`);
return;
} else if ((!row.value3 || !row.value5) && !this.isSt) {
this.$message.warning(`请输入交易指标区间`);
return; return;
} else if (row.value3 && row.value5 && !isNaN(row.value3) && !isNaN(row.value5) && +row.value3 > +row.value5) { } else if (row.value3 && row.value5 && !isNaN(row.value3) && !isNaN(row.value5) && +row.value3 > +row.value5) {
this.$message.warning(`第一个指标必须小于第二个指标`); this.$message.warning(pre + `第一个指标必须小于第二个指标`);
return; return;
} }
} else if (row.type == 6) { } else if (row.type == 6) {
for (let i = 1; i < 9; i++) { for (let i = 1; i < 9; i++) {
if (row['check' + i] && row['val' + i] === '') { if (row['check' + i] && row['val' + i] === '') {
this.$message.warning(`请输入数量`) this.$message.warning(pre + `请输入数量`)
return return
} }
} }
@ -1231,6 +1229,7 @@ export default {
row.isSave = true; row.isSave = true;
row.isDisabled = true; row.isDisabled = true;
this.isAddRule = false; this.isAddRule = false;
return true
}, },
handleCancel (row, index) { // handleCancel (row, index) { //
if (this.judgePoints == true) { if (this.judgePoints == true) {
@ -1314,10 +1313,14 @@ export default {
}, },
// //
saveAll () { saveAll () {
this.tableData.forEach(e => { for (const e of this.tableData) {
if (e.isSubject) {
const result = this.handleSave(e, e.index)
if (!result) break
e.isDisabled = true e.isDisabled = true
e.isSave = true e.isSave = true
}) }
}
}, },
// //
headClass () { headClass () {

Loading…
Cancel
Save