新增下载

main
mo 1 year ago
parent ba70b63b87
commit 481df58681

@ -10,6 +10,7 @@ import store from './store'
import router from './router' import router from './router'
import directive from './directive' // directive import directive from './directive' // directive
import plugins from './plugins' // plugins import plugins from './plugins' // plugins
import { download } from '@/utils/request'
import './assets/icons' // icon import './assets/icons' // icon
import './permission' // permission control import './permission' // permission control
@ -39,6 +40,7 @@ Vue.prototype.DICT_TYPE = DICT_TYPE
Vue.prototype.handleTree = handleTree Vue.prototype.handleTree = handleTree
Vue.prototype.addBeginAndEndTime = addBeginAndEndTime Vue.prototype.addBeginAndEndTime = addBeginAndEndTime
Vue.prototype.divide = divide Vue.prototype.divide = divide
Vue.prototype.download = download
// 全局组件挂载 // 全局组件挂载

@ -196,4 +196,19 @@ function handleAuthorized() {
return Promise.reject('无效的会话,或者会话已过期,请重新登录。') return Promise.reject('无效的会话,或者会话已过期,请重新登录。')
} }
export function download(url, filename) {
const x = new window.XMLHttpRequest();
x.open('GET', url, true);
x.responseType = 'blob';
x.onload = () => {
let time = new Date().toLocaleDateString();
const url = window.URL.createObjectURL(x.response);
const a = document.createElement('a');
a.href = url;
a.download = filename ;
a.click();
};
x.send();
}
export default service export default service

@ -617,7 +617,7 @@ export default {
}, },
// //
handleDownload(row) { handleDownload(row) {
window.open(row.uri); this.download(row.uri, row.name);
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm() { submitForm() {

@ -178,6 +178,13 @@
@click="handleView(scope.row)" @click="handleView(scope.row)"
>查看 >查看
</el-button> </el-button>
<el-button
size="mini"
type="text"
icon="el-icon-download"
@click="handleDownload(scope.row)"
>下载</el-button
>
<el-button <el-button
v-if="scope.row.fileStatus == '0'" v-if="scope.row.fileStatus == '0'"
size="mini" size="mini"
@ -573,6 +580,10 @@ export default {
this.title = "查看会计报表"; this.title = "查看会计报表";
}); });
}, },
//
handleDownload(row) {
this.download(row.url, row.name);
},
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
this.reset(); this.reset();

Loading…
Cancel
Save