lukeyan #42

Merged
lukeyan merged 3 commits from lukeyan into master 2 years ago

@ -39,4 +39,11 @@ export function saveWarnTable(data) {
method: 'post',
data
})
}
// 删除预警数据
export function deleteWarn(params) {
return request({
url: '/safety/system/tbSafeCompanyAlarmRule?' + params,
method: 'delete',
})
}

@ -113,7 +113,6 @@
placeholder="请填入预警等级"
class="table_input_warn_level"
v-model="scope.row.alarmLevel"
@blur="input_warn_blur($event)"
></el-input>
</div>
</template>
@ -159,6 +158,7 @@ import {
saveSafeCalculation,
getWarnTable,
saveWarnTable,
deleteWarn
} from "@/api/systemManagement/safeIndex";
export default {
name: "indexmassageThree",
@ -180,7 +180,6 @@ export default {
color: "", //
sortValue: "",
add_warn_disabled: false, //
input_warnning: "1", //
};
},
created() {
@ -210,7 +209,13 @@ export default {
}
this.tableData_all = []; //
this.tableData_warn = [];
this.tableData_all = JSON.parse(res.data.calculationRule).calculation;
if (res.data.calculationRule === null) {
this.tableData_all = [];
} else {
this.tableData_all = JSON.parse(
res.data.calculationRule
).calculation;
}
console.log("this.tableData_all", this.tableData_all);
this.safeRuleId = res.data.safeRuleId; // safeRuleIdsafeRuleIdsafeRuleId
this.id = res.data.id;
@ -255,14 +260,6 @@ export default {
color: "#fff",
};
},
input_warn_blur(e) {
if (e.target.value === "") {
this.$message.warning("预警等级不能为空");
this.input_warnning = "1";
} else {
this.input_warnning = "0";
}
},
//
add_data() {
this.tableData_all.push({
@ -286,18 +283,20 @@ export default {
} else if (this.tableData_warn.length === 3) {
this.color = "green";
this.sortValue = "4";
this.add_warn_disabled = true;
}
if (this.tableData_warn.length >= 4) {
this.$message.warning("至多四条预警数据");
} else {
this.tableData_warn.push({
id: "",
safeRuleId: this.safeRuleId,
alarmLevel: "",
scoreLowerLimit: "0",
scoreUpperLimit: "0",
color: this.color,
sortValue: this.sortValue,
});
}
this.tableData_warn.push({
id: "",
safeRuleId: this.safeRuleId,
alarmLevel: "",
scoreLowerLimit: "0",
scoreUpperLimit: "0",
color: this.color,
sortValue: this.sortValue,
});
},
//
delete_data(index, row) {
@ -311,7 +310,9 @@ export default {
if (this.tableData_warn.length === index + 1) {
//
this.tableData_warn.splice(index, 1);
if (this.tableData_warn.length != 4) {
const params = `idList=${row.id}`
deleteWarn(params)
if (this.tableData_warn.length < 4) {
this.add_warn_disabled = false; // 4
}
} else {
@ -348,9 +349,13 @@ export default {
},
//
save_data_warn() {
if (this.input_warnning === "1") {
const input_warn = this.tableData_warn.map((item) => item.alarmLevel);
console.log("input_warn", input_warn);
if (input_warn.includes("")) {
this.$message.warning("请填入预警等级");
} else {
console.log("input_warn", input_warn);
console.log('this.tableData_warn', this.tableData_warn);
const obj = {
calculation: [],
};
@ -371,7 +376,6 @@ export default {
.then((res) => {
console.log(res);
this.$message.success("保存成功");
this.input_warnning = "1";
})
.catch((err) => {
console.log(err);

Loading…
Cancel
Save