commit
This commit is contained in:
@@ -13,6 +13,8 @@ import io.v.nutz.sys.models.Sys_file;
|
||||
import io.v.nutz.sys.models.Sys_union;
|
||||
import io.v.nutz.sys.models.Sys_user_role;
|
||||
import io.v.nutz.util.ShiroUtil;
|
||||
import io.v.nutz.web.commons.utils.FileUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.nutz.aop.interceptor.ioc.TransAop;
|
||||
@@ -33,6 +35,11 @@ import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
import org.nutz.mvc.annotation.Param;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -73,9 +80,9 @@ public class Jdh2GzzlglController {
|
||||
@At
|
||||
@ViReturn
|
||||
@RequiresPermissions("sys.jdh2.gzzl.gl")
|
||||
public Object getTreeData(@Param(value = "year",required = false) String year,
|
||||
@Param(value = "jdhid",required = false) String jdhid,
|
||||
@Param(value = "zllx",required = false) String zllx) {
|
||||
public Object getTreeData(@Param(value = "year", required = false) String year,
|
||||
@Param(value = "jdhid", required = false) String jdhid,
|
||||
@Param(value = "zllx", required = false) String zllx) {
|
||||
NutMap nutMap = NutMap.NEW();
|
||||
nutMap.setv("unionname", "工会委员会");
|
||||
Sql sql = Sqls.create("""
|
||||
@@ -114,15 +121,15 @@ public class Jdh2GzzlglController {
|
||||
|
||||
@At
|
||||
@RequiresPermissions("sys.jdh2.gzzl.gl")
|
||||
public Object pageData(@Param(value = "pageNumber",required = false) Integer pageNumber,
|
||||
@Param(value = "pageSize",required = false) Integer pageSize,
|
||||
@Param(value = "pageOrderName",required = false) String pageOrderName,
|
||||
@Param(value = "pageOrderBy",required = false) String pageOrderBy,
|
||||
@Param(value = "year",required = false) String year,
|
||||
@Param(value = "zlname",required = false) String zlname,
|
||||
@Param(value = "jdhid",required = false) String jdhid,
|
||||
@Param(value = "zllx",required = false) String zllx,
|
||||
@Param(value = "unionId",required = false) String unionId) {
|
||||
public Object pageData(@Param(value = "pageNumber", required = false) Integer pageNumber,
|
||||
@Param(value = "pageSize", required = false) Integer pageSize,
|
||||
@Param(value = "pageOrderName", required = false) String pageOrderName,
|
||||
@Param(value = "pageOrderBy", required = false) String pageOrderBy,
|
||||
@Param(value = "year", required = false) String year,
|
||||
@Param(value = "zlname", required = false) String zlname,
|
||||
@Param(value = "jdhid", required = false) String jdhid,
|
||||
@Param(value = "zllx", required = false) String zllx,
|
||||
@Param(value = "unionId", required = false) String unionId) {
|
||||
try {
|
||||
Sql sql = Sqls.create("""
|
||||
SELECT
|
||||
@@ -249,4 +256,56 @@ public class Jdh2GzzlglController {
|
||||
dao.updateIgnoreNull(jdhLevel2);
|
||||
return null;
|
||||
}
|
||||
|
||||
@At
|
||||
@Ok("void")
|
||||
@RequiresPermissions("sys.jdh2.gzzl.gl")
|
||||
public void doDownload(String id, HttpServletResponse response) {
|
||||
|
||||
try {
|
||||
Jdh2_gzzl gzzl = dao.fetch(Jdh2_gzzl.class, id);
|
||||
|
||||
response.reset();
|
||||
response.setContentType("application/x-msdownload;charset=utf-8");
|
||||
String fileName = gzzl.getUsername() + "_" + gzzl.getZlname();
|
||||
/**
|
||||
* 创建临时文件夹
|
||||
*/
|
||||
String tmpPath = "tmp/" + R.UU32();
|
||||
File tmpDir = new File(tmpPath + "/" + fileName);
|
||||
tmpDir.mkdirs();
|
||||
|
||||
List<Sys_file> files = gzzl.getFiles();
|
||||
if (files != null) {
|
||||
for (Sys_file file : files) {
|
||||
File targetFile = new File(tmpDir, file.getFilename());
|
||||
try (FileOutputStream outputStream = new FileOutputStream(targetFile)) {
|
||||
ftpService.download(file.getFilepath(), outputStream);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 压缩到zip文件
|
||||
String zipFileName = fileName + ".zip";
|
||||
String zipFilePath = tmpPath + "/" + zipFileName;
|
||||
FileUtil.compressToZip(tmpDir.getPath(), tmpPath, zipFileName);
|
||||
|
||||
response.setHeader("content-disposition", "attachment;filename="
|
||||
+ URLEncoder.encode(zipFileName, "UTF-8"));
|
||||
|
||||
// 读取并输出zip文件
|
||||
File zipFile = new File(zipFilePath);
|
||||
try (FileInputStream inputStream = new FileInputStream(zipFile)) {
|
||||
IOUtils.copy(inputStream, response.getOutputStream());
|
||||
}
|
||||
|
||||
// 清理临时文件
|
||||
FileUtil.deleteDir(new File(tmpPath)); // 删除整个临时目录
|
||||
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -459,7 +459,7 @@ module.exports = {
|
||||
files: Array,
|
||||
type: {
|
||||
type: Array,
|
||||
default: ['jpg', 'jpeg', 'png', 'doc', 'docx', 'xls', 'xlsx', 'pdf']
|
||||
default: ['jpg', 'jpeg', 'png', 'doc', 'docx', 'xls', 'xlsx', 'pdf', 'zip', 'war']
|
||||
},
|
||||
max: {
|
||||
type: Number,
|
||||
@@ -768,4 +768,4 @@ module.exports = {
|
||||
line-height: 0;
|
||||
}
|
||||
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -239,4 +239,4 @@ module.exports = {
|
||||
.el-upload__tip {
|
||||
text-align: left;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -193,9 +193,9 @@ layout("/layouts/platform.html"){
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item prop="files" label="请示附件" class="is-required">
|
||||
<file-upload :max="1" :files.sync="formData.files">
|
||||
<file-upload :max="10" :files.sync="formData.files">
|
||||
<template #el-upload__tip>
|
||||
<div class="el-upload__tip" slot="tip">图片类请上传jpg/png/jpeg等格式,文档类请上传doc/docx/xls/xlsx/pdf等格式,上传数量为1个</div>
|
||||
<div class="el-upload__tip" slot="tip">图片类请上传jpg/png/jpeg等格式,文档类请上传doc/docx/xls/xlsx/pdf等格式,上传数量为10个</div>
|
||||
</template>
|
||||
</file-upload>
|
||||
</el-form-item>
|
||||
|
||||
@@ -148,6 +148,9 @@ layout("/layouts/platform.html"){
|
||||
<el-dropdown-item :command="{type:'view',data:scope.row}">
|
||||
预览
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item :command="{type:'download',data:scope.row}">
|
||||
下载
|
||||
</el-dropdown-item>
|
||||
<el-dropdown-item
|
||||
v-if="(${@shiro.hasRole('sysadmin')||@shiro.hasRole('A06')}) || scope.row.state == 0"
|
||||
:command="{type:'edit',data:scope.row}">
|
||||
@@ -217,7 +220,13 @@ layout("/layouts/platform.html"){
|
||||
</template>
|
||||
</el-form-item>-->
|
||||
<el-form-item prop="files" label="附件上传">
|
||||
<file-upload :files.sync="formData.files"></file-upload>
|
||||
<file-upload :files.sync="formData.files">
|
||||
<template #el-upload__tip>
|
||||
<div class="el-upload__tip" slot="tip">
|
||||
图片类请上传jpg/png/jpeg等格式,文档类请上传doc/docx/xls/xlsx/pdf等格式,压缩包请上传zip/war,上传数量为10个
|
||||
</div>
|
||||
</template>
|
||||
</file-upload>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-form>
|
||||
@@ -266,7 +275,13 @@ layout("/layouts/platform.html"){
|
||||
</el-form-item>-->
|
||||
|
||||
<el-form-item prop="files" label="附件上传">
|
||||
<file-upload :files.sync="formData.files"></file-upload>
|
||||
<file-upload :files.sync="formData.files" :max="10">
|
||||
<template #el-upload__tip>
|
||||
<div class="el-upload__tip" slot="tip">
|
||||
图片类请上传jpg/png/jpeg等格式,文档类请上传doc/docx/xls/xlsx/pdf等格式,压缩包请上传zip/war,上传数量为10个
|
||||
</div>
|
||||
</template>
|
||||
</file-upload>
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
@@ -416,8 +431,14 @@ layout("/layouts/platform.html"){
|
||||
this.openEdit(data)
|
||||
} else if (type == 'delete') {
|
||||
this.doDelete(data.id)
|
||||
}else if (type == 'download') {
|
||||
this.doDownload(data.id)
|
||||
}
|
||||
},
|
||||
doDownload(id){
|
||||
window.location.href = "/platform/jdh2/gzzlgl/doDownload?id=" + id
|
||||
|
||||
},
|
||||
handleChange: function (file, filelist) {
|
||||
this.fileList = filelist;
|
||||
},
|
||||
@@ -454,7 +475,7 @@ layout("/layouts/platform.html"){
|
||||
const formData = clone(this.formData)
|
||||
formData.files = JSON.stringify(formData.files)
|
||||
const resp = await $.post('/platform/jdh2/gzzlgl/doEdit', formData)
|
||||
if (resp.code===0){
|
||||
if (resp.code === 0) {
|
||||
this.editDialogVisible = false
|
||||
this.doSearch()
|
||||
}
|
||||
@@ -518,7 +539,7 @@ layout("/layouts/platform.html"){
|
||||
formData.files = JSON.stringify(formData.files)
|
||||
|
||||
const resp = await $.post('/platform/jdh2/gzzlgl/doAdd', formData)
|
||||
if (resp.code===0){
|
||||
if (resp.code === 0) {
|
||||
this.addDialogVisible = false
|
||||
this.doSearch()
|
||||
loading.close()
|
||||
|
||||
Reference in New Issue
Block a user