马宇豪
2023-05-05 c819024e241b9f7c54cc3786373ad0d2998f2190
src/views/hiddenDangerManagement/fillRectification.vue
@@ -1,13 +1,290 @@
<template>
    <div class="app-container">
        <div>
            <Titlename title="填写整改"></Titlename>
            <div class="whole-form">
                <el-form :model="config" ref="configTableForm">
                    <el-table
                        :data="tableData"
                        border
                        style="width: 1600px"
                        @cell-mouse-enter="handleCellEnter"
                        @cell-mouse-leave="handleCellLeave"
                    >
                        <el-table-column
                            prop="serial"
                            label="序号"
                            align="center"
                            width="50">
                        </el-table-column>
                        <el-table-column
                            prop="number"
                            label="编号"
                            align="center"
                            width="100">
                        </el-table-column>
                        <el-table-column
                            prop="ht_branch"
                            label="隐患单位"
                            align="center"
                            width="100">
                        </el-table-column>
                        <el-table-column
                            prop="check_man"
                            label="检查人"
                            align="center"
                            width="100">
                        </el-table-column>
                        <el-table-column
                            prop="check_class"
                            label="检查班次"
                            align="center"
                            width="80">
                        </el-table-column>
                        <el-table-column
                            prop="check_date"
                            label="检查时间"
                            :formatter="formatDate"
                            align="center"
                            width="100">
                        </el-table-column>
                        <el-table-column
                            prop="address"
                            label="地点"
                            align="center"
                            width="100">
                        </el-table-column>
                        <el-table-column
                            prop="ht_content"
                            label="内容"
                            align="center"
                            width="180">
                        </el-table-column>
                        <el-table-column
                            prop="ht_typesub"
                            label="类别"
                            align="center"
                            width="80">
                        </el-table-column>
                        <el-table-column
                            prop="ht_level"
                            label="级别"
                            align="center"
                            width="120">
                        </el-table-column>
                        <el-table-column
                            prop="measure"
                            label="整改措施"
                            align="center"
                            width="120">
                        </el-table-column>
                        <el-table-column
                            prop="duty_officer"
                            label="责任人"
                            align="center"
                            width="100">
                        </el-table-column>
                        <el-table-column
                            prop="alter_time"
                            label="限改时间"
                            :formatter="formatDate"
                            align="center"
                            width="120">
                        </el-table-column>
                        <el-table-column
                            prop="ACCOMPLISHTIME"
                            align="center"
                            label="完成时间"
                            width="160">
                            <div class="item" slot-scope="scope">
                                <el-date-picker
                                    v-model="scope.row.ACCOMPLISHTIME"
                                    type="date"
                                    value-format="yyyy-MM-dd"
                                    placeholder="选择日期" clearable>
                                </el-date-picker>
                                <div class="item__txt">{{scope.row.ACCOMPLISHTIME}}</div>
                            </div>
                        </el-table-column>
                        <el-table-column
                            prop="CALLBACKPERSON"
                            label="复查人"
                            align="center"
                            width="160">
                            <div class="item" slot-scope="scope">
                                <el-input class="item__input" v-model="scope.row.CALLBACKPERSON" placeholder="请输入内容" clearable></el-input>
                                <div class="item__txt">{{scope.row.CALLBACKPERSON}}</div>
                            </div>
                        </el-table-column>
                        <el-table-column
                            prop="CALLBACKTIME"
                            align="center"
                            width="160"
                            label="复查时间">
                            <div class="item" slot-scope="scope">
                                <el-date-picker
                                    v-model="scope.row.CALLBACKTIME"
                                    value-format="yyyy-MM-dd"
                                    type="date"
                                    placeholder="选择日期" clearable>
                                </el-date-picker>
                                <div class="item__txt">{{scope.row.CALLBACKTIME}}</div>
                            </div>
                        </el-table-column>
                    </el-table>
                </el-form>
                <div class="btn">
                    <el-button
                        class="btns"
                        type="primary"
                        size="small"
                        @click="submitConfig('config')">保存</el-button>
                    <el-button
                        size="small" @click="close()">关闭</el-button>
                </div>
            </div>
        </div>
    </div>
</template>
<script>
    import {self_edit_do} from "@/api/sgyhpczl/hiddenDangerManagement";
    import Titlename from "../../components/Titlename/index.vue";
    import tab from "../../components/Tab";
    export default {
        name: "fillRectification"
        components: {Titlename},
        name: "fillRectification",
        data() {
            return {
                // 表格数据
                tableData: [],
                // 需要编辑的属性
                editProp: ['completionTime', 'rechecker', 'reviewTimes']
            };
        },
        computed: {
            foodLabel () {
                return (val) => {
                    return this.options.find(o => o.value === val).label
                }
            }
        },
        mounted(){
            this.tableData = this.$route.query.checkData;
        },
        methods: {
            /** 鼠标移入cell */
            handleCellEnter (row, column, cell, event) {
                const property = column.property
                if (this.editProp.includes(property)) {
                    // cell.querySelector('.item__input').style.display = 'block'
                    // cell.querySelector('.item__txt').style.display = 'none'
                }
            },
            /** 鼠标移出cell */
            handleCellLeave (row, column, cell, event) {
                const property = column.property
                if (this.editProp.includes(property)) {
                    // cell.querySelector('.item__input').style.display = 'none'
                    // cell.querySelector('.item__txt').style.display = 'block'
                }
            },
            submitConfig(){
                var requestData = [];
                for (const n of this.tableData) {
                    if (n.CALLBACKTIME == null || n.CALLBACKTIME == ""
                        || n.CALLBACKPERSON == null || n.CALLBACKPERSON == ""
                        || n.ACCOMPLISHTIME == null ) {
                        this.$message({type: 'Warn', message: "请填写完整信息", duration: 3000})
                        return;
                    }
                    var sigleData = {};
                    sigleData.id = n.id;
                    sigleData.type = "1";
                    sigleData.CALLBACKTIME = n.CALLBACKTIME;
                    sigleData.CALLBACKPERSON = n.CALLBACKPERSON;
                    sigleData.ACCOMPLISHTIME = n.ACCOMPLISHTIME;
                    requestData.push(sigleData);
                }
                var successFlag = 0;
                for (let i = 0; i < requestData.length; i++) {
                    self_edit_do(requestData[i]).then(res=>{
                        if(res.data.ok){
                            successFlag ++;
                            if(successFlag== requestData.length){
                                this.$message({type: 'success', message: "操作成功!", duration: 3000})
                                this.$router.push({
                                    path:"/hiddenDangerManagement"
                                })
                            }
                        }
                    })
                }
            },
            formatDate(row, column) {
                // 获取单元格数据
                let data = row[column.property]
                if(data == null) {
                    return null
                }
                let dt = new Date(data)
                return dt.getFullYear() + '-' + (dt.getMonth() + 1) + '-' + dt.getDate()
            },
            close(){
                this.$router.push({
                    path:"/hiddenDangerManagement"
                })
            },
        }
    }
</script>
<style scoped>
    .app-container {
        padding: 20px;
        height: 850px;
        overflow-y: auto;
    }
    .whole-form{
        margin-top: 20px;
    }
    .item .item__input {
        /*display: none;*/
        font-size: 14px;
    }
   /deep/ .item .item__input .el-input__inner{
        font-size: 14px;
   }
   .item .item__txt{
       display: none;
       /*box-sizing: border-box;*/
       /*padding: 0 15px;*/
       /*height: 36px;*/
       /*line-height: 36px;*/
       /*font-size: 14px;*/
       /* border: 1px solid transparent;*/
   }
    /deep/ .item .el-input--medium .el-input__inner{
        /*display: none;*/
       width: 140px;
   }
   /deep/ .is-center{
       font-size: 14px;
   }
    .btn{
        text-align: center;
        margin-top: 50px;
    }
    .btns{
        background-color: #034ea2;
        border: 1px solid #034ea2;
    }
    /*.el-button:hover {*/
    /*    background: #66b1ff;*/
    /*    border-color: #66b1ff;*/
    /*    color: #FFF;*/
    /*}*/
</style>