<template>
|
<div class="app-container">
|
<div style="margin-bottom: 10px;">
|
<img src="../../../assets/back.svg" style="width:30px;height:30px" @click="goBefore()" align="left"></img>
|
</div>
|
<div class="filter-container">
|
<div class="addSelfExam_tree">
|
<el-tree :data="MenuList"
|
:props="defaultProps"
|
@node-click="handleNodeClick"
|
ref="tree"
|
highlight-current
|
style="overflow-y: scroll;"
|
class="right" default-expand-all></el-tree>
|
<div class="left">
|
<div>
|
<el-table
|
v-loading="listLoading"
|
:key="tableKey"
|
:data="tableData"
|
:span-method="objectSpanMethod"
|
border>
|
<el-table-column prop="checkcontent" label="检查内容" align="center">
|
</el-table-column>
|
<el-table-column prop="checkcriteria" label="检查标准" align="center">
|
</el-table-column>
|
<el-table-column prop="basis" label="参考依据" align="center">
|
</el-table-column>
|
<el-table-column label="检查情况" align="center">
|
<el-table-column prop="checkresult1" label="合格项目">
|
<template slot-scope="scope">
|
<el-checkbox v-model="scope.row.qualified" :label="scope.row.checkresult1" @change="addQualifiedProject($event,scope.row)"></el-checkbox>
|
</template>
|
</el-table-column>
|
<el-table-column prop="checkresult0" label="不合格项目">
|
<template slot-scope="scope">
|
<el-checkbox v-model="scope.row.unqualified" :label="scope.row.checkresult0" @change="addUnqualifiedProject($event,scope.row)">
|
</el-checkbox>
|
</template>
|
</el-table-column>
|
</el-table-column>
|
</el-table>
|
</div>
|
<div align="right" style="margin-top: 10px;margin-right: 10px">
|
<div class="basic_search">
|
<span>申报人名称:</span>
|
<input v-model="dataForm.applyperson">
|
</input>
|
</div>
|
<el-button type="primary" @click="submitAdd()">确认</el-button>
|
</div>
|
</div>
|
|
</div>
|
</div>
|
<el-dialog
|
:visible.sync="addProjectVisible"
|
append-to-body
|
:close-on-click-modal="false"
|
width="600px"
|
>
|
<el-form :model="answer" label-position="right" label-width="140px" width="600px">
|
<el-form-item label="发现日期:">
|
<el-date-picker
|
value-format="yyyy-MM-dd"
|
v-model="answer.findtime"
|
type="date"
|
placeholder="选择日期时间">
|
</el-date-picker>
|
</el-form-item>
|
<el-form-item label="隐患级别:">
|
<el-radio v-model="answer.level" :label="1">一般隐患</el-radio>
|
<el-radio v-model="answer.level" :label="2">重大隐患</el-radio>
|
</el-form-item>
|
<el-form-item label="隐患描述:">
|
<el-input v-model="answer.memo"/>
|
</el-form-item>
|
<el-form-item label="隐患整改情况:">
|
<el-radio v-model="answer.rectifystatus" :label="1">正在整改</el-radio>
|
<el-radio v-model="answer.rectifystatus" :label="2">整改到位</el-radio>
|
</el-form-item>
|
<el-form-item label="整改期限:">
|
<el-date-picker
|
value-format="yyyy-MM-dd"
|
v-model="answer.rectifydeadline"
|
type="date"
|
placeholder="选择日期时间">
|
</el-date-picker>
|
</el-form-item>
|
<el-form-item label="整改措施:" >
|
<el-radio v-model="answer.rectifymeasure" :label="1">立即整改</el-radio>
|
<el-radio v-model="answer.rectifymeasure" :label="2">限期整改</el-radio>
|
<el-radio v-model="answer.rectifymeasure" :label="3">停产停业整顿</el-radio>
|
</el-form-item>
|
<el-form-item label="整改负责人:" >
|
<el-input v-model="answer.rectifyprincipal"/>
|
</el-form-item>
|
<el-form-item label="文件:">
|
<input id="upload" ref="upload" type="file" @change="uploadFile"/>
|
</el-form-item>
|
</el-form>
|
<div align="right" style="margin-top: 10px">
|
<el-button @click="cancel">取消</el-button>
|
<el-button type="primary" @click="submit()">确认</el-button>
|
</div>
|
</el-dialog>
|
</div>
|
</template>
|
|
<script>
|
import { getMenu , getSelfExamList ,addSelfExam , updateSelfExam , updateFile , getUpdateSelfExamList} from "../../../api/selfExam";
|
export default {
|
name: "addSelfExam",
|
data(){
|
return{
|
tableKey:'',
|
id:"",
|
level:"",
|
test:"1",
|
updateId:'',
|
MenuList:[],
|
dataList:[],
|
tableData:[],
|
answer:{
|
findtime:"",
|
level: "",
|
memo: "",
|
rectifycompletedate: "",
|
rectifydeadline: "",
|
rectifymeasure: "",
|
rectifyprincipal: "",
|
rectifystatus: "",
|
resultid: "",
|
url: "",
|
},
|
dataForm:{
|
applyperson:'',
|
reportcode:"",
|
reportid:"",
|
report:[],
|
},
|
addProjectVisible:false,
|
listLoading:false,
|
defaultProps: {
|
children: 'submenu',
|
label: 'name'
|
},
|
}
|
},
|
created() {
|
this.getMenuList()
|
this.getSelfExamList()
|
},
|
watch: {
|
tableData: {
|
handler(n, o) {
|
this.getSpanArr(this.tableData)
|
},
|
immediate: true
|
}
|
},
|
methods:{
|
async getMenuList(){
|
let res = await getMenu()
|
this.MenuList = res.data.result
|
},
|
async getSelfExamList(){
|
this.listLoading = true
|
if(this.$route.query.title === '修改'){
|
this.level = this.$route.query.code
|
this.dataForm.reportcode = this.$route.query.code
|
this.dataForm.reportid = this.$route.query.id
|
var res = await getUpdateSelfExamList(this.id,this.level)
|
}else{
|
var res = await getSelfExamList(this.id,this.level)
|
}
|
if(res.data.code === "200"){
|
this.dataList = res.data.result
|
this.tableData = res.data.result
|
}else{
|
this.$message({
|
type:'warning',
|
message:res.data.message
|
})
|
}
|
this.listLoading = false
|
},
|
objectSpanMethod({ row, column, rowIndex, columnIndex }) {
|
// columnIndex === xx 找到第xx列,实现合并随机出现的行数
|
if (columnIndex === 0 || columnIndex==1 || columnIndex === 2) {
|
const _row = this.spanArr[rowIndex];
|
const _col = _row > 0 ? 1 : 0;
|
return {
|
rowspan: _row,
|
colspan: _col
|
};
|
}
|
},
|
getSpanArr(data) {
|
this.spanArr = [];
|
this.pos = 0;
|
for (var i = 0; i < data.length; i++) {
|
if (i === 0) {
|
// 如果是第一条记录(即索引是0的时候),向数组中加入1
|
this.spanArr.push(1);
|
this.pos = 0;
|
} else {
|
if (data[i].checkcontent === data[i - 1].checkcontent || data[i].basis === data[i - 1].basis ||data[i].checkcriteria === data[i - 1].checkcriteria) {
|
// 如果itemCode相等就累加,并且push 0
|
this.spanArr[this.pos] += 1;
|
this.spanArr.push(0);
|
} else {
|
// 不相等push 1
|
this.spanArr.push(1);
|
this.pos = i;
|
}
|
}
|
}
|
},
|
async submitAdd(){
|
this.dataForm.report = JSON.stringify(this.dataList)
|
const formData = new FormData();
|
for (const i in this.dataForm) {
|
if (
|
this.dataForm[i] != undefined &&
|
this.dataForm[i].toString() != ""
|
) {
|
formData.append(i, this.dataForm[i]);
|
}
|
}
|
if(this.$route.query.title === "新增") {
|
let res = await addSelfExam(formData)
|
if (res.data.code === "200") {
|
this.$router.go(-1)
|
this.$notify({
|
title: '成功',
|
message: '新增成功',
|
duration: 2000,
|
type: 'success',
|
})
|
} else {
|
this.$message({
|
message: res.data.message,
|
type: 'warning',
|
})
|
}
|
}else{
|
let res = await updateSelfExam(formData)
|
if (res.data.code === "200") {
|
this.$router.go(-1)
|
this.$notify({
|
title: '成功',
|
message: '修改成功',
|
duration: 2000,
|
type: 'success',
|
})
|
} else {
|
this.$message({
|
message: res.data.message,
|
type: 'warning',
|
})
|
}
|
}
|
},
|
addQualifiedProject(event,value){
|
if(event == true){
|
for(let i = 0;i<this.dataList.length;i++){
|
if(value.result1 == this.dataList[i].result1){
|
this.dataList[i].qualified = true
|
this.dataList[i].unqualified = false
|
this.dataList[i].answer.resultid = this.dataList[i].result1
|
}
|
}
|
for(let i = 0;i<this.tableData.length;i++){
|
if(value.result1 == this.tableData[i].result1){
|
this.tableData[i].qualified = true
|
this.tableData[i].unqualified = false
|
this.tableData[i].answer.resultid = this.tableData[i].result1
|
}
|
}
|
}else if(event == false){
|
for(let i = 0;i<this.dataList.length;i++){
|
if(value.result1 == this.dataList[i].result1){
|
this.dataList[i].qualified = false
|
}
|
}
|
for(let i = 0;i<this.tableData.length;i++){
|
if(value.result1 == this.tableData[i].result1){
|
this.tableData[i].qualified = false
|
}
|
}
|
}
|
},
|
addUnqualifiedProject(event,value){
|
if(event == true){
|
this.addProjectVisible = true
|
this.updateId = value.result1
|
for(let i = 0;i<this.dataList.length;i++){
|
if(this.dataList[i].result1 == value.result1){
|
if(this.dataList[i].answer.findtime == null){
|
this.answer.findtime = ""
|
}else{
|
this.answer.findtime = this.dataList[i].answer.findtime
|
}
|
if(this.dataList[i].answer.level == null){
|
this.answer.level = ""
|
}else{
|
this.answer.level = this.dataList[i].answer.level
|
}
|
if(this.dataList[i].answer.memo == null){
|
this.answer.memo = ""
|
}else{
|
this.answer.memo = this.dataList[i].answer.memo
|
}
|
if(this.dataList[i].answer.rectifycompletedate == null){
|
this.answer.rectifycompletedate = ""
|
}else{
|
this.answer.rectifycompletedate = this.dataList[i].answer.rectifycompletedate
|
}
|
if(this.dataList[i].answer.rectifydeadline == null){
|
this.answer.rectifydeadline = ""
|
}else{
|
this.answer.rectifydeadline = this.dataList[i].answer.rectifydeadline
|
}
|
if(this.dataList[i].answer.rectifymeasure == null){
|
this.answer.rectifymeasure = ""
|
}else{
|
this.answer.rectifymeasure = this.dataList[i].answer.rectifymeasure
|
}
|
if(this.dataList[i].answer.rectifyprincipal == null){
|
this.answer.rectifyprincipal = ""
|
}else{
|
this.answer.rectifyprincipal = this.dataList[i].answer.rectifyprincipal
|
}
|
if(this.dataList[i].answer.rectifystatus == null){
|
this.answer.rectifystatus = ""
|
}else{
|
this.answer.rectifystatus = this.dataList[i].answer.rectifystatus
|
}
|
if(this.dataList[i].answer.url == null){
|
this.answer.url = ""
|
}else{
|
this.answer.url = this.dataList[i].answer.url
|
}
|
this.dataList[i].unqualified = true
|
this.dataList[i].qualified = false
|
}
|
}
|
for(let i = 0;i<this.tableData.length;i++){
|
if(value.result1 == this.tableData[i].result1){
|
if(this.dataList[i].answer.findtime == null){
|
this.answer.findtime = ""
|
}else{
|
this.answer.findtime = this.dataList[i].answer.findtime
|
}
|
if(this.dataList[i].answer.level == null){
|
this.answer.level = ""
|
}else{
|
this.answer.level = this.dataList[i].answer.level
|
}
|
if(this.dataList[i].answer.memo == null){
|
this.answer.memo = ""
|
}else{
|
this.answer.memo = this.dataList[i].answer.memo
|
}
|
if(this.dataList[i].answer.rectifycompletedate == null){
|
this.answer.rectifycompletedate = ""
|
}else{
|
this.answer.rectifycompletedate = this.dataList[i].answer.rectifycompletedate
|
}
|
if(this.dataList[i].answer.rectifydeadline == null){
|
this.answer.rectifydeadline = ""
|
}else{
|
this.answer.rectifydeadline = this.dataList[i].answer.rectifydeadline
|
}
|
if(this.dataList[i].answer.rectifymeasure == null){
|
this.answer.rectifymeasure = ""
|
}else{
|
this.answer.rectifymeasure = this.dataList[i].answer.rectifymeasure
|
}
|
if(this.dataList[i].answer.rectifyprincipal == null){
|
this.answer.rectifyprincipal = ""
|
}else{
|
this.answer.rectifyprincipal = this.dataList[i].answer.rectifyprincipal
|
}
|
if(this.dataList[i].answer.rectifystatus == null){
|
this.answer.rectifystatus = ""
|
}else{
|
this.answer.rectifystatus = this.dataList[i].answer.rectifystatus
|
}
|
if(this.dataList[i].answer.url == null){
|
this.answer.url = ""
|
}else{
|
this.answer.url = this.dataList[i].answer.url
|
}
|
this.tableData[i].unqualified = true
|
this.tableData[i].qualified = false
|
}
|
}
|
}else{
|
for(let i = 0;i<this.dataList.length;i++){
|
if(value.result1 == this.dataList[i].result1){
|
this.dataList[i].unqualified = false
|
}
|
}
|
for(let i = 0;i<this.tableData.length;i++){
|
if(value.result1 == this.tableData[i].result1){
|
this.tableData[i].unqualified = false
|
}
|
}
|
}
|
},
|
submit(){
|
this.addProjectVisible = false
|
for(let i = 0;i<this.dataList.length;i++){
|
if(this.updateId == this.dataList[i].result1){
|
this.dataList[i].answer.unqualified = true
|
this.dataList[i].answer.findtime=this.answer.findtime
|
this.dataList[i].answer.level=this.answer.level
|
this.dataList[i].answer.memo=this.answer.memo
|
this.dataList[i].answer.rectifycompletedate=this.answer.rectifycompletedate
|
this.dataList[i].answer.rectifydeadline=this.answer.rectifydeadline
|
this.dataList[i].answer.rectifymeasure=this.answer.rectifymeasure
|
this.dataList[i].answer.rectifyprincipal=this.answer.rectifyprincipal
|
this.dataList[i].answer.rectifystatus=this.answer.rectifystatus
|
this.dataList[i].answer.resultid = this.dataList[i].result0
|
}
|
}
|
for(let i = 0;i<this.tableData.length;i++){
|
if(this.updateId == this.tableData[i].result1){
|
this.tableData[i].answer.unqualified = true
|
this.tableData[i].answer.findtime=this.answer.findtime
|
this.tableData[i].answer.level=this.answer.level
|
this.tableData[i].answer.memo=this.answer.memo
|
this.tableData[i].answer.rectifycompletedate=this.answer.rectifycompletedate
|
this.tableData[i].answer.rectifydeadline=this.answer.rectifydeadline
|
this.tableData[i].answer.rectifymeasure=this.answer.rectifymeasure
|
this.tableData[i].answer.rectifyprincipal=this.answer.rectifyprincipal
|
this.tableData[i].answer.rectifystatus=this.answer.rectifystatus
|
this.tableData[i].answer.resultid = this.tableData[i].result0
|
}
|
}
|
},
|
cancel(){
|
this.addProjectVisible = false
|
for(let i = 0;i<this.dataList.length;i++){
|
if(this.updateId == this.dataList[i].result1){
|
this.dataList[i].unqualified = false
|
}
|
}
|
for(let i = 0;i<this.tableData.length;i++){
|
if(this.updateId == this.dataList[i].result1){
|
this.tableData[i].unqualified = false
|
}
|
}
|
},
|
handleNodeClick(value){
|
this.tableData = []
|
if(value.name === "基础管理"){
|
for(let i = 0;i<this.dataList.length;i++){
|
if(this.dataList[i].parentmenuid == 3 || this.dataList[i].parentmenuid == 4 || this.dataList[i].parentmenuid == 5 || this.dataList[i].parentmenuid ==6|| this.dataList[i].parentmenuid == 7 || this.dataList[i].parentmenuid == 8 ||this.dataList[i].parentmenuid == 9 ||this.dataList[i].parentmenuid == 10 ||this.dataList[i].parentmenuid == 11 ||this.dataList[i].parentmenuid == 12 || this.dataList[i].parentmenuid == 13){
|
this.tableData.push(this.dataList[i])
|
}
|
}
|
}else if(value.name === "现场管理"){
|
for(let i = 0;i<this.dataList.length;i++){
|
if(this.dataList[i].parentmenuid == 14 || this.dataList[i].parentmenuid == 15 || this.dataList[i].parentmenuid == 16 || this.dataList[i].parentmenuid ==17){
|
this.tableData.push(this.dataList[i])
|
}
|
}
|
}
|
for(let i = 0;i<this.dataList.length;i++){
|
if(value.id == this.dataList[i].parentmenuid){
|
this.tableData.push(this.dataList[i])
|
}
|
}
|
},
|
async uploadFile(){
|
const files1 = this.$refs["upload"].files;
|
const formData = new FormData();
|
if (files1 && files1.length > 0) {
|
for (let i = 0; i < files1.length; i++)
|
formData.append("file", files1[i]);
|
}
|
let res = await updateFile(formData)
|
if(res.data.code === "200"){
|
for(let i = 0;i<this.tableData.length;i++) {
|
if (this.updateId == this.tableData[i].result1) {
|
this.tableData[i].answer.url = res.data.result
|
}
|
}
|
for(let i = 0;i<this.dataList.length;i++) {
|
if (this.updateId == this.dataList[i].result1) {
|
this.dataList[i].answer.url = res.data.result
|
}
|
}
|
this.$message({
|
title:'成功',
|
message:'上传成功',
|
type:'success',
|
duration:2000
|
})
|
}
|
},
|
goBefore(){
|
this.$router.go(-1)
|
}
|
}
|
}
|
</script>
|
|
<style scoped>
|
.addSelfExam_tree {
|
display: flex;
|
margin-top: 40px;
|
|
}
|
|
.right {
|
width: 220px;
|
height: 800px;
|
}
|
|
.left {
|
flex: 1;
|
margin-left: 10px;
|
}
|
|
.el-tree {
|
border: none;
|
}
|
.dis-inline-b{
|
display: inline-block;
|
margin-bottom: 10px;
|
}
|
.w-150{
|
width: 200px;
|
}
|
/deep/ .el-checkbox__inner{
|
width:16px;
|
height:16px;
|
}
|
/deep/ .el-input__inner {
|
width:300px;
|
}
|
.basic_search{
|
width:500px;
|
display:inline-block;
|
}
|
|
</style>
|