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

export const columns: BasicColumn[] = [
  {
    title: '年度',
    dataIndex: 'syear_base',
  },
  {
    title: '图斑编号',
    dataIndex: 'tubannum_base',
    width: 200,
  },
  {
    title: '区县',
    dataIndex: 'weizhixianname_base',
    width: 100,
  },
  {
    title: '乡镇',
    dataIndex: 'weizhizhenname_base',
  },
  {
    title: '社区/村',
    dataIndex: 'weizhicunname_base',
  },
  {
    title: '行政区划编码',
    dataIndex: 'communityname',
  },
  {
    title: '图斑类型',
    dataIndex: 'type_base',
  },
  {
    title: '矿种',
    dataIndex: 'kuangzhong_kcfill',
  },
  {
    title: '图斑变化情况说明',
    dataIndex: 'shuoming_fill',
  },
  {
    title: '所属重点矿区名称',
    dataIndex: 'zhongdianname_base',
  },
  {
    title: '所在国家自热保护区名称',
    dataIndex: 'ziranbaohuname_base',
    width: 200,
  },
  {
    title: '图斑面积',
    dataIndex: 'weifaarea_base',
  },
  {
    title: '耕地面积',
    dataIndex: 'gengdi_area',
  },
  {
    title: '违法开采面积',
    dataIndex: 'kaicaiarea_kcfill',
  },
  {
    title: '违法占地面积',
    dataIndex: 'weifaarea_punish',
  },
  {
    title: '是否持续违法',
    dataIndex: 'handlestatusname',
  },
  {
    title: '当前状态',
    dataIndex: 'status_base',
  },
  {
    title: '判定结果',
    dataIndex: 'hefapanding_fill',
  },
  {
    title: '下发时间',
    dataIndex: 'xiafatime_base',
  },
  {
    title: '项目主体',
    dataIndex: 'kaicaizhuti_kcfill',
  },
  {
    title: '开采违法类型',
    dataIndex: 'wefatype_kcfill',
  },
  {
    title: '加工违法类型',
    dataIndex: 'weifatype_jgfill',
  },
  {
    title: '整改措施',
    dataIndex: 'zhenggaitype_jgzhg',
  },
  {
    title: '处理时限',
    dataIndex: 'chulishixian_base',
  },
  // 表里没有备注
  // {
  //   title: '备注',
  //   dataIndex: 'measurename',
  // },
];
export const searchFormSchema: FormSchema[] = [
  {
    field: 'syear_base',
    component: 'Select',
    colProps: { span: 4 },
    label: '年度',
    componentProps: {
      options: yearOptions,
    },
  },
  {
    field: 'tubanlaiyuan',
    label: '图斑来源',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: ({ formModel }) => {
      return {
        api: getLoad,
        params: { code: 'tubanlaiyuan' },
        // 接口参数
        resultField: 'result',
        labelField: 'itemName',
        valueField: 'itemValue',
      };
    },
  },
  {
    field: 'type_base',
    label: '图斑类型',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: ({ formModel }) => {
      return {
        api: getLoad,
        params: { code: 'kctubanleixing' },
        // 接口参数
        resultField: 'result',
        labelField: 'itemName',
        valueField: 'itemValue',
      };
    },
  },
  {
    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: 'status_base',
    label: '当前状态',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: ({ formModel }) => {
      return {
        api: getLoad,
        params: { code: 'kcdangqianzhuangtai' },
        // 接口参数
        resultField: 'result',
        labelField: 'itemName',
        valueField: 'itemValue',
      };
    },
    slot: 'dangqianzhuangtai',
  },

  {
    field: 'hefapanding_fill',
    label: '判定结果',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: ({ formModel }) => {
      return {
        api: getLoad,
        params: { code: 'kcpandingjieguo' },
        // 接口参数
        resultField: 'result',
        labelField: 'itemName',
        valueField: 'itemValue',
      };
    },
  },

  {
    field: 'zhenggaitype_jgzhg',
    label: '整改措施',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: ({ formModel }) => {
      return {
        api: getLoad,
        params: { code: 'kczhenggaicuoshi' },
        // 接口参数
        resultField: 'result',
        labelField: 'itemName',
        valueField: 'itemValue',
      };
    },
  },

  {
    field: 'wefatype_kcfill',
    label: '开采违法类型',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: ({ formModel }) => {
      return {
        api: getLoad,
        params: { code: 'kaicaiweifa' },
        // 接口参数
        resultField: 'result',
        labelField: 'itemName',
        valueField: 'itemValue',
      };
    },
  },
  {
    field: 'weifatype_jgfill',
    label: '加工违法类型',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: ({ formModel }) => {
      return {
        api: getLoad,
        params: { code: 'jiagongweifa' },
        // 接口参数
        resultField: 'result',
        labelField: 'itemName',
        valueField: 'itemValue',
      };
    },
  },
  // 增加图斑面积、耕地面积、永农面积的筛选项；
  {
    field: 'tubanmianji',
    label: '图斑面积',
    colProps: { span: 4 },
    slot: 'tubanmianji',
  },
  {
    field: 'zhongdianflag_base',
    label: '是否重点矿区',
    component: 'Select',
    colProps: { span: 4 },
    componentProps: {
      options: [
        { label: '全部', value: null },
        { label: '是', value: '是' },
        { label: '否', value: '否' },
      ],
    },
  },
  {
    field: 'kuangzhong_kcfill',
    label: '权属矿种',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: ({ formModel }) => {
      return {
        api: getLoad,
        params: { code: 'kuangzhong' },
        // 接口参数
        resultField: 'result',
        labelField: 'itemName',
        valueField: 'itemValue',
      };
    },
  },
  {
    field: '[startTime, endTime]',
    label: '日期范围',
    component: 'RangePicker',
    componentProps: {
      format: 'YYYY-MM-DD',
      placeholder: ['开始日期', '结束日期'],
    },
    colProps: { span: 6 },
  },
  {
    field: 'tubannum_base',
    label: '图斑编号',
    component: 'Input',
    colProps: { span: 6 },
  },
];
