import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { rules } from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';

export const columns: BasicColumn[] = [
  {
    title: '任务名称',
    dataIndex: 'rwmc',
  },
  {
    title: '下载内容',
    dataIndex: 'xznr',
  },
  {
    title: '下载阶段',
    dataIndex: 'xzjd',
  },
  {
    title: '地块数量',
    dataIndex: 'dksl',
  },
  {
    title: '生成状态',
    dataIndex: 'status',
    customRender: ({ record }: any) => {
      if (record.status == 1) {
        return '执行中';
      } else if (record.status == 2) {
        return '已完成';
      } else if (record.status == 3) {
        return '错误';
      } else {
        return '未开始';
      }
    },
  },
  {
    title: '有效期（截止至最后日期24点）',
    dataIndex: 'yxq',
  },
  {
    title: '创建时间',
    dataIndex: 'scsj',
  },
  {
    title: '生成时间',
    dataIndex: 'scsj',
  },
];
export const columnsHis: BasicColumn[] = [
  {
    title: '任务名称',
    dataIndex: 'rwmc',
  },
  {
    title: '下载内容',
    dataIndex: 'xznr',
  },
  {
    title: '下载阶段',
    dataIndex: 'xzjd',
  },
  {
    title: '地块数量',
    dataIndex: 'dksl',
  },
  {
    title: '有效期（截止至最后日期24点）',
    dataIndex: 'yxq',
  },
  {
    title: '创建时间',
    dataIndex: 'scsj',
  },
  {
    title: '生成时间',
    dataIndex: 'scsj',
  },
];
export const searchFormSchema: FormSchema[] = [
  {
    label: '任务名称',
    field: 'rwmc',
    component: 'Input',
  },
  {
    label: '生成状态',
    field: 'status',
    component: 'Select',
    componentProps: {
      options: [
        { label: '未开始', value: 0 },
        { label: '执行中', value: 1 },
        { label: '已完成', value: 2 },
        { label: '错误', value: 3 },
      ],
    },
  },
  {
    label: '有效期',
    field: 'yxq',
    component: 'DatePicker',
  },
];

export const formSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  { label: '', field: 'id', component: 'Input', show: false },
  { label: '', field: 'bz', component: 'Input', show: false },
  { label: '', field: 'dksl', component: 'Input', show: false },
  {
    label: '任务名称',
    field: 'rwmc',
    component: 'Input',
    required: true,
  },
  {
    label: '下载内容',
    field: 'xznr',
    component: 'CheckboxGroup',
    required: true,
    componentProps: {
      name: '下载内容',
      options: [
        { label: '报告', value: '报告' },
        { label: '边界文件', value: '边界文件' },
        { label: '边界图片', value: '边界图片' },
      ],
    },
  },
  {
    label: '下载阶段',
    field: 'xzjd',
    component: 'CheckboxGroup',
    required: true,
    componentProps: {
      name: '下载阶段',
      options: [
        { label: '调查阶段', value: '调查阶段' },
        { label: '风评阶段', value: '风评阶段' },
        { label: '管控修复', value: '管控修复' },
        { label: '效果评估', value: '效果评估' },
      ],
    },
  },
  {
    label: '文件上传',
    field: 'url',
    component: 'JUpload',
    slot: 'uploadDk'
  },
  {
    label: '文件上传',
    field: 'dkbmFile',
    component: 'Input',
    show: false
  },
];
