Forráskód Böngészése

导出诊断报告H5中修改基础信息和公司信息接口

bmmx 1 éve
szülő
commit
14375ad6f3

+ 3 - 1
src/main/java/com/om/constant/LoginConstant.java

@@ -19,7 +19,9 @@ public class LoginConstant {
 
 
     public static final String[]  USER_ALLOWED_PATHS = {
-            "/app/user/login"
+            "/app/user/login",
+            "/app/diagnosis/report/updateBase",
+            "/app/diagnosis/report/updateCompany"
     };
 
 }

+ 13 - 0
src/main/java/com/om/controller/user/APPRepairController.java

@@ -3,6 +3,7 @@ package com.om.controller.user;
 
 import com.om.entity.dto.APPRepairQueryPageDTO;
 import com.om.entity.dto.APPReportCreateDTO;
+import com.om.entity.dto.AppRepairUpdateBaseDTO;
 import com.om.entity.vo.AppRepairQueryPageVO;
 import com.om.service.IRepairService;
 import com.om.utils.Result;
@@ -48,4 +49,16 @@ public class APPRepairController {
         return repairService.delete(id);
     }
 
+
+    @PostMapping("/updateBase")
+    @ApiOperation("查看诊断报告里的修改基础信息接口")
+    public Result updateBase(@RequestBody AppRepairUpdateBaseDTO dto){
+        return repairService.updateBase(dto);
+    }
+
+    @PostMapping("/updateCompany")
+    @ApiOperation("查看诊断报告里的修改公司信息接口")
+    public Result updateCompany(@RequestBody AppRepairUpdateBaseDTO dto){
+        return repairService.updateCompany(dto);
+    }
 }

+ 19 - 0
src/main/java/com/om/entity/dto/AppRepairUpdateBaseDTO.java

@@ -0,0 +1,19 @@
+package com.om.entity.dto;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+@Data
+@NoArgsConstructor
+public class AppRepairUpdateBaseDTO {
+    @ApiModelProperty(value = "诊断报告id")
+    private Integer id;
+
+    @ApiModelProperty(value = "字段名称")
+    private String type;
+
+    @ApiModelProperty(value = "修改值")
+    private String value;
+
+}

+ 6 - 4
src/main/java/com/om/service/IRepairService.java

@@ -1,9 +1,6 @@
 package com.om.service;
 
-import com.om.entity.dto.APPRepairQueryPageDTO;
-import com.om.entity.dto.APPReportCreateDTO;
-import com.om.entity.dto.RepairDTO;
-import com.om.entity.dto.RepairQueryPageDTO;
+import com.om.entity.dto.*;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.om.entity.po.Repair;
 import com.om.entity.vo.AppRepairQueryPageVO;
@@ -39,4 +36,9 @@ public interface IRepairService extends IService<Repair> {
     Result<String> reportPdf(Integer id);
 
     Result<String> reportH5(Integer id);
+
+    Result updateBase(AppRepairUpdateBaseDTO dto);
+
+    Result updateCompany(AppRepairUpdateBaseDTO dto);
+
 }

+ 61 - 2
src/main/java/com/om/service/impl/RepairServiceImpl.java

@@ -348,7 +348,7 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
 
         Map<String,String> baseMap = new HashMap<>();
         baseMap.put("车架号",repair.getVin());
-        baseMap.put("年款",repair.getMileage());
+        baseMap.put("年款",repair.getModelYear());
         baseMap.put("里程",repair.getMileage());
         baseMap.put("诊断路径",repair.getDiagnosticPath());
         baseMap.put("报告编号",repair.getRepairNum());
@@ -430,7 +430,7 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
 
         Map<String,String> baseMap = new HashMap<>();
         baseMap.put("车架号",repair.getVin());
-        baseMap.put("年款",repair.getMileage());
+        baseMap.put("年款",repair.getModelYear());
         baseMap.put("里程",repair.getMileage());
         baseMap.put("诊断路径",repair.getDiagnosticPath());
         baseMap.put("报告编号",repair.getRepairNum());
@@ -502,6 +502,65 @@ public class RepairServiceImpl extends ServiceImpl<RepairMapper, Repair> impleme
         }
     }
 
+    @Override
+    public Result updateBase(AppRepairUpdateBaseDTO dto) {
+        Integer id = dto.getId();
+        String type = dto.getType();
+        String value = dto.getValue();
+
+        //根据id进行查询
+        Repair repair = this.getById(id);
+        if (BeanUtil.isEmpty(repair)){
+            throw new BadReqException("该诊断报告不存在");
+        }
+
+        if (type.equals("vin")){
+            repair.setVin(value);
+        }else  if (type.equals("year")){
+            repair.setModelYear(value);
+        }
+        else  if (type.equals("mileage")){
+            repair.setMileage(value);
+        }
+
+        this.updateById(repair);
+        return Result.ok();
+    }
+
+    @Override
+    public Result updateCompany(AppRepairUpdateBaseDTO dto) {
+        Integer id = dto.getId();
+        String type = dto.getType();
+        String value = dto.getValue();
+
+        //根据id进行查询
+        Repair repair = this.getById(id);
+        if (BeanUtil.isEmpty(repair)){
+            throw new BadReqException("该诊断报告不存在");
+        }
+        String username = repair.getUsername();
+
+        //根据username查询用户
+        User user = userService.lambdaQuery()
+                .eq(User::getUsername, username)
+                .one();
+        if (BeanUtil.isEmpty(user)){
+            throw new BadReqException("该用户不存在");
+        }
+
+        if (type.equals("company")){
+            user.setCompany(value);
+        }else  if (type.equals("address")){
+            user.setAddress(value);
+        }
+        else  if (type.equals("phone")){
+            user.setTel(value);
+        }
+
+        userService.updateById(user);
+        return Result.ok();
+
+    }
 
 
 }

+ 1 - 0
src/main/java/com/om/utils/HtmlGenerator.java

@@ -34,6 +34,7 @@ public class HtmlGenerator {
             data.put("baseMap", baseMap);
             data.put("controlListMap", controlListMap);
             data.put("companyMap", companyMap);
+            data.put("id", id);
 
             template.process(data, out);
 

+ 85 - 7
src/main/resources/template/static/report.html

@@ -174,7 +174,22 @@
         }
 
 
+        #companyInput{
+            background-color: #ECF1FA;
+        }
+
+        #phoneInput{
+            background-color: #ECF1FA;
+        }
+        #addressInput{
+            background-color: #ECF1FA;
+        }
+
+
     </style>
+    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.css">
+    <script src="https://cdnjs.cloudflare.com/ajax/libs/sweetalert/2.1.2/sweetalert.min.js"></script>
+
     <script src="https://wl-resource.obs.cn-south-1.myhuaweicloud.com/static/axios.min.js"></script>
 </head>
 <body>
@@ -296,11 +311,14 @@
 </#list>
 
 <div class="company-info">
-    <img src="https://wl-resource.obs.cn-south-1.myhuaweicloud.com/static/img.png" height="30" width="30" style="float: right; margin: 0 0 10px 10px;"/>
+    <img src="https://wl-resource.obs.cn-south-1.myhuaweicloud.com/static/img.png"
+         height="30" width="30"
+         style="float: right; margin: 0 0 10px 10px; cursor: pointer;"
+         onclick="editCellFoot()">
     <table>
         <tr>
             <td>公司:</td>
-            <td style="padding-left: 180px">
+            <td id="company" style="padding-left: 180px">
                 <#if companyMap["公司"]?has_content>
                 ${companyMap["公司"]}
                 <#else>
@@ -310,7 +328,7 @@
         </tr>
         <tr>
             <td>电话:</td>
-            <td style="padding-left: 180px">
+            <td id="phone" style="padding-left: 180px">
                 <#if companyMap["电话"]?has_content>
                 ${companyMap["电话"]}
                 <#else>
@@ -320,7 +338,7 @@
         </tr>
         <tr>
             <td>地址:</td>
-            <td style="padding-left: 180px">
+            <td id="address" style="padding-left: 180px">
                 <#if companyMap["地址"]?has_content>
                 ${companyMap["地址"]}
                 <#else>
@@ -333,6 +351,8 @@
     <p STYLE="font-size: 15px"><text style="color: red">*</text>该车辆检测报告仅对本次检查结果负责</p>
 </div>
 <script>
+
+
     function editCell() {
         var vin = document.getElementById('vin');
         var year = document.getElementById('year');
@@ -341,6 +361,8 @@
         var yearText = year.innerText;
         var mileageText = mileage.innerText;
 
+
+
         vin.innerHTML = '<input type="text" id="vinInput" value="' + vinText + '" onblur="saveChanges(\'vin\', this.value)">';
         year.innerHTML = '<input type="text" id="yearInput" value="' + yearText + '" onblur="saveChanges(\'year\', this.value)">';
         mileage.innerHTML = '<input type="text" id="mileageInput" value="' + mileageText + '" onblur="saveChanges(\'mileage\', this.value)">';
@@ -348,25 +370,81 @@
     }
 
 
+
     function saveChanges(field,value) {
         if (value==''){
             return
         }
         var input = document.getElementById(field);
+        var id = ${id};
         // 这里可以进行保存操作,比如向服务器发送请求保存数据
         // 保存完成后可以进行一些提示或其他操作
         // 使用 Axios 发送 POST 请求
-        axios.post('http://localhost:8888/your/api/endpoint', {
+        axios.post('http://localhost:8888/app/diagnosis/report/updateBase', {
+            id: id,
             type: field,
             value: value,
         })
             .then(function (response) {
-                // 请求成功的处理
-                console.log(response);
+
+                if (response.data.code==200){
+                    swal("修改成功!", "", "success");
+                }else {
+                    swal("修改失败!", "", "fail");
+                }
             })
         // 最后销毁输入框,恢复文本
         input.innerHTML = value;
     }
+
+    function editCellFoot() {
+        var address = document.getElementById('address');
+        var company = document.getElementById('company');
+        var phone = document.getElementById('phone');
+        var addressText = address.innerText;
+        var companyText = company.innerText;
+        var phoneText = phone.innerText;
+
+
+
+        address.innerHTML = '<input type="text" id="addressInput" value="' +
+            addressText + '" onblur="saveChangesFoot(\'address\', this.value)">';
+
+        company.innerHTML = '<input type="text" id="companyInput" value="'
+            + companyText + '" onblur="saveChangesFoot(\'company\', this.value)">';
+
+        phone.innerHTML = '<input type="text" id="phoneInput" value="' +
+            phoneText + '" onblur="saveChangesFoot(\'phone\', this.value)">';
+
+    }
+
+
+
+    function saveChangesFoot(field,value) {
+        if (value==''){
+            return
+        }
+        var input = document.getElementById(field);
+        var id = ${id};
+
+        // 使用 Axios 发送 POST 请求
+        axios.post('http://localhost:8888/app/diagnosis/report/updateCompany', {
+            id: id,
+            type: field,
+            value: value,
+        })
+            .then(function (response) {
+                if (response.data.code==200){
+                    swal("修改成功!", "", "success");
+                    // 最后销毁输入框,恢复文本
+                    input.innerHTML = value;
+                }else {
+                    swal("修改失败!", "", "fail");
+                }
+
+            })
+
+    }
 </script>