
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: 'TM1002',
    content: [
      { type: "text", value: "(1) 监管部门发布的上期基础软硬件产品缺陷信息通报中涉及本机构缺陷数量：" },
      { type: "number", value: "", unit: "个", field: "COL31" },
      { type: "br" },
      { type: "text", value: "(2) 根据历史通报，本月处置基础软硬件产品缺陷数量合计：" },
      { type: "number", value: "", unit: "台/套/次", field: "C23A001" },
      { type: "brspace" },
      { type: "text", value: "涉及本机构重要信息系统数量：" },
      { type: "number", value: "", unit: "个", field: "C23A002" },
    ],
    remarks: {
      rows:3,
      field:"C23A002"
    }
  },
  {
    serialNumber: "2",
    project: "本月新发现基础软硬件产品缺陷清单",
    code: 'TM1001',
    type: "MultiColumnTable",
    content: [
      { 
        name: "产品类型", 
        formType: 'radio-group', 
        field: "COL1", 
        options: [
          "机房基础设施", "服务器", "存储", "网络设备", "信息安全设备", 
          "操作系统", "数据库", "中间件"
        ],
        otherOption: true,
        otherFormType: 'input',
        otherField: "COL0"
      },
      { name: "设备型号/软件版本", formType: 'input', field: "COL3" },
      { name: "配件型号", formType: 'input', field: "COL4" },
      { name: "软件版本", formType: 'input', field: "COL5" },
      { name: "生产厂家", formType: 'input', field: "COL7" },
      { 
        name: "缺陷情况外在表现", 
        formType: 'textarea', 
        field: "COL9",
        width: 200
      },
      { 
        name: "缺陷情况实际影响", 
        formType: 'checkbox-group', 
        field: "COL11",
        options: [
          "敏感数据损毁、丢失、泄露", "服务水平下降", "业务运营中断"
        ],
        otherOption: true,
        otherFormType: 'input',
        otherField: "COL10"
      },
      { 
        name: "缺陷情况潜在影响", 
        formType: 'checkbox-group', 
        field: "COL13",
        options: [
          "敏感数据损毁、丢失、泄露", "服务水平下降", "业务运营中断"
        ],
        otherOption: true,
        otherFormType: 'input',
        otherField: "COL12"
      },
      { 
        name: "缺陷原因", 
        formType: 'textarea', 
        field: "COL14",
        width: 200
      },
      { 
        name: "缺陷发现途径", 
        formType: 'radio-group', 
        field: "COL16",
        options: ["自主发现", "生产厂家主动提示"],
        otherOption: true,
        otherFormType: 'input',
        otherField: "COL17"
      },
      { 
        name: "解决方案已采取措施", 
        formType: 'textarea', 
        field: "COL19",
        width: 200
      },
      { 
        name: "生产厂家提供的解决方案", 
        formType: 'textarea', 
        field: "COL20",
        width: 200
      },
      { 
        name: "补丁版本", 
        formType: 'input', 
        field: "COL22"
      },
      { 
        name: "发现时间", 
        formType: 'date', 
        field: "COL24"
      },
      { 
        name: "解决情况", 
        formType: 'radio-group', 
        field: "COL26",
        options: ["已解决", "未解决"]
      },
      { 
        name: "缺陷信息联系人", 
        formType: 'input', 
        field: "COL28"
      },
      { 
        name: "缺陷信息联系电话", 
        formType: 'input', 
        field: "COL29"
      }
    ],
    datas: [],
    remarks: {
      rows:3,
      field:"C23A002"
    }
  }
];

export const attachmentData = [
  { name: "基础软硬件产品缺陷详细报告", field: "TM1001.COL30" },
  { name: "生产厂家提供的解决方案文件", field: "TM1001.COL21" }
];

// 数据结构定义
export interface TM1002 {
  COL31?: string; // 上期通报涉及本机构缺陷数量
  C23A001?: string; // 本月处置缺陷数量合计
  C23A002?: string; // 涉及重要信息系统数量
  COL34?: string; // 备注
}

export interface TM1001Item {
  COL1?: string; // 产品类型
  COL0?: string; // 其他产品类型
  COL3?: string; // 设备型号
  COL4?: string; // 配件型号
  COL5?: string; // 软件版本
  COL7?: string; // 生产厂家
  COL9?: string; // 缺陷外在表现
  COL11?: string; // 缺陷实际影响
  COL10?: string; // 其他实际影响
  COL13?: string; // 缺陷潜在影响
  COL12?: string; // 其他潜在影响
  COL14?: string; // 缺陷原因
  COL16?: string; // 缺陷发现途径
  COL17?: string; // 其他发现途径
  COL19?: string; // 已采取措施
  COL20?: string; // 厂家解决方案
  COL22?: string; // 补丁版本
  COL24?: string; // 发现时间
  COL26?: string; // 解决情况
  COL28?: string; // 联系人
  COL29?: string; // 联系电话
  COL30?: string; // 备注
}

export interface TM1Data {
  FILLIN_DEPT?: string; // 填报部门
  FILLIN_DATE?: string; // 填报日期
  FILLIN_PERSON?: string; // 填报人
  TELEPHONE?: string; // 联系电话
  RES_PERSON?: string; // 负责人
  jiaoyanwei?: string; // 校验位
  isempty?: string; // 是否为空
  itTitle?: string; // 表格标题
  itVersion?: string; // 版本号
  TM1002?: TM1002; // 监管部门通报情况处置结果
  TM1001?: TM1001Item[]; // 本月新发现缺陷清单
}

// 示例数据
export const sampleTM1Data: TM1Data = {
  FILLIN_DEPT: "",
  FILLIN_DATE: "",
  FILLIN_PERSON: "",
  TELEPHONE: "",
  RES_PERSON: "",
  jiaoyanwei: "0",
  isempty: "0",
  itTitle: "T-M-1 基础软硬件产品缺陷信息表",
  itVersion: "23A",
  TM1002: {
    COL31: "",
    C23A001: "",
    C23A002: "",
    COL34: ""
  },
  TM1001: [createEmptyTM1001Item()]
};

// 创建空数据函数
export function createEmptyTM1Data(): TM1Data {
  return {
    ...sampleTM1Data,
    TM1001: [createEmptyTM1001Item()]
  };
}

// 创建空的TM1001项
export function createEmptyTM1001Item(): TM1001Item {
  return {
    COL1: "",
    COL0: "",
    COL3: "",
    COL4: "",
    COL5: "",
    COL7: "",
    COL9: "",
    COL11: "",
    COL10: "",
    COL13: "",
    COL12: "",
    COL14: "",
    COL16: "",
    COL17: "",
    COL19: "",
    COL20: "",
    COL22: "",
    COL24: "",
    COL26: "",
    COL28: "",
    COL29: "",
    COL30: ""
  };
}