lyfO_o
2022-07-12 c562fa2e66f4972ae23fa57ef7412da6e18991ed
src/views/hiddenDangerRegistration/index.vue
@@ -143,39 +143,42 @@
            <el-col :span="14">
                <el-form ref="form" :inline="true" :model="form" label-width="100px">
                    <el-form-item label="EXCEL导入">
                        <el-input v-model="form.name" placeholder="未选择文件"></el-input>
                    </el-form-item>
                    <el-form-item>
<!--                        <el-input v-model="form.name" placeholder="未选择文件"></el-input>-->
                        <el-upload
                            class="upload-demo"
                            class="upload-demo inline-block margin-right-10"
                            ref="upload"
                            action=""
                            :http-request="uploadSectionFile"
                            :on-preview="handlePreview"
                            :on-remove="handleRemove"
                            :file-list="fileList"
                            :before-upload="beforeUpload"
                            :auto-upload="true"
                            :auto-upload="false"
                        >
                            <el-button type="primary" size="small" class="btns">选择文件</el-button>
                            <el-button slot="trigger" size="small" type="primary">选取文件</el-button>
                            <el-button
                                type="primary"
                                class="btns"
                                size="small"
                                icon="el-icon-bottom"
                                @click="dangerImport"
                            >导入</el-button
                            >
                            <el-button
                                type="primary"
                                class="btns"
                                size="small"
                                icon="el-icon-download"
                                @click="downloadTemplate"
                            >下载模板</el-button
                            >
                        </el-upload>
                        <el-button
                            type="primary"
                            class="btns"
                            size="small"
                            icon="el-icon-bottom"
                        >导入</el-button
                        >
                        <el-button
                            type="primary"
                            class="btns"
                            size="small"
                            icon="el-icon-download"
                            @click="downloadTemplate"
                        >下载模板</el-button
                        >
                    </el-form-item>
                </el-form>
            </el-col>
<!--            <el-col :span="14-fileSpan">-->
<!--                -->
<!--            </el-col>-->
            <el-col :span="10" style="text-align: right">
                <el-button
                    class="btns"
@@ -200,7 +203,12 @@
            <el-table-column prop="check_man" label="检查人" align="center" width="120"></el-table-column>
            <el-table-column prop="checktype" label="检查类别" align="center"></el-table-column>
            <el-table-column label="隐患项目" align="center">
                <el-table-column prop="check_date" label="检查时间" :formatter="formatColumnDate"  width="120" align="center"></el-table-column>
                <el-table-column prop="check_date" label="检查时间" width="120" align="center">
                    <template slot-scope="scope">
                        <label>{{ formatDate(scope.row.check_date) }}</label><br/>
                        <label>{{ scope.row.check_class }}</label>
                    </template>
                </el-table-column>
                <el-table-column prop="address" label="地点" align="center"> </el-table-column>
                <el-table-column prop="ht_content" label="内容" align="center">
                    <template slot-scope="scope">
@@ -230,7 +238,7 @@
                </el-table-column>
                <el-table-column prop="ht_branch" label="隐患部门" align="center"> </el-table-column>
                <el-table-column prop="duty_officer" label="责任人" align="center"> </el-table-column>
                <el-table-column prop="alter_time" label="限改时间" width="120" align="center"></el-table-column>
                <el-table-column prop="alter_time" label="限改时间" width="120" :formatter="formatColumnDate"  align="center"></el-table-column>
                <el-table-column prop="ht_level" label="级别" align="center"> </el-table-column>
            </el-table-column>
            <el-table-column label="整改情况" align="center">
@@ -284,7 +292,7 @@
    </div>
</template>
<script>
import {getPageList,delDanger,analogy_export_do,downloadFile} from "@/api/sgyhpczl/hiddenDangerRegistration";
import {getPageList,delDanger,analogy_export_do,downloadFile,danger_import_do} from "@/api/sgyhpczl/hiddenDangerRegistration";
import {initJCBM ,initYHLX, initBC ,initJCLB ,initYHBM ,initYHJB,initLlr} from "@/api/sgyhpczl/initSelect";
export default {
    data() {
@@ -294,7 +302,7 @@
            llrList:[],
            options: [],
            form:{},
            fileSpan:3,
            JCDWList:[{label:"众泰煤焦化",value:0},{label:"上级单位",value:1}],
            JCBMList:[],
            YHLXList:[],
@@ -465,35 +473,33 @@
        },
        beforeUpload(file) {
            var FileExt = file.name.replace(/.+\./, "");
            //.jpg,.gif,.bmp,.png,.doc,.docx,.pdf,.ppt,.pptx,.xls,.xlsx,.rar,.zip
            if (['jpg', 'png', 'bmp', 'gif', 'jpeg','doc','docx','pdf','ppt','xls','pptx','xls','xlsx','rar','zip'].indexOf(FileExt.toLowerCase()) === -1) {
            if (['xls','xlsx'].indexOf(FileExt.toLowerCase()) === -1) {
                this.$message({
                    type: 'warning',
                    message: '请上传后缀名为jpg,gif,bmp,png,doc,docx,pdf,ppt,pptx,xls,xlsx,rar,zip的图片!'
                    message: '请上传后缀名为xls,xlsx的图片!'
                });
                return false;
            }
        },
        //上传
        uploadSectionFile(param) {
            console.log(param)
            let form = new FormData();
            var that = this;
            form.append('file', param.file);
            //隐患延期申请附件
            form.append('type', "0");
            uploadFile(form).then(res => {
                var data = res.data;
                if (data.ok) {
                    var fileName = data.data.fileName[0];
                    if (!fileName.endsWith("a62b")) {
                        fileName = fileName + "a62b";
                    }
                    var fileObj = {
                        "fileName": fileName,
                        "uid": param.file.uid
                    }
                    this.fileNameList.push(fileObj);
            danger_import_do(form).then(res=>{
                if (res.data.ok==1){
                    console.log(res.data)
                } else{
                    this.$message({type:'error', message:res.data.msg, duration:3000})
                }
            }).catch(err => {
                console.log(err)
            })
        },
        //导入
        dangerImport(){
            this.$refs.upload.submit();
        },
        //下载模板
        downloadTemplate(){
@@ -533,6 +539,15 @@
            }).catch(err => {
                console.log(err)
            })
        },
        //方法区
        formatDate(data) {
            // 获取单元格数据
            if (data == null) {
                return null
            }
            let dt = new Date(data)
            return dt.getFullYear() + '-' + (dt.getMonth() + 1) + '-' + dt.getDate()
        },
        //日期格式转换
        formatColumnDate(row, column) {
@@ -620,6 +635,9 @@
};
</script>
<style>
    .inline-block {
        display: inline-block;
    }
    .inquire {
        display: flex;
        justify-content: left;