添加打包功能
This commit is contained in:
parent
19bc7789e4
commit
4b96d2271c
|
@ -102,6 +102,7 @@ public class ShiroConfig {
|
|||
filterChainDefinitionMap.put("/sys/user/passwordChange", "anon");//用户更改密码
|
||||
filterChainDefinitionMap.put("/auth/2step-code", "anon");//登录验证码
|
||||
filterChainDefinitionMap.put("/sys/common/static/**", "anon");//图片预览 &下载文件不限制token
|
||||
filterChainDefinitionMap.put("/sys/common/staticLocal/**", "anon");//图片预览 &下载文件不限制token
|
||||
filterChainDefinitionMap.put("/sys/common/pdf/**", "anon");//pdf预览
|
||||
|
||||
//filterChainDefinitionMap.put("/sys/common/view/**", "anon");//图片预览不限制token
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
package org.jeecg.modules.demo.utils;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
public class ZipFiles {
|
||||
public static void zipFiles(String zipFileName, String... files) throws IOException {
|
||||
FileOutputStream fos = new FileOutputStream(zipFileName);
|
||||
ZipOutputStream zos = new ZipOutputStream(fos);
|
||||
|
||||
for (String file : files) {
|
||||
File srcFile = new File(file);
|
||||
FileInputStream fis = new FileInputStream(srcFile);
|
||||
|
||||
ZipEntry zipEntry = new ZipEntry(srcFile.getName());
|
||||
zos.putNextEntry(zipEntry);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = fis.read(buffer)) > 0) {
|
||||
zos.write(buffer, 0, length);
|
||||
}
|
||||
|
||||
fis.close();
|
||||
zos.closeEntry();
|
||||
}
|
||||
|
||||
zos.close();
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
String[] files = {"d://file1.txt", "d://file2.txt", "d://file3.txt"};
|
||||
String zipFileName = "D://files.zip";
|
||||
|
||||
try {
|
||||
zipFiles(zipFileName, files);
|
||||
|
||||
System.out.println("Files zipped successfully!");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,17 +1,21 @@
|
|||
package org.jeecg.modules.demo.xxhbjwxtscwjxx.controller;
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.common.util.DateUtils;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.demo.utils.ZipFiles;
|
||||
import org.jeecg.modules.demo.xxhbjwxtscwjxx.entity.Xxhbjwxtscwjxx;
|
||||
import org.jeecg.modules.demo.xxhbjwxtscwjxx.service.IXxhbjwxtscwjxxService;
|
||||
|
||||
|
@ -20,6 +24,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.jeecg.modules.utils.SFTPUtil;
|
||||
import org.jeecg.modules.utils.SftpConfig;
|
||||
import org.jeecgframework.poi.excel.ExcelImportUtil;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
|
@ -27,6 +33,7 @@ import org.jeecgframework.poi.excel.entity.ImportParams;
|
|||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||
|
@ -50,7 +57,14 @@ import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|||
public class XxhbjwxtscwjxxController extends JeecgController<Xxhbjwxtscwjxx, IXxhbjwxtscwjxxService> {
|
||||
@Autowired
|
||||
private IXxhbjwxtscwjxxService xxhbjwxtscwjxxService;
|
||||
|
||||
|
||||
@Value(value = "${jeecg.path.webapp}")
|
||||
private String downloadpath;
|
||||
|
||||
@Autowired
|
||||
SftpConfig sftpConfig;
|
||||
// @Autowired
|
||||
// ZipFiles zipFiles;
|
||||
/**
|
||||
* 分页列表查询
|
||||
*
|
||||
|
@ -70,6 +84,9 @@ public class XxhbjwxtscwjxxController extends JeecgController<Xxhbjwxtscwjxx, IX
|
|||
QueryWrapper<Xxhbjwxtscwjxx> queryWrapper = QueryGenerator.initQueryWrapper(xxhbjwxtscwjxx, req.getParameterMap());
|
||||
Page<Xxhbjwxtscwjxx> page = new Page<Xxhbjwxtscwjxx>(pageNo, pageSize);
|
||||
IPage<Xxhbjwxtscwjxx> pageList = xxhbjwxtscwjxxService.page(page, queryWrapper);
|
||||
pageList.getRecords().forEach(item->{
|
||||
item.setId(item.getPath());
|
||||
});
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
|
@ -175,4 +192,14 @@ public class XxhbjwxtscwjxxController extends JeecgController<Xxhbjwxtscwjxx, IX
|
|||
return super.importExcel(request, response, Xxhbjwxtscwjxx.class);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/getBatchDown")
|
||||
public Result<?> getBatchDown(@RequestBody Xxhbjwxtscwjxx xxhbjwxtscwjxx,HttpServletResponse response) {
|
||||
xxhbjwxtscwjxx = xxhbjwxtscwjxxService.getBatchDown(xxhbjwxtscwjxx,response);
|
||||
return Result.ok(xxhbjwxtscwjxx);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,10 +4,8 @@ import java.io.Serializable;
|
|||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.Date;
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
@ -56,4 +54,13 @@ public class Xxhbjwxtscwjxx implements Serializable {
|
|||
@Excel(name = "附件类型", width = 15)
|
||||
@ApiModelProperty(value = "附件类型")
|
||||
private String fjtype;
|
||||
|
||||
@TableField(exist = false)
|
||||
private String id;
|
||||
@TableField(exist = false)
|
||||
private String downPath[];
|
||||
@TableField(exist = false)
|
||||
private String downName;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import org.jeecg.modules.demo.xxhbjwxtjxrw.entity.Xxhbjwxtjxrw;
|
|||
import org.jeecg.modules.demo.xxhbjwxtscwjxx.entity.Xxhbjwxtscwjxx;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -15,4 +16,6 @@ import java.util.List;
|
|||
public interface IXxhbjwxtscwjxxService extends IService<Xxhbjwxtscwjxx> {
|
||||
|
||||
void syncList(List<Xxhbjwxtscwjxx> outDataList);
|
||||
|
||||
Xxhbjwxtscwjxx getBatchDown(Xxhbjwxtscwjxx xxhbjwxtscwjxx, HttpServletResponse response);
|
||||
}
|
||||
|
|
|
@ -6,13 +6,22 @@ import org.jeecg.modules.demo.xxhbjwxtjxrw.entity.Xxhbjwxtjxrw;
|
|||
import org.jeecg.modules.demo.xxhbjwxtscwjxx.entity.Xxhbjwxtscwjxx;
|
||||
import org.jeecg.modules.demo.xxhbjwxtscwjxx.mapper.XxhbjwxtscwjxxMapper;
|
||||
import org.jeecg.modules.demo.xxhbjwxtscwjxx.service.IXxhbjwxtscwjxxService;
|
||||
import org.jeecg.modules.utils.SFTPUtil;
|
||||
import org.jeecg.modules.utils.SftpConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* @Description: 教务系统上传文件信息
|
||||
|
@ -24,12 +33,144 @@ import java.util.List;
|
|||
@DS("multi-datasource1")
|
||||
public class XxhbjwxtscwjxxServiceImpl extends ServiceImpl<XxhbjwxtscwjxxMapper, Xxhbjwxtscwjxx> implements IXxhbjwxtscwjxxService {
|
||||
|
||||
@Value(value = "${jeecg.path.webapp}")
|
||||
private String downloadpath;
|
||||
|
||||
@Autowired
|
||||
SftpConfig sftpConfig;
|
||||
|
||||
@Override
|
||||
public void syncList(List<Xxhbjwxtscwjxx> entityList) {
|
||||
|
||||
syncList(entityList, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Xxhbjwxtscwjxx getBatchDown(Xxhbjwxtscwjxx xxhbjwxtscwjxx, HttpServletResponse response) {
|
||||
Xxhbjwxtscwjxx par = new Xxhbjwxtscwjxx();
|
||||
String downPath[] = xxhbjwxtscwjxx.getDownPath();
|
||||
// 其余处理略
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
try{
|
||||
|
||||
for(String path22:downPath){
|
||||
String imgPath = path22;
|
||||
|
||||
// SFTPUtil.writeFileToRes(sftpConfig,imgPath,response);
|
||||
int index = imgPath.lastIndexOf("/");
|
||||
String path = "temp";
|
||||
if(index != -1){
|
||||
path = imgPath.substring(0,index);
|
||||
}
|
||||
//TODO 不确定是否有问题,
|
||||
Map<String,String> map = SFTPUtil.download(sftpConfig,imgPath,getDownloadPath(path));
|
||||
// if(!map.get("code").equals("0")){
|
||||
// response.setStatus(404);
|
||||
// throw new RuntimeException(map.get("msg"));
|
||||
// }
|
||||
// String localFilePath = map.get("fileName");
|
||||
// File file = new File(localFilePath);
|
||||
// if(!file.exists()){
|
||||
// response.setStatus(404);
|
||||
// throw new RuntimeException("文件["+imgPath+"]不存在..");
|
||||
// }
|
||||
// 设置强制下载不打开
|
||||
// response.setContentType("application/force-download");
|
||||
// response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1"));
|
||||
// inputStream = new BufferedInputStream(new FileInputStream(localFilePath));
|
||||
// outputStream = response.getOutputStream();
|
||||
// byte[] buf = new byte[1024];
|
||||
// int len;
|
||||
// while ((len = inputStream.read(buf)) > 0) {
|
||||
// outputStream.write(buf, 0, len);
|
||||
// }
|
||||
// response.flushBuffer();
|
||||
}
|
||||
|
||||
// response.flushBuffer();
|
||||
}catch (Exception e){
|
||||
// e.printStackTrace();
|
||||
}finally {
|
||||
SFTPUtil.disChannel();
|
||||
SFTPUtil.disSession();
|
||||
}
|
||||
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String files[] = new String[downPath.length];
|
||||
String name = "/"+xxhbjwxtscwjxx.getDownName()+".zip";
|
||||
String zipFileName = downloadpath+name;
|
||||
|
||||
for(int i=0;i<downPath.length;i++) {
|
||||
String imgPath = downPath[i];
|
||||
String downImgPath = downloadpath + imgPath;
|
||||
files[i] = downImgPath;
|
||||
}
|
||||
try {
|
||||
zipFiles(zipFileName, files);
|
||||
System.out.println("Files zipped successfully!");
|
||||
// map2222.put("filepath",name);
|
||||
par.setPath(name);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Xxhbjwxtscwjxx par2 = new Xxhbjwxtscwjxx();
|
||||
par2.setPath(name);
|
||||
return par2;
|
||||
}
|
||||
|
||||
private String getDownloadPath(String path){
|
||||
String filePath = "";
|
||||
// if(StringUtils.isNotBlank(path)){
|
||||
// return "";
|
||||
// }
|
||||
int idx = path.indexOf(downloadpath);
|
||||
if(idx==-1){
|
||||
filePath = downloadpath + File.separator + path;
|
||||
}else{
|
||||
filePath = path;
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public static void zipFiles(String zipFileName, String... files) throws IOException {
|
||||
FileOutputStream fos = new FileOutputStream(zipFileName);
|
||||
ZipOutputStream zos = new ZipOutputStream(fos);
|
||||
|
||||
for (String file : files) {
|
||||
File srcFile = new File(file);
|
||||
FileInputStream fis = new FileInputStream(srcFile);
|
||||
|
||||
ZipEntry zipEntry = new ZipEntry(srcFile.getName());
|
||||
zos.putNextEntry(zipEntry);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = fis.read(buffer)) > 0) {
|
||||
zos.write(buffer, 0, length);
|
||||
}
|
||||
|
||||
fis.close();
|
||||
zos.closeEntry();
|
||||
}
|
||||
zos.close();
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean syncList(Collection<Xxhbjwxtscwjxx> entityList, boolean isDelete) {
|
||||
QueryWrapper dqw = new QueryWrapper();
|
||||
|
|
|
@ -221,7 +221,7 @@ public class XxhbjwxtxsmdController extends JeecgController<Xxhbjwxtxsmd, IXxhbj
|
|||
Xxhbjwxtxsmd par = new Xxhbjwxtxsmd();
|
||||
par.setCj1mc(pageList.getCj2mc());
|
||||
String fjtype = pageList.getCj2mc().substring(0,pageList.getCj2mc().indexOf("["));
|
||||
String zb = pageList.getCj1mc().substring(pageList.getCj1mc().indexOf("[")+1,pageList.getCj1mc().indexOf("]"));
|
||||
String zb = pageList.getCj2mc().substring(pageList.getCj2mc().indexOf("[")+1,pageList.getCj2mc().indexOf("]"));
|
||||
par.setKhfs(fjtype);
|
||||
par.setZb(zb);
|
||||
|
||||
|
@ -243,7 +243,7 @@ public class XxhbjwxtxsmdController extends JeecgController<Xxhbjwxtxsmd, IXxhbj
|
|||
Xxhbjwxtxsmd par = new Xxhbjwxtxsmd();
|
||||
par.setCj1mc(pageList.getCj3mc());
|
||||
String fjtype = pageList.getCj3mc().substring(0,pageList.getCj3mc().indexOf("["));
|
||||
String zb = pageList.getCj1mc().substring(pageList.getCj1mc().indexOf("[")+1,pageList.getCj1mc().indexOf("]"));
|
||||
String zb = pageList.getCj3mc().substring(pageList.getCj3mc().indexOf("[")+1,pageList.getCj3mc().indexOf("]"));
|
||||
par.setKhfs(fjtype);
|
||||
par.setZb(zb);
|
||||
|
||||
|
@ -265,7 +265,7 @@ public class XxhbjwxtxsmdController extends JeecgController<Xxhbjwxtxsmd, IXxhbj
|
|||
Xxhbjwxtxsmd par = new Xxhbjwxtxsmd();
|
||||
par.setCj1mc(pageList.getCj4mc());
|
||||
String fjtype = pageList.getCj4mc().substring(0,pageList.getCj4mc().indexOf("["));
|
||||
String zb = pageList.getCj1mc().substring(pageList.getCj1mc().indexOf("[")+1,pageList.getCj1mc().indexOf("]"));
|
||||
String zb = pageList.getCj4mc().substring(pageList.getCj4mc().indexOf("[")+1,pageList.getCj4mc().indexOf("]"));
|
||||
par.setKhfs(fjtype);
|
||||
par.setZb(zb);
|
||||
|
||||
|
@ -287,7 +287,7 @@ public class XxhbjwxtxsmdController extends JeecgController<Xxhbjwxtxsmd, IXxhbj
|
|||
Xxhbjwxtxsmd par = new Xxhbjwxtxsmd();
|
||||
par.setCj1mc(pageList.getCj5mc());
|
||||
String fjtype = pageList.getCj5mc().substring(0,pageList.getCj5mc().indexOf("["));
|
||||
String zb = pageList.getCj1mc().substring(pageList.getCj1mc().indexOf("[")+1,pageList.getCj1mc().indexOf("]"));
|
||||
String zb = pageList.getCj5mc().substring(pageList.getCj5mc().indexOf("[")+1,pageList.getCj5mc().indexOf("]"));
|
||||
par.setKhfs(fjtype);
|
||||
par.setZb(zb);
|
||||
|
||||
|
@ -324,4 +324,11 @@ public class XxhbjwxtxsmdController extends JeecgController<Xxhbjwxtxsmd, IXxhbj
|
|||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "/getBatchDown")
|
||||
public Result<?> getBatchDown(@RequestBody Xxhbjwxtxsmd xxhbjwxtxsmd,HttpServletResponse response) {
|
||||
xxhbjwxtxsmd = xxhbjwxtxsmdService.getBatchDown(xxhbjwxtxsmd,response);
|
||||
return Result.ok(xxhbjwxtxsmd);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -139,4 +139,12 @@ public class Xxhbjwxtxsmd implements Serializable {
|
|||
private String sort;
|
||||
@TableField(exist = false)
|
||||
private String fsshow;
|
||||
@TableField(exist = false)
|
||||
private String id;
|
||||
@TableField(exist = false)
|
||||
private String studentNo[];
|
||||
@TableField(exist = false)
|
||||
private String downPath[];
|
||||
@TableField(exist = false)
|
||||
private String downName;
|
||||
}
|
||||
|
|
|
@ -10,8 +10,17 @@
|
|||
|
||||
|
||||
<select id="getXsmdxxByFjtype" parameterType="org.jeecg.modules.demo.xxhbjwxtxsmd.entity.Xxhbjwxtxsmd" resultType="org.jeecg.modules.demo.xxhbjwxtxsmd.entity.Xxhbjwxtxsmd">
|
||||
select a.*,b.student_path from xxhbjwxtxsmd a
|
||||
select a.*,a.xsbh as id,b.student_path from xxhbjwxtxsmd a
|
||||
left join (select SUBSTRING(name FROM 1 FOR 10) as student_no,name,path as student_path,cjr,cjsj,kcrwdm from xxhbjwxtscwjxx where fjtype = #{xxhbjwxtxsmd.cdlx}) b on a.kcrwdm =b.kcrwdm and a.xsbh = b.student_no
|
||||
where a.KCRWDM = #{xxhbjwxtxsmd.kcrwdm}
|
||||
|
||||
<if test="xxhbjwxtxsmd.studentNo!=null ">
|
||||
and a.xsbh in
|
||||
<foreach collection="xxhbjwxtxsmd.studentNo" index="index" item="id" open="(" separator="," close=")">
|
||||
#{id}
|
||||
</foreach>
|
||||
and b.student_path is not null
|
||||
</if>
|
||||
order by b.student_path desc
|
||||
</select>
|
||||
</mapper>
|
|
@ -7,6 +7,7 @@ import org.jeecg.modules.demo.xxhbjwxtjxrw.entity.Xxhbjwxtjxrw;
|
|||
import org.jeecg.modules.demo.xxhbjwxtxsmd.entity.Xxhbjwxtxsmd;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -20,4 +21,6 @@ public interface IXxhbjwxtxsmdService extends IService<Xxhbjwxtxsmd> {
|
|||
void syncList(List<Xxhbjwxtxsmd> outDataList);
|
||||
|
||||
IPage<Xxhbjwxtxsmd> getXsmdxxByFjtype(Page<Xxhbjwxtxsmd> page, Xxhbjwxtxsmd xxhbjwxtxsmd);
|
||||
|
||||
Xxhbjwxtxsmd getBatchDown(Xxhbjwxtxsmd xxhbjwxtxsmd, HttpServletResponse response);
|
||||
}
|
||||
|
|
|
@ -6,16 +6,26 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
|
|||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.jeecg.modules.demo.xxhbjwxtjxrw.entity.Xxhbjwxtjxrw;
|
||||
import org.jeecg.modules.demo.xxhbjwxtscwjxx.entity.Xxhbjwxtscwjxx;
|
||||
import org.jeecg.modules.demo.xxhbjwxtxsmd.entity.Xxhbjwxtxsmd;
|
||||
import org.jeecg.modules.demo.xxhbjwxtxsmd.mapper.XxhbjwxtxsmdMapper;
|
||||
import org.jeecg.modules.demo.xxhbjwxtxsmd.service.IXxhbjwxtxsmdService;
|
||||
import org.jeecg.modules.utils.SFTPUtil;
|
||||
import org.jeecg.modules.utils.SftpConfig;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.*;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipEntry;
|
||||
import java.util.zip.ZipOutputStream;
|
||||
|
||||
/**
|
||||
* @Description: 教务系统学生名单
|
||||
|
@ -27,6 +37,11 @@ import java.util.List;
|
|||
@DS("multi-datasource1")
|
||||
public class XxhbjwxtxsmdServiceImpl extends ServiceImpl<XxhbjwxtxsmdMapper, Xxhbjwxtxsmd> implements IXxhbjwxtxsmdService {
|
||||
|
||||
@Value(value = "${jeecg.path.webapp}")
|
||||
private String downloadpath;
|
||||
|
||||
@Autowired
|
||||
SftpConfig sftpConfig;
|
||||
@Override
|
||||
public void syncList(List<Xxhbjwxtxsmd> entityList) {
|
||||
|
||||
|
@ -53,6 +68,72 @@ public class XxhbjwxtxsmdServiceImpl extends ServiceImpl<XxhbjwxtxsmdMapper, Xxh
|
|||
return page1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Xxhbjwxtxsmd getBatchDown(Xxhbjwxtxsmd xxhbjwxtxsmd, HttpServletResponse response) {
|
||||
|
||||
Page<Xxhbjwxtxsmd> page = new Page<Xxhbjwxtxsmd>(1, 1000);
|
||||
IPage<Xxhbjwxtxsmd> page1 = baseMapper.getXsmdxxByFjtype(page,xxhbjwxtxsmd);
|
||||
xxhbjwxtxsmd.setDownPath(page1.getRecords().stream().map(Xxhbjwxtxsmd::getStudentPath).toArray(String[]::new));
|
||||
String downPath[] = xxhbjwxtxsmd.getDownPath();
|
||||
// 其余处理略
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
try{
|
||||
|
||||
for(String path22:downPath){
|
||||
String imgPath = path22;
|
||||
|
||||
int index = imgPath.lastIndexOf("/");
|
||||
String path = "temp";
|
||||
if(index != -1){
|
||||
path = imgPath.substring(0,index);
|
||||
}
|
||||
//TODO 不确定是否有问题,
|
||||
Map<String,String> map = SFTPUtil.download(sftpConfig,imgPath,getDownloadPath(path));
|
||||
}
|
||||
|
||||
}catch (Exception e){
|
||||
}finally {
|
||||
SFTPUtil.disChannel();
|
||||
SFTPUtil.disSession();
|
||||
}
|
||||
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
String files[] = new String[downPath.length];
|
||||
String name = "/"+xxhbjwxtxsmd.getDownName()+".zip";
|
||||
String zipFileName = downloadpath+name;
|
||||
|
||||
for(int i=0;i<downPath.length;i++) {
|
||||
String imgPath = downPath[i];
|
||||
String downImgPath = downloadpath + imgPath;
|
||||
files[i] = downImgPath;
|
||||
}
|
||||
try {
|
||||
zipFiles(zipFileName, files);
|
||||
System.out.println("Files zipped successfully!");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Xxhbjwxtxsmd par2 = new Xxhbjwxtxsmd();
|
||||
par2.setStudentPath(name);
|
||||
return par2;
|
||||
}
|
||||
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean syncList(Collection<Xxhbjwxtxsmd> entityList, boolean isDelete) {
|
||||
QueryWrapper dqw = new QueryWrapper();
|
||||
|
@ -61,4 +142,47 @@ public class XxhbjwxtxsmdServiceImpl extends ServiceImpl<XxhbjwxtxsmdMapper, Xxh
|
|||
}
|
||||
return this.saveBatch(entityList, 1000);
|
||||
}
|
||||
|
||||
|
||||
private String getDownloadPath(String path){
|
||||
String filePath = "";
|
||||
// if(StringUtils.isNotBlank(path)){
|
||||
// return "";
|
||||
// }
|
||||
int idx = path.indexOf(downloadpath);
|
||||
if(idx==-1){
|
||||
filePath = downloadpath + File.separator + path;
|
||||
}else{
|
||||
filePath = path;
|
||||
}
|
||||
return filePath;
|
||||
}
|
||||
|
||||
public static void zipFiles(String zipFileName, String... files) throws IOException {
|
||||
FileOutputStream fos = new FileOutputStream(zipFileName);
|
||||
ZipOutputStream zos = new ZipOutputStream(fos);
|
||||
|
||||
for (String file : files) {
|
||||
try {
|
||||
File srcFile = new File(file);
|
||||
FileInputStream fis = new FileInputStream(srcFile);
|
||||
|
||||
ZipEntry zipEntry = new ZipEntry(srcFile.getName());
|
||||
zos.putNextEntry(zipEntry);
|
||||
|
||||
byte[] buffer = new byte[1024];
|
||||
int length;
|
||||
while ((length = fis.read(buffer)) > 0) {
|
||||
zos.write(buffer, 0, length);
|
||||
}
|
||||
|
||||
fis.close();
|
||||
zos.closeEntry();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
zos.close();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -320,6 +320,66 @@ public class CommonController {
|
|||
|
||||
}
|
||||
|
||||
@GetMapping(value = "/staticLocal/**")
|
||||
public void staticLocal(HttpServletRequest request, HttpServletResponse response) {
|
||||
// ISO-8859-1 ==> UTF-8 进行编码转换
|
||||
String imgPath = extractPathFromPattern(request);
|
||||
if(oConvertUtils.isEmpty(imgPath) || CommonConstant.STRING_NULL.equals(imgPath)){
|
||||
return;
|
||||
}
|
||||
// 其余处理略
|
||||
InputStream inputStream = null;
|
||||
OutputStream outputStream = null;
|
||||
try {
|
||||
imgPath = imgPath.replace("..", "").replace("../","");
|
||||
if (imgPath.endsWith(SymbolConstant.COMMA)) {
|
||||
imgPath = imgPath.substring(0, imgPath.length() - 1);
|
||||
}
|
||||
//update-begin---author:liusq ---date:20230912 for:检查下载文件类型--------------
|
||||
SsrfFileTypeFilter.checkDownloadFileType(imgPath);
|
||||
//update-end---author:liusq ---date:20230912 for:检查下载文件类型--------------
|
||||
String filePath = downloadpath + File.separator + imgPath;
|
||||
File file = new File(filePath);
|
||||
if(!file.exists()){
|
||||
response.setStatus(404);
|
||||
log.error("文件["+imgPath+"]不存在..");
|
||||
return;
|
||||
//throw new RuntimeException();
|
||||
}
|
||||
// 设置强制下载不打开
|
||||
response.setContentType("application/force-download");
|
||||
response.addHeader("Content-Disposition", "attachment;fileName=" + new String(file.getName().getBytes("UTF-8"),"iso-8859-1"));
|
||||
inputStream = new BufferedInputStream(new FileInputStream(filePath));
|
||||
outputStream = response.getOutputStream();
|
||||
byte[] buf = new byte[1024];
|
||||
int len;
|
||||
while ((len = inputStream.read(buf)) > 0) {
|
||||
outputStream.write(buf, 0, len);
|
||||
}
|
||||
response.flushBuffer();
|
||||
} catch (IOException e) {
|
||||
log.error("预览文件失败" + e.getMessage());
|
||||
response.setStatus(404);
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if (inputStream != null) {
|
||||
try {
|
||||
inputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
if (outputStream != null) {
|
||||
try {
|
||||
outputStream.close();
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件真实路径
|
||||
* @param path
|
||||
|
|
|
@ -6,10 +6,10 @@ VITE_PUBLIC_PATH = /
|
|||
|
||||
|
||||
# 跨域代理,您可以配置多个 ,请注意,没有换行符
|
||||
VITE_PROXY = [["/jeecgboot","http://192.168.2.13:8080/jeecg-boot"],["/upload","http://192.168.2.13:3300/upload"]]
|
||||
VITE_PROXY = [["/jeecgboot","http://localhost:8080/jeecg-boot"],["/upload","http://localhost:3300/upload"]]
|
||||
|
||||
#后台接口全路径地址(必填)
|
||||
VITE_GLOB_DOMAIN_URL=http://192.168.2.13:8080/jeecg-boot
|
||||
VITE_GLOB_DOMAIN_URL=http://localhost:8080/jeecg-boot
|
||||
|
||||
#后台接口父地址(必填)
|
||||
VITE_GLOB_API_URL=/jeecgboot
|
||||
|
|
|
@ -35,6 +35,24 @@ export const getFileAccessHttpUrl = (fileUrl, prefix = 'http') => {
|
|||
return result;
|
||||
};
|
||||
|
||||
export const getFileAccessHttpUrlLocal = (fileUrl, prefix = 'http') => {
|
||||
let result = fileUrl;
|
||||
try {
|
||||
if (fileUrl && fileUrl.length > 0 && !fileUrl.startsWith(prefix)) {
|
||||
//判断是否是数组格式
|
||||
let isArray = fileUrl.indexOf('[') != -1;
|
||||
if (!isArray) {
|
||||
let prefix = `${baseApiUrl}/sys/common/staticLocal/`;
|
||||
// 判断是否已包含前缀
|
||||
if (!fileUrl.startsWith(prefix)) {
|
||||
result = `${prefix}${fileUrl}`;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (err) {}
|
||||
return result;
|
||||
};
|
||||
|
||||
/**
|
||||
* 触发 window.resize
|
||||
*/
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { h } from 'vue';
|
||||
import { Avatar, Tag, Tooltip, Image } from 'ant-design-vue';
|
||||
import { getFileAccessHttpUrl } from '/@/utils/common/compUtils';
|
||||
import { getFileAccessHttpUrl,getFileAccessHttpUrlLocal } from '/@/utils/common/compUtils';
|
||||
import { Tinymce } from '/@/components/Tinymce';
|
||||
import Icon from '/@/components/Icon';
|
||||
import { getDictItemsByCode } from '/@/utils/dict/index';
|
||||
|
@ -175,4 +175,21 @@ function downloadFile(url) {
|
|||
}
|
||||
}
|
||||
|
||||
export { render, downloadFile };
|
||||
/**
|
||||
* 文件下载
|
||||
*/
|
||||
function downloadFileLoacl(url) {
|
||||
if (!url) {
|
||||
createMessage.warning('未知的文件');
|
||||
return;
|
||||
}
|
||||
if (url.indexOf(',') > 0) {
|
||||
url = url.substring(0, url.indexOf(','));
|
||||
}
|
||||
url = getFileAccessHttpUrlLocal(url.split(',')[0]);
|
||||
if (url) {
|
||||
window.open(url);
|
||||
}
|
||||
}
|
||||
|
||||
export { render, downloadFile,downloadFileLoacl };
|
||||
|
|
|
@ -190,9 +190,14 @@ export const columns2: BasicColumn[] = [
|
|||
//列表数据
|
||||
export const columns3: BasicColumn[] = [
|
||||
{
|
||||
title: '学年学期',
|
||||
title: '学年',
|
||||
align: "center",
|
||||
dataIndex: 'xnxqdm'
|
||||
dataIndex: 'xn'
|
||||
},
|
||||
{
|
||||
title: '学期',
|
||||
align: "center",
|
||||
dataIndex: 'xqmc'
|
||||
},
|
||||
{
|
||||
title: '课程名称',
|
||||
|
|
|
@ -109,7 +109,7 @@
|
|||
</div>
|
||||
<!-- 学生原始材料-详情 -->
|
||||
<div v-show="sfxk == 5">
|
||||
<XxhbjwxtxsmdList4 ref="xsysclXqFormModal" @callback="init"></XxhbjwxtxsmdList4>
|
||||
<XxhbjwxtxsmdList4 ref="xsysclXqFormModal" @callback="handleXsyscl"></XxhbjwxtxsmdList4>
|
||||
</div>
|
||||
<!-- 选课后的列表 -->
|
||||
<div v-if="sfxk == 999">
|
||||
|
@ -328,6 +328,9 @@ function handleXsysclxq(record) {
|
|||
function handleFanhui() {
|
||||
init();
|
||||
}
|
||||
function init2(){
|
||||
|
||||
}
|
||||
|
||||
//选课确认
|
||||
function handleQueren(record) {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
<div class="jeecg-basic-table-form-container">
|
||||
<a-form ref="formRef" @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||
<a-row :gutter="24">
|
||||
<a-col :span="12"> <span style="font-size: 22px;font-weight: 700;margin-left: 20px;">考核评价材料</span> </a-col>
|
||||
<a-col :span="12"> <span style="font-size: 22px; font-weight: 700; margin-left: 20px">考核评价材料</span> </a-col>
|
||||
<a-col :span="12" style="text-align: right">
|
||||
<a-button type="primary" style="margin-left: 8px" @click="handleFanhui">返回</a-button>
|
||||
</a-col>
|
||||
|
@ -33,12 +33,14 @@
|
|||
</a-row>
|
||||
</div>
|
||||
</a-col>
|
||||
|
||||
</a-row>
|
||||
</a-form>
|
||||
</div>
|
||||
<!--引用表格-->
|
||||
<BasicTable @register="registerTable">
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" v-if="selectedRowKeys.length > 0" @click="batchHandleDown"> 批量下载 </a-button>
|
||||
</template>
|
||||
<!--操作栏-->
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableAction(record)" />
|
||||
|
@ -55,10 +57,11 @@ import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
|||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import { columns, superQuerySchema } from './Xxhbjwxtscwjxx.data';
|
||||
import { list, deleteOne, batchDelete, getImportUrl, getExportUrl } from './Xxhbjwxtscwjxx.api';
|
||||
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||
import { downloadFile,downloadFileLoacl } from '/@/utils/common/renderUtils';
|
||||
import XxhbjwxtscwjxxModal from './components/XxhbjwxtscwjxxModal.vue';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import JInput from '/@/components/Form/src/jeecg/components/JInput.vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const formRef = ref();
|
||||
const queryParam = reactive<any>({});
|
||||
|
@ -66,8 +69,9 @@ const toggleSearchStatus = ref<boolean>(false);
|
|||
const registerModal = ref();
|
||||
const userStore = useUserStore();
|
||||
const jxrwInfo = reactive<any>({});
|
||||
import {getFileAccessHttpUrl} from "@/utils/common/compUtils";
|
||||
import {encryptByBase64} from "@/utils/cipher";
|
||||
import { getFileAccessHttpUrl } from '@/utils/common/compUtils';
|
||||
import { encryptByBase64 } from '@/utils/cipher';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
const emit = defineEmits(['callback']);
|
||||
//注册table数据
|
||||
|
@ -164,6 +168,16 @@ async function batchHandleDelete() {
|
|||
await batchDelete({ ids: selectedRowKeys.value }, handleSuccess);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量下载事件
|
||||
*/
|
||||
async function batchHandleDown() {
|
||||
var downName = '考核评价材料'+dayjs().format('YYYYMMDDHHmmss')+"";
|
||||
defHttp.post({ url: "/xxhbjwxtscwjxx/xxhbjwxtscwjxx/getBatchDown", params: { downPath: selectedRowKeys.value,downName } }).then((res) => {
|
||||
console.log(res);
|
||||
downloadFileLoacl(res.path);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 成功回调
|
||||
*/
|
||||
|
@ -171,22 +185,22 @@ function handleSuccess() {
|
|||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览
|
||||
*/
|
||||
function handleYulan(record){
|
||||
var file = getFileAccessHttpUrl(record.path) ;
|
||||
console.log('🤬', file);
|
||||
// window.open('https://view.xdocin.com/view?src=' + encodeURIComponent(encryptByBase64(file)));
|
||||
// window.open('https://fileview.jeecg.com/onlinePreview?url=' + encodeURIComponent(encryptByBase64(file)));
|
||||
window.open(file,"_blank");
|
||||
}
|
||||
/**
|
||||
* 下载
|
||||
*/
|
||||
function handleDown(record){
|
||||
downloadFile(record.path)
|
||||
}
|
||||
/**
|
||||
* 预览
|
||||
*/
|
||||
function handleYulan(record) {
|
||||
var file = getFileAccessHttpUrl(record.path);
|
||||
console.log('🤬', file);
|
||||
// window.open('https://view.xdocin.com/view?src=' + encodeURIComponent(encryptByBase64(file)));
|
||||
// window.open('https://fileview.jeecg.com/onlinePreview?url=' + encodeURIComponent(encryptByBase64(file)));
|
||||
window.open(file, '_blank');
|
||||
}
|
||||
/**
|
||||
* 下载
|
||||
*/
|
||||
function handleDown(record) {
|
||||
downloadFile(record.path);
|
||||
}
|
||||
/**
|
||||
* 操作栏
|
||||
*/
|
||||
|
@ -243,14 +257,14 @@ function searchReset() {
|
|||
|
||||
function init(record) {
|
||||
queryParam.kcrwdm = record.kcrwdm;
|
||||
queryParam.fjtype = "过程性考核-论文,历次过程性考核-评分标准,课程目标达成情况评价报告,课程考核合理性审核记录单,历次过程性考核-内容及要求(或试题),课程考核质量评价单,期未考试-试题(或内容及要求),期末考试-评分标准"
|
||||
// 平时成绩
|
||||
// 期末成绩
|
||||
// 期中成绩
|
||||
// 实践成绩
|
||||
queryParam.fjtype =
|
||||
'过程性考核-论文,历次过程性考核-评分标准,课程目标达成情况评价报告,课程考核合理性审核记录单,历次过程性考核-内容及要求(或试题),课程考核质量评价单,期未考试-试题(或内容及要求),期末考试-评分标准';
|
||||
// 平时成绩
|
||||
// 期末成绩
|
||||
// 期中成绩
|
||||
// 实践成绩
|
||||
jxrwInfo.value = record;
|
||||
|
||||
|
||||
reload();
|
||||
}
|
||||
|
||||
|
|
|
@ -167,6 +167,7 @@ function handleFanhui() {
|
|||
function handleDetail(record) {
|
||||
console.log('😢handleDetail--------', record);
|
||||
jxrwInfo.value.khfs = record.khfs;
|
||||
jxrwInfo.value.zb = record.zb;
|
||||
jxrwInfo.value.sort = record.sort;
|
||||
console.log('🖕222222222222', jxrwInfo.value);
|
||||
emit('handleXq', jxrwInfo.value);
|
||||
|
|
|
@ -4,13 +4,13 @@
|
|||
<!--查询区域-->
|
||||
<div class="jeecg-basic-table-form-container">
|
||||
<a-form ref="formRef" @keyup.enter.native="searchQuery" :model="queryParam" :label-col="labelCol" :wrapper-col="wrapperCol">
|
||||
<a-row :gutter="24">
|
||||
<a-col :span="12"> <span style="font-size: 22px; font-weight: 700; margin-left: 20px">学生原始材料详情 </span> </a-col>
|
||||
<a-row :gutter="24" v-if="jxrwInfo?.value">
|
||||
<a-col :span="12"> <span style="font-size: 22px; font-weight: 700; margin-left: 20px">{{ jxrwInfo?.value?.khfs }}[{{ jxrwInfo?.value?.zb }}] </span> </a-col>
|
||||
<a-col :span="12" style="text-align: right">
|
||||
<a-button type="primary" @click="handleFanhui">返回</a-button>
|
||||
</a-col>
|
||||
<a-col :gutter="24">
|
||||
<div style="text-align: center; font-size: 16px; font-weight: 700; line-height: 50px" v-if="jxrwInfo.value">
|
||||
<div style="text-align: center; font-size: 16px; font-weight: 700; line-height: 50px" v-if="jxrwInfo?.value">
|
||||
{{ jxrwInfo?.value.xn }}{{ jxrwInfo?.value.xqmc }}学期《{{ jxrwInfo?.value.kcmc }}》
|
||||
</div>
|
||||
<div v-if="jxrwInfo.value">
|
||||
|
@ -41,7 +41,10 @@
|
|||
详细信息
|
||||
</div> -->
|
||||
<!--引用表格-->
|
||||
<BasicTable @register="registerTable" >
|
||||
<BasicTable @register="registerTable" :rowSelection="rowSelection">
|
||||
<template #tableTitle>
|
||||
<a-button type="primary" v-if="selectedRowKeys.length > 0" @click="batchHandleDown"> 批量下载 </a-button>
|
||||
</template>
|
||||
<!--操作栏-->
|
||||
<template #action="{ record }">
|
||||
<TableAction :actions="getTableAction(record)" />
|
||||
|
@ -53,115 +56,129 @@
|
|||
</template>
|
||||
|
||||
<script lang="ts" name="xxhbjwxtxsmd-xxhbjwxtxsmd" setup>
|
||||
import { ref, reactive,defineExpose } from 'vue';
|
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import { columns5, superQuerySchema } from './Xxhbjwxtxsmd.data';
|
||||
import { list3, deleteOne, batchDelete, getImportUrl, getExportUrl } from './Xxhbjwxtxsmd.api';
|
||||
import { downloadFile } from '/@/utils/common/renderUtils';
|
||||
import XxhbjwxtxsmdModal from './components/XxhbjwxtxsmdModal.vue'
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import {getFileAccessHttpUrl} from "@/utils/common/compUtils";
|
||||
import {encryptByBase64} from "@/utils/cipher";
|
||||
import { ref, reactive, defineExpose } from 'vue';
|
||||
import { BasicTable, useTable, TableAction } from '/@/components/Table';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import { columns5, superQuerySchema } from './Xxhbjwxtxsmd.data';
|
||||
import { list3, deleteOne, batchDelete, getImportUrl, getExportUrl } from './Xxhbjwxtxsmd.api';
|
||||
import { downloadFile, downloadFileLoacl } from '/@/utils/common/renderUtils';
|
||||
import XxhbjwxtxsmdModal from './components/XxhbjwxtxsmdModal.vue';
|
||||
import { useUserStore } from '/@/store/modules/user';
|
||||
import { getFileAccessHttpUrl } from '@/utils/common/compUtils';
|
||||
import { encryptByBase64 } from '@/utils/cipher';
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const formRef = ref();
|
||||
const queryParam = reactive<any>({});
|
||||
const toggleSearchStatus = ref<boolean>(false);
|
||||
const registerModal = ref();
|
||||
const userStore = useUserStore();
|
||||
const spinning = ref<boolean>(false);
|
||||
const emit = defineEmits(['callback']);
|
||||
const formRef = ref();
|
||||
const queryParam = reactive<any>({});
|
||||
const toggleSearchStatus = ref<boolean>(false);
|
||||
const registerModal = ref();
|
||||
const userStore = useUserStore();
|
||||
const spinning = ref<boolean>(false);
|
||||
const emit = defineEmits(['callback']);
|
||||
|
||||
const jxrwInfo = reactive<any>({});
|
||||
//注册table数据
|
||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title:'详细信息',
|
||||
api: list3,
|
||||
columns: columns5,
|
||||
canResize:false,
|
||||
useSearchForm: false,
|
||||
actionColumn: {
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
},
|
||||
beforeFetch: async (params) => {
|
||||
return Object.assign(params, queryParam);
|
||||
},
|
||||
const jxrwInfo = reactive<any>({});
|
||||
//注册table数据
|
||||
const { prefixCls, tableContext, onExportXls, onImportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '详细信息',
|
||||
api: list3,
|
||||
columns: columns5,
|
||||
canResize: false,
|
||||
useSearchForm: false,
|
||||
actionColumn: {
|
||||
width: 120,
|
||||
fixed: 'right',
|
||||
},
|
||||
exportConfig: {
|
||||
name: "教务系统学生名单",
|
||||
url: getExportUrl,
|
||||
params: queryParam,
|
||||
beforeFetch: async (params) => {
|
||||
return Object.assign(params, queryParam);
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess
|
||||
},
|
||||
});
|
||||
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] = tableContext;
|
||||
const labelCol = reactive({
|
||||
xs:24,
|
||||
sm:4,
|
||||
xl:6,
|
||||
xxl:4
|
||||
});
|
||||
const wrapperCol = reactive({
|
||||
xs: 24,
|
||||
sm: 20,
|
||||
});
|
||||
},
|
||||
exportConfig: {
|
||||
name: '教务系统学生名单',
|
||||
url: getExportUrl,
|
||||
params: queryParam,
|
||||
},
|
||||
importConfig: {
|
||||
url: getImportUrl,
|
||||
success: handleSuccess,
|
||||
},
|
||||
});
|
||||
const [registerTable, { reload, collapseAll, updateTableDataRecord, findTableDataRecord, getDataSource }, { rowSelection, selectedRowKeys }] =
|
||||
tableContext;
|
||||
const labelCol = reactive({
|
||||
xs: 24,
|
||||
sm: 4,
|
||||
xl: 6,
|
||||
xxl: 4,
|
||||
});
|
||||
const wrapperCol = reactive({
|
||||
xs: 24,
|
||||
sm: 20,
|
||||
});
|
||||
|
||||
function textDown(){
|
||||
var a = document.createElement("a"); //创建一个<a></a>标签
|
||||
a.href = "/download/a.docx";
|
||||
//给a标签的href属性值加上地址,注意,这里是绝对路径,不用加 点.
|
||||
a.download ="a.docx";
|
||||
//设置下载文件文件名,这里加上.xlsx指定文件类型,pdf文件就指定.fpd即可
|
||||
a.style.display = "none"; // 障眼法藏起来a标签
|
||||
document.body.appendChild(a);
|
||||
// 将a标签追加到文档对象中
|
||||
a.click(); //模拟点击了a标签,会触发a标签的href的读取,浏览器就会自动下载了
|
||||
a.remove();
|
||||
// 一次性的,用完就删除a标签
|
||||
function textDown() {
|
||||
var a = document.createElement('a'); //创建一个<a></a>标签
|
||||
a.href = '/download/a.docx';
|
||||
//给a标签的href属性值加上地址,注意,这里是绝对路径,不用加 点.
|
||||
a.download = 'a.docx';
|
||||
//设置下载文件文件名,这里加上.xlsx指定文件类型,pdf文件就指定.fpd即可
|
||||
a.style.display = 'none'; // 障眼法藏起来a标签
|
||||
document.body.appendChild(a);
|
||||
// 将a标签追加到文档对象中
|
||||
a.click(); //模拟点击了a标签,会触发a标签的href的读取,浏览器就会自动下载了
|
||||
a.remove();
|
||||
// 一次性的,用完就删除a标签
|
||||
}
|
||||
|
||||
/**
|
||||
* 编辑事件
|
||||
*/
|
||||
function handleEdit(record: Recordable) {
|
||||
registerModal.value.disableSubmit = false;
|
||||
registerModal.value.edit(record);
|
||||
}
|
||||
/**
|
||||
* 编辑事件
|
||||
*/
|
||||
function handleEdit(record: Recordable) {
|
||||
registerModal.value.disableSubmit = false;
|
||||
registerModal.value.edit(record);
|
||||
}
|
||||
|
||||
/**
|
||||
* 预览
|
||||
*/
|
||||
function handleYulan(record){
|
||||
var file = getFileAccessHttpUrl(record.studentPath) ;
|
||||
console.log('🤬', file);
|
||||
// window.open('https://view.xdocin.com/view?src=' + encodeURIComponent(encryptByBase64(file)));
|
||||
// window.open('https://fileview.jeecg.com/onlinePreview?url=' + encodeURIComponent(encryptByBase64(file)));
|
||||
window.open(file,"_blank");
|
||||
}
|
||||
/**
|
||||
* 下载
|
||||
*/
|
||||
function handleDown(record){
|
||||
downloadFile(record.studentPath)
|
||||
}
|
||||
/**
|
||||
* 预览
|
||||
*/
|
||||
function handleYulan(record) {
|
||||
var file = getFileAccessHttpUrl(record.studentPath);
|
||||
console.log('🤬', file);
|
||||
// window.open('https://view.xdocin.com/view?src=' + encodeURIComponent(encryptByBase64(file)));
|
||||
// window.open('https://fileview.jeecg.com/onlinePreview?url=' + encodeURIComponent(encryptByBase64(file)));
|
||||
window.open(file, '_blank');
|
||||
}
|
||||
/**
|
||||
* 下载
|
||||
*/
|
||||
function handleDown(record) {
|
||||
downloadFile(record.studentPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 成功回调
|
||||
*/
|
||||
function handleSuccess() {
|
||||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
/**
|
||||
* 批量下载事件
|
||||
*/
|
||||
async function batchHandleDown() {
|
||||
var downName = '学生原始材料' + dayjs().format('YYYYMMDDHHmmss') + '';
|
||||
console.log('👩🦰', selectedRowKeys.value);
|
||||
defHttp.post({ url: "/xxhbjwxtxsmd/xxhbjwxtxsmd/getBatchDown", params: { studentNo: selectedRowKeys.value,downName,cdlx:jxrwInfo.value.khfs,kcrwdm:jxrwInfo.value.kcrwdm } }).then((res) => {
|
||||
console.log(res);
|
||||
downloadFileLoacl(res.studentPath);
|
||||
});
|
||||
}
|
||||
/**
|
||||
* 成功回调
|
||||
*/
|
||||
function handleSuccess() {
|
||||
(selectedRowKeys.value = []) && reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作栏
|
||||
*/
|
||||
function getTableAction(record) {
|
||||
if(record.studentPath){
|
||||
/**
|
||||
* 操作栏
|
||||
*/
|
||||
function getTableAction(record) {
|
||||
if (record.studentPath) {
|
||||
return [
|
||||
{
|
||||
label: '查看',
|
||||
|
@ -172,36 +189,35 @@ function textDown(){
|
|||
onClick: handleDown.bind(null, record),
|
||||
},
|
||||
];
|
||||
|
||||
}else{
|
||||
return [
|
||||
} else {
|
||||
return [
|
||||
{
|
||||
label: '暂无文件',
|
||||
disabled:true,
|
||||
},];
|
||||
}
|
||||
disabled: true,
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
function searchQuery() {
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询
|
||||
*/
|
||||
function searchQuery() {
|
||||
reload();
|
||||
}
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function searchReset() {
|
||||
formRef.value.resetFields();
|
||||
selectedRowKeys.value = [];
|
||||
//刷新数据
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* 重置
|
||||
*/
|
||||
function searchReset() {
|
||||
formRef.value.resetFields();
|
||||
selectedRowKeys.value = [];
|
||||
//刷新数据
|
||||
reload();
|
||||
}
|
||||
|
||||
function handleFanhui() {
|
||||
emit('callback');
|
||||
function handleFanhui() {
|
||||
emit('callback',jxrwInfo.value);
|
||||
}
|
||||
function init(record) {
|
||||
console.log('🧞', record);
|
||||
|
@ -215,33 +231,31 @@ function init(record) {
|
|||
defineExpose({
|
||||
init,
|
||||
});
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
.jeecg-basic-table-form-container {
|
||||
padding: 0;
|
||||
.table-page-search-submitButtons {
|
||||
display: block;
|
||||
margin-bottom: 24px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.query-group-cust{
|
||||
min-width: 100px !important;
|
||||
}
|
||||
.query-group-split-cust{
|
||||
width: 30px;
|
||||
display: inline-block;
|
||||
text-align: center
|
||||
}
|
||||
.ant-form-item:not(.ant-form-item-with-help){
|
||||
margin-bottom: 16px;
|
||||
height: 32px;
|
||||
}
|
||||
:deep(.ant-picker),:deep(.ant-input-number){
|
||||
width: 100%;
|
||||
}
|
||||
.jeecg-basic-table-form-container {
|
||||
padding: 0;
|
||||
.table-page-search-submitButtons {
|
||||
display: block;
|
||||
margin-bottom: 24px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.query-group-cust {
|
||||
min-width: 100px !important;
|
||||
}
|
||||
.query-group-split-cust {
|
||||
width: 30px;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
}
|
||||
.ant-form-item:not(.ant-form-item-with-help) {
|
||||
margin-bottom: 16px;
|
||||
height: 32px;
|
||||
}
|
||||
:deep(.ant-picker),
|
||||
:deep(.ant-input-number) {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
Loading…
Reference in New Issue