mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-07 15:45:08 +08:00
1. 完成用户导出的功能
2. 完成前后端的导出的封装
This commit is contained in:
@ -16,7 +16,7 @@ import './assets/icons' // icon
|
||||
import './permission' // permission control
|
||||
import { getDicts } from "@/api/system/dict/data";
|
||||
import { getConfigKey } from "@/api/system/config";
|
||||
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree } from "@/utils/ruoyi";
|
||||
import { parseTime, resetForm, addDateRange, selectDictLabel, selectDictLabels, download, handleTree, downloadExcel } from "@/utils/ruoyi";
|
||||
import Pagination from "@/components/Pagination";
|
||||
// 自定义表格工具扩展
|
||||
import RightToolbar from "@/components/RightToolbar"
|
||||
@ -33,6 +33,7 @@ Vue.prototype.addDateRange = addDateRange
|
||||
Vue.prototype.selectDictLabel = selectDictLabel
|
||||
Vue.prototype.selectDictLabels = selectDictLabels
|
||||
Vue.prototype.download = download
|
||||
Vue.prototype.downloadExcel = downloadExcel
|
||||
Vue.prototype.handleTree = handleTree
|
||||
|
||||
Vue.prototype.msgSuccess = function (msg) {
|
||||
|
@ -101,6 +101,21 @@ export function download(fileName) {
|
||||
window.location.href = baseURL + "/common/download?fileName=" + encodeURI(fileName) + "&delete=" + true;
|
||||
}
|
||||
|
||||
// 下载 Excel 方法
|
||||
export function downloadExcel(data, fileName) {
|
||||
// 创建 blob
|
||||
let blob = new Blob([data], {type: 'application/vnd.ms-excel'});
|
||||
// 创建 href 超链接,点击进行下载
|
||||
window.URL = window.URL || window.webkitURL;
|
||||
let href = URL.createObjectURL(blob);
|
||||
let downA = document.createElement("a");
|
||||
downA.href = href;
|
||||
downA.download = fileName;
|
||||
downA.click();
|
||||
// 销毁超连接
|
||||
window.URL.revokeObjectURL(href);
|
||||
}
|
||||
|
||||
// 字符串格式化(%s )
|
||||
export function sprintf(str) {
|
||||
var args = arguments, flag = true, i = 1;
|
||||
|
@ -510,7 +510,7 @@ export default {
|
||||
this.reset();
|
||||
},
|
||||
// 取消按钮(角色权限)
|
||||
cancelMenu() {
|
||||
cancelRole() {
|
||||
this.openRole = false;
|
||||
this.reset();
|
||||
},
|
||||
@ -647,7 +647,10 @@ export default {
|
||||
},
|
||||
/** 导出按钮操作 */
|
||||
handleExport() {
|
||||
const queryParams = this.queryParams;
|
||||
const queryParams = this.addDateRange(this.queryParams, [
|
||||
this.dateRange[0] ? this.dateRange[0] + ' 00:00:00' : undefined,
|
||||
this.dateRange[1] ? this.dateRange[1] + ' 23:59:59' : undefined,
|
||||
]);
|
||||
this.$confirm('是否确认导出所有用户数据项?', "警告", {
|
||||
confirmButtonText: "确定",
|
||||
cancelButtonText: "取消",
|
||||
@ -655,15 +658,7 @@ export default {
|
||||
}).then(function() {
|
||||
return exportUser(queryParams);
|
||||
}).then(response => {
|
||||
// this.download(response.msg);
|
||||
let blob = new Blob([response], {type: 'application/vnd.ms-excel'});
|
||||
window.URL = window.URL || window.webkitURL;
|
||||
let href = URL.createObjectURL(blob);
|
||||
let downA = document.createElement("a");
|
||||
downA.href = href;//
|
||||
downA.download = '123321.xls';
|
||||
downA.click();
|
||||
window.URL.revokeObjectURL(href);
|
||||
this.downloadExcel(response, '用户数据.xls');
|
||||
})
|
||||
},
|
||||
/** 导入按钮操作 */
|
||||
|
Reference in New Issue
Block a user