<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";

const columns = [
    {
        title: '编号',
        dataIndex: 'key',
    },
    {
        title: '任务编号',
        dataIndex: 'key',
    },
    {
        title: '子任务编号',
        dataIndex: 'key',
    },
    {
        title: '文字',
        dataIndex: 'key',
    },
    {
        title: '图片',
        dataIndex: 'image',
        slotName: 'image',
    },
    {
        title: '来源',
        dataIndex: 'key',
    },
    {
        title: 'ID',
        dataIndex: 'key',
    },
    {
        title: '类型',
        dataIndex: 'key',
    },
    {
        title: '时间',
        dataIndex: 'key',
    },
    {
        title: '操作',
        dataIndex: 'action',
        slotName: 'action',
        width: 110,
        fixed: 'right',
    },
];
const FilterConfig = [
    {
        key: 'm_code',
        type: 'input',
        label: '任务编号',
        placeholder: '请输入任务编号',
    },
    {
        key: 'uid',
        type: 'input',
        label: '子任务编号',
        placeholder: '请输入子任务编号',
    },
    {
        key: 'status',
        type: 'select',
        label: '审核状态',
        placeholder: '请选择审核状态',
        api: async () => {
            return await Api.admin.getStatusAttr();
        },
    },
    {
        key: 'pattern',
        type: 'select',
        label: '类型',
        placeholder: '请选择类型',
        span: 6,
        api: async () => {
            return await Api.admin.getPattenAttr();
        },
    },
    {
        key: 'type',
        type: 'select',
        label: '来源',
        placeholder: '请选择来源',
        span: 6,
        api: async () => {
            return await Api.admin.getTypeAttr();
        },
    },
    {
        key: 'code',
        type: 'input',
        label: 'ID',
        placeholder: '请输入ID',
        span: 6,
    },
    {
        key: 'rangeTime',
        start: 'start_time',
        end: 'end_time',
        type: 'datetime',
        label: '创建日期',
        span: 6,
    }
];

const rowSelection = reactive({
    type: 'checkbox',
    showCheckedAll: true,
    onlyCurrent: false,
});
const po = reactive({
    pass: 0
});
const vo = reactive({
    page: '',
    rows: [],
    total: 0,
});

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

<template>
    <!-- 消息审核 -->
    <a-card>
        <Filter
            @search="initFetchData"
            v-model:from="po"
            :config="FilterConfig">
        </Filter>

        <a-table
            :row-selection="rowSelection"
            :data="vo.rows"
            @page-change="(e) => pagination.current = e"
            :pagination="pagination"
            :loading="loading"
            :columns="columns"
            class="flex-grow">
            <template v-slot:image>
                <a-image
                    width="40px"
                    height="40px"
                    src="https://p1-arco.byteimg.com/tos-cn-i-uwbnlip3yd/a8c8cdb109cb051163646151a4a5083b.png~tplv-uwbnlip3yd-webp.webp">
                </a-image>
            </template>

            <template v-slot:action>
                <div class="flex items-center gap-[20px]">
                    <a-link :hoverable="false" status="success">通过</a-link>
                    <a-link :hoverable="false" status="danger">拒绝</a-link>
                </div>
            </template>
        </a-table>
    </a-card>
</template>

<style scoped>

</style>
