<template>
    <div class="head-container">
        <el-table :data="tableData.data" v-loading="tableData.loading">
            <el-table-column label="商品信息">
                <template v-slot="scope">
                    <div class="shop_info">
                        <el-image :src="scope.row.imgUrl"
                            style="width: 50px;height: 50px;border-radius: 4px;background-color: #efefef;">
                            <div class="img_error" slot="error">
                                <i class="icon el-icon-document-delete"></i>
                            </div>
                        </el-image>
                        <div class="info">
                            <span>{{ scope.row.name }}</span>
                        </div>
                    </div>
                </template>
            </el-table-column>
            <el-table-column label="有效存酒" prop="savNum"></el-table-column>
            <el-table-column label="已过期存酒" prop="expNum"></el-table-column>
        </el-table>
    </div>
</template>

<script>
import { countRecord } from '@/api/application'
export default {
    data() {
        return {
            tableData: {
                data: [],
                page: 0,
                size: 10,
                loading: false,
                total: 0
            }
        }
    },
    mounted() {
        this.getTableData()
    },
    methods: {
        // 分页回调
        paginationChange(e) {
            this.tableData.page = e - 1
            this.getTableData()
        },
        // 获取商品列表
        async getTableData() {
            try {
                this.tableData.loading = true
                const res = await countRecord({
                    page: this.tableData.page,
                    size: this.tableData.size
                })
                this.tableData.loading = false
                this.tableData.data = res.content
                this.tableData.total = res.totalElements
            } catch (error) {
                console.log(error)
            }
        }
    }
}
</script>

<style scoped lang="scss">
.shop_info {
    display: flex;

    .info {
        flex: 1;
        padding-left: 8px;
        display: flex;
        flex-direction: column;

        .tag_wrap {
            display: flex;
        }
    }
}
</style>