export-data.vue 1.05 KB
<template>
<Button type="primary" size="large" @click="exportData"><Icon type="ios-download-outline"></Icon> 导出全部</Button>
</template>
<script>
import config from 'config';

export default {
    name: 'export-data',
    props: ['allCount', 'config', 'exportParam'],
    data() {
        return {};
    },
    methods: {
        exportData() {
            this.$Modal.confirm({
                title: '确认消息',
                content: '您是否要导出' + this.allCount + '条数据?',
                loading: true,
                onOk: () => {
                    let params = this.exportParam.export ? _.assign(this.config, {_export: 'excel'}) : this.config;
                    let link = [];

                    _.forEach(params, function(item, key){
                        link.push(key + '=' + item);                
                    });

                    location.href = `${config.apiURL}${this.exportParam.urlType}?${link.join('&')}`;
                    this.$Modal.remove();
                }
            });
        }
    }
}
</script>