<template>
    <el-form :inline="true" :model="unitquery" class="query-form" size="mini">
        <el-form-item class="query-form-item">
            <el-input v-model="unitquery.key" placeholder="搜索"></el-input>
        </el-form-item>
        <el-form-item>
            <el-button
                type="primary"
                icon="search"
                @click.native.stop="getUnitList()"
            >查询
            </el-button
            >
        </el-form-item>
    </el-form>

    <el-table
        v-loading="loading"
        :data="unitlist"
        style="width: 100%"
        @row-click="selectUnit"
    >
        <el-table-column
            label="往来单位ID"
            prop="erpId"
            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="addr"
            show-overflow-tooltip
        ></el-table-column>
        <el-table-column label="状态" prop="status"></el-table-column>
        <el-table-column label="类型" prop="type"></el-table-column>
    </el-table>
</template>

<script>
import {updateUnit} from "@/api/warehouse/order";
import {getBasicUnitMaintains} from "@/api/basic/basicUnitMaintain";

export default {
    name: "DialogSelectUnit",
    data() {
        return {
            unitquery: {key: "", page: 1, limit: 20},
            unitlist: [],
            unitUpdateQuery: {
                id: "",
                fromCorpId: "",
                fromCorp: "",
            },
        }
    },
    methods: {
        getUnitList() {
            this.loading = true;
            getBasicUnitMaintains(this.unitquery)
                .then((response) => {
                    this.loading = false;
                    this.unitlist = response.data.page.list || [];
                })
                .catch(() => {
                    this.loading = false;
                });
        },
        selectUnit(row) {
            console.log(row.id);
            this.$emit("selectUnit", row);
        },
    },
}
</script>

<style scoped>

</style>
