Merge pull request 'lukeyan' (#42) from lukeyan into master

Reviewed-on: #42
pull/44/head
lukeyan 2 years ago
commit b02af83f2f

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

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

Loading…
Cancel
Save