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

const columns = [
    {
        title: '商家ID',
        dataIndex: 'key',
    },
    {
        title: '昵称',
        dataIndex: 'key',
    },
    {
        title: '头像',
        dataIndex: 'key',
    },
    {
        title: '手机号',
        dataIndex: 'key',
    },
    {
        title: '微信号',
        dataIndex: 'image',
        slotName: 'image',
    },
    {
        title: '状态',
        dataIndex: 'status',
        slotName: 'status',
    },
    {
        title: '邀请人',
        dataIndex: 'key',
    },
    {
        title: '上上',
        dataIndex: 'key',
    },
    {
        title: '上上上',
        dataIndex: 'key',
    },
    {
        title: '等级',
        dataIndex: 'key',
    },
    {
        title: '入驻日期',
        dataIndex: 'key',
    },
    {
        title: '分佣比例',
        dataIndex: 'key',
    },
    {
        title: '任务收益',
        dataIndex: 'key',
    },
    {
        title: '操作',
        dataIndex: 'action',
        slotName: 'action',
        width: 140,
    },
];
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: 'rangTime',
        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.getUserList,
    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>
                状态
            </template>
            <template v-slot:action>
                <div class="flex gap-[20px]">
                    <EditExpertInfoModal></EditExpertInfoModal>
                    <a-link :hoverable="false">快速进入</a-link>
                </div>
            </template>
        </a-table>
    </a-card>
</template>

<style scoped>

</style>
