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",
    width:100,
    dataIndex: 'fillYear',
    sorter: true,
    resizable:true,
   },
   {
    title: '季度',
    align:"center",
    width:100,
    dataIndex: 'fillQuarter',
    sorter: true,
    resizable:true,
   },
   {
    title: '计划内停止分钟',
    align:"center",
    width:100,
    dataIndex: 'stopTimelen',
    sorter: true,
    resizable:true,
   },
   {
    title: '计划外停止分钟',
    align:"center",
    width:100,
    dataIndex: 'planStopTimelen',
    sorter: true,
    resizable:true,
   },
  //  {
  //   title: '总运行分钟数',
  //   align:"center",
  //   width:10,
  //   dataIndex: 'totalTimelen',
  //   sorter: true,
  //   resizable:true,
  //  },
   {
    title: '事件发生次数',
    align:"center",
    width:100,
    dataIndex: 'eventCount'
   },
   {
    title: '紧急变更次数',
    align:"center",
    width:100,
    dataIndex: 'eventCount'
   },
   {
    title: '运行故障次数',
    align:"center",
    width:100,
    dataIndex: 'eventCount'
   }, 
  //  {
  //   title: '填报时间',
  //   align:"center",
  //   width:140,
  //   dataIndex: 'fillTime',
  //   customRender:({text}) =>{
  //     return !text?"":(text.length>10?text.substr(0,10):text)
  //   },
  //  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '年份',
    field: 'fillYear',
    component: 'Select',
    required:true,
    componentProps: () => {
      
      const currentYear = new Date().getFullYear();
      let lineYearOptions = [];
    
      for(let i=0;i<5;i++){
        let option = {}
        option["value"] = currentYear-i
        option["label"] = currentYear-i
        lineYearOptions.push(option)
      }
    
      return {
        type:'radio',
        options:lineYearOptions
      }
      
    }
  },
  {
    label: '选择季度',
    field: 'fillQuarter',
    component: 'Select',
    componentProps: {
      type: 'radio',
      options: [{
        label:'一季度',
        value:1
      },{
        label:'二季度',
        value:2
      },{
        label:'三季度',
        value:3
      },{
        label:'四季度',
        value:4
      }]
    },
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请选择!'}
      ];
    }
  },
  {
    label: '计划内停止时间',
    field: 'stopTimelen',
    component: 'InputNumber',
    required:true,
    suffix:'分钟'
  },
  {
    label: '计划外停止时间',
    field: 'planStopTimelen',
    component: 'InputNumber',
    required:true,
    suffix:'分钟'
  },
  // {
  //   label: '持续运行时间',
  //   field: 'totalTimelen',
  //   component: 'InputNumber',
  //   required:true,
  //   suffix:'分钟'
  // },
  {
    label: '事件发生数',
    field: 'eventCount',
    defaultValue:0,
    component: 'InputNumber',
    suffix:'次'
  },
   {
    label: '紧急变更',
    field: 'urgentCount',
    defaultValue:0,
    component: 'InputNumber',
    suffix:'次'
   },
   {
    label: '运行故障',
    defaultValue:0,
    field: 'fault_count',
    component: 'InputNumber',
    suffix:'次'
   }, 

	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
  {
	  label: '',
	  field: 'appSysId',
	  component: 'Input',
	  show: false
	},
  
];



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