licailing 5 лет назад
Родитель
Сommit
bc1931737a

+ 7 - 9
src/main/java/com/izouma/wenlvju/service/RateService.java

@@ -18,23 +18,20 @@ import org.springframework.stereotype.Service;
 import javax.servlet.http.HttpServletResponse;
 import java.io.File;
 import java.io.PrintWriter;
-import java.net.URLEncoder;
-import java.nio.charset.StandardCharsets;
 import java.nio.file.Paths;
-import java.text.SimpleDateFormat;
+import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.stream.Collectors;
 
 @Service
 @AllArgsConstructor
 public class RateService {
 
-    private RateRepo rateRepo;
+    private final RateRepo rateRepo;
 
     public Page<Rate> all(PageQuery pageQuery) {
         return rateRepo.findAll(JpaUtils.toSpecification(pageQuery, Rate.class), JpaUtils.toPageRequest(pageQuery));
@@ -74,7 +71,8 @@ public class RateService {
             //单位
             dataMap.put("name", rate.getName());
             //日期
-            dataMap.put("date", DateTimeFormatter.ofPattern(DateConfig.DEFAULT_DATE_FORMAT).format(rate.getCreatedAt()));
+            dataMap.put("date", DateTimeFormatter.ofPattern(DateConfig.DEFAULT_DATE_FORMAT)
+                    .format(rate.getCreatedAt()));
             //负责人
             dataMap.put("owner", rate.getOwner());
             //电话
@@ -84,7 +82,7 @@ public class RateService {
             //承办过
             dataMap.put("undertake", rate.isUndertakeExamination() ? "是" : "否");
             //考级机构名称
-            if (rate.isUndertakeExamination()){
+            if (rate.isUndertakeExamination()) {
                 dataMap.put("examination", String.join(",", rate.getExamination()));
             }
             //单位概况
@@ -92,13 +90,13 @@ public class RateService {
             //Configuration 用于读取ftl文件
             Configuration configuration = new Configuration(new Version("2.3.0"));
 
-
             configuration.setDefaultEncoding("utf-8");
 
             configuration.setDirectoryForTemplateLoading(new File(Paths.get(System.getProperty("user.dir"), "src", "main", "resources", "templates")
                     .toString()));//指定ftl所在目录,根据自己的改
             response.setContentType("application/msword");
-            response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("等级评定申报表", "UTF-8")+".doc");
+            String fileName = DateTimeFormatter.ofPattern("yyyyMMdd").format(LocalDate.now());
+            response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".doc");
             response.setCharacterEncoding("utf-8");
             PrintWriter out = response.getWriter();
             Template template = configuration.getTemplate("RateTemplate.ftl", "utf-8");//以utf-8的编码读取ftl文件

+ 25 - 1
src/main/vue/src/views/RateAudit.vue

@@ -9,6 +9,7 @@
             style="max-width: 600px;"
         >
             <div class="info-content">
+                <div class="tag" v-if="grade">{{ grade }}</div>
                 <div class="info-item">
                     <div class="name">机构名称</div>
                     <div class="val">
@@ -185,6 +186,15 @@ export default {
                 .get('rate/get/' + this.$route.query.id)
                 .then(res => {
                     this.formData = res;
+                    if (res.grade == 'EXCELLENT') {
+                        this.grade = '优秀';
+                    } else if (res.grade == 'ELIGIBLE') {
+                        this.grade = '合格';
+                    } else if (res.grade == 'NOT_ELIGIBLE') {
+                        this.grade = '不合格';
+                    } else {
+                        this.grade = '';
+                    }
                     let data = res.rateAudits;
                     if (typeof data != 'undefined') {
                         this.showAudit = true;
@@ -222,7 +232,8 @@ export default {
             inputVisible: false,
             inputValue: '',
             saving: false,
-            districts: []
+            districts: [],
+            grade: ''
         };
     },
     methods: {
@@ -284,6 +295,19 @@ export default {
             width: 190px;
         }
     }
+    .tag {
+        margin: 20px 20px;
+        width: 50px;
+        height: 22px;
+        background: rgba(255, 165, 38, 0.3);
+        font-size: 12px;
+        line-height: 22px;
+        text-align: center;
+        color: #0f264d;
+        position: absolute;
+        left: 0;
+        top: 12px;
+    }
 }
 .el-tag + .el-tag {
     margin-left: 10px;