import type { VxeGridProps, VxeColumnPropTypes } from 'vxe-table';
import XEUtils from 'xe-utils';

interface VxeColumn {
  type?: string;
  field?: string;
  title?: string;
  width?: number | string;
  minWidth?: number | string;
  maxWidth?: number | string;
  sortable?: boolean;
  formatter?: (value: any) => string;
  treeNode?: boolean;
  slots?: {};
  visible?: boolean;
  editRender?: {};
  align?: string;
  showOverflow?: boolean | string;
  fixed?: string;
  filters?: [] | {};
  filterMethod?: any;
  filterMethodTp?: string;
  filterRender?: any;
}

export const tableFormData = {
  serialNumber: '1',
  project: '信息科技重大项目情况表',
  code: 'TB4001',
  type: 'VxeTable',
  showFooter: false,
  rowHeight: 96,
  columns: [
    { type: 'seq', visible: true, width: '60', showOverflow: false },
    { field: 'COL1', title: '项目名称', width: 180, editRender: { name: 'VxeInput' } },
    { field: 'COL2', title: '项目实现功能', width: 200, editRender: { name: 'VxeTextarea', rows: 3 } },

    {
      field: 'COL3',
      title: '实施情况',
      width: 120,
      editRender: { name: 'VxeSelect', options: ['新增', '执行中', '完成', '已取消'] },
      slots: { edit: 'select', default: 'default_select' },
    },

    {
      field: 'COL4',
      title: '项目类别',
      width: 150,
      editRender: { name: 'VxeSelect', options: ['软件类(银行业)', '软件类(保险业)', '基础设施类', '其他'] },
      slots: { edit: 'select', default: 'default_select' },
    },

    {
      field: 'COL5',
      title: '软件类细分',
      width: 150,
      showHeaderOverflow: true,
      editRender: {
        name: 'VxeSelect',
        getOptions: (row: any) => {
          if (row?.COL4 === '软件类(银行业)') {
            return ['综合业务', '渠道管理', '客户管理', '产品管理', '财务管理', '决策支持', '共享支持', '其他'];
          }
          if (row?.COL4 === '软件类(保险业)') {
            return ['核心业务', '销售服务', '客户管理', '综合管理', '财务管理', '内控合规', '其他'];
          }
          return [];
        },
      },
      slots: { edit: 'select_dynamic', default: 'default_select' },
    },
    {
      field: 'COL99',
      title: '其他(软件类别)',
      width: 200,
      showHeaderOverflow: true,
      editRender: { name: 'VxeInput' },
      slots: { edit: 'input', default: 'default_input' },
    },
    {
      field: 'COL6',
      title: '其他(项目类别)',
      width: 200,
      editRender: { name: 'VxeInput' },
      slots: { edit: 'other_input', default: 'default_other' },
    },
    { field: 'COL7', title: '合同金额(万元)', width: 140, showHeaderOverflow: true, editRender: { name: 'VxeNumberInput' } },

    { field: 'COL8', title: '计划上线日期', width: 160, editRender: { name: 'VxeDatePicker' } },
    { field: 'COL9', title: '项目开始日期', width: 160, editRender: { name: 'VxeDatePicker' } },
    { field: 'COL10', title: '实际完成日期', width: 160, editRender: { name: 'VxeDatePicker' } },
    { field: 'C20A001', title: '项目取消日期', width: 160, editRender: { name: 'VxeDatePicker' }, visible: (row) => row.COL3 == '已取消' },

    {
      field: 'COL11',
      title: '实施模式',
      width: 160,
      editRender: { name: 'VxeSelect', options: ['自主研发(建设)', '整体外包', '部分外包'] },
      slots: { edit: 'select', default: 'default_select' },
    },

    { field: 'COL12', title: '创新点和意义', width: 180, showHeaderOverflow: true, editRender: { name: 'VxeTextarea', rows: 3 } },
    { field: 'COL13', title: '新技术应用情况', width: 180, showHeaderOverflow: true, editRender: { name: 'VxeTextarea', rows: 3 } },
    { field: 'COL14', title: '备注', width: 160, editRender: { name: 'VxeInput' } },
    { title: '操作', slots: { default: 'action' }, width: 120 },
  ],

  data: [{ COL1: '', COL2: '', COL3: '', COL4: '', COL5: '', COL6: '', COL7: '', COL99: '' }],
};
