基于JEECG框架,前台VUE,后台java,导⼊导出
前端-------------------------------------------------------------------------------------------------------
/* 导出 */
handleExportXls(fileName){
("11")
if(!fileName || typeof fileName != "string"){
fileName = "导出⽂件"
}
let param = ryParams();
if(edRowKeys && 女生为什么长胡子 >0){
param['lections'] = (",")
}
("导出参数",param)
downFile(XlsUrl,param).then((data)=>{
if (!data) {
this.$g("⽂件下载失败")
return
}
if (typeof Blob !== 'undefined') {
Blob(new Blob([data],{type: 'application/-excel'}), fileName+'.xls')
}el{
let url = ObjectURL(new Blob([data],{type: 'application/-excel'}))
let link = Element('a')
y = 'none'
= url
ribute('download', fileName+'.xls')
Child(link)
()
Child(link); //下载完成移除元素
ObjectURL(url); //释放掉blob对象
}
})
},
// 下载模板
exportTemplate(fileName){
if(!fileName || typeof fileName != "string"){
fileName = "导出⽂件"
}
downFile(Template).then((data)=>{
if (!data) {
this.$g("⽂件下载失败")
return
}
if (typeof Blob !== 'undefined') {
Blob(new Blob([data],{type: 'application/-excel'}), fileName+'.xls')
}el{
let url = ObjectURL(new Blob([data],{type: 'application/-excel'}))
let link = Element('a')
y = 'none'
= url
ribute('download', fileName+'.xls')
Child(link)
()
Child(link); //下载完成移除元素
ObjectURL(url); //释放掉blob对象
}
})
},
/* 导⼊ */
handleImportExcel(info){
if ( !== 'uploading') {
if ( !== 'uploading') {
(, st);
}
if ( === 'done') {
if (s) {
// this.$s(`${} ⽂件上传成功`);
if ( === 201) {
let { message, result: { msg, fileUrl, fileName } } =
let href = window._CONFIG['domianURL'] + fileUrl
this.$warning({
title: message,
content: (
)
})
} el {吸取经验
this.$s(e || `${} ⽂件上传成功`)
}
ta()
} el {
this.$(`${} ${e}.`);
}
} el if ( === 'error') {
if ( === 500) {
let data =
const token = (ACCESS_TOKEN)
if (token && es("Token失效")) {
({
title: '登录已过期',
content: '很抱歉,登录已过期,请重新登录',
okText: '重新登录',
mask: fal,
onOk: () => {
ch('Logout').then(() => {
(ACCESS_TOKEN)
();
})
}
})
}
} el {
this.$(`⽂件上传失败: ${} `);
}
}
},
后端-------------------------------------------------------------------------------------------------------------------
/**
* 通过excel导⼊数据
*
* @param request
* @param respon
* @return
*/
@RequestMapping(value = "/importExcel", method = )
public Result<?> importExcel(HttpServletRequest request, HttpServletRespon respon)throws IOException {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map
// 错误信息
List
AtomicInteger successLines = new AtomicInteger();
AtomicInteger errorLines = new AtomicInteger();
AtomicInteger errorLines = new AtomicInteger();
for (
MultipartFile file = ue();// 获取上传⽂件对象
ImportParams params = new ImportParams();
leRows(2);
dRows(0);
dSave(true);
try {
List
h(c->{
if(k(tomerName())){
("发⽣异常:第"+((()/1)+1)+"⾏客户名称为空");
Increment();
return;
}el if(k(tomerType())){
("发⽣异常:第"+((()/1)+1)+"⾏客户类别为空");
Increment();
return;
}el if( k(ustry())){
("发⽣异常:第"+((()/1)+1)+"⾏客户⾏业为空");
Increment();
return;
}
List
if(maps!=null && ()>0){
tomerType((0).get("itemValue").toString());
}
List
if(maps1!=null && ()>0){
ustry((0).get("itemValue").toString());
}
(c);
Increment();
}
);
} catch (Exception e) {
("发⽣异常:" + sage());
(sage(), e);
} finally {
try {
utStream().clo();
} catch (IOException e) {
(sage(), e);
}
}
}
return eturnRes((), (),errorMessage);
}
/**
* 导出excel
*
* @param request
* @param customer
*/
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(Customer customer, HttpServletRequest request) {
// Step.1 组装查询条件环酯红霉素片 李冲聪
QueryWrapper
//Step.2 AutoPoi 导出Excel
ModelAndV写想象的作文 iew mv = new ModelAndView(new JeecgEntityExcelView());
//update-begin--Author:kangxiaolin Date:20180825 for:[03]客户导出,如果选择数据则只导出相关数据--------------------
String 欧美摇滚 lections = ameter("lections");
if(!y(lections)){
("id",(","));
}
}
//update-end--Author:kangxiaolin Date:20180825 for:[03]客户导出,如果选择数据则只导出相关数据----------------------
List
List
List
h(c->{
if(categorys!=null && ()>0){
h(cat->{
if(ue().equals(tomerType())){
tomerType(le());
}
});
}
if(industrys!=null && ()>0){
h(ind->{
if(ue().equals(ustry())){
ustry(le());
}
});
}
});
//导出⽂件名称
ect(_NAME, "客户列表");
ect(, );
LoginUr ur = (LoginUr) ject().getPrincipal();
ExportParams exportParams = new ExportParams("客户列表数据", "导出⼈:"+lname(), "导出信息");
ect(, exportParams);
ect(_LIST, pageList);
return mv;
}
/**
* 导出模板
*
* @param
*/
@RequestMapping(value = "/exportTemplate")
public ModelAndView exportTemplate() {
List
//Step.2 AutoPoi 导出Excel
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
//导出⽂件名称
ect(_NAME, "客户列表导⼊模板");
ect(, );
LoginUr ur = (LoginUr) ject().getPrincipal();
ExportParams exportParams = new ExportParams("客户列表数据", "导出⼈:"+lname(), "导出信息");
清新小炒 ect(, exportParams);
ect(_LIST, pageList);
return mv;
}
本文发布于:2023-04-24 16:58:20,感谢您对本站的认可!
本文链接:https://www.wtabcd.cn/fanwen/fan/82/512580.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |