import { BasicColumn, FormSchema } from '@/components/Table';
import { getChildrenTree } from '@/api/demo/system';
import {
  patchSourceOptions,
  yearOptions,
  markTypeOptions,
  kcNEWNowStatusOptions,
  mapTypeOptions,
} 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: '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',
  },

];

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',
        mode: 'multiple',
        maxTagCount: 1
      };
    },
  },
  {
    field: 'countyid',
    label: '区县',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: ({ tableAction, 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',
      };
    },
  },
  {
    field: 'status_base',
    label: '当前状态',
    component: 'Select',
    componentProps: {
      options: kcNEWNowStatusOptions,
      mode: 'multiple',
      maxTagCount: 1
    },
    colProps: { span: 4 },
  },
  {
    field: 'isIllegal',
    label: '判定结果',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: ({ formModel }) => {
      return {
        api: getLoad,
        params: { code: 'kcpandingjieguo' },
        // 接口参数
        resultField: 'result',
        labelField: 'itemName',
        valueField: 'itemValue',
      };
    },
  },
  {
    field: '[startTime, endTime]',
    label: '日期范围',
    component: 'RangePicker',
    colProps: { span: 8 },
    componentProps: {
      format: 'YYYY-MM-DD',
      placeholder: ['开始日期', '结束日期'],
    },
  },
  {
    field: 'tubannum_base',
    label: '线索编号',
    component: 'Input',
    colProps: { span: 6 },
  },
];
export const uploadColumns: BasicColumn[] = [
  {
    title: '名称',
    dataIndex: 'name',
    width: 150,
  },
  {
    title: '大小',
    dataIndex: 'size',
    width: 80,
  },
  {
    title: '进度',
    dataIndex: 'percent',
    width: 100,
  },
  {
    title: '状态',
    dataIndex: 'status',
    width: 80,
    align: 'center',
  },
  {
    title: '路径/上传图片失败原因',
    dataIndex: 'url',
    width: 280,
  },
];
