lyfO_o
2022-03-24 c251626c67a55dfa8305fd49a47a0a2aa00fc32f
src/views/hiddenDanger/report.vue
@@ -1,12 +1,14 @@
<template>
    <div class="app-container">
        <div style="margin: 10px">
            <span class="span-filter-label" style="margin-left: unset">作业编号</span>
            <el-input style="width: 160px" v-model="filter.filter.taskcode"></el-input>
            <span class="span-filter-label">单号</span>
            <el-input style="width: 140px" v-model="filter.filter.code" ></el-input>
            <span class="span-filter-label">状态</span>
            <el-select
                v-model="filter.filter.status"
                class="filter-item"
                clearable
                @clear="clearStatus"
                style="width:150px;margin-bottom: 10px">
                <el-option
                    v-for="item in reportStatus"
@@ -16,7 +18,10 @@
                </el-option>
            </el-select>
            <span class="span-filter-label">隐患等级</span>
            <el-select v-model="filter.filter.level"  placeholder="请选择">
            <el-select v-model="filter.filter.level"
                       clearable
                       @clear="clearLevel"
                       placeholder="请选择">
                <el-option
                    v-for="item in levels"
                    :key="item.key"
@@ -25,10 +30,9 @@
                </el-option>
            </el-select>
            <span class="span-filter-label">负责人</span>
            <el-input style="width: 160px" v-model="filter.filter.principal"></el-input>
            <span class="span-filter-label">整改人</span>
            <el-input style="width: 160px" v-model="filter.filter.supervisor"></el-input>
            <el-input style="width: 160px" v-model="filter.filter.rectifierName"></el-input>
            <el-button class="filter-item" style="margin-left: 10px;" type="primary"
                       icon="el-icon-plus" @click="showCreateHandle">新增
@@ -47,18 +51,32 @@
                style="width: 100%;"
            >
                <el-table-column type="index" label="序号" align="center" width="80"/>
                <el-table-column label="状态" prop="status" align="center" />
                <el-table-column label="作业编号" prop="taskcode" align="center" />
                <el-table-column label="单号" prop="code" align="center" />
                <el-table-column label="状态" prop="status" align="center" >
                    <template slot-scope="scope">
                        <span >{{scope.row.status}}</span>
                         <span v-if="new Date(scope.row.rectifydeadline) < new Date() && scope.row.status  !== '已完成'" class="overdue-img">逾期</span>
                    </template>
                </el-table-column>
                <el-table-column label="隐患等级" prop="level" align="center" >
                    <template slot-scope="scope">
                        <el-tag :type="scope.row.level == '紧急'?'danger':'warning'">{{scope.row.level}}</el-tag>
                    </template>
                </el-table-column>
                <el-table-column label="上报人" prop="requestor" align="center" />
                <el-table-column label="负责人" prop="principal" align="center" />
                <el-table-column label="整改人" prop="supervisor" align="center" />
                <el-table-column label="上报时间" prop="createtime" align="center" />
                <el-table-column label="整改人" prop="rectifier" align="center" />
                <el-table-column label="创建时间" prop="createtime" align="center" />
                <el-table-column label="整改期限"   prop="rectifydeadline" align="center" >
                    <template slot-scope="scope">
                        <span v-bind:class="{'overdue':new Date(scope.row.rectifydeadline) < new Date() && scope.row.status  !== '已完成'}">{{scope.row.rectifydeadline}}
                        </span>
                    </template>
                </el-table-column>
                <el-table-column label="整改时间"   prop="rectifytime" align="center" >
                </el-table-column>
                <el-table-column label="验收时间"   prop="accepttime" align="center" >
                </el-table-column>
                <el-table-column label="操作" align="center" width="240" class-name="small-padding fixed-width">
                    <template slot-scope="scope">
                        <el-button  type="text" @click="viewHandle(scope.row)">查看</el-button>
@@ -68,9 +86,9 @@
            <br>
            <el-pagination
                v-show="recordTotal>0"
                :current-page="currentPage"
                :current-page="filter.pageIndex"
                :page-sizes="[10, 20, 30, 50]"
                :page-size="pageSize"
                :page-size="filter.pageSize"
                :total="recordTotal"
                layout="total, sizes, prev, pager, next, jumper"
                background
@@ -79,340 +97,136 @@
                @current-change="handleCurrentChange"
            />
        </div>
        <el-dialog :title="dialogStatus==='create'?'新增':'查看'" :visible.sync="dialogFormVisible"
                   :modal-append-to-body="false" :close-on-click-modal="false" width="800px">
            <el-form ref="dataForm" :rules="dataFormRules" :model="dataForm" label-position="right" label-width="140px"
                     style="" element-loading-text="保存中...">
                <el-form-item label="作业编号:">
                    <el-input v-model="dataForm.taskCode" readonly style="width: 205px"  placeholder="请选择" >
                    </el-input>
                    <el-button style="margin-left: 10px;" type="primary"
                                @click="showTask">选择
                    </el-button>
                </el-form-item>
                <el-form-item label="隐患级别:">
                    <el-select v-model="dataForm.level"  placeholder="请选择" :disabled="isView">
                        <el-option
                            v-for="item in levels"
                            :key="item.key"
                            :label="item.value"
                            :value="item.key">
                        </el-option>
                    </el-select>
                </el-form-item>
                <el-form-item label="上报说明:" >
                    <el-input
                        style="width: 400px"
                        type="textarea"
                        :rows="3"
                        :disabled="isView"
                        placeholder="请输入内容"
                        v-model="dataForm.note">
                    </el-input>
                </el-form-item>
                <el-form-item label="上报图片:" v-if="!isView">
                    <el-upload
                        ref="upload"
                        :action="baseUrl"
                        :auto-upload="false"
                        :headers="headers"
                        :on-change="handleChange"
                        name="file"
                        :file-list="fileList"
                        list-type="picture-card"
                        multiple
                    >
                        <i class="el-icon-plus"></i>
                    </el-upload>
                </el-form-item>
                <el-form-item label="上报图片:" v-if="isView" >
                    <el-image
                        class="upload-img"
                        v-for='item in imgUrls'
                        :key='item.id'
                        :src="item.url"
                        :preview-src-list="imgPreviewUrls"
                        style="width:200px;height: 200px;margin: 10px;"
                    >
                    </el-image>
                </el-form-item>
                <el-form-item label="确认说明:" :disabled="!isView" v-if="isConfirm">
                    <el-input
                        style="width: 400px"
                        type="textarea"
                        :rows="3"
                        placeholder="请输入内容"
                        v-model="dataForm.note">
                    </el-input>
                </el-form-item>
            </el-form>
            <div style="margin-top: 20px;margin-left: 140px;"  class="dialog-footer" v-if="!isView">
                <el-button @click="dialogFormVisible = false">取消</el-button>
                <el-button type="primary" @click="trigger2Submit" :disabled="submiting">上报</el-button>
            </div>
        </el-dialog>
        <div style="clear: both;"></div>
        <task-select ref="selectTask" @getInfo="selectSetValue" ></task-select>
        <report-view ref="reportView" ></report-view>
        <report-dialog ref="reportDialog" @refresh="hiddenDangerList"></report-dialog>
    </div>
</template>
<script>
import Cookies from 'js-cookie'
import { checkBtnPermission} from "@/utils/permission";
import { parseError} from "@/utils/messageDialog";
import { computePageCount} from "@/utils";
import { mapGetters} from "vuex";
import { dictionaryAllItems } from '@/api/dictionary';
import { getSelectTask,hiddenDangerReport ,hiddenDangerReportList} from '@/api/hiddenDanger';
import  taskSelect from './taskSelect/taskSelect';
import {hiddenDangerReportList} from '@/api/hiddenDanger';
import reportView from './reportView/reportView'
import { Message, MessageBox } from 'element-ui'
import {addHelpDoc, delHelpDoc, editHelpDoc, helpDocList} from "@/api/helpDoc";
import {getToken} from "@/utils/auth";
import reportDialog from './reportDialog/reportDialog'
export default {
    name: "helpDoc",
    name: "report",
    components: {
        taskSelect,
        reportView
        reportView,
        reportDialog,
     },
    data() {
      return {
        baseUrl: process.env.BASE_API + 'hiddenDanger/report',
        headers: {
          'Authorization': getToken()
        },
        tasksInfo: [],
        imgUrls:[],
        imgPreviewUrls:[],
        isView:false,
        isConfirm:false,
        isRectify:false,
        fileList: [],
        pageSize: 10,
        recordTotal: 0,
        currentPage: 1,
        pageTotal: 0,
        tableKey: 0,
        tableData:[],
        helpDocData: null,
        listLoading: true,
        submiting:false,
        levels:[
          {"key":"URGENT","value":"紧急"},
          {"key":"COMMON","value":"一般"},
        ],
        reportStatus:[
          {"key":"UNCONFIRMED","value":"未确认"},
          {"key":"CONFIRMED","value":"确认未整改"},
          {"key":"REJECT","value":"已驳回"},
          {"key":"RECTIFIED","value":"已整改"},
          {"key":"TORECTIFY","value":"待整改"},
          {"key":"TOACCEPT","value":"整改待验收"},
          {"key":"REJECTED","value":"驳回待整改"},
          {"key":"COMPLETED","value":"已完成"},
        ],
        dataForm: {
          taskCode:'',
          taskid: '',
          rectifydeadline:'',
          rectifymeasure:'',
          rectifier:'',
          rectifierid:'',
          note: '',
          level:''
        },
        queryForm: {
          name: ''
        },
        dialogFormVisible: false,
        dialogStatus: '',
        dataFormRules: {},
        fileType: [],
        productVoList: [],
        productVoDialogVisible: false,
        productDialogFormVisible: false,
        productData: [],
        pageSizeProduct: 10,
        currentPageProduct: 1,
        recordTotalProduct: 0,
        pageTotalProduct: 0,
        queryProductForm: {
          name: '',
          manufacturer: '',
          directionCode: '',
          type: ''
        },
        isSupervision: '',
        manufacturer: '',
        enterpriseList: [],
        enterpriseDialogFormVisible: false,
        pageSizeEnterpise: 10,
        currentPageEnterpise: 1,
        recordTotalEnterpise: 0,
        pageTotalEnterpise: 0,
        filter:{
          pageIndex:1,
          pageSize:10,
          filter:{
            taskcode:'',
            status:"UNCONFIRMED",
            requestor:"",
            principal:"",
            supervisor:"",
            level:""
            code:'',
            status:null,
            level:null,
            rectifierName:'',
          }
        }
        },
      }
    },
    created() {
      this.hiddenDangerList();
    },
    methods: {
        refreshHandle: function () {
            this.hiddenDangerList()
        },
        queryHandle: function () {
            this.currentPage = 1
            this.filter.pageIndex = 1
            this.hiddenDangerList()
        },
        resetDataForm() {
            this.dataForm = {
                taskid: '',
                taskCode:'',
           this.dataForm= {
                rectifydeadline:'',
                rectifymeasure:'',
                rectifier:'',
                rectifierid:'',
                note: '',
                level:''
            }
        },
        showCreateHandle() {
            this.getSelectTasks()
            this.dialogFormVisible = true
            this.dialogStatus = 'create'
            this.isView = false
            this.resetDataForm()
            this.$refs.reportDialog.show()
        },
        viewHandle: function (row) {
           this.$refs.reportView.showDialog("查看",row)
        },
        handleSizeChange: function (val) {
            this.pageSize = val
            this.currentPage = 1
            this.filter.pageIndex = 1
            this.filter.pageSize = val
            this.hiddenDangerList()
        },
        handleCurrentChange: function (val) {
            this.currentPage = val
            this.filter.pageIndex = val
            this.hiddenDangerList()
        },
        getBtnPermission(btnType) {
            return checkBtnPermission(this.userType, btnType)
        },
        showProductHandle(){
            this.productDialogFormVisible = true;
        },
        showEnterprise(){
            this.enterpriseDialogFormVisible = true;
        },
        downloadHandle(fileurl){
            window.open(fileurl, '_blank')
            ;
        },
      selectSetValue(row){
          this.dataForm.taskCode = row.code
          this.dataForm.taskid = row.id
      },
        getSelectTasks(){
          getSelectTask()
            .then(res=>{
              if (res.status !== 200)
                this.$message({
                  message: '接口错误',
                  type: 'success'
                });
              else{
                this.tasksInfo = res.data.result.map(item=>{return {"id":item.id,"code":item.code}})
              }
            })
            .catch(res=>{
              console.log(res)
            })
        },
      handleChange(file, fileList) {
        this.fileList = fileList
      },
      trigger2Submit(){
        this.submiting = true
        let formData = new FormData()
        formData.append('taskid', this.dataForm.taskid)
        formData.append("note",this.dataForm.note)
        formData.append("level",this.dataForm.level)
        this.fileList.forEach(file=>{
          formData.append("files",file.raw)
        })
        hiddenDangerReport(formData).then(res=>{
          this.submiting = false
          if (res.status === 200) {
            if (res.data.code === '200') {
              this.dialogFormVisible = false
              this.$message({
                message: '创建成功',
                type: 'success'
              });
              this.hiddenDangerList()
            }else{
              this.$message({
                message: res.data.message,
                type: 'success'
              });
            }
            this.fileList = []
          }
          else{
            this.$message({
              message: '接口错误',
              type: 'warning'
            });
          }
          }
        )
      },
      hiddenDangerList(){
        hiddenDangerReportList(this.filter).then(res=>{
          this.listLoading = false
          if (res.status === 200) {
        this.listLoading = true
        hiddenDangerReportList(this.filter)
            .then(res=>{
            if (res.data.code === '200') {
              this.tableData =  res.data.result.records
              this.recordTotal =  res.data.result.total
            }
          }else{
            this.$message({
              message: '接口错误',
              type: 'warning'
            });
          }
            else{
              this.$message({message:  res.data.message, type: 'warning'});
            }
        })
            .catch(err=>{
                console.log(err)
                this.$message({message: '接口错误', type: 'warning'});
            })
            .finally(()=>{
                this.listLoading = false
            })
      },
      showTask(){
        this.$refs.selectTask.showTask()
      }
        clearStatus(){
            this.filter.filter.status = null
        },
        clearLevel(){
            this.filter.filter.level = null
        }
    }
}
@@ -425,5 +239,23 @@
        margin-right: 4px;
        margin-left: 7px;
    }
    .overdue{
        color: red;
    }
    .overdue-img{
        position: fixed;
        background-color: #f56c6c;
        border-radius: 4px;
        color: #fff;
        display: inline-block;
        font-size: 12px;
        height: 21px;
        line-height: 18px;
        text-align: center;
        white-space: nowrap;
        border: 1px solid #fff;
        transform: scale(0.8);
        padding: 1px 3px 0 3px;
    }
</style>