From c819024e241b9f7c54cc3786373ad0d2998f2190 Mon Sep 17 00:00:00 2001 From: 马宇豪 <978517621@qq.com> Date: 星期五, 05 五月 2023 08:55:46 +0800 Subject: [PATCH] 修改 --- src/views/safetyproduction/gojudging.vue | 205 +++++++++++++++++++++++++++++++++++++++++++++----- 1 files changed, 182 insertions(+), 23 deletions(-) diff --git a/src/views/safetyproduction/gojudging.vue b/src/views/safetyproduction/gojudging.vue index 30a46e0..55b365f 100644 --- a/src/views/safetyproduction/gojudging.vue +++ b/src/views/safetyproduction/gojudging.vue @@ -1,7 +1,21 @@ <template> <div> <div class="box-right"> - <div v-for="(item, index) in lists" :key="index" style="padding:0 0 20px 0"> + <el-button + type="primary" + class="btn" + v-if="typeId == 2 ? false : true" + @click="finish()" + >结单</el-button> + <div class="point"> + 所有A级要素总分= {{remark}} + </div> + + <div + v-for="(item, index) in lists" + :key="index" + style="padding: 0 0 20px 0" + > <div class="title"> A级要素:<span>{{ item.elementAName }}</span> </div> @@ -11,12 +25,20 @@ ><p><span>B级要素:</span>{{ item.elementBName }}</p></el-col > <el-col :span="6" - ><p><span>得分:</span>50</p></el-col + ><p><span>总分:</span>{{ item.points }}</p></el-col + > + <el-col :span="6" + ><p><span>得分:</span>{{ item.point }}</p></el-col > </el-row> <el-row> <el-col :span="24"> - <el-table border :data="item.child" :header-cell-style="{background:'#eef1f6',color:'#606266'}" :cell-style="{background:'#fff',color:'#606266'}"> + <el-table + border + :data="item.child" + :header-cell-style="{ background: '#eef1f6', color: '#606266' }" + :cell-style="{ background: '#fff', color: '#606266' }" + > <el-table-column prop="standardizationRequirements" align="center" @@ -40,10 +62,10 @@ ></el-table-column> <el-table-column align="center" label="评审结果"> <template slot-scope="scope"> - <span v-if="(scope.row.safetyInspectionItemResult== 0)" + <span v-if="scope.row.safetyInspectionItemResult == 0" >否决</span > - <span v-if="(scope.row.safetyInspectionItemResult == 1)" + <span v-if="scope.row.safetyInspectionItemResult == 1" >扣分</span > </template> @@ -54,22 +76,32 @@ type="expand" width="100px" > - <template slot-scope="scope"> - <el-table - :data="scope.row.selfDeductionList" - > - <el-table-column prop="name" align="center" label="扣分项"> - </el-table-column> - <el-table-column prop="point" align="center" label="扣分"> - </el-table-column> - <el-table-column - prop="remark" - align="center" - label="扣分备注" + <template slot-scope="scope"> + <el-table + :data="scope.row.selfDeductionList" + border + :header-cell-style="{ + background: '#eef1f6', + color: '#606266', + }" + :cell-style="{ background: '#fff', color: '#606266' }" > - </el-table-column> - </el-table> - </template> + <el-table-column + prop="name" + align="center" + label="扣分项" + > + </el-table-column> + <el-table-column prop="point" align="center" label="扣分"> + </el-table-column> + <el-table-column + prop="remark" + align="center" + label="扣分备注" + > + </el-table-column> + </el-table> + </template> </el-table-column> <el-table-column prop="remark" @@ -82,7 +114,8 @@ @click="handleClick(scope.row)" type="text" size="small" - >评价</el-button + :disabled="typeId == 2 ? true : false" + >评审</el-button > <!-- <el-button type="text" size="small" style="color: red" >删除</el-button @@ -99,7 +132,10 @@ </template> <script> import Titlename from "../../components/Titlename/index.vue"; -import { safetySelfInspectionInfo } from "@/api/safetySelfInspection.js"; +import { + safetySelfInspectionInfo, + safetySelfInspectionFinish, +} from "@/api/safetySelfInspection.js"; export default { components: { Titlename }, data() { @@ -115,21 +151,102 @@ }, list: [], lists: [], + listType: [], + typeId: "", + remark:"", }; }, created() { this.id = this.$route.query.id; + this.typeId = this.$route.query.type; this.safeInitem(this.id); }, methods: { + finish() { + var faly = ""; + var bar = []; + for (var i = 0; i < this.listType.length; i++) { + if (this.listType[i].safetyInspectionItemResult == null) { + faly = false; + } else { + faly = true; + } + bar.push(faly); + } + if (bar.indexOf(false) == -1) { + let id = this.id; + this.$confirm("确定要结单吗?", "提示", { + confirmButtonText: "确定", + cancelButtonText: "取消", + type: "warning", + }) + .then(() => { + safetySelfInspectionFinish({ id: this.id }).then((res) => { + if (res.data.code === "200") { + this.$notify({ + title: "成功", + message: "结单成功", + type: "success", + duration: 2000, + }); + this.$router.push({ + path:"/safetyproduction/safetyproduction/checklistself" + }); + } else { + this.$message({ + message: res.data.message, + type: "warning", + }); + } + }); + }) + .catch((error) => {}); + } else { + alert("所有的检查项评审后才可以结单!"); + } + }, + safeInitem(id) { safetySelfInspectionInfo({ id: id }).then((res) => { if (res.data.code == 200) this.list = res.data.result; + this.listType = res.data.result.itemList; var arr = this.checkSameDataA(this.list.itemList); for (var i = 0; i < arr.length; i++) { arr[i].child = this.checkSameData(arr[i].child); + arr[i].elementAWeight = arr[i].child[0].elementAWeight; + arr[i].child.points = arr[i].child.point; } this.lists = arr; + let showDetail = '' + for (let i = 0 ; i < arr.length ; i++){ + if (i < arr.length - 1 ){ + showDetail+='('+arr[i].elementAName + ' * '+arr[i].elementAWeight+ ') + ' + } else{ + showDetail+='('+arr[i].elementAName + ' * '+arr[i].elementAWeight+ ')' + } + } + this.remark+=showDetail + if (this.typeId==2){ + let pointA = '' + let pointDetail = ' = ' + let finalPoint=0 + for (let i = 0 ; i < arr.length ; i++){ + let childData = arr[i].child + pointA = 0 + for (let j = 0 ; j < childData.length ; j++){ + //改A级要素的总分 + pointA += childData[j].point + } + finalPoint += pointA * arr[i].elementAWeight + if (i < arr.length - 1 ){ + pointDetail +='('+pointA + ' * '+arr[i].elementAWeight+ ') + ' + } else{ + pointDetail +='('+pointA + ' * '+arr[i].elementAWeight+ ') = ' + } + } + pointDetail +=finalPoint + this.remark+=pointDetail + } }); }, checkSameDataA(resData) { @@ -139,6 +256,7 @@ if (!dataInfo[elementAName]) { dataInfo[elementAName] = { elementAName, + elementAWeight:'', child: [], }; } @@ -154,12 +272,37 @@ if (!dataInfo[elementBName]) { dataInfo[elementBName] = { elementBName, + point: "", + elementAWeight:item.elementAWeight, + points: item.point, child: [], }; } dataInfo[elementBName].child.push(item); }); let list = Object.values(dataInfo); // list 转换成功的数据 + for (var i = 0; i < list.length; i++) { + var pot = list[i].points; + for (var j = 0; j < list[i].child.length; j++) { + if (list[i].child[j].safetyInspectionItemResult != 0) { + for ( + var s = 0; + s < list[i].child[j].selfDeductionList.length; + s++ + ) { + pot = pot - list[i].child[j].selfDeductionList[s].point; + } + } else { + var cont = 0; + pot = 0; + } + } + if (pot > 0) { + list[i].point = pot; + } else { + list[i].point = 0; + } + } return list; }, handleClick(data) { @@ -167,7 +310,7 @@ path: "/review", query: { idC: data.id, - id:this.id + id: this.id, }, }); }, @@ -186,6 +329,14 @@ background-color: white; border-radius: 5px; padding: 20px; + height: 850px; + overflow-y: overlay; +} +.point { + background-color: rgba(3,78,162,0.1); + font-size: 20px; + padding: 10px 5px; + font-weight: bold; } .title { font-size: 16px; @@ -195,4 +346,12 @@ .titles { font-size: 14px; } +.box-right /deep/ .el-table__expanded-cell { + background-color: #fff !important; +} +.btn { + background-color: #034ea2; + border: 1px solid #034ea2; + float: right; +} </style> -- Gitblit v1.9.2