<template>
    <div :class="sizeTypeClass">
        <div class="print-title">{{ storeInfo.name }}入库单</div>
        <div v-if="sizeTypeClass == 'a5'">
            <div class="print-fee-info">
                <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 small-item">
                    <div class="print-fee-title">单号:</div>
                    <div class="print-fee-value">{{ feeInfo.no }}</div>
                </div>
                <div class="print-fee-item-wrapper">
                    <div class="print-fee-title">供应商:</div>
                    <div class="print-fee-value">{{ feeInfo.supplier }}</div>
                </div>
                <div class="print-fee-item-wrapper small-item">
                    <div class="print-fee-title">制单人:</div>
                    <div class="print-fee-value">{{ nickname() }}</div>
                </div>
                <div class="print-fee-item-wrapper">
                    <div class="print-fee-title">仓库名:</div>
                    <div class="print-fee-value">{{ feeInfo.warehouseName }}</div>
                </div>
                <div class="print-fee-item-wrapper small-item">
                    <div class="print-fee-title">类型:</div>
                    <div class="print-fee-value">{{ feeInfo.type }}</div>

                </div>
            </div>

            <div class="print-fees">
                <div class="print-fees-header fee-row">
                    <div class="fee-cell flex-2">商品类别</div>
                    <div class="fee-cell">商品名称</div>
                    <div class="fee-cell">数量</div>
                    <div class="fee-cell">单位</div>
                    <div class="fee-cell">价格</div>
                    <div class="fee-cell">库存</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">
                <div class="fee-cell flex-2">{{item.goodType}}</div>
                <div class="fee-cell">{{item.goodName}}</div>
                <div class="fee-cell">{{item.number}}</div>
                <div class="fee-cell">{{item.unit}}</div>
                <div class="fee-cell">{{item.price}}</div>
                <div class="fee-cell">{{item.stock}}</div>
                <div class="fee-cell">{{item.size}}</div>
            </div>
            <div class="info-split"></div>

        </div>
        <div v-else>
            <div class="print-fee-info">
                <div class="print-fee-item-wrapper">
                    <div class="print-fee-title">单号:</div>
                    <div class="print-fee-value">{{ feeInfo.no }}</div>
                </div>
                <div class="print-fee-item-wrapper">
                    <div class="print-fee-title">制单人:</div>
                    <div class="print-fee-value">{{ nickname() }}</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.warehouseName }}</div>
                </div>
                <div class="print-fee-item-wrapper">
                    <div class="print-fee-title">类型:</div>
                    <div class="print-fee-value">{{ feeInfo.type }}</div>
                </div>
                <div class="print-fee-item-wrapper">
                    <div class="print-fee-title">供应商:</div>
                    <div class="print-fee-value">{{ feeInfo.supplier }}</div>
                </div>
            </div>

            <div class="print-fees">
                <div class="print-fees-header fee-row">
                    <div class="fee-cell flex-2">商品名称</div>
                    <div class="fee-cell">数量</div>
                    <div class="fee-cell">单位</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">
                <div class="fee-cell flex-2">{{item.goodName}}</div>
                <div class="fee-cell">{{item.number}}</div>
                <div class="fee-cell">{{item.unit}}</div>
                <div class="fee-cell">{{item.price}}</div>
            </div>
            <div class="info-split"></div>

        </div>

        <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">{{ printDate }}</div>
            </div>
            <div class="print-fee-item-wrapper">
                <div class="print-fee-title">申请人:</div>
                <div class="print-fee-value">{{ nickname() }}</div>
            </div>
            <div class="print-fee-item-wrapper row">
                <div class="print-fee-title">申请备注:</div>
                <div class="print-fee-value">{{ feeInfo.remarks }}</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">{{ nickname() }}</div>
            </div>
            <div class="print-fee-item-wrapper">
                <div class="print-fee-title">审批状态:</div>
                <div class="print-fee-value">{{ feeInfo.status }}</div>
            </div>
            <div class="print-fee-item-wrapper row">
                <div class="print-fee-title">审批意见:</div>
                <div class="print-fee-value">{{ feeInfo.opinion }}</div>
            </div>
        </div>
    </div>
</template>

<script>
    import { mapActions, mapGetters, mapState } from 'vuex'
    import { httpAction, getAction } from '@/api/manage'
    export default {
        props: {
            title: {
                type: String,
                default: '入库单'
            },
            sizeTypeClass: {
                type: String,
                default: "mm58"
            },
            feeInfo: {
                type: Object,
                default() {
                    return {
                        no: "NO202305172255",
                        name: '',
                        warehouseName:'大仓库',
                        type:'采购入库',
                        supplier:'测试',
                        remarks:'无',
                        status:'未审核',
                        opinion:'无'
                    }
                }
            },
            defContent: {
                type: String,
                default: ""
            },
            dataSource:{
                type:Array ,
                default() {
                    return [
                        {
                            goodType:'8025',
                            goodName:'商品',
                            number:'20',
                            unit:'元',
                            price:'6.99',
                            stock:'88',
                            size:'3.55*1.2',
                        },
                        {
                            goodType:'8025',
                            goodName:'商品',
                            number:'20',
                            unit:'元',
                            price:'6.99',
                            stock:'88',
                            size:'3.55*1.2',
                        },
                    ];
                }
            }
        },
        data() {
            let storeInfo = JSON.parse(localStorage.getItem("storeInfo"))
            return {
                storeInfo,
                printDate: new Date().format('yyyy/MM/dd hh:mm:ss')
            }
        },
        created() {
        },
        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: 60%;
            }

            .small-item {
                width: 40%;

                .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: 50%;
            }

            .print-fee-title {
                width: 20%;
                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: 45%;
            }
            .row{
                width: 100%;
            }
        }
    }

    .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;
        }
    }

    .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>
