<template>
    <div :class="sizeTypeClass">
        <div class="print-title">{{ storeInfo.name }}预结单</div>
        <div class="print-fee-info">
            <div class="print-fee-item-wrapper">
                <div class="print-fee-title">餐台:</div>
                <div class="print-fee-value">{{ feeInfo.tableName }}</div>
            </div>
            <div class="print-fee-item-wrapper">
                <div class="print-fee-title">创建时间:</div>
                <div class="print-fee-value">{{ feeInfo.createTime }}</div>
            </div>
            <div class="print-fee-item-wrapper">
                <div class="print-fee-title">打印时间:</div>
                <div class="print-fee-value">{{ printDate }}</div>
            </div>
            <div class="print-fee-item-wrapper">
                <div class="print-fee-title">操作员:</div>
                <div class="print-fee-value">{{ feeInfo.operName }}</div>
            </div>
        </div>

        <div class="print-fees">
            <div class="print-fees-header fee-row">
                <div class="fee-cell flex-3">项目</div>
                <div class="fee-cell flex-2">单价</div>
                <div class="fee-cell flex-2">优惠价</div>
                <div class="fee-cell flex-2">数量</div>
                <div class="fee-cell">金额</div>
            </div>
        </div>

        <div class="info-split"></div>
        <div class="info-split-dashed"></div>
        <div class="print-fees-header fee-row" style="padding-bottom: 5px" v-for="(item,index) in dataSource.childs">
            <div class="fee-cell flex-3">{{item.projectName}}</div>
            <div class="fee-cell flex-2">{{item.price}}</div>
            <div class="fee-cell flex-2">{{item.preferentialPrice}}</div>
            <div class="fee-cell flex-2">{{item.number}}</div>
            <div class="fee-cell">{{item.money}}</div>
        </div>
        <div class="info-split"></div>

        <div class="print-fees">
            <div class="print-fees-header fee-row">
                <div class="fee-cell flex-5">项目合计:</div>
                <div class="fee-cell flex-8"></div>
                <div class="fee-cell">{{dataSource.amount}}</div>
            </div>
        </div>

        <hr style="border: 1px dashed rgb(0, 0, 0); height: 1px;">

        <div class="print-fee-item-wrapper">
            <div class="print-fee-title">消费合计:</div>
            <div class="print-fee-value">{{ feeInfo.xfhj }}</div>
        </div>
        <div class="print-fee-item-wrapper">
            <div class="print-fee-title">优惠金额:</div>
            <div class="print-fee-value">{{ feeInfo.yhje }}</div>
        </div>
        <div class="print-fee-item-wrapper">
            <div class="print-fee-title">结账优惠:</div>
            <div class="print-fee-value">{{ feeInfo.jzyh }}</div>
        </div>
        <div class="print-fee-item-wrapper">
            <div class="print-fee-title">实际应收:</div>
            <div class="print-fee-value">{{ feeInfo.sjys }}</div>
        </div>

        <hr style="border: 1px dashed rgb(0, 0, 0); height: 1px;">

        <pre style="white-space: pre-wrap;" class="print-def-content">{{ defContent }}</pre>


        <div class="a5-partail">
            <div class="print-fee-item-wrapper">
                <div class="print-fee-title">预定电话:</div>
                <div class="print-fee-value">{{ storeInfo.linkTel }}</div>
            </div>
            <div class="print-fee-item-wrapper">
                <div class="print-fee-title">酒店地址:</div>
                <div class="print-fee-value">{{ storeInfo.address }}</div>
            </div>
            <div class="print-fee-item-wrapper">
                <div>贵宾签字:</div>
                <div class="print-fee-value value-underline"></div>
            </div>
        </div>
        <div class="qr-code-wrapper">
            <div class="code-content"></div>
            <div style="margin-bottom: 10px;font-size: smaller;">扫码自助开票</div>
        </div>
    </div>
</template>
<script>
    import { mapActions, mapGetters, mapState } from 'vuex'
    export default {
        props: {
            title: {
                type: String,
                default: '预结单'
            },
            sizeTypeClass: {
                type: String,
                default: "mm58"
            },
            feeInfo: {
                type: Object,
                default() {
                    return {
                        tableName: '',
                        operName:'',
                        createTime: '2023-05-15 15:30',
                        xfhj: 0,
                        yhje: 0,
                        jzyh: 0,
                        sjys: 0,
                    }
                }
            },
            defContent: {
                type: String,
                default: ""
            },
            dataSource:{
                type:Object,
                default() {
                    return {
                        amount:'99',
                        childs:[
                            {
                                projectName: '点菜',
                                price: '88.8',
                                preferentialPrice: '78',
                                number: '1',
                                money: '78',
                            },
                        ]
                    };
                }
            }
        },
        data() {
            let storeInfo = JSON.parse(localStorage.getItem("storeInfo"))
            return {
                storeInfo,
                printDate: new Date().format('yyyy/MM/dd hh:mm:ss')
            }
        },
        methods: {
            ...mapGetters(["nickname", "avatar", "userInfo"]),
        }
    }
</script>
<style lang="less">
    .mm58 {
        width: 58mm;
        border: 1px solid #00000055;

        .print-title {
            text-align: center;
            font-size: 16px;
            font-weight: 600;
        }
    }

    .mm80 {
        width: 80mm;
        border: 1px solid #00000055;
        padding-left: 3mm;

        .print-fee-info {
            display: flex;
            flex-wrap: wrap;

            .print-fee-item-wrapper {
                width: 65%;
            }

            .small-item {
                width: 35%;

                .print-fee-value {
                    margin-right: 3mm;
                }
            }

            .print-fee-title {
                width: fit-content;
                text-align: right;
            }

        }

        .print-title {
            text-align: center;
            font-size: 16px;
            font-weight: 600;
        }
    }

    .a5 {
        width: 210mm;
        border: 1px solid #00000055;
        padding: 3mm;

        .print-fee-info {
            display: flex;
            flex-wrap: wrap;


            .print-fee-item-wrapper {
                width: 100%;
            }

            .print-fee-title {
                width: 10%;
                text-align: right;
            }

        }

        .print-no{
            text-align: center;
        }
        .print-title {
            text-align: center;
            font-size: 16px;
            font-weight: 600;
        }
        .a5-partail{
            display: flex;
            flex-wrap: wrap;
            .print-fee-item-wrapper {
                margin: 3mm 0;
                width: 80%;
            }
        }
    }

    .print-no {
        text-align: left;
        font-weight: 600;
    }

    .print-fee-item-wrapper {
        display: flex;
        width: 100%;
        padding: 4px 0;
        font-size: small;

        .print-fee-title {
            width: 65px;
            text-align: right;
        }

        .print-fee-value {
            flex: 1;
        }

        .value-underline {
            border-bottom: 1px solid #00000088;
        }
    }

    .print-fees {
        margin-bottom: 5px;
    }

    .fee-row {
        display: flex;
        margin-left: 2px;

        .fee-cell {
            color: black;
            flex: 1;
            margin: 0 3px;
            font-size: smaller;
            text-align: left;
        }

        .flex-2 {
            flex: 1.5;
        }

        .flex-3 {
            flex: 2;
        }
.flex-5{
    flex: 3;
}
        .flex-8 {
            flex: 5;
        }
    }

    .info-split-dashed {
        margin: 8px 0;
        border: 1px dashed #000000;


    }

    .info-split {
        border: 1px solid #000000;
        width: 100%;
        margin: 8px 0;
    }

    .qr-code-wrapper {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;

    }

    .code-content {
        width: 150px;
        height: 150px;
        background-image: url('data:image/jpeg;base64,[encoded data, 25532 characters]');
    }
</style>
