<template>
<div>
    <el-dialog
        :close-on-click-modal="false"
        width="900px"
        title="选择对照"
        :visible.sync="visible"
        append-to-body>
        <el-card class="el-card">
            <el-form
                :inline="true"
                :model="queryParams"
                size="mini">
                <el-form-item>
                    <el-input
                        v-model="queryParams.name"
                        size="mini"
                        placeholder="请输入通用名称"
                    ></el-input>
                </el-form-item>
                <el-form-item>
                    <el-input v-model="queryParams.manufactureName" placeholder="请输入生产企业" clearable/>
                </el-form-item>
                <el-form-item>
                    <el-input v-model="queryParams.distributorName" placeholder="请输入配送企业" clearable/>
                </el-form-item>

                <el-form-item>
                    <el-input v-model="queryParams.regNum" placeholder="请输入注册证号" clearable/>
                </el-form-item>
                <el-form-item>
                    <el-input v-model="queryParams.model" placeholder="请输入型号" clearable/>
                </el-form-item>
                <el-form-item>
                    <el-input v-model="queryParams.spec" placeholder="请输入规格" clearable/>
                </el-form-item>

                <el-form-item>
                    <el-date-picker
                        :picker-options="pickerOptions"
                        v-model="dateRange"
                        type="daterange"
                        format="yyyy 年 MM 月 dd 日"
                        value-format="yyyy-MM-dd"
                        range-separator="至"
                        start-placeholder="开始日期"
                        end-placeholder="结束日期"
                    >
                    </el-date-picker>
                </el-form-item>
                <el-form-item>
                    <el-button-group>
                        <el-button
                            type="primary"
                            icon="el-icon-refresh"
                            @click="onReset"
                        ></el-button>
                        <el-button type="primary" icon="search" @click="onSubmit"
                        >查询
                        </el-button
                        >

                    </el-button-group>
                </el-form-item>

            </el-form>
            <el-table
                v-loading="loading"
                :data="list"
                style="width: 100%"
                @row-click="rowClick"
            >
                <el-table-column label="选择" width="50px">
                    <template slot-scope="scope">
                        <el-radio :label="scope.row.deliveryGoodsId" v-model="selectValue.deliveryGoodsId">&nbsp;</el-radio>
                    </template>
                </el-table-column>
                <el-table-column label="ID" prop="deliveryGoodsId"/>
                <el-table-column label="产品名称" prop="productName"/>
                <el-table-column label="联采目录编码" prop="projectGoodsCode"/>
                <el-table-column label="医保编码" prop="medicalCode"/>

            </el-table>
            <el-pagination
                :current-page="queryParams.page"
                :page-size="queryParams.limit"
                @current-change="handleCurrentChange"
                layout="prev, pager, next"
                :total="total"
            ></el-pagination>


        </el-card>
        <span slot="footer" class="dialog-footer">
            <el-button @click="visible = false">取 消</el-button>
            <el-button type="primary" @click="selectAction">选好了</el-button>
        </span>
    </el-dialog>

</div>
</template>

<script>
import {GetList} from "@/api/udplat/udplatGoods";
import myMinix from './minixs/commMinixs';
export default {
    name: "selectGoods",
    props:{
        dialogVisible:Boolean
    },
    data(){
        return{
            queryParams: {
                page: 1,
                limit: 10,
                name: "",
                manufactureName: "",
                distributorName: "",
                regNum: "",
                model: "",
                spec: ""
            },
            selectValue:{
                deliveryGoodsId:"",
                medicalCode:""
            }
        }
    },
    computed:{
        visible:{
            get(){return this.dialogVisible},
            set(val){
                this.$emit("updateVisible",val);
            }
        }
    },
    mixins:[myMinix],
    methods:{
        getList() {
            this.loading = true;
            GetList(this.addDateRange(this.queryParams, this.dateRange)).then(res => {
                this.loading = false;
                this.list = res.data.list || [];
                this.total = res.data.total || 0;
            }).catch(error => {
                this.$message.error(error);
                this.loading = false;
            })
        },
        rowClick(row){
            console.log(row);
            this.selectValue.deliveryGoodsId = row.deliveryGoodsId;
            this.selectValue.medicalCode = row.medicalCode;
        },
        selectAction(){
            this.$emit("selectAction",this.selectValue);
            this.visible = false;
        }
    }
}
</script>

<style scoped>

</style>
