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

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: 'typename',
    width: 120,
  },
  {
    title: '图斑面积',
    dataIndex: 'area',
    width: 100,
  },
  {
    title: '农用地面积',
    dataIndex: 'nongyongdiarea',
    width: 100,
  },
  {
    title: '耕地面积',
    dataIndex: 'gengdiarea',
    width: 100,
  },
  {
    title: '永农面积',
    dataIndex: 'yongjiujibennongtianarea',
    width: 100,
  },
  {
    title: '当前状态',
    dataIndex: 'handlestatusname',
    width: 80,
  },
  {
    title: '下发时间',
    dataIndex: 'identificationtime',
  },
  {
    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: 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',
        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 },
  },
];
