src/main/java/com/zy/crm/manager/controller/PriOnlineController.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/zy/crm/manager/entity/PriOnline.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/resources/excel/uploadCheckData/lock | 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/webapp/static/js/priOnline/priOnline.js | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/webapp/views/priOnline/priOnline.html | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/webapp/views/priOnline/priOnline_check.html | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
src/main/java/com/zy/crm/manager/controller/PriOnlineController.java
@@ -18,8 +18,13 @@ import com.zy.crm.common.web.BaseController; import com.zy.crm.manager.service.PriService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.io.ClassPathResource; import org.springframework.util.ClassUtils; import org.springframework.web.bind.annotation.*; import org.springframework.web.multipart.MultipartFile; import javax.servlet.http.HttpServletResponse; import java.io.*; import java.text.SimpleDateFormat; import java.util.*; @@ -181,16 +186,73 @@ @RequestMapping(value = "/priOnline/uploadCheck/auth") @ManagerAuth public R uploadCheck(@RequestBody Map<String,Object> map){ PriOnline priOnline = priOnlineService.selectById(Long.parseLong(map.get("id").toString())); public R uploadCheck(@RequestParam("id") Integer id, @RequestParam("checkData") String checkData, @RequestParam("file") MultipartFile[] files){ PriOnline priOnline = priOnlineService.selectById(id); if (priOnline.getStatus() == 1) { return R.error("核价已完成,禁止上传"); } priOnline.setCheckData(map.get("checkData").toString()); priOnline.setCheckData(checkData); MultipartFile file = files[0]; SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd_HHmmss"); String path = ClassUtils.getDefaultClassLoader().getResource("excel/uploadCheckData").getPath(); //文件后缀名 String suffix = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".")); //上传文件名 String filename = format.format(new Date()) + suffix; //最终文件路径 String filepath = path + "/" + filename; //服务器端保存的文件对象 File serverFile = new File(filepath); if(!serverFile.exists()) { try { //创建文件 serverFile.createNewFile(); //将上传的文件写入到服务器端文件内 file.transferTo(serverFile); } catch (IOException e) { e.printStackTrace(); } } //保存文件名 priOnline.setCheckDataFile(filename); priOnlineService.updateById(priOnline); return R.ok(); } @GetMapping("/priOnline/checkDataDownload/{filename}") public void download(@PathVariable String filename, HttpServletResponse response) { try { ClassPathResource pathResource = new ClassPathResource("excel/uploadCheckData/" + filename); File file = pathResource.getFile(); InputStream inputStream = pathResource.getInputStream(); //输出文件 InputStream fis = new BufferedInputStream(inputStream); byte[] buffer = new byte[fis.available()]; fis.read(buffer); fis.close(); response.reset(); //获取文件的名字再浏览器下载页面 String name = file.getName(); response.addHeader("Content-Disposition", "attachment;filename=" + new String(name.getBytes(), "iso-8859-1")); response.addHeader("Content-Length", "" + file.length()); OutputStream out = new BufferedOutputStream(response.getOutputStream()); response.setContentType("application/octet-stream"); out.write(buffer); out.flush(); out.close(); } catch (Exception e) { e.printStackTrace(); } } @RequestMapping(value = "/priOnline/delete/auth") @ManagerAuth public R delete(Long[] ids){ src/main/java/com/zy/crm/manager/entity/PriOnline.java
@@ -91,6 +91,10 @@ @TableField("member_id") private Long memberId; @ApiModelProperty(value= "上传报价excel数据的原始文件地址") @TableField("check_data_file") private String checkDataFile; public PriOnline() {} public PriOnline(String title,String sheetData,Date createTime,String filepath) { src/main/resources/excel/uploadCheckData/lock
src/main/webapp/static/js/priOnline/priOnline.js
@@ -248,16 +248,23 @@ return; } let formData = new FormData($("#uploadFile")[0]); formData.append("id", data.id); formData.append("checkData", zip(exportJson.sheets)); $.ajax({ url: baseUrl+"/priOnline/uploadCheck/auth", headers: {'token': localStorage.getItem('token')}, data: JSON.stringify({ id: data.id, checkData: zip(exportJson.sheets) }), data: formData, // data: JSON.stringify({ // id: data.id, // checkData: zip(exportJson.sheets) // }), // dataType: "json", method: 'POST', dataType: "json", contentType:'application/json;charset=UTF-8', cache: false, processData: false, contentType: false, // contentType:'application/json;charset=UTF-8', success: function (res) { if (res.code == 200) { layer.msg('上传成功',{time:1000},() => { src/main/webapp/views/priOnline/priOnline.html
@@ -41,7 +41,11 @@ </div> </script> <input type="file" style="display: none;" id="uploadQuote"> <form id="uploadFile" enctype="multipart/form-data" style="display: none;" > <input type="file" name="file" id="uploadQuote"> <input type="button" onclick="upload()" value="上传"/> </form> <script type="text/html" id="operate"> <a class="layui-btn layui-btn-xs btn-edit" lay-event="check">核价</a> src/main/webapp/views/priOnline/priOnline_check.html
@@ -26,6 +26,7 @@ <!-- <div><button type="button" id="otherSave">另保存到服务器</button></div>--> <div><button type="button" class="layui-btn layui-btn-primary layui-btn-xs btn-edit" id="allprint">全部打印</button></div> <div><button type="button" class="layui-btn layui-btn-primary layui-btn-xs btn-edit" id="print">选区打印</button></div> <div><button type="button" class="layui-btn layui-btn-primary layui-btn-xs btn-edit" id="download">下载</button></div> </div> <div id="luckysheet" style="margin:0px;padding:0px;position:absolute;width:100%;height: 100vh;left: 0px;top: 0px;"></div> <script> @@ -43,6 +44,8 @@ myFolderUrl: '' //左上角<返回按钮的链接 } let checkDataFile = ""; if(getUrlParams('id') == false || getUrlParams('id') == undefined){ //新增 luckysheet.create(options) @@ -58,6 +61,7 @@ headers: {'token': localStorage.getItem('token')}, success:function(res) { if (res.code == 200) { checkDataFile = res.data.checkDataFile options.data = unzip(res.data.checkData) luckysheet.create(options) $("#luckysheet_info_detail_update").hide() @@ -130,6 +134,10 @@ } }) $("#download").on("click",() => { window.open(baseUrl + "/priOnline/checkDataDownload/" +checkDataFile) }) }) $("#allprint").on("click",() => {