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: 'wrdkbm'
  },
  {
    title: '推送内容',
    dataIndex: 'node'
  },
  {
    title: '推送地址',
    dataIndex: 'url'
  },
  {
    title: '推送参数',
    dataIndex: 'param'
  },
  {
    title: '推送结果',
    dataIndex: 'rest'
  },
  {
    title: '状态',
    dataIndex: 'status',
    resizable: true,
    customRender: ({ record }: any) => {
      return record.status == 1 ? '成功' : '失败'
    },
    align: 'center'
  },
  {
    title: '推送时间',
    dataIndex: 'tsamp'
  },

];

export const searchFormSchema: FormSchema[] = [
  {
    label: '污染地块编码',
    field: 'wrdkbm',
    component: 'Input'
  },
];

export const formSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  { label: '', field: 'id', component: 'Input', show: false },
  {
    label: '污染地块编码',
    field: 'wrdkbm',
    component: 'Input',
    componentProps: {
      disabled: true
    },
  },
  {
    label: '推送内容',
    field: 'node',
    component: 'Input',
    componentProps: {
      disabled: true
    },
  },
  {
    label: '推送地址',
    field: 'url',
    component: 'Input',
    componentProps: {
      disabled: true
    },
  },
  {
    label: '推送参数',
    field: 'param',
    component: 'Input',
    componentProps: {
      disabled: true
    },
  },
  {
    label: '推送结果',
    field: 'rest',
    component: 'Input',
    componentProps: {
      disabled: true
    },
  },
  {
    label: '状态',
    field: 'status',
    component: 'Select',
    componentProps: () => {
      return {
        options: [
          {
            label: '成功',
            value: 1,
          },
          {
            label: '失败',
            value: 0,
          },
        ],
        disabled: true
      };
    },
  },
  {
    label: '推送时间',
    field: 'tsamp',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD hh:mm:ss',
      disabled: true
    },
  },
];
