diff --git a/src/api/systemManagement/safeIndex/index.js b/src/api/systemManagement/safeIndex/index.js index a8899bb..1568a93 100644 --- a/src/api/systemManagement/safeIndex/index.js +++ b/src/api/systemManagement/safeIndex/index.js @@ -16,6 +16,14 @@ export function saveSafeCalculation(data) { data }) } +// 未有数据时修改综合指数 +export function saveSafeCalculationTwo(data) { + return request({ + url: '/safety/system/tbSafeCalculationRule', + method: 'post', + data + }) +} // 指标表格数据 export function getIndexTable(params) { return request({ diff --git a/src/views/systemManagement/safeIndex/components/indexTable.vue b/src/views/systemManagement/safeIndex/components/indexTable.vue index 4db5db5..8e7b661 100644 --- a/src/views/systemManagement/safeIndex/components/indexTable.vue +++ b/src/views/systemManagement/safeIndex/components/indexTable.vue @@ -231,7 +231,7 @@ - 企业技防设施连入平台情况 + 企业技防设施连入平台情况 @@ -251,7 +251,7 @@ - 部门检查不合格及有缺陷的要求企业整改 + 部门检查不合格及有缺项的要求企业整改 @@ -468,6 +468,17 @@ export default { }, // 一级指标点击事件 click_onelevel(id) { + let obj = document.querySelectorAll("td"); + let index = 0; + if (id < 6) { + index = id - 3; + } else { + index = id - 4; + } + obj.forEach((item) => { + item.className = ""; + }); + obj[index].className = "lightcolor"; const massage = { safeRuleId: id, level: "1", @@ -477,6 +488,17 @@ export default { }, // 二级点击事件 click_twolevel(id) { + let obj = document.querySelectorAll("td"); + let index = 0; + if (id < 6) { + index = id - 3; + } else { + index = id - 4; + } + obj.forEach((item) => { + item.className = ""; + }); + obj[index].className = "lightcolor"; const massage = { safeRuleId: id, level: "2", @@ -491,6 +513,18 @@ export default { level: "3", table_num: num, }; + let obj = document.querySelectorAll("td"); + console.log("obj", obj); + let index = 0; + if (id < 6) { + index = id - 3; + } else { + index = id - 4; + } + obj.forEach((item) => { + item.className = ""; + }); + obj[index].className = "lightcolor"; this.$emit("back", massage); bus.$emit("send_three", massage); // 传给三级指标详情 }, @@ -599,4 +633,8 @@ table { } } } +.lightcolor { + background: #3c4b4a; + color: #54ffbe; +} \ No newline at end of file diff --git a/src/views/systemManagement/safeIndex/components/indexmassageThree.vue b/src/views/systemManagement/safeIndex/components/indexmassageThree.vue index f568c72..fa88d7d 100644 --- a/src/views/systemManagement/safeIndex/components/indexmassageThree.vue +++ b/src/views/systemManagement/safeIndex/components/indexmassageThree.vue @@ -17,7 +17,6 @@
~
@@ -156,9 +155,10 @@ import { safeCalculation, getIndexTable, saveSafeCalculation, + saveSafeCalculationTwo, getWarnTable, saveWarnTable, - deleteWarn + deleteWarn, } from "@/api/systemManagement/safeIndex"; export default { name: "indexmassageThree", @@ -180,6 +180,8 @@ export default { color: "", // 预警新增的颜色 sortValue: "", add_warn_disabled: false, // 预警新增是否禁用,如果四条时则不可再新增 + save_flag: "", + person_flag: true, }; }, created() { @@ -201,20 +203,48 @@ export default { safeCalculation({ safeRuleId: this.three_level_id, levelIndex: 3 }).then( (res) => { console.log("3res", res); + this.tableData_all = []; // 清空表格内容 + this.tableData_warn = []; // if 在这里从请求回的数据里拿回关键字段判别两种表格中的一种 if (this.table_num === "1") { this.is_flag = true; + if (res.data.calculationRule === null) { + this.tableData_all = []; + this.save_flag = "1"; // 后台未传数据,通知待保存选择接口 + } else { + this.tableData_all = JSON.parse( + res.data.calculationRule + ).calculation; + this.save_flag = "2"; // 后台传数据,通知待保存选择接口 + } } else if (this.table_num === "2") { + // 是否的表格 this.is_flag = false; - } - this.tableData_all = []; // 清空表格内容 - this.tableData_warn = []; - if (res.data.calculationRule === null) { - this.tableData_all = []; - } else { - this.tableData_all = JSON.parse( - res.data.calculationRule - ).calculation; + if (res.data.calculationRule === null) { + this.tableData_all = [ + { + scoreLowerLimit: "是", + score: "", + }, + { + scoreLowerLimit: "否", + score: "", + }, + ]; + } else { + this.tableData_all = [ + { + scoreLowerLimit: "是", + score: JSON.parse(res.data.calculationRule).calculation[0] + .score, + }, + { + scoreLowerLimit: "否", + score: JSON.parse(res.data.calculationRule).calculation[1] + .score, + }, + ]; + } } console.log("this.tableData_all", this.tableData_all); this.safeRuleId = res.data.safeRuleId; // 此safeRuleId为保存表格数据时的safeRuleId,不和兄弟传来的safeRuleId混淆 @@ -310,8 +340,8 @@ export default { if (this.tableData_warn.length === index + 1) { // 按顺序删,只能删最后一行 this.tableData_warn.splice(index, 1); - const params = `idList=${row.id}` - deleteWarn(params) + const params = `idList=${row.id}`; + deleteWarn(params); if (this.tableData_warn.length < 4) { this.add_warn_disabled = false; // 当预警数据不为4条时,接触新增禁用 } @@ -321,31 +351,61 @@ export default { console.log("roww", row); }, // + limit(e) { + console.log("e", e.target.value); + let reg = /^(0|[1-9][0-9]*)$/; + if (!reg.test(e.target.value)) { + this.person_flag = false; + } else { + this.person_flag = true; + } + }, save_data() { - console.log("this.tableData_all", this.tableData_all); - const obj = { - calculation: [], - }; - obj.calculation = this.tableData_all.map((item) => ({ - scoreLowerLimit: item.scoreLowerLimit, - scoreUpperLimit: item.scoreUpperLimit, - score: item.score, - })); - const params = { - calculationRule: JSON.stringify(obj), - id: this.id, - safeRuleId: this.safeRuleId, - }; - console.log("params123", params); - saveSafeCalculation(params) - .then((res) => { - console.log("ressave", res); - this.$message.success("保存成功"); - }) - .catch((err) => { - console.log("errsave", err); - this.$message.warning("保存失败"); - }); + // const lower_input = this.tableData_all.map((item) => item.scoreLowerLimit); + // const upper_input = this.tableData_all.map((item) => item.scoreUpperLimit); + // ( /^\d+(?=\.{0,1}\d+$|$)/.test()) + console.log("this.person_flag", this.person_flag); + if (this.person_flag) { + const obj = { + calculation: [], + }; + obj.calculation = this.tableData_all.map((item) => ({ + scoreLowerLimit: item.scoreLowerLimit, + scoreUpperLimit: item.scoreUpperLimit, + score: item.score, + })); + const params = { + calculationRule: JSON.stringify(obj), + id: this.id == -1 ? null : this.id, + safeRuleId: this.safeRuleId, + }; + console.log("params123", params); + if (this.save_flag === "2") { + console.log("this.tableData_all2", this.tableData_all); + saveSafeCalculation(params) + .then((res) => { + console.log("ressave", res); + this.$message.success("保存成功"); + }) + .catch((err) => { + console.log("errsave", err); + this.$message.warning("保存失败"); + }); + } else if (this.save_flag === "1") { + console.log("this.tableData_all1", this.tableData_all); + saveSafeCalculationTwo(params) + .then((res) => { + console.log("ressave", res); + this.$message.success("保存成功"); + }) + .catch((err) => { + console.log("errsave", err); + this.$message.warning("保存失败"); + }); + } + } else { + this.$message.warning("分级人数为大于等于0的整数"); + } }, // 保存预警数据 save_data_warn() { @@ -355,7 +415,7 @@ export default { this.$message.warning("请填入预警等级"); } else { console.log("input_warn", input_warn); - console.log('this.tableData_warn', this.tableData_warn); + console.log("this.tableData_warn", this.tableData_warn); const obj = { calculation: [], };