<template>
    <div>
        <el-card>
            <el-form :inline="true" :model="query" size="mini">
                <el-row>
                    <el-form-item class="query-form-item">
                        <el-input v-model="filterQuery.billNo" placeholder="UDI编码"></el-input>
                    </el-form-item>

                    <el-form-item>
                        <el-button-group style="display:flex;">
                            <el-button type="primary" icon="el-icon-refresh" @click="onReset"></el-button>
                            <el-button type="primary" icon="search" @click="getList">查询</el-button>
                        </el-button-group>
                    </el-form-item>
                </el-row>
            </el-form>

            <el-table
                v-loading="loading"
                :data="list"
                style="width: 100%"
            >
                <el-table-column label="序号" type="index"></el-table-column>
                <el-table-column label="单据号" prop="billNo"></el-table-column>
                <el-table-column label="往来单位ID" prop="corpId"
                                 show-overflow-tooltip="true"></el-table-column>
                <el-table-column label="往来单位" prop="corpName"
                                 show-overflow-tooltip="true"></el-table-column>

                <el-table-column label="扫码单据类型" prop="billType">
                </el-table-column>
                <el-table-column label="单据状态" prop="billFlag" width="80" show-overflow-tooltip="true"></el-table-column>
                <el-table-column label="单据日期" prop="billdate" show-overflow-tooltip="true"></el-table-column>
                <el-table-column label="产品编码" prop="productId" show-overflow-tooltip="true"></el-table-column>
                <el-table-column label="产品名称" prop="productName" show-overflow-tooltip="true"></el-table-column>
                <el-table-column label="规格型号" prop="spec" show-overflow-tooltip="true"></el-table-column>
                <el-table-column label="批次号" prop="batchNo" show-overflow-tooltip="true"></el-table-column>
                <el-table-column label="生产日期" prop="productDate" show-overflow-tooltip="true"></el-table-column>
                <el-table-column label="失效日期" prop="expireDate" show-overflow-tooltip="true"></el-table-column>
                <el-table-column label="单据数量" prop="reCount" show-overflow-tooltip="true"></el-table-column>
                <el-table-column label="实际数量" prop="count" show-overflow-tooltip="true"></el-table-column>
            </el-table>
            <el-pagination
                :page-size="filterQuery.limit"
                @current-change="handleCurrentChange"
                layout="prev, pager, next"
                :total="total"
            ></el-pagination>

        </el-card>
    </div>
</template>

<script>
    import {
        filterDetail,
    } from "../../api/thrsys/thrOrderImport";

    export default {
        name: "ThrOrderImportDetail",
        props: {
            currentRow: {
                type: Object,
                required: true,
            },

        },
        data() {
            return {
                filterQuery: {
                    genKey: null,
                    billNo: null,
                    status: null,
                    page: 1,
                    limit: 10,
                },
                list: [],
                detailList: [],
                total: 0,
                status: {
                    0: "未处理",
                    1: "处理失败",
                    2: "处理成功"
                },
            };
        },

        methods: {
            onReset() {
                this.$router.push({
                    path: "",
                });
                this.filterQuery = {
                    genKey: null,
                    billNo: null,
                    status: null,
                    page: 1,
                    limit: 10,
                };
                this.getList();
            },
            getList() {
                this.loading = true;
                console.log(" this.genKey = " + this.currentRow)
                this.filterQuery.genKey = this.currentRow.genKey;
                filterDetail(this.filterQuery)
                    .then((response) => {
                        if (response.code == 20000) {
                            this.list = response.data.list || [];
                            this.total = response.data.total || 0;
                        }else {
                            this.$message.error(response.message);
                        }
                        this.loading = false;
                    })
                    .catch(() => {
                        this.loading = false;
                        this.list = [];
                        this.total = 0;
                    });
            },
            statusFilterType(status) {
                const statusMap = {
                    0: "warning",
                    1: "danger",
                    2: "success",
                };
                return statusMap[status];
            },
            handleCurrentChange(val) {
                this.filterQuery.page = val;
                this.getList();
            },
        },
        mounted() {
        },
        created() {
            this.getList();
        },
        filters: {},
    };
</script>
<style>
    .itemTag {
        float: left;
        text-align: left;
        margin-top: 10px;
        width: 100px;
    }

    .text {
        font-size: 13px;
        font-family: "Microsoft YaHei";
    }

    .el-row {
        display: flex;
        flex-wrap: wrap;

    }

    .el-col {
        border-radius: 4px;
        flex-wrap: wrap;
    }
</style>
