Pārlūkot izejas kodu

feat(issue): 添加问题清单和操作清单的附件功能

- 在问题清单和操作清单页面添加附件按钮
- 实现附件上传、下载和删除功能
- 添加 PDF 文件预览功能
- 优化导入模板下载流程
jiangbiao 2 nedēļas atpakaļ
vecāks
revīzija
0442750c72

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

@@ -448,6 +448,12 @@ public class CommonController extends BaseController
         }else if( type.equals("pssrFrameTmpl") ) {
             downloadname = "PSSR支(吊)架模板数据维护.xlsx";
             url = "static/template/pssr/frameModel.xlsx";
+        }else if( type.equals("issuelist") ) {
+            downloadname = "问题清单和行动计划导入模板.xlsx";
+            url = "static/template/issue/issuelistTmpl.xlsx";
+        }else if( type.equals("operationlist") ) {
+            downloadname = "工艺事件清单导入模板.xlsx";
+            url = "static/template/issue/OperationlistTmpl.xlsx";
         }
 
         InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream(url);

+ 220 - 31
master/src/main/java/com/ruoyi/project/issue/controller/TPlantIssuelistController.java

@@ -1,24 +1,38 @@
 package com.ruoyi.project.issue.controller;
 
-import java.util.List;
-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 com.alibaba.fastjson.JSON;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.file.ExcelUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.framework.aspectj.lang.annotation.Log;
 import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
-import com.ruoyi.project.issue.domain.TPlantIssuelist;
-import com.ruoyi.project.issue.service.ITPlantIssuelistService;
 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 com.ruoyi.project.issue.domain.TPlantIssuelist;
+import com.ruoyi.project.issue.service.ITPlantIssuelistService;
+import com.ruoyi.project.plant.domain.TStaffmgr;
+import com.ruoyi.project.system.domain.SysDept;
+import com.ruoyi.project.system.domain.SysDictData;
+import com.ruoyi.project.training.domain.*;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+import java.util.stream.Collectors;
 
 /**
  * 问题清单和行动计划Controller
@@ -28,8 +42,7 @@ import com.ruoyi.framework.web.page.TableDataInfo;
  */
 @RestController
 @RequestMapping("/issue/issuelist")
-public class TPlantIssuelistController extends BaseController
-{
+public class TPlantIssuelistController extends BaseController {
     @Autowired
     private ITPlantIssuelistService tPlantIssuelistService;
 
@@ -38,8 +51,7 @@ public class TPlantIssuelistController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('issue:issuelist:list')")
     @GetMapping("/list")
-    public TableDataInfo list(TPlantIssuelist tPlantIssuelist)
-    {
+    public TableDataInfo list(TPlantIssuelist tPlantIssuelist) {
         startPage();
         List<TPlantIssuelist> list = tPlantIssuelistService.selectTPlantIssuelistList(tPlantIssuelist);
         return getDataTable(list);
@@ -51,11 +63,110 @@ public class TPlantIssuelistController extends BaseController
     @PreAuthorize("@ss.hasPermi('issue:issuelist:export')")
     @Log(title = "问题清单和行动计划", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
-    public AjaxResult export(TPlantIssuelist tPlantIssuelist)
-    {
+    public AjaxResult export(TPlantIssuelist tPlantIssuelist) {
         List<TPlantIssuelist> list = tPlantIssuelistService.selectTPlantIssuelistList(tPlantIssuelist);
-        ExcelUtil<TPlantIssuelist> util = new ExcelUtil<TPlantIssuelist>(TPlantIssuelist.class);
-        return util.exportExcel(list, "issuelist");
+        if (!list.isEmpty()) {
+            return AjaxResult.success(exportTmpl(list));
+        } else {
+            return AjaxResult.error("暂无可导出数据");
+        }
+    }
+
+    public String exportTmpl(List<TPlantIssuelist> list) {
+        OutputStream out;
+        String filename = null;
+        try {
+            List<TPlantIssuelist> bdList = list.stream()
+                    .filter(item -> "BD".equals(item.getPlant()))
+                    .collect(Collectors.toList());
+
+            List<TPlantIssuelist> ibList = list.stream()
+                    .filter(item -> "IB".equals(item.getPlant()))
+                    .collect(Collectors.toList());
+            String tempUrl = "static/word/issue/issuelistTmpl.xlsx"; // 模板文件
+            InputStream is;
+            is = Thread.currentThread().getContextClassLoader().getResourceAsStream(tempUrl);
+            XSSFWorkbook wb = new XSSFWorkbook(is);
+            XSSFSheet sheet1 = wb.getSheetAt(0);
+
+            //填充数据
+            int rowIndex1 = 7;
+            int num1 = 1;
+
+            Row originalRow1 = sheet1.getRow(7);
+            Cell originalcell1 = originalRow1.getCell(0);
+            // 获取单元格样式
+            CellStyle originalStyle1 = originalcell1.getCellStyle();
+
+            for (TPlantIssuelist t : bdList) {
+                Row row = sheet1.createRow(rowIndex1);
+                row.setHeight((short) 800);
+                row.createCell(0).setCellValue(num1);
+                row.createCell(1).setCellValue(t.getArea());
+                row.createCell(2).setCellValue(DateUtils.dateTime(t.getIdentifiedDate()));
+                row.createCell(3).setCellValue(t.getIssueSource());
+                row.createCell(4).setCellValue(t.getIssueIdentified());
+                row.createCell(5).setCellValue(t.getActionsTaken());
+                row.createCell(6).setCellValue(t.getIssueClass());
+                row.createCell(7).setCellValue(t.getResponsiblePerson());
+                row.createCell(8).setCellValue(t.getResponsibleUnit());
+                row.createCell(9).setCellValue(t.getCurrentStates());
+                row.createCell(10).setCellValue(t.getCompletionDate());
+                row.createCell(11).setCellValue(t.getAdditionalDeadline());
+
+
+                //渲染样式
+                for (int i = 0; i < 12; i++) {
+                    row.getCell(i).setCellStyle(originalStyle1);
+                }
+                num1++;
+                rowIndex1++;
+            }
+
+            XSSFSheet sheet2 = wb.getSheetAt(1);
+
+            //填充数据
+            int rowIndex2 = 7;
+            int num2 = 1;
+
+            Row originalRow2 = sheet2.getRow(7);
+            Cell originalcell2 = originalRow2.getCell(0);
+            // 获取单元格样式
+            CellStyle originalStyle2 = originalcell2.getCellStyle();
+
+            for (TPlantIssuelist t : ibList) {
+                Row row = sheet2.createRow(rowIndex2);
+                row.setHeight((short) 800);
+                row.createCell(0).setCellValue(num2);
+                row.createCell(1).setCellValue(t.getArea());
+                row.createCell(2).setCellValue(DateUtils.dateTime(t.getIdentifiedDate()));
+                row.createCell(3).setCellValue(t.getIssueSource());
+                row.createCell(4).setCellValue(t.getIssueIdentified());
+                row.createCell(5).setCellValue(t.getActionsTaken());
+                row.createCell(6).setCellValue(t.getIssueClass());
+                row.createCell(7).setCellValue(t.getResponsiblePerson());
+                row.createCell(8).setCellValue(t.getResponsibleUnit());
+                row.createCell(9).setCellValue(t.getCurrentStates());
+                row.createCell(10).setCellValue(t.getCompletionDate());
+                row.createCell(11).setCellValue(t.getAdditionalDeadline());
+
+
+                //渲染样式
+                for (int i = 0; i < 12; i++) {
+                    row.getCell(i).setCellStyle(originalStyle2);
+                }
+                num2++;
+                rowIndex2++;
+            }
+            filename = "滚动问题清单和行动计划" + DateUtils.dateTimeNow() + ".xlsx";
+            out = Files.newOutputStream(Paths.get(ExcelUtil.getAbsoluteFile(filename)));
+            wb.write(out);
+            wb.close();
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return filename;
     }
 
     /**
@@ -63,8 +174,7 @@ public class TPlantIssuelistController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('issue:issuelist:query')")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Long id)
-    {
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
         return AjaxResult.success(tPlantIssuelistService.selectTPlantIssuelistById(id));
     }
 
@@ -74,8 +184,7 @@ public class TPlantIssuelistController extends BaseController
     @PreAuthorize("@ss.hasPermi('issue:issuelist:add')")
     @Log(title = "问题清单和行动计划", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody TPlantIssuelist tPlantIssuelist)
-    {
+    public AjaxResult add(@RequestBody TPlantIssuelist tPlantIssuelist) {
         return toAjax(tPlantIssuelistService.insertTPlantIssuelist(tPlantIssuelist));
     }
 
@@ -85,8 +194,7 @@ public class TPlantIssuelistController extends BaseController
     @PreAuthorize("@ss.hasPermi('issue:issuelist:edit')")
     @Log(title = "问题清单和行动计划", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody TPlantIssuelist tPlantIssuelist)
-    {
+    public AjaxResult edit(@RequestBody TPlantIssuelist tPlantIssuelist) {
         return toAjax(tPlantIssuelistService.updateTPlantIssuelist(tPlantIssuelist));
     }
 
@@ -95,9 +203,90 @@ public class TPlantIssuelistController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('issue:issuelist:remove')")
     @Log(title = "问题清单和行动计划", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids)
-    {
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(tPlantIssuelistService.deleteTPlantIssuelistByIds(ids));
     }
+
+    @PreAuthorize("@ss.hasPermi('issue:issuelist:add')")
+    @Log(title = "问题清单和行动计划", businessType = BusinessType.INSERT)
+    @PostMapping("/importData")
+    public AjaxResult importData(@RequestParam("file") MultipartFile file) throws IOException {
+        //获取操作人员ID
+        Long userId = getUserId();
+        //报错行数统计
+        List<Integer> failRow = new ArrayList<>();
+        Workbook workbook = ExcelUtils.getWorkBook(file);
+        Sheet sheet = workbook.getSheetAt(0);
+        List<TPlantIssuelist> list = new ArrayList<>();
+        int rowNum = sheet.getPhysicalNumberOfRows();
+        int failNumber = 0;
+        for (int i = 1; i < rowNum; i++) {
+            try {
+                logger.info("读取行数:" + i);
+                Row row = sheet.getRow(i);
+                int cellNum = row.getLastCellNum();
+                TPlantIssuelist entity = new TPlantIssuelist();
+                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.setPlant(cellValue);
+                    } else if (j == 1) {
+                        entity.setArea(cellValue);
+                    } else if (j == 2) {
+                        entity.setIdentifiedDate(DateUtils.parseDate(cellValue));//员工姓名
+                    } else if (j == 3) {
+                        entity.setIssueSource(cellValue);
+                    } else if (j == 4) {
+                        entity.setIssueIdentified(cellValue);
+                    } else if (j == 5) {
+                        entity.setActionsTaken(cellValue);
+                    } else if (j == 6) {
+                        entity.setIssueClass(cellValue);
+                    } else if (j == 7) {
+                        entity.setResponsiblePerson(cellValue);
+                    } else if (j == 8) {
+                        entity.setResponsibleUnit(cellValue);
+                    } else if (j == 9) {
+                        entity.setCurrentStates(cellValue);
+                    } else if (j == 10) {
+                        entity.setCompletionDate(cellValue);
+                    } else if (j == 11) {
+                        entity.setAdditionalDeadline(cellValue);
+                    }
+                }
+                entity.setCreaterCode(userId.toString());
+                logger.info("entity:" + entity);
+                list.add(entity);
+            } catch (Exception e) {
+                failNumber++;
+                logger.info("e:" + e);
+                failRow.add(i + 1);
+            }
+        }
+        int successNumber = 0;
+        int failNum = 0;
+        for (TPlantIssuelist t : list
+        ) {
+            failNum++;
+            try {
+                add(t);
+                                successNumber++;
+            } catch (Exception e) {
+                failNumber++;
+                logger.info("e:" + e);
+                failRow.add(failNum + 1);
+            }
+        }
+        logger.info("list:" + JSON.toJSONString(list));
+        logger.info("successNumber:" + successNumber);
+        logger.info("failNumber:" + failNumber);
+        logger.info("failRow:" + failRow);
+        return AjaxResult.success(String.valueOf(successNumber), failRow);
+    }
 }

+ 150 - 31
master/src/main/java/com/ruoyi/project/issue/controller/TPlantOperationlistController.java

@@ -1,24 +1,31 @@
 package com.ruoyi.project.issue.controller;
 
-import java.util.List;
-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 com.alibaba.fastjson.JSON;
+import com.ruoyi.common.utils.DateUtils;
+import com.ruoyi.common.utils.file.ExcelUtils;
+import com.ruoyi.common.utils.poi.ExcelUtil;
 import com.ruoyi.framework.aspectj.lang.annotation.Log;
 import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
-import com.ruoyi.project.issue.domain.TPlantOperationlist;
-import com.ruoyi.project.issue.service.ITPlantOperationlistService;
 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 com.ruoyi.project.issue.domain.TPlantOperationlist;
+import com.ruoyi.project.issue.service.ITPlantOperationlistService;
+import org.apache.poi.ss.usermodel.*;
+import org.apache.poi.xssf.usermodel.XSSFSheet;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * CBPB工艺事件清单Controller
@@ -28,8 +35,7 @@ import com.ruoyi.framework.web.page.TableDataInfo;
  */
 @RestController
 @RequestMapping("/issue/operationlist")
-public class TPlantOperationlistController extends BaseController
-{
+public class TPlantOperationlistController extends BaseController {
     @Autowired
     private ITPlantOperationlistService tPlantOperationlistService;
 
@@ -38,8 +44,7 @@ public class TPlantOperationlistController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('issue:operationlist:list')")
     @GetMapping("/list")
-    public TableDataInfo list(TPlantOperationlist tPlantOperationlist)
-    {
+    public TableDataInfo list(TPlantOperationlist tPlantOperationlist) {
         startPage();
         List<TPlantOperationlist> list = tPlantOperationlistService.selectTPlantOperationlistList(tPlantOperationlist);
         return getDataTable(list);
@@ -51,11 +56,61 @@ public class TPlantOperationlistController extends BaseController
     @PreAuthorize("@ss.hasPermi('issue:operationlist:export')")
     @Log(title = "CBPB工艺事件清单", businessType = BusinessType.EXPORT)
     @GetMapping("/export")
-    public AjaxResult export(TPlantOperationlist tPlantOperationlist)
-    {
+    public AjaxResult export(TPlantOperationlist tPlantOperationlist) {
         List<TPlantOperationlist> list = tPlantOperationlistService.selectTPlantOperationlistList(tPlantOperationlist);
-        ExcelUtil<TPlantOperationlist> util = new ExcelUtil<TPlantOperationlist>(TPlantOperationlist.class);
-        return util.exportExcel(list, "operationlist");
+        if (!list.isEmpty()) {
+            return AjaxResult.success(exportTmpl(list));
+        } else {
+            return AjaxResult.error("暂无可导出数据");
+        }
+    }
+
+    public String exportTmpl(List<TPlantOperationlist> list) {
+        OutputStream out;
+        String filename = null;
+        try {
+            String tempUrl = "static/word/issue/OperationlistTmpl.xlsx"; // 模板文件
+            InputStream is;
+            is = Thread.currentThread().getContextClassLoader().getResourceAsStream(tempUrl);
+            XSSFWorkbook wb = new XSSFWorkbook(is);
+            XSSFSheet sheet1 = wb.getSheetAt(0);
+
+            //填充数据
+            int rowIndex1 = 2;
+            int num1 = 1;
+
+            Row originalRow1 = sheet1.getRow(2);
+            Cell originalcell1 = originalRow1.getCell(0);
+            // 获取单元格样式
+            CellStyle originalStyle1 = originalcell1.getCellStyle();
+
+            for (TPlantOperationlist t : list) {
+                Row row = sheet1.createRow(rowIndex1);
+                row.setHeight((short) 800);
+                row.createCell(0).setCellValue(num1);
+                row.createCell(1).setCellValue(t.getPlant());
+                row.createCell(2).setCellValue(t.getShiftClass());
+                row.createCell(3).setCellValue(t.getIncidentDescription());
+                row.createCell(4).setCellValue(t.getCauseRes());
+                row.createCell(5).setCellValue(t.getCoutermeasures());
+
+
+                //渲染样式
+                for (int i = 0; i < 6; i++) {
+                    row.getCell(i).setCellStyle(originalStyle1);
+                }
+                num1++;
+                rowIndex1++;
+            }
+            filename = "工艺事件清单" + DateUtils.dateTimeNow() + ".xlsx";
+            out = Files.newOutputStream(Paths.get(ExcelUtil.getAbsoluteFile(filename)));
+            wb.write(out);
+            wb.close();
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return filename;
     }
 
     /**
@@ -63,8 +118,7 @@ public class TPlantOperationlistController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('issue:operationlist:query')")
     @GetMapping(value = "/{id}")
-    public AjaxResult getInfo(@PathVariable("id") Long id)
-    {
+    public AjaxResult getInfo(@PathVariable("id") Long id) {
         return AjaxResult.success(tPlantOperationlistService.selectTPlantOperationlistById(id));
     }
 
@@ -74,8 +128,7 @@ public class TPlantOperationlistController extends BaseController
     @PreAuthorize("@ss.hasPermi('issue:operationlist:add')")
     @Log(title = "CBPB工艺事件清单", businessType = BusinessType.INSERT)
     @PostMapping
-    public AjaxResult add(@RequestBody TPlantOperationlist tPlantOperationlist)
-    {
+    public AjaxResult add(@RequestBody TPlantOperationlist tPlantOperationlist) {
         return toAjax(tPlantOperationlistService.insertTPlantOperationlist(tPlantOperationlist));
     }
 
@@ -85,8 +138,7 @@ public class TPlantOperationlistController extends BaseController
     @PreAuthorize("@ss.hasPermi('issue:operationlist:edit')")
     @Log(title = "CBPB工艺事件清单", businessType = BusinessType.UPDATE)
     @PutMapping
-    public AjaxResult edit(@RequestBody TPlantOperationlist tPlantOperationlist)
-    {
+    public AjaxResult edit(@RequestBody TPlantOperationlist tPlantOperationlist) {
         return toAjax(tPlantOperationlistService.updateTPlantOperationlist(tPlantOperationlist));
     }
 
@@ -95,9 +147,76 @@ public class TPlantOperationlistController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('issue:operationlist:remove')")
     @Log(title = "CBPB工艺事件清单", businessType = BusinessType.DELETE)
-	@DeleteMapping("/{ids}")
-    public AjaxResult remove(@PathVariable Long[] ids)
-    {
+    @DeleteMapping("/{ids}")
+    public AjaxResult remove(@PathVariable Long[] ids) {
         return toAjax(tPlantOperationlistService.deleteTPlantOperationlistByIds(ids));
     }
+
+    @PreAuthorize("@ss.hasPermi('issue:issuelist:add')")
+    @Log(title = "CBPB工艺事件清单", businessType = BusinessType.INSERT)
+    @PostMapping("/importData")
+    public AjaxResult importData(@RequestParam("file") MultipartFile file) throws IOException {
+        //获取操作人员ID
+        Long userId = getUserId();
+        //报错行数统计
+        List<Integer> failRow = new ArrayList<>();
+        Workbook workbook = ExcelUtils.getWorkBook(file);
+        Sheet sheet = workbook.getSheetAt(0);
+        List<TPlantOperationlist> list = new ArrayList<>();
+        int rowNum = sheet.getPhysicalNumberOfRows();
+        int failNumber = 0;
+        for (int i = 1; i < rowNum; i++) {
+            try {
+                logger.info("读取行数:" + i);
+                Row row = sheet.getRow(i);
+                int cellNum = row.getLastCellNum();
+                TPlantOperationlist entity = new TPlantOperationlist();
+                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.setPlant(cellValue);
+                    } else if (j == 1) {
+                        entity.setShiftClass(cellValue);
+                    } else if (j == 2) {
+                        entity.setIncidentDescription(cellValue);
+                    } else if (j == 3) {
+                        entity.setCauseRes(cellValue);
+                    } else if (j == 4) {
+                        entity.setCoutermeasures(cellValue);
+                    }
+                }
+                entity.setCreaterCode(userId.toString());
+                logger.info("entity:" + entity);
+                list.add(entity);
+            } catch (Exception e) {
+                failNumber++;
+                logger.info("e:" + e);
+                failRow.add(i + 1);
+            }
+        }
+        int successNumber = 0;
+        int failNum = 0;
+        for (TPlantOperationlist t : list
+        ) {
+            failNum++;
+            try {
+                add(t);
+                successNumber++;
+            } catch (Exception e) {
+                failNumber++;
+                logger.info("e:" + e);
+                failRow.add(failNum + 1);
+            }
+        }
+        logger.info("list:" + JSON.toJSONString(list));
+        logger.info("successNumber:" + successNumber);
+        logger.info("failNumber:" + failNumber);
+        logger.info("failRow:" + failRow);
+        return AjaxResult.success(String.valueOf(successNumber), failRow);
+    }
 }

BIN
master/src/main/resources/static/template/issue/OperationlistTmpl.xlsx


BIN
master/src/main/resources/static/template/issue/issuelistTmpl.xlsx


BIN
master/src/main/resources/static/word/issue/OperationlistTmpl.xlsx


BIN
master/src/main/resources/static/word/issue/issuelistTmpl.xlsx


+ 216 - 38
ui/src/views/issue/issuelist/index.vue

@@ -16,14 +16,6 @@
           @keyup.enter.native="handleQuery"
         />
       </el-form-item>
-      <el-form-item label="提出日期" prop="identifiedDate">
-        <el-date-picker clearable size="small" style="width: 200px"
-                        v-model="queryParams.identifiedDate"
-                        type="date"
-                        value-format="yyyy-MM-dd"
-                        placeholder="选择提出日期">
-        </el-date-picker>
-      </el-form-item>
       <el-form-item>
         <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
         <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
@@ -87,27 +79,31 @@
     </el-row>
 
     <el-table v-loading="loading" :data="issuelistList" @selection-change="handleSelectionChange" :height="clientHeight"
-              border>
+              border >
       <el-table-column type="selection" width="55" align="center"/>
-      <el-table-column label="归属装置" align="center" prop="plant" :show-overflow-tooltip="true"/>
-      <el-table-column label="区域" align="center" prop="area" :show-overflow-tooltip="true"/>
+      <el-table-column label="归属装置" align="center" prop="plant" :show-overflow-tooltip="true" width="150"/>
+      <el-table-column label="区域" align="center" prop="area" :show-overflow-tooltip="true" width="150"/>
       <el-table-column label="提出日期" align="center" prop="identifiedDate" width="100">
         <template slot-scope="scope">
           <span>{{ parseTime(scope.row.identifiedDate, '{y}-{m}-{d}') }}</span>
         </template>
       </el-table-column>
-      <el-table-column label="问题来源" align="center" prop="issueSource" :show-overflow-tooltip="true"/>
-      <el-table-column label="识别出的问题" align="center" prop="issueIdentified" :show-overflow-tooltip="true"/>
-      <el-table-column label="要采取的措施" align="center" prop="actionsTaken" :show-overflow-tooltip="true"/>
-      <el-table-column label="问题类别" align="center" prop="issueClass" :show-overflow-tooltip="true"/>
-      <el-table-column label="负责部门" align="center" prop="responsibleUnit" :show-overflow-tooltip="true"/>
-      <el-table-column label="负责人员" align="center" prop="responsiblePerson" :show-overflow-tooltip="true"/>
-      <el-table-column label="当前状态" align="center" prop="currentStates" :show-overflow-tooltip="true"/>
-      <el-table-column label="完成日期" align="center" prop="completionDate" :show-overflow-tooltip="true"/>
+      <el-table-column label="问题来源" align="center" prop="issueSource" :show-overflow-tooltip="true" width="150"/>
+      <el-table-column label="识别出的问题" align="center" prop="issueIdentified" :show-overflow-tooltip="true"
+                       width="150"/>
+      <el-table-column label="要采取的措施" align="center" prop="actionsTaken" :show-overflow-tooltip="true"
+                       width="150"/>
+      <el-table-column label="问题类别" align="center" prop="issueClass" :show-overflow-tooltip="true" width="150"/>
+      <el-table-column label="负责部门" align="center" prop="responsibleUnit" :show-overflow-tooltip="true"
+                       width="150"/>
+      <el-table-column label="负责人员" align="center" prop="responsiblePerson" :show-overflow-tooltip="true"
+                       width="150"/>
+      <el-table-column label="当前状态" align="center" prop="currentStates" :show-overflow-tooltip="true" width="150"/>
+      <el-table-column label="完成日期" align="center" prop="completionDate" :show-overflow-tooltip="true" width="150"/>
       <el-table-column label="未按期完成时,所要采取的额外" align="center" prop="additionalDeadline"
                        :show-overflow-tooltip="true"/>
-      <el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip="true"/>
-      <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
+      <el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip="true" width="150"/>
+      <el-table-column label="操作" align="center" fixed="right" width="160" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
             size="mini"
@@ -125,6 +121,13 @@
             v-hasPermi="['issue:issuelist:remove']"
           >删除
           </el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-document"
+            @click="handleDoc(scope.row)"
+            v-hasPermi="['issue:issuelist:edit']"
+          >{{ $t('附件') }}</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -138,7 +141,7 @@
     />
 
     <!-- 添加或修改问题清单和行动计划对话框 -->
-    <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
+    <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body :close-on-click-modal="false">
       <el-form ref="form" :model="form" :rules="rules" label-width="180px">
         <el-form-item label="归属装置" prop="plant">
           <el-select v-model="form.plant" placeholder="请选择装置" clearable size="small" style="width: 240px">
@@ -193,14 +196,87 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </el-dialog>
+    <!-- 报告附件对话框 -->
+    <el-dialog :close-on-click-modal="false" v-dialogDrag :title="doc.title" :visible.sync="doc.open" width="700px"
+               append-to-body>
+      <el-upload
+        ref="doc"
+        :limit="50"
+        :headers="doc.headers"
+        :action="doc.url + '?pType=' + doc.pType + '&pId=' + doc.pId"
+        :disabled="doc.isUploading"
+        :on-progress="handleFileDocProgress"
+        :on-success="handleFileDocSuccess"
+        :auto-upload="true"
+        drag
+      >
+        <i class="el-icon-upload"></i>
+        <div class="el-upload__text">
+          {{ $t('将文件拖到此处,或') }}
+          <em>{{ $t('点击上传') }}</em>
+        </div>
+      </el-upload>
+      <el-table :data="doc.commonfileList" border>
+        <el-table-column :label="$t('文件名')" align="center" prop="fileName" :show-overflow-tooltip="true">
+          <template slot-scope="scope">
+            <a class="link-type" @click="handleDownload(scope.row)">
+              <span>{{ scope.row.fileName }}</span>
+            </a>
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('大小(Kb)')" align="center" prop="fileSize" :show-overflow-tooltip="true"
+                         width="80"/>
+        <el-table-column :label="$t('上传人')" align="center" prop="creator" :show-overflow-tooltip="true" width="120"/>
+        <el-table-column :label="$t('操作')" align="center" width="120" class-name="small-padding fixed-width">
+          <template slot-scope="scope">
+            <el-button
+              v-if="scope.row.fileName.endsWith('pdf')"
+              size="mini"
+              type="text"
+              icon="el-icon-view"
+              @click="handleSee(scope.row)"
+            >{{ $t('预览') }}
+            </el-button>
+            <el-button
+              size="mini"
+              type="text"
+              icon="el-icon-download"
+              @click="handleDownload(scope.row)"
+            >{{ $t('下载') }}
+            </el-button>
+            <el-button
+              size="mini"
+              type="text"
+              icon="el-icon-delete"
+              @click="handleDeleteDoc(scope.row)"
+            >{{ $t('删除') }}
+            </el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      <el-dialog :close-on-click-modal="false" v-dialogDrag :title="pdf.title" :visible.sync="pdf.open" width="1300px"
+                 append-to-body>
+        <div style="margin-top: -60px;float: right;margin-right: 40px;">
+          <el-button size="mini" type="text" @click="openPdf">{{ $t('新页面打开PDF') }}</el-button>
+        </div>
+        <div style="margin-top: -30px">
+          <iframe :src="pdf.pdfUrl" frameborder="0" width="100%" height="700px"></iframe>
+        </div>
+      </el-dialog>
+      <div slot="footer" class="dialog-footer">
+        <!--        <el-button type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button>-->
+        <el-button @click="doc.open = false">{{ $t('返 回') }}</el-button>
+      </div>
+    </el-dialog>
     <!-- 用户导入对话框 -->
-    <el-dialog :title="upload.title" :visible.sync="upload.open" width="500px" append-to-body>
+    <el-dialog :close-on-click-modal="false" v-dialogDrag :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"
+        :action="upload.url"
         :disabled="upload.isUploading"
         :on-progress="handleFileUploadProgress"
         :on-success="handleFileSuccess"
@@ -209,19 +285,21 @@
       >
         <i class="el-icon-upload"></i>
         <div class="el-upload__text">
-          将文件拖到此处,或
-          <em>点击上传</em>
+          {{ $t('将文件拖到此处,或') }}
+          <em>{{ $t('点击上传') }}</em>
         </div>
         <div class="el-upload__tip" slot="tip">
-          <el-checkbox v-model="upload.updateSupport"/>
-          是否更新已经存在的用户数据
-          <el-link type="info" style="font-size:12px" @click="importTemplate">下载模板</el-link>
+          <!--<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
+          <el-link type="info" style="font-size:12px" @click="importTemplate">{{ $t('下载模板') }}</el-link>
         </div>
-        <div class="el-upload__tip" style="color:red" slot="tip">提示:仅允许导入“xls”或“xlsx”格式文件!</div>
+        <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
+          <input name="type" :value="upload.type" hidden/>
+        </form>
+        <div class="el-upload__tip" style="color:red" slot="tip">{{ $t('提示:仅允许导入“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>
+        <el-button type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button>
+        <el-button @click="upload.open = false">{{ $t('取 消') }}</el-button>
       </div>
     </el-dialog>
   </div>
@@ -233,7 +311,6 @@ import {
   delIssuelist,
   exportIssuelist,
   getIssuelist,
-  importTemplate,
   listIssuelist,
   updateIssuelist
 } from "@/api/issue/issuelist";
@@ -241,6 +318,7 @@ import {treeselect} from "@/api/system/dept";
 import {getToken} from "@/utils/auth";
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+import {allFileList, delCommonfile} from "@/api/common/commonfile";
 
 export default {
   name: "Issuelist",
@@ -270,6 +348,9 @@ export default {
       open: false,
       // 用户导入参数
       upload: {
+        downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
+        //下载模板类型
+        type: "issuelist",
         // 是否显示弹出层(用户导入)
         open: false,
         // 弹出层标题(用户导入)
@@ -283,6 +364,40 @@ export default {
         // 上传的地址
         url: process.env.VUE_APP_BASE_API + "/issue/issuelist/importData"
       },
+      // 报告附件参数
+      doc: {
+        file: "",
+        // 是否显示弹出层(报告附件)
+        open: false,
+        // 弹出层标题(报告附件)
+        title: "",
+        // 是否禁用上传
+        isUploading: false,
+        // 是否更新已经存在的用户数据
+        updateSupport: 0,
+        // 报告附件上传位置编号
+        ids: 0,
+        // 设置上传的请求头部
+        headers: {Authorization: "Bearer " + getToken()},
+        // 上传的地址
+        url: process.env.VUE_APP_BASE_API + "/common/commonfile/uploadFile",
+        commonfileList: null,
+        queryParams: {
+          pId: null,
+          pType: 'issuelist'
+        },
+        pType: 'issuelist',
+        pId: null
+      },
+      pdf : {
+        title: '',
+        pdfUrl: '',
+        numPages: null,
+        open: false,
+        pageNum: 1,
+        pageTotalNum: 1,
+        loadedRatio: 0,
+      },
       // 查询参数
       queryParams: {
         pageNum: 1,
@@ -459,9 +574,7 @@ export default {
     },
     /** 下载模板操作 */
     importTemplate() {
-      importTemplate().then(response => {
-        this.download(response.msg);
-      });
+      this.$refs['downloadFileForm'].submit()
     },
     // 文件上传中处理
     handleFileUploadProgress(event, file, fileList) {
@@ -472,13 +585,78 @@ export default {
       this.upload.open = false;
       this.upload.isUploading = false;
       this.$refs.upload.clearFiles();
-      this.$alert(response.msg, "导入结果", {dangerouslyUseHTMLString: true});
+      if (response.data[0] != null) {
+        this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据') + "," + this.$t('第') + response.data + this.$t('行数据出现错误导入失败') + "。", this.$t('导入结果'), {dangerouslyUseHTMLString: true});
+      } else {
+        this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据'), this.$t('导入结果'), {dangerouslyUseHTMLString: true});
+      }
       this.getList();
     },
     // 提交上传文件
     submitFileForm() {
       this.$refs.upload.submit();
-    }
+    },
+    /** 报告附件按钮操作 */
+    handleDoc(row) {
+      this.doc.id = row.id;
+      this.doc.title = this.$t('附件');
+      this.doc.open = true;
+      this.doc.queryParams.pId = row.id
+      this.doc.pId = row.id
+      this.getFileList()
+      this.$nextTick(() => {
+        this.$refs.doc.clearFiles()
+      })
+    },
+    getFileList() {
+      allFileList(this.doc.queryParams).then(response => {
+        this.doc.commonfileList = response;
+      });
+    },
+    //附件上传中处理
+    handleFileDocProgress(event, file, fileList) {
+      this.doc.file = file;
+      this.doc.isUploading = true;
+    },
+    //附件上传成功处理
+    handleFileDocSuccess(response, file, fileList) {
+      this.doc.isUploading = false;
+      this.$alert(response.msg, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
+      this.getFileList()
+    },
+    /** 删除按钮操作 */
+    handleDeleteDoc(row) {
+      const ids = row.id || this.ids;
+      this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
+        confirmButtonText: this.$t('确定'),
+        cancelButtonText: this.$t('取消'),
+        type: "warning"
+      }).then(function () {
+        return delCommonfile(ids);
+      }).then(() => {
+        this.getFileList()
+        this.msgSuccess(this.$t('删除成功'));
+      })
+    },
+    // 文件下载处理
+    handleDownload(row) {
+      var name = row.fileName;
+      var url = row.fileUrl;
+      var suffix = url.substring(url.lastIndexOf("."), url.length);
+      const a = document.createElement('a')
+      a.setAttribute('download', name)
+      a.setAttribute('target', '_blank')
+      a.setAttribute('href', process.env.VUE_APP_BASE_API + url)
+      a.click()
+    },
+    openPdf() {
+      window.open(this.pdf.pdfUrl);//path是文件的全路径地址
+    },
+    handleSee(row) {
+      this.pdf.open = true
+      this.pdf.title = row.fileName
+      this.pdf.pdfUrl = process.env.VUE_APP_BASE_API + '/pdf/web/viewer.html?file=' + process.env.VUE_APP_BASE_API + row.fileUrl
+    },
   }
 };
 </script>

+ 330 - 135
ui/src/views/issue/operationlist/index.vue

@@ -33,7 +33,8 @@
           size="mini"
           @click="handleAdd"
           v-hasPermi="['issue:operationlist:add']"
-        >新增</el-button>
+        >新增
+        </el-button>
       </el-col>
       <el-col :span="1.5">
         <el-button
@@ -43,7 +44,8 @@
           :disabled="single"
           @click="handleUpdate"
           v-hasPermi="['issue:operationlist:edit']"
-        >修改</el-button>
+        >修改
+        </el-button>
       </el-col>
       <el-col :span="1.5">
         <el-button
@@ -53,17 +55,19 @@
           :disabled="multiple"
           @click="handleDelete"
           v-hasPermi="['issue:operationlist:remove']"
-        >删除</el-button>
+        >删除
+        </el-button>
+      </el-col>
+      <el-col :span="1.5">
+        <el-button
+          type="info"
+          icon="el-icon-upload2"
+          size="mini"
+          @click="handleImport"
+          v-hasPermi="['issue:operationlist:edit']"
+        >导入
+        </el-button>
       </el-col>
-        <el-col :span="1.5">
-            <el-button
-                    type="info"
-                    icon="el-icon-upload2"
-                    size="mini"
-                    @click="handleImport"
-                    v-hasPermi="['issue:operationlist:edit']"
-            >导入</el-button>
-        </el-col>
       <el-col :span="1.5">
         <el-button
           type="warning"
@@ -71,20 +75,22 @@
           size="mini"
           @click="handleExport"
           v-hasPermi="['issue:operationlist:export']"
-        >导出</el-button>
+        >导出
+        </el-button>
       </el-col>
-	  <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
+      <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
     </el-row>
 
-    <el-table v-loading="loading" :data="operationlistList" @selection-change="handleSelectionChange" :height="clientHeight" border>
-      <el-table-column type="selection" width="55" align="center" />
+    <el-table v-loading="loading" :data="operationlistList" @selection-change="handleSelectionChange"
+              :height="clientHeight" border>
+      <el-table-column type="selection" width="55" align="center"/>
       <el-table-column label="装置" align="center" prop="plant" :show-overflow-tooltip="true"/>
       <el-table-column label="班组" align="center" prop="shiftClass" :show-overflow-tooltip="true"/>
       <el-table-column label="事件描述" align="center" prop="incidentDescription" :show-overflow-tooltip="true"/>
       <el-table-column label="原因" align="center" prop="causeRes" :show-overflow-tooltip="true"/>
       <el-table-column label="措施" align="center" prop="coutermeasures" :show-overflow-tooltip="true"/>
       <el-table-column label="备注" align="center" prop="remarks" :show-overflow-tooltip="true"/>
-      <el-table-column label="操作" align="center" fixed="right" width="120" class-name="small-padding fixed-width">
+      <el-table-column label="操作" align="center" fixed="right" width="160" class-name="small-padding fixed-width">
         <template slot-scope="scope">
           <el-button
             size="mini"
@@ -92,14 +98,23 @@
             icon="el-icon-edit"
             @click="handleUpdate(scope.row)"
             v-hasPermi="['issue:operationlist:edit']"
-          >修改</el-button>
+          >修改
+          </el-button>
           <el-button
             size="mini"
             type="text"
             icon="el-icon-delete"
             @click="handleDelete(scope.row)"
             v-hasPermi="['issue:operationlist:remove']"
-          >删除</el-button>
+          >删除
+          </el-button>
+          <el-button
+            size="mini"
+            type="text"
+            icon="el-icon-document"
+            @click="handleDoc(scope.row)"
+            v-hasPermi="['issue:operationlist:edit']"
+          >{{ $t('附件') }}</el-button>
         </template>
       </el-table-column>
     </el-table>
@@ -113,25 +128,25 @@
     />
 
     <!-- 添加或修改CBPB工艺事件清单对话框 -->
-    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
+    <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body :close-on-click-modal="false">
       <el-form ref="form" :model="form" :rules="rules" label-width="80px">
         <el-form-item label="装置" prop="plant">
-          <el-input v-model="form.plant" placeholder="请输入装置" />
+          <el-input v-model="form.plant" placeholder="请输入装置"/>
         </el-form-item>
         <el-form-item label="班组" prop="shiftClass">
-          <el-input v-model="form.shiftClass" placeholder="请输入班组" />
+          <el-input v-model="form.shiftClass" placeholder="请输入班组"/>
         </el-form-item>
         <el-form-item label="事件描述" prop="incidentDescription">
-          <el-input v-model="form.incidentDescription" placeholder="请输入事件描述" />
+          <el-input v-model="form.incidentDescription" placeholder="请输入事件描述"/>
         </el-form-item>
         <el-form-item label="原因" prop="causeRes">
-          <el-input v-model="form.causeRes" placeholder="请输入原因" />
+          <el-input v-model="form.causeRes" placeholder="请输入原因"/>
         </el-form-item>
         <el-form-item label="措施" prop="coutermeasures">
-          <el-input v-model="form.coutermeasures" placeholder="请输入措施" />
+          <el-input v-model="form.coutermeasures" placeholder="请输入措施"/>
         </el-form-item>
         <el-form-item label="备注" prop="remarks">
-          <el-input v-model="form.remarks" placeholder="请输入备注" />
+          <el-input v-model="form.remarks" placeholder="请输入备注"/>
         </el-form-item>
       </el-form>
       <div slot="footer" class="dialog-footer">
@@ -139,49 +154,131 @@
         <el-button @click="cancel">取 消</el-button>
       </div>
     </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-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据
-                  <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>
+    <!-- 用户导入对话框 -->
+    <el-dialog  :close-on-click-modal="false" v-dialogDrag :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"
+        :disabled="upload.isUploading"
+        :on-progress="handleFileUploadProgress"
+        :on-success="handleFileSuccess"
+        :auto-upload="false"
+        drag
+      >
+        <i class="el-icon-upload"></i>
+        <div class="el-upload__text">
+          {{ $t('将文件拖到此处,或') }}
+          <em>{{ $t('点击上传') }}</em>
+        </div>
+        <div class="el-upload__tip" slot="tip">
+          <!--<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的用户数据-->
+          <el-link type="info" style="font-size:12px" @click="importTemplate">{{ $t('下载模板') }}</el-link>
+        </div>
+        <form ref="downloadFileForm" :action="upload.downloadAction" target="FORMSUBMIT">
+          <input name="type" :value="upload.type" hidden />
+        </form>
+        <div class="el-upload__tip" style="color:red" slot="tip">{{ $t('提示:仅允许导入“xls”或“xlsx”格式文件!') }}</div>
+      </el-upload>
+      <div slot="footer" class="dialog-footer">
+        <el-button type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button>
+        <el-button @click="upload.open = false">{{ $t('取 消') }}</el-button>
+      </div>
+    </el-dialog><!-- 报告附件对话框 -->
+    <el-dialog :close-on-click-modal="false" v-dialogDrag :title="doc.title" :visible.sync="doc.open" width="700px"
+               append-to-body>
+      <el-upload
+        ref="doc"
+        :limit="50"
+        :headers="doc.headers"
+        :action="doc.url + '?pType=' + doc.pType + '&pId=' + doc.pId"
+        :disabled="doc.isUploading"
+        :on-progress="handleFileDocProgress"
+        :on-success="handleFileDocSuccess"
+        :auto-upload="true"
+        drag
+      >
+        <i class="el-icon-upload"></i>
+        <div class="el-upload__text">
+          {{ $t('将文件拖到此处,或') }}
+          <em>{{ $t('点击上传') }}</em>
+        </div>
+      </el-upload>
+      <el-table :data="doc.commonfileList" border>
+        <el-table-column :label="$t('文件名')" align="center" prop="fileName" :show-overflow-tooltip="true">
+          <template slot-scope="scope">
+            <a class="link-type" @click="handleDownload(scope.row)">
+              <span>{{ scope.row.fileName }}</span>
+            </a>
+          </template>
+        </el-table-column>
+        <el-table-column :label="$t('大小(Kb)')" align="center" prop="fileSize" :show-overflow-tooltip="true"
+                         width="80"/>
+        <el-table-column :label="$t('上传人')" align="center" prop="creator" :show-overflow-tooltip="true" width="120"/>
+        <el-table-column :label="$t('操作')" align="center" width="120" class-name="small-padding fixed-width">
+          <template slot-scope="scope">
+            <el-button
+              v-if="scope.row.fileName.endsWith('pdf')"
+              size="mini"
+              type="text"
+              icon="el-icon-view"
+              @click="handleSee(scope.row)"
+            >{{ $t('预览') }}
+            </el-button>
+            <el-button
+              size="mini"
+              type="text"
+              icon="el-icon-download"
+              @click="handleDownload(scope.row)"
+            >{{ $t('下载') }}
+            </el-button>
+            <el-button
+              size="mini"
+              type="text"
+              icon="el-icon-delete"
+              @click="handleDeleteDoc(scope.row)"
+            >{{ $t('删除') }}
+            </el-button>
+          </template>
+        </el-table-column>
+      </el-table>
+      <el-dialog :close-on-click-modal="false" v-dialogDrag :title="pdf.title" :visible.sync="pdf.open" width="1300px"
+                 append-to-body>
+        <div style="margin-top: -60px;float: right;margin-right: 40px;">
+          <el-button size="mini" type="text" @click="openPdf">{{ $t('新页面打开PDF') }}</el-button>
+        </div>
+        <div style="margin-top: -30px">
+          <iframe :src="pdf.pdfUrl" frameborder="0" width="100%" height="700px"></iframe>
+        </div>
       </el-dialog>
+      <div slot="footer" class="dialog-footer">
+        <!--        <el-button type="primary" @click="submitFileForm">{{ $t('确 定') }}</el-button>-->
+        <el-button @click="doc.open = false">{{ $t('返 回') }}</el-button>
+      </div>
+    </el-dialog>
   </div>
 </template>
 
 <script>
-import { listOperationlist, getOperationlist, delOperationlist, addOperationlist, updateOperationlist, exportOperationlist, importTemplate} from "@/api/issue/operationlist";
-import { treeselect } from "@/api/system/dept";
-import { getToken } from "@/utils/auth";
+import {
+  addOperationlist,
+  delOperationlist,
+  exportOperationlist,
+  getOperationlist,
+  listOperationlist,
+  updateOperationlist
+} from "@/api/issue/operationlist";
+import {treeselect} from "@/api/system/dept";
+import {getToken} from "@/utils/auth";
 import Treeselect from "@riophae/vue-treeselect";
 import "@riophae/vue-treeselect/dist/vue-treeselect.css";
+import {allFileList, delCommonfile} from "@/api/common/commonfile";
 
 export default {
   name: "Operationlist",
-  components: { Treeselect },
+  components: {Treeselect},
   data() {
     return {
       // 遮罩层
@@ -202,24 +299,61 @@ export default {
       title: "",
       // 部门树选项
       deptOptions: undefined,
-      clientHeight:300,
+      clientHeight: 300,
       // 是否显示弹出层
       open: false,
-        // 用户导入参数
-        upload: {
-            // 是否显示弹出层(用户导入)
-            open: false,
-            // 弹出层标题(用户导入)
-            title: "",
-            // 是否禁用上传
-            isUploading: false,
-            // 是否更新已经存在的用户数据
-            updateSupport: 0,
-            // 设置上传的请求头部
-            headers: { Authorization: "Bearer " + getToken() },
-            // 上传的地址
-            url: process.env.VUE_APP_BASE_API + "/issue/operationlist/importData"
+      // 用户导入参数
+      upload: {
+        downloadAction: process.env.VUE_APP_BASE_API + '/common/template',
+        //下载模板类型
+        type: "operationlist",
+        // 是否显示弹出层(用户导入)
+        open: false,
+        // 弹出层标题(用户导入)
+        title: "",
+        // 是否禁用上传
+        isUploading: false,
+        // 是否更新已经存在的用户数据
+        updateSupport: 0,
+        // 设置上传的请求头部
+        headers: {Authorization: "Bearer " + getToken()},
+        // 上传的地址
+        url: process.env.VUE_APP_BASE_API + "/issue/operationlist/importData"
+      },
+      // 报告附件参数
+      doc: {
+        file: "",
+        // 是否显示弹出层(报告附件)
+        open: false,
+        // 弹出层标题(报告附件)
+        title: "",
+        // 是否禁用上传
+        isUploading: false,
+        // 是否更新已经存在的用户数据
+        updateSupport: 0,
+        // 报告附件上传位置编号
+        ids: 0,
+        // 设置上传的请求头部
+        headers: {Authorization: "Bearer " + getToken()},
+        // 上传的地址
+        url: process.env.VUE_APP_BASE_API + "/common/commonfile/uploadFile",
+        commonfileList: null,
+        queryParams: {
+          pId: null,
+          pType: 'operationlist'
         },
+        pType: 'operationlist',
+        pId: null
+      },
+      pdf : {
+        title: '',
+        pdfUrl: '',
+        numPages: null,
+        open: false,
+        pageNum: 1,
+        pageTotalNum: 1,
+        loadedRatio: 0,
+      },
       // 查询参数
       queryParams: {
         pageNum: 1,
@@ -239,21 +373,20 @@ export default {
       // 表单参数
       form: {},
       // 表单校验
-      rules: {
-      }
+      rules: {}
     };
   },
   watch: {
-        // 根据名称筛选部门树
-        deptName(val) {
-            this.$refs.tree.filter(val);
-        }
-   },
+    // 根据名称筛选部门树
+    deptName(val) {
+      this.$refs.tree.filter(val);
+    }
+  },
   created() {
-      //设置表格高度对应屏幕高度
-      this.$nextTick(() => {
-          this.clientHeight = document.body.clientHeight -250
-      })
+    //设置表格高度对应屏幕高度
+    this.$nextTick(() => {
+      this.clientHeight = document.body.clientHeight - 250
+    })
     this.getList();
     this.getTreeselect();
   },
@@ -267,12 +400,12 @@ export default {
         this.loading = false;
       });
     },
-     /** 查询部门下拉树结构 */
-     getTreeselect() {
-          treeselect().then(response => {
-              this.deptOptions = response.data;
-          });
-     },
+    /** 查询部门下拉树结构 */
+    getTreeselect() {
+      treeselect().then(response => {
+        this.deptOptions = response.data;
+      });
+    },
     // 取消按钮
     cancel() {
       this.open = false;
@@ -310,7 +443,7 @@ export default {
     // 多选框选中数据
     handleSelectionChange(selection) {
       this.ids = selection.map(item => item.id)
-      this.single = selection.length!==1
+      this.single = selection.length !== 1
       this.multiple = !selection.length
     },
     /** 新增按钮操作 */
@@ -353,56 +486,118 @@ export default {
     handleDelete(row) {
       const ids = row.id || this.ids;
       this.$confirm('是否确认删除?', "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        }).then(function() {
-          return delOperationlist(ids);
-        }).then(() => {
-          this.getList();
-          this.msgSuccess("删除成功");
-        })
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(function () {
+        return delOperationlist(ids);
+      }).then(() => {
+        this.getList();
+        this.msgSuccess("删除成功");
+      })
     },
     /** 导出按钮操作 */
     handleExport() {
       const queryParams = this.queryParams;
       this.$confirm('是否确认导出所有CBPB工艺事件清单数据项?', "警告", {
-          confirmButtonText: "确定",
-          cancelButtonText: "取消",
-          type: "warning"
-        }).then(function() {
-          return exportOperationlist(queryParams);
-        }).then(response => {
-          this.download(response.msg);
-        })
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning"
+      }).then(function () {
+        return exportOperationlist(queryParams);
+      }).then(response => {
+        this.download(response.msg);
+      })
     },
-      /** 导入按钮操作 */
-      handleImport() {
-          this.upload.title = "用户导入";
-          this.upload.open = true;
-      },
-      /** 下载模板操作 */
-      importTemplate() {
-          importTemplate().then(response => {
-              this.download(response.msg);
-          });
-      },
-      // 文件上传中处理
-      handleFileUploadProgress(event, file, fileList) {
-          this.upload.isUploading = true;
-      },
-      // 文件上传成功处理
-      handleFileSuccess(response, file, fileList) {
-          this.upload.open = false;
-          this.upload.isUploading = false;
-          this.$refs.upload.clearFiles();
-          this.$alert(response.msg, "导入结果", { dangerouslyUseHTMLString: true });
-          this.getList();
-      },
-      // 提交上传文件
-      submitFileForm() {
-          this.$refs.upload.submit();
+    /** 导入按钮操作 */
+    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[0] != null) {
+        this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据') + "," + this.$t('第') + response.data + this.$t('行数据出现错误导入失败') + "。", this.$t('导入结果'), {dangerouslyUseHTMLString: true});
+      } else {
+        this.$alert(this.$t('成功导入') + response.msg + this.$t('条数据'), this.$t('导入结果'), {dangerouslyUseHTMLString: true});
       }
+      this.getList();
+    },
+    // 提交上传文件
+    submitFileForm() {
+      this.$refs.upload.submit();
+    },/** 报告附件按钮操作 */
+    handleDoc(row) {
+      this.doc.id = row.id;
+      this.doc.title = this.$t('附件');
+      this.doc.open = true;
+      this.doc.queryParams.pId = row.id
+      this.doc.pId = row.id
+      this.getFileList()
+      this.$nextTick(() => {
+        this.$refs.doc.clearFiles()
+      })
+    },
+    getFileList() {
+      allFileList(this.doc.queryParams).then(response => {
+        this.doc.commonfileList = response;
+      });
+    },
+    //附件上传中处理
+    handleFileDocProgress(event, file, fileList) {
+      this.doc.file = file;
+      this.doc.isUploading = true;
+    },
+    //附件上传成功处理
+    handleFileDocSuccess(response, file, fileList) {
+      this.doc.isUploading = false;
+      this.$alert(response.msg, this.$t('导入结果'), {dangerouslyUseHTMLString: true});
+      this.getFileList()
+    },
+    /** 删除按钮操作 */
+    handleDeleteDoc(row) {
+      const ids = row.id || this.ids;
+      this.$confirm(this.$t('是否确认删除?'), this.$t('警告'), {
+        confirmButtonText: this.$t('确定'),
+        cancelButtonText: this.$t('取消'),
+        type: "warning"
+      }).then(function () {
+        return delCommonfile(ids);
+      }).then(() => {
+        this.getFileList()
+        this.msgSuccess(this.$t('删除成功'));
+      })
+    },
+    // 文件下载处理
+    handleDownload(row) {
+      var name = row.fileName;
+      var url = row.fileUrl;
+      var suffix = url.substring(url.lastIndexOf("."), url.length);
+      const a = document.createElement('a')
+      a.setAttribute('download', name)
+      a.setAttribute('target', '_blank')
+      a.setAttribute('href', process.env.VUE_APP_BASE_API + url)
+      a.click()
+    },
+    openPdf() {
+      window.open(this.pdf.pdfUrl);//path是文件的全路径地址
+    },
+    handleSee(row) {
+      this.pdf.open = true
+      this.pdf.title = row.fileName
+      this.pdf.pdfUrl = process.env.VUE_APP_BASE_API + '/pdf/web/viewer.html?file=' + process.env.VUE_APP_BASE_API + row.fileUrl
+    },
   }
 };
 </script>