kongdeqiang
2023-09-12 b6809f71253a524d81c086ef1293acafdaba395e
src/components/page/invoice/invoiceForm.vue
@@ -1,77 +1,71 @@
<template>
    <div class="invoiceForm-wrap">
        <div v-if="isWeiXin ">
            <div class="title">订单发票</div>
            <div class="invoiceForm-main">
                <div class="invoiceForm-main-inside">
                    <div class="invoice-date-box">
                        <el-date-picker
                                :editable="false"
                                format="yyyy-MM"
                                value-format="yyyy-MM"
                                v-model="date"
                                type="month"
                                @change="changeDate"
                                placeholder="选择日期">
                        </el-date-picker>
        <div class="title">订单发票</div>
        <div class="invoiceForm-main">
            <div class="invoiceForm-main-inside">
                <div class="invoice-date-box">
                    <el-date-picker
                            :editable="false"
                            format="yyyy-MM"
                            value-format="yyyy-MM"
                            v-model="date"
                            type="month"
                            @change="changeDate"
                            placeholder="选择日期">
                    </el-date-picker>
                </div>
                <van-list
                        v-model="loading"
                        :finished="finished"
                        finished-text="没有更多了"
                        :offset="50"
                        :immediate-check="false"
                        @load="onLoad"
                >
                    <div v-for="(item,index) in invoiceData" :key="index">
                        <el-checkbox
                                v-model="item.isShow"
                                class="invoiceForm-block"
                                @change="handleCheckedCitiesChange(invoiceData)">
                            <div>
                                <div class="invoiceForm-content">
                                    <svg class="iconSvg" style="font-size: 12px" aria-hidden="true">
                                        <use xlink:href="#icon-shijian3"></use>
                                    </svg>
                                    {{item.enterTime}}
                                </div>
                                <div class="invoiceForm-content">
                                    <svg class="iconSvg" style="font-size: 12px" aria-hidden="true">
                                        <use xlink:href="#icon-shijian3"></use>
                                    </svg>
                                    {{item.outTime}}
                                </div>
                                <div class="invoiceForm-content">
                                    <svg class="iconSvg" style="font-size: 12px" aria-hidden="true">
                                        <use xlink:href="#icon-dizhi1"></use>
                                    </svg>
                                    {{item.address}}
                                </div>
                            </div>
                            <div class="money-main">
                                <h1 class="money-box">{{item.money}}<font class="money-small">元</font></h1>
                            </div>
                        </el-checkbox>
                    </div>
                    <van-list
                            v-model="loading"
                            :finished="finished"
                            finished-text="没有更多了"
                            :offset="50"
                            :immediate-check="false"
                            @load="onLoad"
                    >
                        <div v-for="(item,index) in invoiceData" :key="index">
                            <el-checkbox
                                    v-model="item.isShow"
                                    class="invoiceForm-block"
                                    @change="handleCheckedCitiesChange(invoiceData)">
                                <div>
                                    <div class="invoiceForm-content">
                                        <svg class="iconSvg" style="font-size: 12px" aria-hidden="true">
                                            <use xlink:href="#icon-shijian3"></use>
                                        </svg>
                                        {{item.enterTime}}
                                    </div>
                                    <div class="invoiceForm-content">
                                        <svg class="iconSvg" style="font-size: 12px" aria-hidden="true">
                                            <use xlink:href="#icon-shijian3"></use>
                                        </svg>
                                        {{item.outTime}}
                                    </div>
                                    <div class="invoiceForm-content">
                                        <svg class="iconSvg" style="font-size: 12px" aria-hidden="true">
                                            <use xlink:href="#icon-dizhi1"></use>
                                        </svg>
                                        {{item.address}}
                                    </div>
                                </div>
                                <div class="money-main">
                                    <h1 class="money-box">{{item.money}}<font class="money-small">元</font></h1>
                                </div>
                            </el-checkbox>
                        </div>
                    </van-list>
                    <div class="fapiao-btn">
                        <el-checkbox v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
                        <div class="fapiao-right">
                            <span class="money">金额:<font class="big">{{countMoney}}</font>元</span>
                            <el-button size="mini" @click="seeInvoice">下载发票</el-button>
                        </div>
                </van-list>
                <div class="fapiao-btn">
                    <el-checkbox v-model="checkAll" @change="handleCheckAllChange">全选</el-checkbox>
                    <div class="fapiao-right">
                        <span class="money">金额:<font class="big">{{countMoney}}</font>元</span>
                        <el-button size="mini" @click="seeInvoice">下载发票</el-button>
                    </div>
                </div>
            </div>
        </div>
        <div class="middlePge-wrap" v-else>
            <div class="middlePge-main">
                <img src="../../../assets/images/middlePage.png" alt="">
            </div>
        </div>
    </div>
</template>
@@ -84,7 +78,6 @@
        },
        data() {
            return {
                isWeiXin: false,
                date:'',
                checkedInvoices: [1,2],
                invoiceData:[],
@@ -99,22 +92,12 @@
            }
        },
        created() {
            this.checkWeiXin()
            this.date = this.$byutil.dateFormat(new Date(), "yyyy-MM");
        },
        mounted() {
            this.getByCarNo()
        },
        methods: {
            checkWeiXin() {
                let userAgent = navigator.userAgent;
                console.log(userAgent)
                if (userAgent.includes("MicroMessenger")) {
                    this.isWeiXin = true
                } else {
                    this.isWeiXin = false
                }
            },
            onLoad() {
                this.loading = true
                this.current += 1
@@ -123,7 +106,7 @@
            },
            getByCarNo() {
                this.invoiceData = []
                let url = this.$systemconfig.basePath + '/orderrecord/getByCarNo';
                let url = this.$systemconfig.basePath + '/ffzf/orderrecord/getByCarNo';
                let params = {
                    carNo: this.$route.query.carNo,
                    phone: this.$route.query.phone,
@@ -176,20 +159,42 @@
                this.checkAll = checkedCount === ids.length;
            },
            seeInvoice() {  //查看发票
                console.log(this.filedId.length,'this.filedId====')
                if(this.filedId.length == 0){
                    alert("请至少选择一项")
                }else {
                    let url = this.$systemconfig.basePath + '/fileInfo/download/downloadPng';
                    this.filedId.forEach(item => {
                        console.log(item,'item=======')
                    if(this.filedId.length == 1) {
                        let url = this.$systemconfig.basePath + '/ffzf/fileInfo/download/downloadPng';
                        this.filedId.forEach(item => {
                            let param = {
                                    fileId : item
                            }
                            this.$byutil.exportData(this,url,param,res => {
                                console.log(res,'res====')
                                let date = new Date()
                                let time = this.$moment(date).format('YYYY-MM-DD HH:mm:ss') + '-' + item
                                let blob = new Blob([res], {type: 'image/png'});
                                let downloadElement = document.createElement("a");
                                downloadElement.style.display = "none";
                                let href = window.URL.createObjectURL(blob); //创建下载的链接
                                downloadElement.href = href;
                                downloadElement.download = '发票下载.png'
                                document.body.appendChild(downloadElement);
                                downloadElement.click(); //点击下载
                                document.body.removeChild(downloadElement); //下载完成移除元素
                                window.URL.revokeObjectURL(href); //释放掉blob对象
                            })
                        })
                    }else if(this.filedId.length > 1) {
                        let result =  this.filedId.join(",")
                        let url = this.$systemconfig.basePath + '/ffzf/fileInfo/download/downloadZips';
                        let param = {
                                fileId : item
                            fileIds : result
                        }
                        this.$byutil.exportData(this,url,param,res => {
                            console.log(res,'res====')
                            let date = new Date()
                            let time = this.$moment(date).format('YYYY-MM-DD HH:mm:ss')
                            let blob = new Blob([res], {type: 'image/png'});
                            let blob = new Blob([res], {type: 'application/zip'});
                            let downloadElement = document.createElement("a");
                            downloadElement.style.display = "none";
                            let href = window.URL.createObjectURL(blob); //创建下载的链接
@@ -200,7 +205,7 @@
                            document.body.removeChild(downloadElement); //下载完成移除元素
                            window.URL.revokeObjectURL(href); //释放掉blob对象
                        })
                    })
                    }
                }
            },
            changeDate(){
@@ -285,18 +290,6 @@
        .el-checkbox__inner::after{
            left: 5px;
            top: 2px;
        }
    }
    .middlePge-wrap{
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.7);
        .middlePge-main{
            width: 100%;
            height: 100%;
            img{
                width: 100%;
            }
        }
    }
    .iconSvg{