Browse Source

付款申请附件批量查看功能添加

ly 6 months ago
parent
commit
df406c55ba

+ 23 - 0
src/main/java/com/liang/controller/StaPayapprovalController.java

@@ -13,7 +13,9 @@ import com.liang.dao.StaReimbursementDao;
13 13
 import com.liang.entity.*;
14 14
 import com.liang.service.*;
15 15
 //import com.liang.vo.service.*;
16
+import com.liang.vo.dto.ViewFileVo;
16 17
 import io.swagger.annotations.ApiOperation;
18
+import netscape.javascript.JSObject;
17 19
 import org.springframework.data.domain.Page;
18 20
 import org.springframework.data.domain.PageRequest;
19 21
 import org.springframework.http.ResponseEntity;
@@ -21,6 +23,7 @@ import org.springframework.stereotype.Controller;
21 23
 import org.springframework.transaction.annotation.Transactional;
22 24
 import org.springframework.ui.Model;
23 25
 import org.springframework.web.bind.annotation.*;
26
+import springfox.documentation.spring.web.json.Json;
24 27
 
25 28
 import javax.annotation.Resource;
26 29
 import javax.servlet.http.HttpServletResponse;
@@ -713,5 +716,25 @@ public class StaPayapprovalController extends BaseController {
713 716
         return  BaseResult.success("该笔付款计划作废成功 ");
714 717
     }
715 718
 
719
+    // 批量查看
720
+
721
+    @RequestMapping(value = "/Viewfile", method = RequestMethod.POST)
722
+    @ResponseBody
723
+    public BaseResult viewFile(@RequestBody String data) {
724
+        // json 解析
725
+        StaPayapproval staPayapproval = JsonTool.parseObject(data,StaPayapproval.class);
726
+        PrjContract prjContract = prjContractService.queryById(staPayapproval.getId());
727
+        if (staPayapproval.getType().equals("ht") && !prjContract.getWj().equals("[]")){
728
+                List<ViewFileVo> vo = staPayapprovalService.viewfile(prjContract.getWj());
729
+                return BaseResult.success(vo);
730
+        }
731
+        if (staPayapproval.getType().equals("ys") && !prjContract.getYszl().equals("[]")){
732
+                List<ViewFileVo> vo = staPayapprovalService.viewfile(prjContract.getYszl());
733
+                return BaseResult.success(vo);
734
+                    }
735
+        return BaseResult.failure(-1,"暂无可查看文件!");
736
+
737
+    }
738
+
716 739
 }
717 740
 

+ 1 - 0
src/main/java/com/liang/entity/StaPayapproval.java

@@ -99,5 +99,6 @@ public class StaPayapproval implements Serializable {
99 99
 //     报账金额
100 100
     private Double bzje;
101 101
 
102
+    private String type;
102 103
 }
103 104
 

+ 5 - 0
src/main/java/com/liang/service/StaPayapprovalService.java

@@ -4,6 +4,7 @@ import com.liang.entity.PrjProject;
4 4
 import com.liang.entity.StaBudgetapproval;
5 5
 import com.liang.entity.StaPayapproval;
6 6
 import com.liang.entity.StaReimbursement;
7
+import com.liang.vo.dto.ViewFileVo;
7 8
 import org.springframework.data.domain.Page;
8 9
 import org.springframework.data.domain.PageRequest;
9 10
 
@@ -97,4 +98,8 @@ public interface StaPayapprovalService {
97 98
     List<StaPayapproval> queryByHtId(Integer id);
98 99
 
99 100
     StaPayapproval getYFKJE(String fysq);
101
+
102
+    List<ViewFileVo> viewfile(String file);
103
+
104
+
100 105
 }

+ 48 - 4
src/main/java/com/liang/service/impl/StaPayapprovalServiceImpl.java

@@ -1,13 +1,17 @@
1 1
 package com.liang.service.impl;
2 2
 
3
-import com.liang.entity.PrjContract;
4
-import com.liang.entity.PrjPayplan;
5
-import com.liang.entity.PrjProject;
6
-import com.liang.entity.StaPayapproval;
3
+import com.liang.common.JsonTool;
4
+import com.liang.common.constants.CommonConstant;
5
+import com.liang.common.exception.CustomException;
6
+import com.liang.dao.BaseDictDao;
7
+import com.liang.entity.*;
7 8
 import com.liang.dao.StaPayapprovalDao;
8 9
 import com.liang.service.PrjContractService;
9 10
 import com.liang.service.PrjPayplanService;
10 11
 import com.liang.service.StaPayapprovalService;
12
+import com.liang.vo.dto.StaReimbursementVo;
13
+import com.liang.vo.dto.ViewFileVo;
14
+import io.jsonwebtoken.lang.Collections;
11 15
 import org.springframework.stereotype.Service;
12 16
 import org.springframework.data.domain.Page;
13 17
 import org.springframework.data.domain.PageImpl;
@@ -18,6 +22,7 @@ import javax.annotation.Resource;
18 22
 import java.util.HashMap;
19 23
 import java.util.List;
20 24
 import java.util.Map;
25
+import java.util.stream.Collectors;
21 26
 
22 27
 /**
23 28
  * 付款申请(StaPayapproval)表服务实现类
@@ -181,4 +186,43 @@ public class StaPayapprovalServiceImpl implements StaPayapprovalService {
181 186
     public StaPayapproval getYFKJE(String fysq) {
182 187
         return this.staPayapprovalDao.getYFKJE(fysq);
183 188
     }
189
+
190
+    @Resource
191
+    private BaseDictDao dictDao;
192
+    @Override
193
+    public List<ViewFileVo> viewfile(String file) {
194
+
195
+        List<StaReimbursementVo> staReimbursementVos = JsonTool.parseArray(file, StaReimbursementVo.class);
196
+        //获取数据库配置 http://localhost:8081//files/
197
+        List<Map<String, String>> dictByCode = dictDao.getDictByCode(CommonConstant.VIEW_FILE_PATH);
198
+        if (Collections.isEmpty(dictByCode)) {
199
+            throw new CustomException("请联系管理员添加文件查看字典");
200
+        }
201
+        String viewFilePath = dictByCode.get(0).get("name");
202
+        if (!Collections.isEmpty(staReimbursementVos)) {
203
+            return staReimbursementVos.stream().map(item -> {
204
+                //从url "http:/1 ocalhost:8082/202305/dcccd096e08a4a1 obaacadae7477d996我的阅读推荐.docx",中截取 dcccd096e08a4a1 obaacadae7477d996我的阅读推荐.docx
205
+                String url = item.getUrl();
206
+                String substring = url.substring(url.lastIndexOf("/", url.lastIndexOf("/") - 1) + 1);
207
+                ;
208
+                String content = "";
209
+                if (substring.endsWith("png") || substring.endsWith("gif") || substring.endsWith("jpeg") || substring.endsWith("jpg")) {
210
+                    //图片 使用img标签拼接 <img frameborder="0" src="http://localhost:8081//files/eaedfdfe22834ed391fc353085741c37_1715051628960.jpg" scrolling="auto" style="auto">
211
+                    content = "<img frameborder=\"0\" src=\"" + viewFilePath + substring + "\" scrolling=\"auto\" style=\"max-width:100%; height: auto\">";
212
+                } else {
213
+                    // 使用 iframe 标签拼接 <iframe frameborder="0" src="http://localhost:8081//files/eaedfdfe22834ed391fc353085741c37_1715051628960.pdf" scrolling="auto" style="width: 99%; height: 950px;"></iframe>
214
+                    content = "<iframe frameborder=\"0\" src=\"" + viewFilePath + substring + "\" scrolling=\"auto\" style=\"width: 99%; height: 950px;\"></iframe>";
215
+                }
216
+                return ViewFileVo.builder()
217
+                        //文件路径  http://localhost:8081//files/eaedfdfe22834ed391fc353085741c37_1715051628960.jpg
218
+                        .content(content)
219
+                        //文件名称
220
+                        .title(item.getWjm())
221
+                        .build();
222
+            }).collect(Collectors.toList());
223
+        } else {
224
+            throw new CustomException("暂无可查看文件");
225
+        }
226
+    }
227
+
184 228
 }

+ 95 - 0
src/main/resources/templates/payapply/view.html

@@ -70,6 +70,12 @@
70 70
 
71 71
         <!-- 右侧悬浮按钮 -->
72 72
         <div class="right-bottom-btn">
73
+            <button type="button" class="layui-btn" lay-filter="cancleBtn1">
74
+                <i class="layui-icon layui-icon-list"></i>合同文件预览
75
+            </button>
76
+            <button type="button" class="layui-btn" lay-filter="cancleBtn2">
77
+                <i class="layui-icon layui-icon-list"></i>验收资料预览
78
+            </button>
73 79
             <button type="button" class="layui-btn" lay-filter="cancleBtn">
74 80
                 <i class="layui-icon layui-icon-close"></i>关闭
75 81
             </button>
@@ -150,6 +156,95 @@
150 156
             done: function (res, curr, count) { // done为数据渲染完的回调
151 157
             }
152 158
         });
159
+        // 批量查看合同文件
160
+        $("button[lay-filter='cancleBtn1']").click(function () {
161
+            // 创建一个对象
162
+            var data = {
163
+                'id': [[${payapproval.ht}]]
164
+                ,'type':'ht'
165
+            }
166
+            AjaxUtil.post({
167
+                url: AjaxUtil.ctx + 'staPayapproval/Viewfile',
168
+                contentType:"application/json",// 传输文件类型
169
+                data: JSON.stringify(data), // 传输数据类型
170
+                success: function (res) {
171
+
172
+                    if (res.code === 0){
173
+                        //你的代码
174
+                        layer.tab({
175
+                            area: ['100%', '100%'],
176
+                            tab: res.data,
177
+                            maxmin: true,
178
+                            shadeClose: true,
179
+                            success: function (index, layero) {//打开tab后的执行的内容
180
+                                //你的代码
181
+                                $(".layui-layer-title").attr("style", "width: 100%; height: 10%; overflow-y: scroll;  white-space: nowrap; border: 1px solid #ccc;");
182
+                                $("div>span").attr("style", "padding: 10px; display: inline-block;");
183
+                            }
184
+                        })
185
+
186
+                    }else {
187
+
188
+                        layer.msg(res.message,{icon: 3});
189
+                        return false;
190
+                    }
191
+
192
+                },
193
+                fail:function (res) {
194
+                    layer.close(index);// 关闭页面
195
+                    layer.msg(res.message,{icon:3});
196
+                },
197
+                error:function (error) {
198
+                    layer.close(index);
199
+                    layer.msg('服务器异常!请联系管理员!',{icon:3})
200
+
201
+                }
202
+            })
203
+
204
+        });
205
+
206
+        // 批量查看验收资料
207
+        $("button[lay-filter='cancleBtn2']").click(function () {
208
+            var data = {
209
+                'id':[[${payapproval.ht}]]
210
+                ,'type':'ys'
211
+            }
212
+            AjaxUtil.post({
213
+                url: AjaxUtil.ctx + 'staPayapproval/Viewfile',
214
+                contentType: "application/json", // 传输文件类型 韦 json 类型
215
+                data:JSON.stringify(data), // 传输数据类型 为 Json类型
216
+                success: function (res) {
217
+                    console.log(res);
218
+                    if (res.code === 0){
219
+                        layer.tab({
220
+                            area: ['100%', '100%'],
221
+                            tab: res.data,
222
+                            maxmin: true,
223
+                            shadeClose: true,
224
+                            success: function (index, layero) {//打开tab后的执行的内容
225
+                                //你的代码
226
+                                $(".layui-layer-title").attr("style", "width: 100%; height: 10%; overflow-y: scroll;  white-space: nowrap; border: 1px solid #ccc;");
227
+                                $("div>span").attr("style", "padding: 10px; display: inline-block;");
228
+                            }
229
+                        })
230
+                    }else {
231
+                        layer.msg(res.message,{icon: 3});
232
+                        return false;
233
+                    }
234
+                },
235
+                fail: function (res) {
236
+                    layer.close(index);
237
+                    layer.msg(res.message,{icon : 3});
238
+
239
+                },
240
+                error: function (error) {
241
+                    layer.close(index);
242
+                    layer.msg('服务器异常!请联系管理员');
243
+
244
+                }
245
+            })
246
+
247
+        })
153 248
         //双击(验收资料)
154 249
         table.on('rowDouble(currentTableFilter2)', function (obj) {
155 250
             window.open(obj.data.Url);

+ 2 - 0
src/main/resources/templates/stafeemanage/list_allapply.html

@@ -226,6 +226,8 @@
226 226
         <button class="layui-btn layui-btn-sm" lay-event="export" style="background-color: black">
227 227
             <i class="layui-icon layui-icon-export" style="font-size: 10px;"></i>导出列表
228 228
         </button>
229
+
230
+
229 231
     </div>
230 232
 </script>
231 233
 <script>