import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '事件编号',
    align:"center",
    dataIndex: 'id'
   },
   {
    title: '事件名称',
    align:"center",
    dataIndex: 'eventName'
   },
   {
    title: '事件类型',
    align:"center",
    sorter: true,
    dataIndex: 'eventType_dictText'
   },
   {
    title: '发现时间',
    align:"center",
    sorter: true,
    dataIndex: 'discTime',
    customRender:({text}) =>{
      return !text?"":(text.length>15?text.substr(0,15):text)
    },
   },
   {
    title: '结束时间',
    align:"center",
    dataIndex: 'endTime',
    customRender:({text}) =>{
      return !text?"":(text.length>15?text.substr(0,15):text)
    },
   },
   {
    title: '影响等级',
    align:"center",
    sorter: true,
    dataIndex: 'linkLevel_dictText'
   },
   {
    title: '处置状态',
    align:"center",
    sorter: true,
    dataIndex: 'checkStatus_dictText'
   },

   {
    title: '来源',
    align:"center",
    dataIndex: 'discFrom'
   },


   {
    title: '处置用时',
    align:"center",
    dataIndex: 'checkTime'
   },
   
   {
    title: '影响系统名称',
    align:"center",
    dataIndex: 'linkSystemName'
   },
   
   {
    title: '发现事件渠道',
    align:"center",
    dataIndex: 'discChannel'
   },
   {
    title: '事件描述',
    align:"center",
    dataIndex: 'eventDesc'
   },
   {
    title: '事件原因',
    align:"center",
    dataIndex: 'eventCause'
   },
   {
    title: '事件处理人/事件解决方法',
    align:"center",
    dataIndex: 'checkUser'
   },
   {
    title: '经办人',
    align:"center",
    dataIndex: 'dutyUser'
   },
   {
    title: '备注',
    align:"center",
    dataIndex: 'remark'
   },
   

   {
    title: '影响范围',
    align:"center",
    dataIndex: 'linkScope'
   },
   {
    title: '处置措施',
    align:"center",
    dataIndex: 'checkMethod'
   },
   {
    title: '处置结果',
    align:"center",
    dataIndex: 'checkResult'
   },

   {
    title: '控制项',
    align:"center",
    dataIndex: 'act'
   },
   /** 
   {
    title: '文件id',
    align:"center",
    dataIndex: 'fileId',
    slots: { customRender: 'fileSlot' },
   },
   {
    title: '相关附件',
    align:"center",
    dataIndex: 'filename'
   },
   */
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	
	{
      label: "事件名称",
      field: 'eventName',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "事件类型",
      field: 'eventType',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"event_type"
      },
      colProps: {span: 6},
 	},
   {
    label: "发现时间",
    field: 'discTime',
    component: 'DatePicker',
    colProps: {span: 6},
 },
	{
      label: "影响等级",
      field: 'linkLevel',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"link_level"
      },
      colProps: {span: 6},
 	},
	{
      label: "处置状态",
      field: 'checkStatus',
      component: 'JDictSelectTag',
      componentProps:{
          dictCode:"check_status"
      },
      colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  /** 
  {
    label: '事件编号',
    field: 'eventNo',
    component: 'Input',
  },
  */
  {
    label: '发现时间',
    field: 'discTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入发现时间!'},
          ];
     },
     componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    colProps: {
      span: 24,
    },
  },
  {
    label: '结束时间',
    field: 'endTime',
    component: 'DatePicker',
    componentProps: {
      showTime: true,
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
    },
    colProps: {
      span:24,
    },

  },
  {
    label: '处置用时',
    field: 'checkTime',
    component: 'Input',
  },
  {
    label: '事件名称',
    field: 'eventName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入事件名称!'},
          ];
     },
  },
  {
    label: '影响系统名称',
    field: 'linkSystemName',
    component: 'Input',
  },
  {
    label: '事件类型',
    field: 'eventType',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"event_type"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入事件类型!'},
          ];
     },
  },
  {
    label: '发现事件渠道',
    field: 'discChannel',
    component: 'Input',
  },
  {
    label: '事件描述',
    field: 'eventDesc',
    component: 'InputTextArea',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入事件描述!'},
          ];
     },
  },
  {
    label: '事件原因',
    field: 'eventCause',
    component: 'Input',
  },
  {
    label: '事件处理人/事件解决方法',
    field: 'checkUser',
    component: 'Input',
  },
  {
    label: '经办人',
    field: 'dutyUser',
    component: 'Input',
  },
  {
    label: '备注',
    field: 'remark',
    component: 'Input',
  },
  {
    label: '影响等级',
    field: 'linkLevel',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"link_level"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入影响等级!'},
          ];
     },
  },
  {
    label: '处置状态',
    field: 'checkStatus',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"check_status"
     },
  },
  {
    label: '影响范围',
    field: 'linkScope',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入影响范围!'},
          ];
     },
  },
  {
    label: '处置措施',
    field: 'checkMethod',
    component: 'InputTextArea',
  },
  {
    label: '处置结果',
    field: 'checkResult',
    component: 'InputTextArea',
  },
  {
    label: '来源',
    field: 'discFrom',
    component: 'Input',
  },
  {
    label: '控制项',
    field: 'act',
    component: 'Input',
  },
  /**
  {
    label: '文件id',
    field: 'fileId',
    component: 'InputNumber',
  },
  */
  {
    label: '相关附件',
    field: 'filename',
    component: 'JUpload',
    helpMessage: '无限制上传',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}