import { BasicColumn, FormSchema } from '@/components/Table';
import { h } from 'vue';
import { Tag } from 'ant-design-vue';

export const columns: BasicColumn[] = [
    {
        title: 'id',
        dataIndex: 'id',
        ifShow: false,
    },
    {
        title: 'taskId',
        dataIndex: 'taskId',
        ifShow: false,
    },
    {
        title: 'taskGroupId',
        dataIndex: 'taskGroupId',
        ifShow: false,
    },
    {
        title: '任务名称',
        dataIndex: 'taskName',
        width: 180,
        // customRender: ({ record }) => {
        //     return record.taskName + '（' + record.beginNum + '-' + record.endNum + '）';
        // },
    },
    {
        title: '任务说明',
        dataIndex: 'taskRemark',
        width: 180,
    },
    {
        title: '领取任务状态',
        dataIndex: 'taskState',
        width: 100,
        customRender: ({ record }) => {
            const enable = record.isComplate;
            const color = enable ? 'green' : 'red';
            const text = enable ? '已完成' : '未完成';
            return h(Tag, { color: color }, () => text);
        },
    },
    {
        title: '领取时间',
        dataIndex: 'reciveTime',
        width: 120,
    },
    {
        title: '接收人',
        dataIndex: 'reciveUserId',
        width: 100,
    },
    {
        title: '接收人图斑数量',
        dataIndex: 'tubanNum',
        customRender: ({ record }) => {
            return record.tubanNum + ' （' + record.beginNum + '-' + record.endNum + '）';
        },
        width: 200,
    },
    // {
    //     title: '领取人备注',
    //     dataIndex: 'remark',
    // },
    {
        title: '操作',
        dataIndex: 'action',
        width: 150,
        fixed: 'right',
    },
];

// import { LoadAllUsers } from '@/api/task/index';
// export const allUsersOptions = await LoadAllUsers();

export const searchFormSchema: FormSchema[] = [
  {
    field: 'key',
    label: '任务名称',
    component: 'Input',
    colProps: { span: 6 },
  },
//   {
//     field: 'reciveUserId',
//     label: '接收人',
//     component: 'Select',
//     colProps: { span: 6 },
//     componentProps: {
//         placeholder: '请选择',
//         options: allUsersOptions.items.map(item => ({
//             label: item.name,
//             value: item.id,
//           })),
//       },
//   },
];
