<script setup>
import useTableQuery from "../../../../hooks/useTableQuery.js";
import Api from "../../../../api/index.js";
import {reactive} from "vue";
import {Message} from "@arco-design/web-vue";

const columns = [
    {
        title: 'ID',
        dataIndex: 'id',
    },
    {
        title: '渠道',
        dataIndex: 'platform',
    },
    {
        title: '已拉黑达人',
        dataIndex: 'uid',
    },
    {
        title: '拉黑原因',
        dataIndex: 'remark',
    },
    {
        title: '拉黑效果',
        dataIndex: 'type_text',
    },
    {
        title: '拉黑开始日期',
        dataIndex: 'createtime',
    },
    {
        title: '拉黑结束日期',
        dataIndex: 'endtime',
    },
    {
        title: '关联任务ID',
        dataIndex: 'task_id',
    },
    {
        title: '关联子任务ID',
        dataIndex: 'task_children_id',
    },
    {
        title: '操作',
        dataIndex: 'action',
        slotName: 'action',
        width: 100,
    },
]

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

const {loading, pagination, initFetchData, fetchData} = useTableQuery({
    parameter: po,
    api: Api.merchant.getTaskBlock,
    callback: (data) => {
        Object.assign(vo, data);
        console.log(vo);
    }
});

const cancelTaskBlock = async (id) => {
    const {msg} = await Api.merchant.cancelTaskBlock({id: id});
    Message.success(msg);
    await fetchData();
}
</script>

<template>
    <!-- 拉黑管理 -->
    <div class="mb-[20px]">
        <a-breadcrumb
            :routes="[{path: '/home/expert-management', label: '达人管理'}, {path: '/', label: '拉黑管理'},]">
        </a-breadcrumb>
    </div>

    <a-card>
        <div class="title">拉黑管理</div>

        <div class="flex-grow">
            <a-table
                class="h-full"
                :data="vo.rows"
                @page-change="(e) => pagination.current = e"
                :pagination="pagination"
                :loading="loading"
                :columns="columns">
                <template v-slot:action="{record}">
                    <a-popconfirm content="确定取消吗?" @ok="cancelTaskBlock(record.id)" v-if="record.is_cancel !== 1">
                        <a-link :hoverable="false" :disabled="false">取消拉黑</a-link>
                    </a-popconfirm>
                    <a-link :hoverable="false" :disabled="true" v-else>已取消</a-link>
                </template>
            </a-table>
        </div>
    </a-card>
</template>

<style lang="scss" scoped>
.title {
    color: rgb(29, 33, 41);
    font-size: 16px;
    font-weight: 400;
    line-height: 24px;
    letter-spacing: 0;
    margin-bottom: 20px;
}
</style>
