Sfoglia il codice sorgente

徐明浩
压力容器年检报告-批量导入更新、模板下载、导出
压力管道年检报告-批量导入更新、模板下载、导出

徐明浩 3 anni fa
parent
commit
db49797663

+ 3 - 0
master/src/main/java/com/ruoyi/project/common/CommonController.java

@@ -271,6 +271,9 @@ public class CommonController extends BaseController
         }else if( type.equals("reportYlrq") ) {
             downloadname = "压力容器年检报告批量导入更新模板.xlsx";
             url = "static/template/sems/reportYlrq.xlsx";
+        }else if( type.equals("reportYlgd") ) {
+            downloadname = "压力管道年检报告批量导入更新模板.xlsx";
+            url = "static/template/sems/reportYlgd.xlsx";
         }
         InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(url);
 

+ 132 - 8
master/src/main/java/com/ruoyi/project/sems/controller/TReportYlgdController.java

@@ -1,17 +1,18 @@
 package com.ruoyi.project.sems.controller;
 
+import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 
+import com.alibaba.fastjson.JSON;
+import com.ruoyi.common.utils.file.ExcelUtils;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.security.access.prepost.PreAuthorize;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
 import com.ruoyi.framework.aspectj.lang.annotation.Log;
 import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
 import com.ruoyi.project.sems.domain.TReportYlgd;
@@ -20,6 +21,7 @@ import com.ruoyi.framework.web.controller.BaseController;
 import com.ruoyi.framework.web.domain.AjaxResult;
 import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.framework.web.page.TableDataInfo;
+import org.springframework.web.multipart.MultipartFile;
 
 /**
  * 压力管道年检报告Controller
@@ -106,4 +108,126 @@ public class TReportYlgdController extends BaseController {
     public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(tReportYlgdService.deleteTReportYlgdByIds(ids));
     }
+
+    /**
+     * 批量导入
+     */
+    @Log(title = "压力容器批量导入更新", businessType = BusinessType.INSERT)
+    @PostMapping("/importForUpdate")
+    public AjaxResult importData(@RequestParam("file") MultipartFile file) throws IOException {
+        //获取操作人员ID
+        Long userId = getUserId();
+        //报错行数统计
+        List<Integer> failRow = new ArrayList<Integer>();
+        Workbook workbook = ExcelUtils.getWorkBook(file);
+        Sheet sheet = workbook.getSheetAt(0);
+        List<TReportYlgd> list = new ArrayList<>();
+
+        int rowNum = sheet.getPhysicalNumberOfRows();
+        int failNumber = 0;
+        for (int i = 2; i < rowNum; i++) {
+            try {
+                logger.info("读取行数:" + i);
+                Row row = sheet.getRow(i);
+                int cellNum = row.getPhysicalNumberOfCells();
+                TReportYlgd entity = new TReportYlgd();
+                for (int j = 0; j < cellNum; j++) {
+                    Cell cell = row.getCell(j);
+                    if (cell == null) {
+                        continue;
+                    }
+                    String cellValue = ExcelUtils.getCellValue(cell);
+                    logger.info("cellValue:" + cellValue);
+                    if (j == 0) {
+                        //使用证
+                        entity.setUseno(cellValue);
+                    } else if (j == 1) {
+                        //注册编号
+                        entity.setRegno(cellValue);
+                    } else if (j == 2) {
+                        //位号
+                        entity.setDevno(cellValue);
+                    } else if (j == 3) {
+                        //位号
+                        entity.setPj1(cellValue);
+                    } else if (j == 4) {
+                        //位号
+                        entity.setPj2(cellValue);
+                    } else if (j == 5) {
+                        //位号
+                        entity.setPj3(cellValue);
+                    } else if (j == 6) {
+                        //位号
+                        entity.setPj4(cellValue);
+                    } else if (j == 7) {
+                        //位号
+                        entity.setPj5(cellValue);
+                    } else if (j == 8) {
+                        //位号
+                        entity.setPj6(cellValue);
+                    } else if (j == 9) {
+                        //位号
+                        entity.setPj7(cellValue);
+                    } else if (j == 10) {
+                        //位号
+                        entity.setPj8(cellValue);
+                    } else if (j == 11) {
+                        //位号
+                        entity.setPj9(cellValue);
+                    } else if (j == 12) {
+                        //位号
+                        entity.setPj10(cellValue);
+                    } else if (j == 13) {
+                        //位号
+                        entity.setPj11(cellValue);
+                    } else if (j == 14) {
+                        //位号
+                        entity.setPj12(cellValue);
+                    } else if (j == 15) {
+                        //位号
+                        entity.setPj13(cellValue);
+                    } else if (j == 16) {
+                        //位号
+                        entity.setPj14(cellValue);
+                    } else if (j == 17) {
+                        //位号
+                        entity.setPj15(cellValue);
+                    } else if (j == 18) {
+                        //位号
+                        entity.setPj16(cellValue);
+                    } else if (j == 19) {
+                        //位号
+                        entity.setPj17(cellValue);
+                    }
+                }
+                entity.setCreaterCode(userId);
+                logger.info("entity:" + entity);
+                list.add(entity);
+            } catch (Exception e) {
+                failNumber++;
+                logger.info("e:" + JSON.toJSONString(e));
+                failRow.add(i + 1);
+            }
+        }
+        int successNumber = 0;
+        int failNum = 0;
+        for (TReportYlgd t : list
+        ) {
+            failNum++;
+            try {
+                //根据使用证、注册编号、位号,进行数据更新
+                this.tReportYlgdService.updateForImport(t);
+                successNumber++;
+            } catch (Exception e) {
+                failNumber++;
+                logger.info("e:" + e);
+                failRow.add(failNum + 1);
+            }
+        }
+        logger.info("list:" + JSON.toJSONString(list));
+        logger.info("successNumber:" + String.valueOf(successNumber));
+        logger.info("failNumber:" + String.valueOf(failNumber));
+        logger.info("failRow:" + String.valueOf(failRow));
+        return AjaxResult.success(String.valueOf(successNumber), failRow);
+    }
 }

+ 1 - 1
master/src/main/java/com/ruoyi/project/sems/controller/TReportYlrqController.java

@@ -222,7 +222,7 @@ public class TReportYlrqController extends BaseController {
         ) {
             failNum++;
             try {
-                //TODO 根据使用证、注册编号、位号,进行数据更新
+                //根据使用证、注册编号、位号,进行数据更新
                 this.tReportYlrqService.updateForImport(t);
                 successNumber++;
             } catch (Exception e) {

+ 0 - 35
master/src/main/java/com/ruoyi/project/sems/domain/TReportHiYlgd.java

@@ -24,146 +24,111 @@ public class TReportHiYlgd extends BaseEntity
     private Long reportId;
 
     /** 装置名称 */
-    @Excel(name = "装置名称")
     private String plantCode;
 
     /** 单元 */
-    @Excel(name = "单元")
     private String unit;
 
     /** 管道名称 */
-    @Excel(name = "管道名称")
     private String devname;
 
     /** 管道编号 */
-    @Excel(name = "管道编号")
     private String devno;
 
     /** 管道级别 */
-    @Excel(name = "管道级别")
     private String grade;
 
     /** 介质 */
-    @Excel(name = "介质")
     private String medium;
 
     /** 设计压力 */
-    @Excel(name = "设计压力")
     private String desPressure;
 
     /** 设计温度 */
-    @Excel(name = "设计温度")
     private String desTemp;
 
     /** 操作压力 */
-    @Excel(name = "操作压力")
     private String optPressure;
 
     /** 安全状况等级 */
-    @Excel(name = "安全状况等级")
     private String safeClass;
 
     /** 下次定期检验日期 */
     @JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+8")
-    @Excel(name = "下次定期检验日期", width = 30, dateFormat = "yyyy-MM-dd")
     private Date nextWarnDate;
 
     /** 操作温度 */
-    @Excel(name = "操作温度")
     private String optTemp;
 
     /** 年检报告编号 */
-    @Excel(name = "年检报告编号")
     private String yearReportNo;
 
     /** 1 */
-    @Excel(name = "1")
     private String pj1;
 
     /** 2 */
-    @Excel(name = "2")
     private String pj2;
 
     /** 3 */
-    @Excel(name = "3")
     private String pj3;
 
     /** 4 */
-    @Excel(name = "4")
     private String pj4;
 
     /** 5 */
-    @Excel(name = "5")
     private String pj5;
 
     /** 6 */
-    @Excel(name = "6")
     private String pj6;
 
     /** 7 */
-    @Excel(name = "7")
     private String pj7;
 
     /** 8 */
-    @Excel(name = "8")
     private String pj8;
 
     /** 9 */
-    @Excel(name = "9")
     private String pj9;
 
     /** 10 */
-    @Excel(name = "10")
     private String pj10;
 
     /** 11 */
-    @Excel(name = "11")
     private String pj11;
 
     /** 12 */
-    @Excel(name = "12")
     private String pj12;
 
     /** 13 */
-    @Excel(name = "13")
     private String pj13;
 
     /** 14 */
-    @Excel(name = "14")
     private String pj14;
 
     /** 15 */
-    @Excel(name = "15")
     private String pj15;
 
     /** 16 */
-    @Excel(name = "16")
     private String pj16;
 
     /** 17 */
-    @Excel(name = "17")
     private String pj17;
 
     /** 备注 */
-    @Excel(name = "备注")
     private String remarks;
 
     /** 检查日期 */
     @JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+8")
-    @Excel(name = "检查日期", width = 30, dateFormat = "yyyy-MM-dd")
     private Date checkDate;
 
     /** 下次年度检查日期 */
     @JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+8")
-    @Excel(name = "下次年度检查日期", width = 30, dateFormat = "yyyy-MM-dd")
     private Date nextCheckDate;
 
     /** 问题及处理 */
-    @Excel(name = "问题及处理")
     private String problem;
 
     /** 检查结论 */
-    @Excel(name = "检查结论")
     private String con;
 
     /** 生成时间 */

+ 0 - 51
master/src/main/java/com/ruoyi/project/sems/domain/TReportHiYlrq.java

@@ -24,210 +24,159 @@ public class TReportHiYlrq extends BaseEntity
     private Long reportId;
 
     /** 装置名称 */
-    @Excel(name = "装置名称")
     private String plantCode;
 
     /** 单元 */
-    @Excel(name = "单元")
     private String unit;
 
     /** 位号 */
-    @Excel(name = "位号")
     private String devno;
 
     /** 名称 */
-    @Excel(name = "名称")
     private String devname;
 
     /** 使用证号码 */
-    @Excel(name = "使用证号码")
     private String useno;
 
     /** 注册代码 */
-    @Excel(name = "注册代码")
     private String regno;
 
     /** 介质 */
-    @Excel(name = "介质")
     private String medium;
 
     /** 设计压力 */
-    @Excel(name = "设计压力")
     private String desPressure;
 
     /** 设计温度 */
-    @Excel(name = "设计温度")
     private String desTemp;
 
     /** 操作压力 */
-    @Excel(name = "操作压力")
     private String optPressure;
 
     /** 操作温度 */
-    @Excel(name = "操作温度")
     private String optTemp;
 
     /** 安全状况等级 */
-    @Excel(name = "安全状况等级")
     private String safeClass;
 
     /** 下次定期检验日期 */
     @JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+8")
-    @Excel(name = "下次定期检验日期", width = 30, dateFormat = "yyyy-MM-dd")
     private Date nextWarnDate;
 
     /** 年检报告编号 */
-    @Excel(name = "年检报告编号")
     private String yearReportNo;
 
     /** 1 */
-    @Excel(name = "1")
     private String pj1;
 
     /** 2 */
-    @Excel(name = "2")
     private String pj2;
 
     /** 3 */
-    @Excel(name = "3")
     private String pj3;
 
     /** 4 */
-    @Excel(name = "4")
     private String pj4;
 
     /** 5 */
-    @Excel(name = "5")
     private String pj5;
 
     /** 6 */
-    @Excel(name = "6")
     private String pj6;
 
     /** 7 */
-    @Excel(name = "7")
     private String pj7;
 
     /** 8 */
-    @Excel(name = "8")
     private String pj8;
 
     /** 9 */
-    @Excel(name = "9")
     private String pj9;
 
     /** 10 */
-    @Excel(name = "10")
     private String pj10;
 
     /** 11 */
-    @Excel(name = "11")
     private String pj11;
 
     /** 12 */
-    @Excel(name = "12")
     private String pj12;
 
     /** 13 */
-    @Excel(name = "13")
     private String pj13;
 
     /** 14 */
-    @Excel(name = "14")
     private String pj14;
 
     /** 15 */
-    @Excel(name = "15")
     private String pj15;
 
     /** 16 */
-    @Excel(name = "16")
     private String pj16;
 
     /** 17 */
-    @Excel(name = "17")
     private String pj17;
 
     /** 18 */
-    @Excel(name = "18")
     private String pj18;
 
     /** 19 */
-    @Excel(name = "19")
     private String pj19;
 
     /** 20 */
-    @Excel(name = "20")
     private String pj20;
 
     /** 21 */
-    @Excel(name = "21")
     private String pj21;
 
     /** 22 */
-    @Excel(name = "22")
     private String pj22;
 
     /** 23 */
-    @Excel(name = "23")
     private String pj23;
 
     /** 24 */
-    @Excel(name = "24")
     private String pj24;
 
     /** 25 */
-    @Excel(name = "25")
     private String pj25;
 
     /** 26 */
-    @Excel(name = "26")
     private String pj26;
 
     /** 27 */
-    @Excel(name = "27")
     private String pj27;
 
     /** 28 */
-    @Excel(name = "28")
     private String pj28;
 
     /** 29 */
-    @Excel(name = "29")
     private String pj29;
 
     /** 30 */
-    @Excel(name = "30")
     private String pj30;
 
     /** 31 */
-    @Excel(name = "31")
     private String pj31;
 
     /** 32 */
-    @Excel(name = "32")
     private String pj32;
 
     /** 备注 */
-    @Excel(name = "备注")
     private String remarks;
 
     /** 检查日期 */
     @JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+8")
-    @Excel(name = "检查日期", width = 30, dateFormat = "yyyy-MM-dd")
     private Date checkDate;
 
     /** 下次年度检查日期 */
     @JsonFormat(pattern = "yyyy-MM-dd" , timezone = "GMT+8")
-    @Excel(name = "下次年度检查日期", width = 30, dateFormat = "yyyy-MM-dd")
     private Date nextCheckDate;
 
     /** 问题及处理 */
-    @Excel(name = "问题及处理")
     private String problem;
 
     /** 检查结论 */
-    @Excel(name = "检查结论")
     private String con;
 
     /** 生成时间 */

+ 25 - 0
master/src/main/java/com/ruoyi/project/sems/domain/TReportYlgd.java

@@ -24,6 +24,12 @@ public class TReportYlgd extends TReportHiYlgd
     /** 设备id */
     private Long devId;
 
+    /** 注册代码 */
+    private String regno;
+
+    /** 使用证编号 */
+    private String useno;
+
     @TableField(exist = false)
     private TSpecdevYlgd devEntity;
 
@@ -214,6 +220,25 @@ public class TReportYlgd extends TReportHiYlgd
     @TableField(exist = false)
     private Long reportId;
 
+    public void setRegno(String regno)
+    {
+        this.regno = regno;
+    }
+
+    public String getRegno()
+    {
+        return regno;
+    }
+    public void setUseno(String useno)
+    {
+        this.useno = useno;
+    }
+
+    public String getUseno()
+    {
+        return useno;
+    }
+
     public Date getBuildDate() {
         return buildDate;
     }

+ 9 - 0
master/src/main/java/com/ruoyi/project/sems/mapper/TReportYlgdMapper.java

@@ -5,6 +5,7 @@ import java.util.List;
 import com.ruoyi.framework.aspectj.lang.annotation.DataScope;
 import com.ruoyi.framework.aspectj.lang.annotation.DataScopePlant;
 import com.ruoyi.project.sems.domain.TReportYlgd;
+import com.ruoyi.project.sems.domain.TReportYlrq;
 import com.ruoyi.project.sems.domain.TSpecdevYlgd;
 
 /**
@@ -52,6 +53,14 @@ public interface TReportYlgdMapper {
      */
     public List<Long> queryNeedUpdateIds();
 
+    /**
+     * 根据excel导入的数据进行数据更新操作
+     * 根据 位号、使用证、注册编号 3个条件去更新
+     * @param tReportYlgd excel中获取的数据
+     * @return
+     */
+    public int updateForImport(TReportYlgd tReportYlgd);
+
     /**
      * 查询压力管道年检报告
      *

+ 8 - 1
master/src/main/java/com/ruoyi/project/sems/service/ITReportYlgdService.java

@@ -3,7 +3,6 @@ package com.ruoyi.project.sems.service;
 import java.util.List;
 
 import com.ruoyi.project.sems.domain.TReportYlgd;
-import com.ruoyi.project.sems.domain.TSpecdevYlgd;
 
 /**
  * 压力管道年检报告Service接口
@@ -29,6 +28,14 @@ public interface ITReportYlgdService {
 
     public int deleteTReportYlgdByIds();
 
+    /**
+     * 根据excel导入的数据进行数据更新操作
+     * 根据 位号、使用证、注册编号 3个条件去更新
+     * @param tReportYlgd excel中获取的数据
+     * @return
+     */
+    public int updateForImport(TReportYlgd tReportYlgd);
+
     /**
      * 查询压力管道年检报告
      *

+ 5 - 0
master/src/main/java/com/ruoyi/project/sems/service/impl/TReportYlgdServiceImpl.java

@@ -70,6 +70,11 @@ class TReportYlgdServiceImpl implements ITReportYlgdService {
         return 0;
     }
 
+    @Override
+    public int updateForImport(TReportYlgd tReportYlgd) {
+        return this.tReportYlgdMapper.updateForImport(tReportYlgd);
+    }
+
     /**
      * 查询压力管道年检报告
      *

+ 32 - 1
master/src/main/resources/mybatis/sems/TReportYlgdMapper.xml

@@ -129,6 +129,37 @@
 
     </select>
 
+    <update id="updateForImport">
+        update t_report_ylgd
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="pj1 != null">pj1 = #{pj1},</if>
+            <if test="pj2 != null">pj2 = #{pj2},</if>
+            <if test="pj3 != null">pj3 = #{pj3},</if>
+            <if test="pj4 != null">pj4 = #{pj4},</if>
+            <if test="pj5 != null">pj5 = #{pj5},</if>
+            <if test="pj6 != null">pj6 = #{pj6},</if>
+            <if test="pj7 != null">pj7 = #{pj7},</if>
+            <if test="pj8 != null">pj8 = #{pj8},</if>
+            <if test="pj9 != null">pj9 = #{pj9},</if>
+            <if test="pj10 != null">pj10 = #{pj10},</if>
+            <if test="pj11 != null">pj11 = #{pj11},</if>
+            <if test="pj12 != null">pj12 = #{pj12},</if>
+            <if test="pj13 != null">pj13 = #{pj13},</if>
+            <if test="pj14 != null">pj14 = #{pj14},</if>
+            <if test="pj15 != null">pj15 = #{pj15},</if>
+            <if test="pj16 != null">pj16 = #{pj16},</if>
+            <if test="pj17 != null">pj17 = #{pj17},</if>
+        </trim>
+        where dev_id = (
+        select id
+        from t_specdev_ylgd
+        where devno = #{devno}
+        and useno = #{useno}
+        and regno = #{regno}
+        and del_flag = 0
+        )
+    </update>
+
     <select id="queryNeedUpdateIds" resultType="Long">
         SELECT b.id
         FROM t_specdev_ylgd b
@@ -370,4 +401,4 @@
         </foreach>
     </update>
 
-</mapper>
+</mapper>

+ 1 - 0
master/src/main/resources/mybatis/sems/TReportYlrqMapper.xml

@@ -283,6 +283,7 @@
         where devno = #{devno}
         and useno = #{useno}
         and regno = #{regno}
+        and del_flag = 0
         )
     </update>
 

BIN
master/src/main/resources/static/template/sems/reportYlgd.xlsx


+ 117 - 2
ui/src/views/sems/reportYlgd/index.vue

@@ -58,9 +58,28 @@
           type="warning"
           size="mini"
           @click="dialogVisible = true"
-        >{{ $t('批量')+$t('下载')+$t('历史报告') }}
+        >{{ $t('批量') + $t('下载') + $t('历史报告') }}
         </el-button>
       </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="info"
+          icon="el-icon-upload2"
+          size="mini"
+          @click="handleImport"
+          v-hasPermi="['sems:reportYlgd:edit']"
+        >导入更新数据
+        </el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          icon="el-icon-download"
+          size="mini"
+          @click="handleExport"
+          v-hasPermi="['sems:reportYlgd:export']"
+        >{{ $t('导出') }}</el-button>
+      </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
@@ -534,6 +553,38 @@
       <el-button type="primary" @click="exportDataForYear">确 定</el-button>
       </span>
     </el-dialog>
+    <!-- 用户导入对话框 -->
+    <el-dialog :title="upload.title" :visible.sync="upload.open" width="400px" append-to-body>
+      <el-upload
+        ref="upload"
+        :limit="1"
+        accept=".xlsx, .xls"
+        :headers="upload.headers"
+        :action="upload.url + '?updateSupport=' + upload.updateSupport"
+        :disabled="upload.isUploading"
+        :on-progress="handleFileUploadProgress"
+        :on-success="handleFileSuccess"
+        :auto-upload="false"
+        drag
+      >
+        <i class="el-icon-upload"></i>
+        <div class="el-upload__text">
+          将文件拖到此处,或
+          <em>点击上传</em>
+        </div>
+        <div class="el-upload__tip" slot="tip">
+          <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
+        </div>
+        <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
+      </el-upload>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitFileForm">确 定</el-button>
+        <el-button @click="upload.open = false">取 消</el-button>
+      </div>
+      <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
+        <input name="type" :value="upload.type" hidden/>
+      </form>
+    </el-dialog>
   </div>
 </template>
 
@@ -554,12 +605,30 @@ import {getToken} from "@/utils/auth";
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 import YearApprove from './yearapprove'
+import {exportSpecGl} from "@/api/sems/specGl";
 
 export default {
   name: "ReportYlgd",
   components: {Treeselect, YearApprove},
   data() {
     return {
+      // 用户导入参数
+      upload: {
+        downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
+        type: "reportYlgd",
+        // 是否显示弹出层(用户导入)
+        open: false,
+        // 弹出层标题(用户导入)
+        title: "",
+        // 是否禁用上传
+        isUploading: false,
+        // 是否更新已经存在的用户数据
+        updateSupport: 0,
+        // 设置上传的请求头部
+        headers: {Authorization: "Bearer " + getToken()},
+        // 上传的地址
+        url: process.env.VUE_APP_BASE_API + "/sems/reportYlgd/importForUpdate"
+      },
       exportCheckYear: null,
       dialogVisible: false,
       // 遮罩层
@@ -1045,7 +1114,53 @@ export default {
       })
       //下载完成后关闭弹窗
       this.dialogVisible = false;
-    }
+    },
+    /** 导入按钮操作 */
+    handleImport() {
+      this.upload.title = "用户导入";
+      this.upload.open = true;
+    },
+    /** 下载模板操作 */
+    importTemplate() {
+      this.$refs['downloadFileForm'].submit()
+    },
+    // 文件上传中处理
+    handleFileUploadProgress(event, file, fileList) {
+      this.upload.isUploading = true;
+    },
+    // 文件上传成功处理
+    handleFileSuccess(response, file, fileList) {
+      this.upload.open = false;
+      this.upload.isUploading = false;
+      this.$refs.upload.clearFiles();
+      if (response.data.length > 0) {
+        let failrow = ''
+        for (let i = 0; i < response.data.length; i++) {
+          failrow += response.data[i] + ','
+        }
+        this.$alert(this.$t('导入成功条数:') + response.msg + '<br>' + this.$t('失败行数:') + failrow, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
+      } else {
+        this.$alert(this.$t('导入成功条数:') + response.msg, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
+      }
+      this.getList();
+    },
+    // 提交上传文件
+    submitFileForm() {
+      this.$refs.upload.submit();
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      const queryParams = this.queryParams;
+      this.$confirm(this.$t('是否确认导出所有特种设备压力管道年检报告数据项?'), this.$t('警告'), {
+        confirmButtonText: this.$t('确定'),
+        cancelButtonText: this.$t('取消'),
+        type: "warning"
+      }).then(function() {
+        return exportReportYlgd(queryParams);
+      }).then(response => {
+        this.download(response.msg);
+      })
+    },
   }
 };
 </script>

+ 34 - 3
ui/src/views/sems/reportYlrq/index.vue

@@ -79,6 +79,15 @@
         >导入更新数据
         </el-button>
       </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="warning"
+          icon="el-icon-download"
+          size="mini"
+          @click="handleExport"
+          v-hasPermi="['sems:reportYlrq:export']"
+        >{{ $t('导出') }}</el-button>
+      </el-col>
       <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
@@ -791,7 +800,7 @@
       </div>
     </el-dialog>
     <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
-      <input name="type" :value="upload.type" hidden />
+      <input name="type" :value="upload.type" hidden/>
     </form>
   </div>
 </template>
@@ -813,6 +822,7 @@ import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
 import YearApprove from './yearapprove'
 import {getToken} from "@/utils/auth";
+import {exportReportYlgd} from "@/api/sems/reportYlgd";
 
 export default {
   name: "ReportYlrq",
@@ -1523,13 +1533,34 @@ export default {
       this.upload.open = false;
       this.upload.isUploading = false;
       this.$refs.upload.clearFiles();
-      this.$alert(response.msg, "导入结果", {dangerouslyUseHTMLString: true});
+      if (response.data.length > 0) {
+        let failrow = ''
+        for (let i = 0; i < response.data.length; i++) {
+          failrow += response.data[i] + ','
+        }
+        this.$alert(this.$t('导入成功条数:') + response.msg + '<br>' + this.$t('失败行数:') + failrow, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
+      } else {
+        this.$alert(this.$t('导入成功条数:') + response.msg, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
+      }
       this.getList();
     },
     // 提交上传文件
     submitFileForm() {
       this.$refs.upload.submit();
-    }
+    },
+    /** 导出按钮操作 */
+    handleExport() {
+      const queryParams = this.queryParams;
+      this.$confirm(this.$t('是否确认导出所有特种设备压力容器年检报告数据项?'), this.$t('警告'), {
+        confirmButtonText: this.$t('确定'),
+        cancelButtonText: this.$t('取消'),
+        type: "warning"
+      }).then(function() {
+        return exportReportYlrq(queryParams);
+      }).then(response => {
+        this.download(response.msg);
+      })
+    },
 
   }
 };