import { BasicColumn, FormSchema } from '/@/components/Table';
import { getTown } from '/@/api/common/api';
import { useUserStore } from '/@/store/modules/user';

const userStore: any = useUserStore();

export const columns: BasicColumn[] = [
  {
    title: '标识代码',
    dataIndex: 'bsm',
    resizable: true,
  },
  {
    title: '要素代码',
    dataIndex: 'ysdm',
    resizable: true,
  },
  {
    title: '行政区代码',
    dataIndex: 'xzqdm',
    resizable: true,
  },
  {
    title: '行政区名称',
    dataIndex: 'xzqmc',
    resizable: true,
  },
  {
    title: '地块名称',
    dataIndex: 'dkmc',
    resizable: true,
  },
  {
    title: '地块编码',
    dataIndex: 'dkdm',
    resizable: true,
  },
  {
    title: '地块面积',
    dataIndex: 'ydmj',
    resizable: true,
  },
  {
    title: '地块土壤污染风险管控和修复阶段',
    dataIndex: 'dktrwrfxgkhxfjd',
    resizable: true,
  },
  {
    title: '土壤污染风险管控和修复阶段完成时间',
    dataIndex: 'trwrfxgkhxfjdwcsj',
    resizable: true,
    customRender: ({ text }) => {
      if (text && text.length === 8) {
        return text.substring(0, 4) + '-' + text.substring(4, 6) + '-' + text.substring(6, 8);
      } else {
        return text;
      }
    },
  },
  {
    title: '土壤环境质量',
    dataIndex: 'trhjzl',
    resizable: true,
  },
  {
    title: '地下水质量',
    dataIndex: 'dxszl',
    resizable: true,
  },
  {
    title: '土壤污染风险评估情况',
    dataIndex: 'trwrfxpgqk',
    resizable: true,
  },
  {
    title: '土壤污染风险管控和修复名录管理情况',
    dataIndex: 'trwrfxgkhxfmlglqk',
    resizable: true,
  },
  {
    title: '后期管理要求',
    dataIndex: 'hqglyq',
    resizable: true,
  },
  {
    title: '地块数据最新更新时间',
    dataIndex: 'dksjzxgxsj',
    resizable: true,
    customRender: ({ text }) => {
      if (text) {
        return text.substring(0, 4) + '-' + text.substring(4, 6) + '-' + text.substring(6, 8);
      } else {
        return '';
      }
    },
  },
  {
    title: '备注',
    dataIndex: 'bz',
    resizable: true,
  },
];
let year = new Date().getFullYear();
let month = new Date().getMonth();

const getNd = () => {
  let nd = 2025;
  if (month < 3) {
    nd = year -1
  } else {
    nd = year;
  }
  return nd +'';
}
const getJd = () => {
  let jd = '04';
  if (month < 3) {
    jd = '04';
  } else if (month < 6) {
    jd = '01';
  } else if (month < 9) {
    jd = '02';
  } else{
    jd = '03';
  }
  return jd;
}

// T1：填报中 DSL：待受理 T2：待评审 SH：评审通过 SHBTG：评审不通过 SHHDWS：评审后待完善 BPS：不评审 DKDTC：地块待退出 DKYTC：地块已退出
export const searchFormSchema: FormSchema[] = [
  {
    label: '年度',
    field: 'nd',
    component: 'DatePicker',
    defaultValue: getNd(),
    componentProps: {
      style: { width: '100%' },
      picker: 'year',
      format:'YYYY',
      valueFormat:'YYYY',
    },
  },
  {
    label: '季度',
    field: 'jd',
    component: 'Select',
    defaultValue: getJd(),
    componentProps: {
      options: [
        {
          label: '第一季度',
          value: '01',
        },
        {
          label: '第二季度',
          value: '02',
        },
        {
          label: '第三季度',
          value: '03',
        },
        {
          label: '第四季度',
          value: '04',
        },
      ],
    },
  },
];

export const formSchema: FormSchema[] = [
  // TODO 主键隐藏字段，目前写死为ID
  { label: '', field: 'id', component: 'Input', show: false },
  {
    label: '市编码',
    field: 'code',
    component: 'Input',
  },
  {
    label: '接收人',
    field: 'jsr',
    component: 'Input',
  },
  {
    label: '文件',
    field: 'wjlj',
    component: 'Input',
  },
  {
    label: '说明',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '审核',
    field: 'audits',
    component: 'Input',
  },
  {
    label: '操作人名称',
    field: 'createName',
    component: 'Input',
  },
];
