<script setup>
import {reactive} from "vue";
import useTableQuery from "../../../../hooks/useTableQuery.js";
import Api from "../../../../api/index.js";
import Filter from "../../../../components/Filter/index.vue";
import EditInfoModal from "./components/EditInfoModal.vue";

const columns = [
    {
        title: '商家ID',
        dataIndex: 'uid',
    },
    {
        title: '昵称',
        dataIndex: 'nickname',
    },
    {
        title: '头像',
        dataIndex: 'avatar',
    },
    {
        title: '手机号',
        dataIndex: 'mobile',
    },
    {
        title: '微信号',
        dataIndex: 'wechat',
        slotName: 'image',
    },
    {
        title: '状态',
        dataIndex: 'status_text',
        slotName: 'status_text',
    },
    {
        title: '邀请人',
        dataIndex: 'puid',
    },
    {
        title: '入驻日期',
        dataIndex: 'createtime',
    },
    {
        title: '操作',
        dataIndex: 'action',
        slotName: 'action',
        width: 120,
    },
];
const FilterConfig = [
    {
        key: 'uid',
        type: 'input',
        label: '商家ID',
        placeholder: '请输入商家ID',
    },
    {
        key: 'puid',
        type: 'input',
        label: '邀请人',
        placeholder: '请输入邀请人',
    },
    {
        key: 'mobile',
        type: 'input',
        label: '手机号',
        placeholder: '请输入手机号',
    },
    {
        key: 'status',
        type: 'select',
        label: '状态',
        placeholder: '请选择状态',
        api: async () => ({
            data: [
                {
                    name: '禁用',
                    id: 0,
                },
                {
                    name: '可用',
                    id: 1,
                },
            ]
        }),
    },
    {
        key: 'rangeTime',
        start: 'start_time',
        end: 'end_time',
        type: 'datetime',
        label: '入驻时间',
    },
    {
        key: 'wd',
        type: 'datetime',
        label: '确认结算金额所属日期',
    },
];

const po = reactive({
    wd: null,
});
const vo = reactive({
    page: '',
    rows: [],
    total: 0,
});

const {loading, pagination, initFetchData} = useTableQuery({
    parameter: po,
    api: Api.admin.getBusinessList,
    callback: (data) => {
        Object.assign(vo, data);
    }
});
</script>

<template>
    <!-- 商家账号 -->
    <a-card>
        <Filter
            @search="initFetchData"
            v-model:from="po"
            :config="FilterConfig">
        </Filter>

        <a-table
            :data="vo.rows"
            @page-change="(e) => pagination.current = e"
            :pagination="pagination"
            :loading="loading"
            :columns="columns"
            class="flex-grow">
            <template v-slot:status_text>
                状态
            </template>
            <template v-slot:action>
                <div class="flex gap-[20px]">
                    <EditInfoModal></EditInfoModal>
                    <a-link :hoverable="false">卡密</a-link>
                </div>
            </template>
        </a-table>
    </a-card>
</template>

<style scoped>

</style>
