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

export const columns: BasicColumn[] = [
  {
    title: '项目编号',
    dataIndex: 'xiangmu_no',
  },
  {
    title: '项目名称',
    dataIndex: 'xiangmu_name',
    width: 200,
  },
  {
    title: '乡镇',
    dataIndex: 'streetname',
  },
  {
    title: '村庄',
    dataIndex: 'communityname',
  },
  {
    title: '权利人',
    dataIndex: 'quanliren',
  },
  {
    title: '联系方式',
    dataIndex: 'lianxifangshi',
  },
  {
    title: '行政区划',
    dataIndex: 'xingzhengquhua',
  },
  {
    title: '备案编号',
    dataIndex: 'beian_no',
  },
  {
    title: '备案日期',
    dataIndex: 'beianriqi',
    customRender: ({ text }) => {
      if (!text) return '';
      return dayjs(text).format('YYYY-MM-DD');
    },
  },
  {
    title: '项目状态',
    dataIndex: 'handle_status_name',
  },
  {
    title: '项目开始时间',
    dataIndex: 'start_time',
    width: 200,
    customRender: ({ text }) => {
      if (!text) return '';
      return dayjs(text).format('YYYY-MM-DD');
    },
  },
  {
    title: '项目结束时间',
    dataIndex: 'end_time',
    customRender: ({ text }) => {
      if (!text) return '';
      return dayjs(text).format('YYYY-MM-DD');
    },
  },
  {
    title: '设施农业类型',
    dataIndex: 'xiangmu_yt',
    width: 110,
  },
  {
    title: '建筑结构',
    dataIndex: 'jianzhujiegou',
    width: 110,
  },
  {
    title: '设施农业申请用地面积(公顷)',
    dataIndex: 'shenqing_area',
    width: 200,
  },
  {
    title: '生产设施用地(公顷)',
    dataIndex: 'shengchan_area',
    width: 200,
  },
  {
    title: '辅助设施用地(公顷)',
    dataIndex: 'fuzhu_area',
    width: 200,
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'xiangmu_no',
    component: 'Input',
    colProps: { span: 4 },
    label: '项目编号',
  },
  {
    field: 'xiangmu_name',
    component: 'Input',
    colProps: { span: 4 },
    label: '项目名称',
  },
  {
    field: 'xiangmu_yt',
    component: 'ApiSelect',
    colProps: { span: 4 },
    label: '设施农业类型',
    componentProps: ({ formModel }) => {
      return {
        api: getLoad,
        params: { code: 'ssnyddqyt' },
        resultField: 'result',
        labelField: 'itemName',
        valueField: 'itemValue',
        // mode: 'multiple',
        // maxTagCount: 1
      };
    },
  },
  {
    field: 'streetid',
    label: '乡镇',
    component: 'ApiSelect',
    colProps: { span: 4 },
    componentProps: ({ formModel }) => {
      return {
        api: getChildrenTree,
        params: { parentId: 371325 },
        // 接口参数
        resultField: 'result',
        labelField: 'name',
        valueField: 'id',
      };
    },
  },
];
