import { BasicColumn, FormSchema } from '@/components/Table';
import { getChildrenTree } from '@/api/demo/system';
import { getLoad } from '@/api/sys/sysDataItemDetail';
import {
  patchSourceOptions,
  yearOptions,
  markTypeOptions,
  keyProblemMapStatusOptions,
  keyIssuesIIMapTypeOptions,
} 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',
  },
  {
    title: '图斑面积',
    dataIndex: 'area',
    width: 110,
  },
  {
    title: '农用地面积',
    dataIndex: 'nongyongdiarea',
    width: 110,
  },
  {
    title: '耕地面积',
    dataIndex: 'gengdiarea',
    width: 110,
  },
  {
    title: '永农面积',
    dataIndex: 'yongjiujibennongtianarea',
    width: 110,
  },
  {
    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: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: ({ formModel }) => {
      return {
        api: getLoad,
        params: { code: 'zd2tbly' },
        // 接口参数
        resultField: 'result',
        labelField: 'itemName',
        valueField: 'itemValue',
        mode: 'multiple',
        maxTagCount: 1
      };
    },
  },
  {
    field: 'picihao',
    label: '批次',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: [],
    },
  },
  
  {
    field: 'typename',
    label: '图斑类型',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: ({ formModel }) => {
      return {
        api: getLoad,
        params: { code: 'zd2tblx' },
        // 接口参数
        resultField: 'result',
        labelField: 'itemName',
        valueField: 'itemValue',
      };
    },
  },
  {
    field: 'isBuildName',
    label: '标注类型',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: markTypeOptions,
    },
  },
  {
    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: 'communityid',
  //   label: '村',
  //   component: 'ApiSelect',
  //   colProps: { span: 4 },
  //   componentProps: ({ formModel }) => {
  //     return {
  //       api: formModel.countyid && formModel.streetid && getChildrenTree,
  //       params: { parentId: formModel.streetid },
  //       // 接口参数
  //       resultField: 'result',
  //       labelField: 'name',
  //       valueField: 'id',
  //     };
  //   },
  // },
  {
    field: 'nowStatus',
    label: '当前状态',
    component: 'Select',
    componentProps: {
      options: [],
    },
    colProps: { span: 4 },
    slot: 'dangqianzhuangtai',
  },
  {
    field: 'isIllegal',
    label: '判定结果',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: keyIssuesIIMapTypeOptions,
    },
  },
  // {
  //   field: 'weifaleixing',
  //   label: '违法类型',
  //   component: 'Select',
  //   colProps: { span: 4 },
  //   componentProps: {
  //     options: [
  //       { label: '非农化违法用地', value: '0' },
  //       { label: '非粮化违法用地', value: '1' },
  //     ],
  //   },
  // },
  {
    field: 'measureName',
    label: '整改措施',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: [
        { label: '拆除', value: '1' },
        { label: '没收', value: '2' },
      ],
    },
  },

  // 增加图斑面积、耕地面积、永农面积的筛选项；
  {
    field: 'tubanmianji',
    label: '图斑面积',
    colProps: { span: 4 },
    slot: 'tubanmianji',
  },
  {
    field: 'gengdimianji',
    label: '耕地面积',
    colProps: { span: 4 },
    slot: 'gengdimianji',
  },
  {
    field: 'jibennongtianmianji',
    label: '永农面积',
    colProps: { span: 4 },
    slot: 'jibennongtianmianji',
  },
  {
    field: 'originalcaseno',
    label: '标识号',
    component: 'Input',
    colProps: { span: 4 },
  },
  {
    field: '[startTime, endTime]',
    label: '下发时间',
    component: 'RangePicker',
    colProps: { span: 5 },
    componentProps: {
      format: 'YYYY-MM-DD',
      placeholder: ['开始日期', '结束日期'],
    },
  },
  {
    field: 'caseNo',
    label: '图斑编号',
    component: 'Input',
    colProps: { span: 6 },
  },
];
