import { BasicColumn, FormSchema } from '@/components/Table';
import { getChildrenTree } from '@/api/demo/system';
import { yearOptions, nowStatusOptions } from '@/utils/global';
import { getLoad } from '@/api/sys/sysDataItemDetail';
import { getAppEnvConfig } from '@/utils/env';

const {  VITE_GLOB_GEOSERVER_PREFECTURE_CITY } = getAppEnvConfig();

export const columns: BasicColumn[] = [
  // {
  //   title: '线索来源',
  //   dataIndex: 'tubanlaiyuan',
  //   width: 120,
  // },
  {
    title: '区县',
    dataIndex: 'countyname',
    width: 100,
  },
  {
    title: '乡镇',
    dataIndex: 'streetname',
    width: 100,
  },
  {
    title: '社区/村',
    dataIndex: 'communityname',
    width: 100,
  },
  {
    title: '备案编号',
    dataIndex: 'caseno',
    width: 200,
  },
  {
    title: '项目名称',
    dataIndex: 'xiangmumc',
    width: 200,
  },
  {
    title: '备案时间',
    dataIndex: 'beianshijian',
    width: 120,
  },
  {
    title: '线索状态',
    dataIndex: 'handlestatusname',
    width: 120,
  },
  {
    title: '线索面积',
    dataIndex: 'area',
    width: 100,
  },
  {
    title: '农用地面积',
    dataIndex: 'nongyongdiarea',
    width: 100,
  },
  {
    title: '耕地面积',
    dataIndex: 'gengdiarea',
    width: 100,
  },
  {
    title: '永农面积',
    dataIndex: 'yongjiujibennongtianarea',
    width: 100,
  },
  {
    title: '生态红线面积',
    dataIndex: 'shengtaihongxianarea',
    width: 100,
  },
  {
    title: '林保面积',
    dataIndex: 'linbaoarea',
    width: 100,
  },
  {
    title: '情况说明',
    dataIndex: 'pandingyijushuoming',
    width: 120,
  },
];

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: 'stxftbly' },
  //       // 接口参数
  //       resultField: 'result',
  //       labelField: 'itemName',
  //       valueField: 'itemValue',
  //       mode: 'multiple',
  //       maxTagCount: 1
  //     };
  //   },
  // },
  // {
  //   field: 'picihao',
  //   label: '批次',
  //   component: 'ApiSelect',
  //   colProps: { span: 4 },
  //   componentProps: ({ formModel }) => {
  //     return {
  //       api: getLoad,
  //       params: { code: 'stxfpc' },
  //       // 接口参数
  //       resultField: 'result',
  //       labelField: 'itemName',
  //       valueField: 'itemValue',
  //     };
  //   },
  // },
  // {
  //   field: 'typename',
  //   label: '线索类型',
  //   component: 'ApiSelect',
  //   colProps: { span: 4 },
  //   componentProps: ({ formModel }) => {
  //     return {
  //       api: getLoad,
  //       params: { code: 'stxftblx' },
  //       // 接口参数
  //       resultField: 'result',
  //       labelField: 'itemName',
  //       valueField: 'itemValue',
  //     };
  //   },
  // },
  {
    field: 'countyid',
    label: '区县',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: ({ formModel }) => {
      return {
        api: getChildrenTree,
        params: { parentId: VITE_GLOB_GEOSERVER_PREFECTURE_CITY },
        // 接口参数
        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',
        placeholder: '请先选择区县',
      };
    },
  },
  {
    field: 'nowStatus',
    label: '线索状态',
    component: 'Select',
    colProps: { span: 4 },
    slot: 'dangqianzhuangtai',
  },
  // 增加线索面积、耕地面积、永农面积的筛选项；
  {
    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: 'caseNo',
    label: '编号',
    component: 'Input',
    colProps: { span: 5 },
  },
];
