import { BasicColumn } from '/@/components/Table';
import { FormSchema } from '/@/components/Table';
import { useMessage } from '/@/hooks/web/useMessage';
const { createMessage } = useMessage();
export const columns: BasicColumn[] = [
  {
    title: '专家姓名',
    dataIndex: 'zjxm',
  },
  {
    title: '地块名称',
    dataIndex: 'wrdkmc',
  },
  {
    title: '评分',
    dataIndex: 'pf',
  },
  {
    title: '审核意见',
    dataIndex: 'sfyj',
  },
  {
    title: '创建时间',
    dataIndex: 'createTsamp',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    label: '地块名称',
    field: 'wrdkmc',
    component: 'Input',
  },
  {
    label: '专家姓名',
    field: 'zjxm',
    component: 'Input',
  },
];

export const formSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  { label: '', field: 'id', component: 'Input', show: false },
  {
    label: '地块',
    field: 'wrdkid',
    required: true,
    component: 'Select',
    slot: 'wrdkid',
  },
  {
    label: '专家',
    field: 'zjcyId',
    required: true,
    component: 'Select',
    slot: 'zjcyId',
  },
  {
    label: '评分',
    field: 'pf',
    required: true,
    component: 'InputNumber',
  },
  {
    label: '审核意见',
    field: 'sfyj',
    required: true,
    component: 'InputTextArea',
    componentProps: {
      rows: 2,
    },
    colProps: { span: 24 },
  },
  {
    label: '审核附件',
    field: 'sffj',
    required: true,
    colProps: { span: 24 },
    component: 'JUpload',
    componentProps: () => {
      return {
        showUploadList: false,
        fileName: '审核附件',
        accept: '.pdf,.zip',
        beforeUpload: (file) => {
          let isshow = false;
          const isFile = file.name.split('.')[file.name.split('.').length - 1];
          if (isFile == 'pdf' || isFile == 'zip' || isFile == 'PDF') {
            isshow = true;
          } else {
            createMessage.error('只能上传.pdf/.zip格式的文件');
            isshow = false;
          }
          return isshow;
        },
      };
    },
  },
];
