<template>
    <div>
        <el-card class="el-card">
            <div>
                <el-form :inline="true" :model="query" style="display: flex" size="mini">

                    <el-form-item class="query-form-item">
                        <el-input v-model="query.key" placeholder="搜索" style="width: 300px" clearable="true"></el-input>
                    </el-form-item>
                    <el-form-item style="display: flex">
                        <el-button-group>
                            <el-button type="primary" icon="search" @click="getList">查询</el-button>
                            <el-button type="primary" size="mini" icon="search" @click="combine"
                                       :loading="combineLoading"
                            >选入
                            </el-button>
                        </el-button-group>
                    </el-form-item>
                </el-form>

                <el-table
                    v-loading="loading"
                    :data="list"
                    highlight-current-row
                    @current-change="handleSelectChange"
                    style="width: 100%"
                >
                    <el-table-column label="序号" type="index"></el-table-column>
                    <el-table-column
                        label="往来单位编码"
                        prop="erpId"
                        show-overflow-tooltip
                    ></el-table-column>
                    <el-table-column
                        label="第三方主系统ID"
                        prop="thirdId"
                        show-overflow-tooltip
                    ></el-table-column>
                    <el-table-column
                        label="名称"
                        prop="name"
                        show-overflow-tooltip
                    ></el-table-column>
                    <el-table-column
                        label="简写"
                        prop="spell"
                        show-overflow-tooltip
                    ></el-table-column>
                    <el-table-column
                        label="社会信用号"
                        prop="creditNo"
                        show-overflow-tooltip
                    ></el-table-column>
                    <el-table-column
                        label="地址"
                        prop="addr"
                        show-overflow-tooltip
                    ></el-table-column>

                </el-table>

            </div>
        </el-card>
        <el-pagination
            :page-size="query.limit"
            @current-change="handleCurrentChange"
            layout="prev, pager, next"
            :total="total"
            :current-page="query.page"
        ></el-pagination>
    </div>
</template>

<script>
import {combineSingle, getBasicUnitMaintains} from "../../api/basic/basicUnitMaintain";

export default {
    name: "combinType",
    props: {
        closeDialog: {
            type: Function,
            required: true,
        },

    },
    data() {
        return {
            query: {
                key: "",
                page: 1,
                limit: 20,
            },
            total: 0,
            loading: false,
            list: [],
            currentRow: null,
            combineLoading: false,
        };
    },
    methods: {
        handlepageChange(val) {
            this.unitQuery.page = val;
            this.getList();
        },
        handleErppageChange(val) {
            this.erpQuery.page = val;
            this.getErpList();
        },
        onReset() {
            this.$router.push({
                path: "",
            });
            this.query = {
                key: "",
                page: 1,
                limit: 20,
            };
            this.getList();
        },
        getList() {
            this.loading = true;
            getBasicUnitMaintains(this.query)
                .then((response) => {
                    this.loading = false;
                    this.list = response.data.page.list || [];
                    this.total = response.data.page.total || 0;
                })
                .catch(() => {
                    this.loading = false;
                    this.list = [];
                    this.total = 0;
                });
        },


        handleSelectChange(val) {
            this.currentRow = val;
        },

        handleCurrentChange(val) {
            this.query.page = val;
            this.getList();
        },
        combine() {
            this.closeDialog(this.currentRow);
        },
        handleSelectionUdiChange(val) {
            console.log("----" + val[0].id);
            this.multipleUdiSelection = val;
        },
    },
    created() {
    },
};
</script>

<style scoped>

</style>
