import * as DateFormatter from '@/utils/DateFormatter';
|
import {mapGetters} from 'vuex';
|
import * as dataExport from "@/api/exportExcel"
|
import {downLoad} from "@/utils/base";
|
|
export default {
|
data() {
|
return {
|
loading: false,
|
list: [],
|
items: [],
|
filterFrom: {},
|
editSetting: {
|
title: '',
|
id: '',
|
orgId: '',
|
show: false,
|
},
|
detailSetting: {
|
title: '详情',
|
id: '',
|
show: false,
|
},
|
pageNum: 1,
|
pageSize: 10,
|
total: 0,
|
}
|
},
|
computed: {
|
...mapGetters(['userInfo']),
|
clientHeight() {
|
return document.documentElement.clientHeight;
|
},
|
},
|
created() {
|
},
|
filters: {
|
formatTime(time) {
|
if (!time) return '-';
|
return DateFormatter.LongToDateTime(time);
|
},
|
},
|
methods: {
|
// 导出
|
handleExport(api, fileName, params) {
|
console.log(fileName)
|
let loading = this.$loading({
|
lock: true,
|
text: '导出中,请稍候...',
|
spinner: 'el-icon-loading',
|
background: 'rgba(0, 0, 0, 0.7)',
|
});
|
// 判断总条数是否大于最大支持条数
|
dataExport[api](params)
|
.then((res) => {
|
const blob = new Blob([res], {type: 'application/vnd.ms-excel'});
|
/*if ('download' in document.createElement('a')) {
|
// 非IE下载
|
const elink = document.createElement('a');
|
elink.download = `${fileName}.xls`;
|
elink.style.display = 'none';
|
const URL = window.URL || window.webkitURL
|
const href = URL.createObjectURL(blob)
|
elink.href = href;
|
document.body.appendChild(elink);
|
elink.click();
|
URL.revokeObjectURL(elink.href);
|
document.body.removeChild(elink);
|
window.URL.revokeObjectURL(href)
|
} else {
|
// IE10+下载
|
navigator.msSaveBlob(blob, `${fileName}.xls`);
|
}*/
|
downLoad(res)
|
this.$message.success('导出成功!');
|
loading.close();
|
})
|
.catch(() => {
|
loading.close();
|
});
|
},
|
// 新增
|
handleAdd() {
|
this.editSetting.id = null;
|
this.editSetting.info = null;
|
this.editSetting.title = '新增';
|
this.editSetting.show = true;
|
},
|
// 编辑
|
handleEdit(row) {
|
this.editSetting.id = row.id;
|
this.editSetting.info = null;
|
this.editSetting.title = '编辑';
|
this.editSetting.show = true;
|
},
|
// 详情
|
handleDetail(row) {
|
this.detailSetting.id = row.id;
|
this.detailSetting.title = '详情';
|
this.detailSetting.show = true;
|
},
|
// 分页
|
handleSizeChange(pageSize) {
|
this.pageSize = pageSize;
|
this.search({pageNum: 1});
|
},
|
handleCurrentChange(pageNum) {
|
this.pageNum = pageNum;
|
this.search();
|
},
|
// 查询table列表
|
search(pageNum) {
|
if (pageNum) {
|
this.pageNum = pageNum
|
}
|
this.fetchData();
|
},
|
refreshData() {
|
this.pageNum = 1;
|
this.pageSize = 10;
|
this.search();
|
},
|
fifterForm(params) {
|
this.filterFrom = Object.assign(this.filterFrom, params);
|
this.search(1);
|
},
|
}
|
}
|