<template>
    <div class="ProductQuery">
        <h2 style="margin-bottom: 20px;padding-bottom:7px;border-bottom:2px solid #ddd">产品追溯</h2>
        <header id="header">
            <el-row type="flex" :gutter="20">
                <el-col :span="4">
                    <el-input v-model="search" placeholder="请选择"></el-input>
                </el-col>
                <el-col :span="4">
                    <el-button type="primary" @click="getProductQueryList">查找</el-button>
                </el-col>
            </el-row>
        </header>
        <section>
            <article class="table">
                <el-table
                    ref="multipleTable"
                    :data="tableData"
                    tooltip-effect="dark"
                    style="width: 100%"
                >
                    <el-table-column prop="id" label="序号" width="80"></el-table-column>
                    <el-table-column prop="productCode" label="产品编码"></el-table-column>
                    <el-table-column prop="productName" label="产品名称"></el-table-column>
                    <el-table-column prop="saleNo" label="销售单号"></el-table-column>
                    <el-table-column prop="buyer" label="购买人"></el-table-column>
                    <el-table-column prop="splitTime" label="分割时间"></el-table-column>
                    <el-table-column prop="saleNo" label="分割时间"></el-table-column>
                    <el-table-column prop="acidTime" label="排酸时间"></el-table-column>
                    <el-table-column prop="slaughterTime" label="屠宰时间"></el-table-column>
                    <el-table-column prop="quarantineTime" label="检疫时间"></el-table-column>
                    <el-table-column prop="quarantineResult" label="检疫结果"></el-table-column>
                    <el-table-column prop="acquisitionTime" label="收购时间"></el-table-column>
                    <el-table-column prop="placeOrigin" label="来源牧场"></el-table-column>
                    <el-table-column prop="sheepId" label="羊只编码"></el-table-column>
                    <el-table-column prop="sheepWeight" label="羊只重量"></el-table-column>
                </el-table>

                <el-row type="flex" justify="end">
                    <el-col :span="8" class="pagination">
                        <el-pagination
                            @current-change="pageChange"
                            background
                            layout="prev, pager, next"
                            :page-count="Number(totalPages)"
                        ></el-pagination>
                    </el-col>
                </el-row>
            </article>
        </section>

        
    </div>
</template>

<script>
import {
    reqProductQueryList,
} from "@/api/storeTransportation.js";

const pageSize = 10;
const rules = {};

export default {
    name: "ProductQuery",
    data() {
        return {
            search: "",
            page: 1,
            tableData: [],
            totalPages: 0,
            isShow: false,
            rules
        };
    },
    created() {
        // 产品追溯列表
        this.getProductQueryList();
    },
    methods: {
        //
        // 产品追溯列表
        getProductQueryList() {
            reqProductQueryList({
                searchStr: this.search,
                pageSize,
                pageNum: this.page
            })
                .then(res => {
                    this.tableData = res.content;
                    this.totalPages = res.totalPages;
                })
                .catch(err => {
                    console.log(err);
                });
        },
        pageChange(p) {
            console.log(p);
            this.page = p;
            // 产品追溯列表
            this.getProductQueryList();
        }
    }
};
</script>

<style lang="scss" scoped>
#header {
    margin-bottom: 15px;
}
.table {
    .pagination {
        margin-top: 20px;
    }
}
</style>