From f75de810f3d85e4408f4d5be871daf1c3d1d9325 Mon Sep 17 00:00:00 2001 From: pyt <626651354@qq.com> Date: 星期四, 20 三月 2025 16:31:55 +0800 Subject: [PATCH] Merge branch 'main' of http://120.76.84.145:10101/gitblit/r/H5/chongzhouResettle --- src/utils/index.js | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 57 insertions(+), 0 deletions(-) diff --git a/src/utils/index.js b/src/utils/index.js index df5db12..50e04aa 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -1,4 +1,5 @@ import { parseTime } from './ruoyi' +import { getToken } from '@/utils/auth' /** * 表格时间格式化 @@ -388,3 +389,59 @@ return /^[+-]?(0|([1-9]\d*))(\.\d+)?$/g.test(str) } + + +export const exportExcell = (name, params, url) => { + fetch(BASE_URL + url, { + method: 'POST', + body: JSON.stringify({ + ...params, + }), + headers: { + Authorization:'Bearer ' + localStorage.getItem('token'), + 'ConTent-Type': 'application/json;charset=UTF-8', + timestamp: new Date().getTime(), + client: localStorage.getItem('client') + }, + responseType: 'blob', + }) + .then((res) => res.blob()) + .then((res) => { + + const link = document.createElement('a'); + link.style.display = 'none'; + link.href = URL.createObjectURL(res); + link.download = name; + document.body.appendChild(link); + link.click(); + // 释放的 URL 对象以及移除 a 标签 + URL.revokeObjectURL(link.href); + document.body.removeChild(link); + }); +}; + +//下载导入末班 +export const downLoad = (url, name) => { + fetch(process.env.VUE_APP_BASE_API + url, { + method: 'post', + responseType: 'blob', + headers: { + Authorization:'Bearer ' + getToken(), + 'ConTent-Type': 'application/json;charset=UTF-8', + timestamp: new Date().getTime(), + client: localStorage.getItem('client') + }, + }) + .then((res) => res.blob()) + .then((res) => { + const link = document.createElement('a'); + link.style.display = 'none'; + link.href = URL.createObjectURL(res); + link.download = name; + document.body.appendChild(link); + link.click(); + // 释放的 URL 对象以及移除 a 标签 + URL.revokeObjectURL(link.href); + document.body.removeChild(link); + }); +}; \ No newline at end of file -- Gitblit v1.7.1