import { BasicColumn, FormSchema } from '@/components/Table';
import { getChildrenTree } from '@/api/demo/system';
import {
  patchSourceOptions,
  yearOptions,
  markTypeOptions,
  nowStatusOptions,
  mapTypeOptions,
} from '@/utils/global';

export const columns: BasicColumn[] = [
  {
    title: '图斑来源',
    dataIndex: 'tubanlaiyuan',
  },
  {
    title: '区县',
    dataIndex: 'countyname',
    width: 100,
  },
  {
    title: '乡镇',
    dataIndex: 'streetname',
  },
  {
    title: '社区/村',
    dataIndex: 'communityname',
  },
  {
    title: '图斑编号',
    dataIndex: 'caseno',
    width: 200,
  },
  {
    title: '图斑类型',
    dataIndex: 'typename',
    width: 80,
  },
  {
    title: '图斑面积',
    dataIndex: 'area',
  },
  {
    title: '耕地面积',
    dataIndex: 'gengdiarea',
  },
  {
    title: '永农面积',
    dataIndex: 'yongjiujibennongtianarea',
  },
  {
    title: '当前状态',
    dataIndex: 'handlestatusname',
    width: 80,
  },
  {
    title: '判定结果',
    dataIndex: 'isillegal',
    width: 80,
  },
  {
    title: '下发时间',
    dataIndex: 'identificationtime',
  },
  {
    title: '项目名称',
    dataIndex: 'xiangmumc',
  },
  {
    title: '项目主体',
    dataIndex: 'xiangmuzhuti',
  },
  {
    title: '实际用途',
    dataIndex: 'actualuseto',
  },
  {
    title: '违法类型',
    dataIndex: 'weifaleixing',
  },
  {
    title: '整改措施',
    dataIndex: 'measurename',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'year',
    component: 'Select',
    colProps: { span: 4 },
    label: '年份',
    componentProps: {
      options: yearOptions,
    },
  },
  {
    field: 'tubanlaiyuan',
    label: '图斑来源',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: patchSourceOptions,
    },
  },
  {
    field: 'picihao',
    label: '批次',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: [],
    },
  },
  {
    field: 'typename',
    label: '图斑类型',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: [
        { label: '农用地', value: '农用地' },
        { label: '建设用地', value: '建设用地' },
        { label: '推堆土', value: '推堆土' },
      ],
    },
  },
  {
    field: 'isBuildName',
    label: '标注类型',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: markTypeOptions,
    },
  },
  {
    field: 'isIllegal',
    label: '判定结果',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: mapTypeOptions,
    },
  },
  {
    field: 'nowStatus',
    label: '当前状态',
    component: 'Select',
    componentProps: {
      options: nowStatusOptions,
    },
    colProps: { span: 4 },
  },
  {
    field: 'measureName',
    label: '整改措施',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: [
        { label: '拆除复耕', value: '0' },
        { label: '补办手续', value: '1' },
      ],
    },
  },
  {
    field: 'countyid',
    label: '区县',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: ({ tableAction, formModel }) => {
      return {
        api: getChildrenTree,
        params: { parentId: 371300 },
        // 接口参数
        resultField: 'result',
        labelField: 'name',
        valueField: 'id',
        onChange: () => {
          formModel.streetid = '';
        },
      };
    },
  },
  {
    field: 'streetid',
    label: '乡镇',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: ({ formModel }) => {
      return {
        api: formModel.countyid && getChildrenTree,
        params: { parentId: formModel.countyid },
        // 接口参数
        resultField: 'result',
        labelField: 'name',
        valueField: 'id',
      };
    },
  },
  {
    field: 'caseNo',
    label: '图斑编号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: 'originalcaseno',
    label: '标识号',
    component: 'Input',
    colProps: { span: 4 },
  },
  // 增加图斑面积、耕地面积、永农面积的筛选项；
  {
    field: 'tubanmianji',
    label: '图斑面积',
    colProps: { span: 4 },
    slot: 'tubanmianji',
  },
  {
    field: 'gengdimianji',
    label: '耕地面积',
    colProps: { span: 4 },
    slot: 'gengdimianji',
  },
  {
    field: 'jibennongtianmianji',
    label: '永农面积',
    colProps: { span: 4 },
    slot: 'jibennongtianmianji',
  },
];
