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;
  span?:number;
  fixed?:number | string;
  filters?: [] | {};
  filterMethod?: any;
  filterMethodTp?:string;
  filterRender?:any
}

const textFilterRender: VxeColumnPropTypes.FilterRender = {
  name: 'VxeInput'
}

function textFilterMethod ({ option, row, column }) {
  if (option.data) {
    return `${row[column.field]}`.indexOf(option.data) > -1
  }
  return true
}

export const complianceCol: VxeColumn[] = [
  {type:'seq',width:60},
  { field: 'cgrpPath', title: '分组',   sortable: true, span:1 ,type:'html',filters:[],filterMethodTp:'check'},
  { field: 'item', title: '条目',span:3,type:'html'},
  { field: 'content', title: '内容',span:3,type:'html'},
  { field: 'fileName', title: '参考文件', visible: true, type:"html", slots: { default: 'fileName_default' }, showOverflow: 'ellipsis',filters:[],filterMethodTp:'check'},
  { title: '操作', align: 'center', width: '15%', visible: true, fixed: 'right', slots: { default: 'operate' } },
];

export const innerCtlCol: VxeColumn[] = [
  {type:'seq',width:60},
  { field: 'strategy', title: '策略',span:3,type:'html'},
  { field: 'claim', title: '内控要求',span:3,type:'html'},
  { field: 'fileName', title: '参考文件', span: 3,type:'html', slots: { default: 'fileName_default' }, showOverflow: 'ellipsis',filters:[],filterMethodTp:'check'},
  { title: '操作', align: 'center', width: '15%', visible: true, fixed: 'right', slots: { default: 'operate' } },
];

export const innerCtlOrderCol: VxeColumn[] = [
  {type:'seq',width:60},
  { field: 'cgrpPath', title: '分组',   sortable: true, span:1 ,type:'html',filters:[],filterMethodTp:'check'},
  { field: 'item', title: '条目',span:3,type:'html'},
  { field: 'content', title: '内容',span:3,type:'html'},
  { field: 'fileName', title: '参考文件', visible: true, type:"html", slots: { default: 'fileName_default' }, showOverflow: 'ellipsis',filters:[],filterMethodTp:'check'},
  { title: '操作', align: 'center', width: '15%', visible: true, fixed: 'right', slots: { default: 'operate' } },
];

export const problemCol: VxeColumn[] = [
  {type:'seq',width:60},
  { field: 'pbItem', title: '问题项',span:3,type:'html'},
  { field: 'pbExample', title: '问题示例',span:3,type:'html'},
  { field: 'pbAdvise', title: '问题建议', span: 3,type:'html'},
  { field: 'pbAnalysis', title: '问题分析',span:3,type:'html'},
  { field: 'pbNature', title: '问题性质', span:3,type:'html'},
  { field: 'fileName', title: '参考文件', span: 3,type:'html', slots: { default: 'fileName_default' }, showOverflow: 'ellipsis',filters:[],filterMethodTp:'check'},
  { title: '操作', align: 'center', width: '15%', visible: true, fixed: 'right', slots: { default: 'operate' } },
];

export const checkMethodCol: VxeColumn[] = [
  {type:'seq',width:60},
  { field: 'content', title: '检查内容',span:3,type:'html'},
  { field: 'des', title: '备注', span:3,type:'html',visible:false},
  { field: 'fileName', title: '参考文件', span: 3,type:'html', slots: { default: 'fileName_default' }, showOverflow: 'ellipsis',filters:[],filterMethodTp:'check'},
  { title: '操作', align: 'center', width: '15%', visible: true, fixed: 'right', slots: { default: 'operate' } },
];

export const riskEventCol: VxeColumn[] = [
  {type:'seq',width:60},
  { field: 'riskEventName', title: '风险事件',span:3,type:'html'},
  { field: 'riskEventDesc', title: '风险事件描述',span:3,type:'html'},
  { field: 'fileName', title: '参考文件', span: 3,type:'html', slots: { default: 'fileName_default' }, showOverflow: 'ellipsis',filters:[],filterMethodTp:'check'},
  { title: '操作', align: 'center', width: '15%', visible: true, fixed: 'right', slots: { default: 'operate' } },
];

export const practiceCol: VxeColumn[] = [
  {type:'seq',width:60},
  { field: 'content', title: '行业实践',span:3,type:'html'},
  { field: 'exeRule', title: '执行规则',span:3,type:'html'},
  { field: 'fileName', title: '参考文件', span: 3,type:'html', slots: { default: 'fileName_default' }, showOverflow: 'ellipsis',filters:[],filterMethodTp:'check'},
  { title: '操作', align: 'center', width: '15%', visible: true, fixed: 'right', slots: { default: 'operate' } },
];

export const actCol: VxeColumn[] = [
  {type:'seq',width:60},
  { field: 'caName', title: '控制项名称',span:3,type:'html'},
  { field: 'caDesc', title: '说明',span:3,type:'html'},
  { field: 'domainName', title: '所属领域', span: 3,type:'html'},
  { field: 'labelNames', title: '标签', span: 3,type:'html'},
  { field: 'fileName', title: '参考文件', span: 3,type:'html', slots: { default: 'fileName_default' }, showOverflow: 'ellipsis',filters:[],filterMethodTp:'check'},
  { title: '操作', align: 'center', width: '15%', visible: true, fixed: 'right', slots: { default: 'operate' } },
];


export const auditCols = {
  1: complianceCol,
  2: innerCtlCol,
  3: innerCtlOrderCol,
  4: problemCol,
  5: checkMethodCol,
  6: riskEventCol,
  7: practiceCol,
  9: actCol,
};
