Admin
2022-11-24 ffd20ad90aa3dfb3ce5b3860f3556cdbb75f1c7a
优化loading
已修改4个文件
38 ■■■■ 文件已修改
src/views/specialCheck/components/areaForm.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/specialCheck/components/sumSheet.vue 32 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/specialCheck/components/wholesaleForm.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/specialCheck/index.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/specialCheck/components/areaForm.vue
@@ -8,6 +8,7 @@
                :data="checkData"
                border
                fit
                id="areaSheet"
                highlight-current-row
                style="width: 100%;"
            >
src/views/specialCheck/components/sumSheet.vue
@@ -10,8 +10,7 @@
            <div style="display: flex;justify-content: space-between;align-items: center;margin: 10px 0 20px;height: 40px">
                <div style="width: 140px"></div>
                <h2 style="text-align: center;margin: 0">{{taskName}}{{ activeTab==1?'批发':'零售' }}环节信息报送汇总表({{sheetStatus==1?'省级层面':(sheetStatus==2?'市级层面':'区县级')}})</h2>
                <el-button icon="el-icon-download" v-if="sheetStatus==1||sheetStatus==2" style="width: 140px" size="medium" type="primary" @click="exportSheet()" id="export">导出汇总表</el-button>
                <div v-else style="width: 140px"></div>
                <el-button icon="el-icon-download" style="width: 140px" size="medium" type="primary" @click="exportSheet()" id="export">导出汇总表</el-button>
            </div>
            <div class="tabpanel">
                <table v-show="sheetStatus==1||sheetStatus==2" class="data-table" id="tableExcel" v-if="thisLevelStatistic && institutionalData && institutionalData.length>0">
@@ -202,6 +201,8 @@
import { getCheckUnitType,getDataStatistics, getSpecialCheckTask } from "@/api/specialCheck"
import areaForm from "./areaForm"
import checkEnterprises from "./checkEnterprises"
import FileSaver from 'file-saver'
import XLSX from 'xlsx'
export default {
name: "sumSheet",
@@ -284,6 +285,13 @@
        },
        async getDataStatistics(){
            const t = this
            const loading = this.$loading({
                lock: true,
                target: document.querySelector('.tabpanel'),
                text: '正在获取汇总数据',
                spinner: 'el-icon-loading',
                fullscreen: false
            });
            const data = {id: t.taskId,enterpriseType: t.activeTab,enterpriseCity: t.enterpriseCity,enterpriseArea: t.enterpriseArea,pageIndex: t.currentPage,pageSize: t.pageSize}
            const res = await getDataStatistics(data)
            if(res.data.code === "200"){
@@ -326,6 +334,7 @@
                    message:res.data.message
                })
            }
            loading.close();
        },
        switchSheet() {
            const t = this
@@ -356,8 +365,8 @@
            const t = this
            if(t.sheetStatus==1){
                t.enterpriseCity = city
                t.getDataStatistics()
                t.sheetStatus = 2
                t.getDataStatistics()
            }else{
                t.sheetStatus = 3
                t.$refs.areaSheet.taskId = t.taskId
@@ -368,14 +377,14 @@
            }
        },
        tableToExcel(tableid,btnname,sheetname) {
            var uri = 'data:application/vnd.ms-excel;base64,'
            let uri = 'data:application/vnd.ms-excel;base64,'
                , template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="UTF-8"><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
                , base64 = function (s) { return window.btoa(unescape(encodeURIComponent(s))) }
                , format = function (s, c) { return s.replace(/{(\w+)}/g, function (m, p) { return c[p]; }) }
            //根据ID获取table表格HTML
            var table = document.getElementById(tableid);
            var ctx = { worksheet: 'Worksheet', table: table.innerHTML };
            var alink = document.createElement("a");
            let table = document.getElementById(tableid);
            let ctx = { worksheet: 'Worksheet', table: table.innerHTML };
            let alink = document.createElement("a");
            alink.href = uri + base64(format(template, ctx));
            alink.download = sheetname + ').xls';
            alink.click();
@@ -383,8 +392,17 @@
        exportSheet(){
            const t = this
            const sheetName = t.taskName + (t.activeTab==1 ?'批发':'零售') + '环节信息报送汇总表(' + (t.sheetStatus==1?'省级层面':(t.sheetStatus==2?'市级层面':'区县级'))
            if(t.sheetStatus==1||t.sheetStatus==2){
            t.tableToExcel("tableExcel", "export",sheetName);
            }else{
                let wb = XLSX.utils.table_to_book(document.querySelector('#' + 'areaSheet'))
                let wbout = XLSX.write(wb, { bookType: 'xlsx', bookSST: true, type: 'array' })
                try {
                    FileSaver.saveAs(new Blob([wbout], { type: 'application/octet-stream' }), sheetName + ').xlsx')
                } catch (e) { if (typeof console !== 'undefined') console.log(e, wbout) }
                // return wbout
        }
        },
    }
}
</script>
src/views/specialCheck/components/wholesaleForm.vue
@@ -168,7 +168,6 @@
    methods:{
        async getCheckUnitType(){
            const t = this
            t.listLoading = true
            let res = await getCheckUnitType()
            if(res.data.code === "200"){
                t.unitType = res.data.result.checkUnitType
@@ -178,10 +177,10 @@
                    message:res.data.message
                })
            }
            t.listLoading = false
        },
        async getCheckTask(){
            const t = this
            t.listLoading = true
            const res = await getSpecialCheckTask()
            if(res.data.code === "200"){
                t.taskId = res.data.result.specialCheckTaskSimplifyInfos[0].id
@@ -194,6 +193,7 @@
                    message:res.data.message
                })
            }
            t.listLoading = false
        },
        async getEnterpriseCompleteInfoList(){
            const t = this
src/views/specialCheck/index.vue
@@ -124,6 +124,7 @@
                    t.$refs.sumSheet.sheetStatus = t.unitType
                    t.$refs.sumSheet.activeTab = 1
                    t.$refs.sumSheet.getDataStatistics()
                    console.log(t.$refs.sumSheet.sheetStatus,t.$refs.sumSheet.institutionalData,'55555555555555555')
                }
                t.curTab = Number(key.split('-')[1])
            },