| | |
| | | package com.javaweb.geo.controller; |
| | | |
| | | import java.io.File; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import cn.hutool.core.io.FileUtil; |
| | | import com.javaweb.common.config.Global; |
| | | import com.javaweb.geo.vo.FileVo; |
| | | import org.apache.shiro.authz.annotation.RequiresPermissions; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Controller; |
| | |
| | | } |
| | | mmap.put("urlAddress",path); |
| | | return prefix + "/image_view"; |
| | | } |
| | | |
| | | /** |
| | | * 项目文件列表页面 |
| | | * @return |
| | | */ |
| | | @GetMapping("/projectDataFileList") |
| | | public String projectDataFileList(String id ,ModelMap modelMap){ |
| | | modelMap.put("id",id); |
| | | return prefix + "/files"; |
| | | } |
| | | |
| | | /** |
| | |
| | | return projectDataService.uploadZIP(file,request); |
| | | } |
| | | |
| | | /** |
| | | * 获取文件列表 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | @PostMapping( "/listFile") |
| | | @ResponseBody |
| | | public TableDataInfo listFile(String id){ |
| | | List<FileVo> paths = new ArrayList<>(); |
| | | ProjectData projectData = projectDataService.selectProjectDataById(id); |
| | | // if (!ObjectUtils.isEmpty(projectData)){ |
| | | // String num = project.getNum(); |
| | | // |
| | | // String diskPath = Global.getUploadPath() + "\\sources\\项目资料\\"+num; |
| | | // |
| | | // File file = new File(diskPath); |
| | | // |
| | | // if(FileUtil.exist(file)){ |
| | | // if(file.isDirectory()){ |
| | | // File []lists = file.listFiles(); |
| | | // for(int i =0;i<lists.length;i++){ |
| | | // String name =lists[i].getName(); |
| | | // String path = urlPrefixPath + num + "/" +name; |
| | | // FileVo vo = new FileVo() ; |
| | | // vo.setName(name); |
| | | // vo.setPath(path); |
| | | // paths.add(vo); |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | return getDataTable(paths); |
| | | } |
| | | |
| | | } |
New file |
| | |
| | | package com.javaweb.geo.vo; |
| | | |
| | | public class FileVo { |
| | | |
| | | private String path ; |
| | | private String name ; |
| | | |
| | | public String getPath() { |
| | | return path; |
| | | } |
| | | |
| | | public void setPath(String path) { |
| | | this.path = path; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | } |
| | |
| | | columns: [{ |
| | | checkbox: true |
| | | }, |
| | | { |
| | | field : 'ids', |
| | | title : '主键', |
| | | visible: false |
| | | }, |
| | | { |
| | | field : 'code', |
| | | title : '场地编号', |
New file |
| | |
| | | <!DOCTYPE html> |
| | | <html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"> |
| | | <head> |
| | | <th:block th:include="include :: header('资料列表')" /> |
| | | <th:block th:include="include :: bootstrap-fileinput-css" /> |
| | | </head> |
| | | <body class="gray-bg"> |
| | | <div class="container-div"> |
| | | <div class="row"> |
| | | <div class="col-sm-12 select-table table-striped"> |
| | | <table id="bootstrap-table"></table> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | <th:block th:include="include :: footer" /> |
| | | |
| | | <script th:inline="javascript"> |
| | | |
| | | var id =[[${id}]]; |
| | | var prefix = ctx + "geo/projectData"; |
| | | |
| | | $(function() { |
| | | var options = { |
| | | showFooter: true, |
| | | showSearch: false, |
| | | showRefresh: false, |
| | | showToggle: false, |
| | | showColumns: false, |
| | | url: prefix + "/listFile?id=" + id, |
| | | modalName: "资料列表", |
| | | columns: [{ |
| | | checkbox: true |
| | | }, |
| | | { |
| | | field : 'name', |
| | | title : '文件名称' |
| | | |
| | | }, |
| | | { |
| | | field : 'path', |
| | | title : '文件路径', |
| | | visible:false |
| | | }, |
| | | { |
| | | title: '操作', |
| | | align: 'center', |
| | | formatter: function(value, row, index) { |
| | | var actions = []; |
| | | actions.push('<a class="btn btn-warning btn-xs ' + '" href="javascript:void(0)" onclick="file(\'' + row.path + '\')"><i class="fa fa-eye"></i>查看</a> '); |
| | | return actions.join(''); |
| | | } |
| | | } |
| | | ] |
| | | }; |
| | | $.table.init(options); |
| | | }); |
| | | |
| | | /** |
| | | * 打开文件 |
| | | * @param path |
| | | */ |
| | | function file(path) { |
| | | window.open(path); |
| | | } |
| | | </script> |
| | | </body> |
| | | |
| | | </html> |
| | |
| | | var actions = []; |
| | | actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> '); |
| | | actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a> '); |
| | | actions.push('<a class="btn btn-info btn-xs ' + '" href="javascript:void(0)" onclick="viewImg(\'' + row.dataUrl + '\' , \'' + row.id + '\')"><i class="glyphicon glyphicon-menu-hamburger"></i>查看附件</a>'); |
| | | actions.push('<a class="btn btn-info btn-xs ' + '" href="javascript:void(0)" onclick="viewResource(\'' + row.id + '\' , \'' + row.id + '\')"><i class="glyphicon glyphicon-menu-hamburger"></i>查看附件</a>'); |
| | | return actions.join(''); |
| | | } |
| | | }] |
| | |
| | | var url = prefix + "/viewImage?id=" + id; |
| | | $.modal.open("查看图片", url, 800, 600); |
| | | } |
| | | |
| | | //查看资料 |
| | | function viewResource(id){ |
| | | $.modal.open("资料列表", prefix + "/projectDataFileList?id=" + id, 800, 600); |
| | | } |
| | | </script> |
| | | </body> |
| | | </html> |