Commit ad43204f by sunxiwang

员工活码下载

1 parent 067b521b
...@@ -189,6 +189,22 @@ public class WeEmpleCodeController extends BaseController { ...@@ -189,6 +189,22 @@ public class WeEmpleCodeController extends BaseController {
} }
} }
@PreAuthorize("@ss.hasPermi('wecom:code:download')")
@Log(title = "员工活码下载", businessType = BusinessType.OTHER)
@GetMapping("/download")
public void download(String id, HttpServletRequest request, HttpServletResponse response){
WeEmpleCode weEmpleCode = weEmpleCodeService.selectWeEmpleCodeById(Long.valueOf(id));
if (StringUtils.isEmpty(weEmpleCode.getQrCode())){
return;
}else {
try {
FileUtils.downloadFile(weEmpleCode.getQrCode(), response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
}
/** /**
* 成员添加客户统计 * 成员添加客户统计
......
...@@ -141,7 +141,16 @@ export function downloadBatch(ids) { ...@@ -141,7 +141,16 @@ export function downloadBatch(ids) {
}, },
responseType: 'blob' responseType: 'blob'
}) })
//return process.env.VUE_APP_BASE_API + service + '/downloadBatch/?ids=' + ids }
export function download(id) {
return request({
url: service + '/download',
params: {
id,
},
responseType: 'blob'
})
} }
/** /**
......
<script> <script>
import { getDetail, getUserAddCustomerStat } from '@/api/drainageCode/staff' import { getDetail, getUserAddCustomerStat, download } from '@/api/drainageCode/staff'
import { download, downloadBatch } from '@/api/common'
import ClipboardJS from 'clipboard' import ClipboardJS from 'clipboard'
import echarts from 'echarts' import echarts from 'echarts'
export default { export default {
...@@ -105,7 +104,22 @@ export default { ...@@ -105,7 +104,22 @@ export default {
return year + '-' + month + '-' + date return year + '-' + month + '-' + date
}, },
download() { download() {
window.open(this.form.qrCode) let userName ="";
this.form.weEmpleCodeUseScops.forEach((item) =>{
userName+=item.businessName+",";
})
let name = userName.substr(0,userName.length-1) +"-"+this.form.activityScene+".png"
download(this.form.id).then((res) =>{
if (res!=null) {
let blob = new Blob([res], {type: 'application/zip'});
let url = window.URL.createObjectURL(blob);
const link = document.createElement('a'); // 创建a标签
link.href = url;
link.download = name; // 重命名文件
link.click();
URL.revokeObjectURL(url); // 释放内存
}
})
}, },
}, },
} }
......
...@@ -4,8 +4,8 @@ import { ...@@ -4,8 +4,8 @@ import {
remove, remove,
batchAdd, batchAdd,
downloadBatch, downloadBatch,
download,
} from '@/api/drainageCode/staff' } from '@/api/drainageCode/staff'
import { download } from '@/api/common'
import SelectUser from '@/components/SelectUser' import SelectUser from '@/components/SelectUser'
import ClipboardJS from 'clipboard' import ClipboardJS from 'clipboard'
export default { export default {
...@@ -129,12 +129,23 @@ export default { ...@@ -129,12 +129,23 @@ export default {
this.getList(1) this.getList(1)
}) })
}, },
download(id,userName,activityScene){
let name = userName+"-"+activityScene+".png"
download(id).then((res) =>{
if (res!=null) {
let blob = new Blob([res], {type: 'application/zip'});
let url = window.URL.createObjectURL(blob);
const link = document.createElement('a'); // 创建a标签
link.href = url;
link.download = name; // 重命名文件
link.click();
URL.revokeObjectURL(url); // 释放内存
}
})
},
/** 下载 */ /** 下载 */
downloadBatch(qrCode) { downloadBatch(qrCode) {
// window.open(download(row.qrCode, row.createBy.split(',')[0] + '.png')) this.$confirm('是否确认下载所有图片吗?', '警告', {
qrCode && window.open(qrCode)
qrCode ||
this.$confirm('是否确认下载所有图片吗?', '警告', {
confirmButtonText: '确定', confirmButtonText: '确定',
cancelButtonText: '取消', cancelButtonText: '取消',
type: 'warning', type: 'warning',
...@@ -296,7 +307,7 @@ export default { ...@@ -296,7 +307,7 @@ export default {
<template slot-scope="{ row }"> <template slot-scope="{ row }">
<el-button <el-button
type="text" type="text"
@click="downloadBatch(row.qrCode)" @click="download(row.id,row.useUserName,row.activityScene)"
v-hasPermi="['monitor:operlog:query']" v-hasPermi="['monitor:operlog:query']"
>下载</el-button >下载</el-button
> >
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!