import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { left } from 'inquirer/lib/utils/readline';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '报告类型',
    align:"center",
    dataIndex: 'tp',
    resizable:true,
    sorter:true,
    width:100,
    customRender: ({ text }) => {
      return render.renderDict(text, 'metric_sta_report_tp');
    },
   },
   {
    title: '主标题',
    align:"left",
    dataIndex: 'heading',
    resizable:true,
    sorter:true,
    width:300
   },
   {
    title: '副标题',
    align:"left",
    dataIndex: 'subtitle',
    resizable:true,
    sorter:true,
    width:300
   },
   {
    title: '报告部门',
    align:"left",
    dataIndex: 'departId_dictText',
    resizable:true,
    sorter:true,
    width:180,
   },
   {
    title: '统计方法',
    align:"center",
    dataIndex: 'statMethod',
    resizable:true,
    sorter:true,
    width:100,
    customRender: ({ text }) => {
      return render.renderDict(text, 'metric_sta_method');
    },
   },
   {
    title: '评价标准【按低风险指标占比】',
    align:"center",
    children:[
      {
        title: '优秀【%】',
        align:"center",
        dataIndex: 'level1',
        resizable:true,
        sorter:true,
        width:100
      },
      {
        title: '良好【%】',
        align:"center",
        dataIndex: 'level2',
        resizable:true,
        sorter:true,
        width:100
      },
      {
        title: '一般【%】',
        align:"center",
        dataIndex: 'level3',
        resizable:true,
        sorter:true,
        width:100
      },
      {
        title: '较差【%】',
        align:"center",
        dataIndex: 'level4',
        resizable:true,
        sorter:true,
        width:100
      },
      {
        title: '差【%】',
        align:"center",
        dataIndex: 'level5',
        resizable:true,
        sorter:true,
        width:100
      },
    ]
  }
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '报告类型',
    field: 'tp',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'metric_sta_report_tp',
      type: 'radio',
      stringToNumber: true,
    }
  
  },
  {
    label: '主标题',
    field: 'heading',
    component: 'Input',
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '报告类型',
    field: 'tp',
    component: 'JDictSelectTag',
    defaultValue:2,
    componentProps: {
      dictCode: 'metric_sta_report_tp',
      type: 'radio',
      stringToNumber: true,
    },
    dynamicRules: ({model,schema}) => {
      return [
             { required: true},
      ];
    },
  },
  {
    label: '主标题',
    field: 'heading',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入主标题!'},
        { min: 0, max: 32, message: '长度不能超过 32 个字符', trigger: 'blur' },
      ];
    },
  },
  {
    label: '副标题',
    field: 'subtitle',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
        { required: true, message: '请输入副标题!'},
        { min: 0, max: 32, message: '长度不能超过 32 个字符', trigger: 'blur' },
      ];
    },
  },
  {
    label: '报告部门',
    field: 'departId',
    component: 'JSelectDept',
    componentProps: ({ formActionType, formModel }) => {
     
    },
    dynamicRules: ({model,schema}) => {
      return [
          { required: true,message: '请选择部门!'},
      ];
    },
  },
  {
    label: '统计方法',
    field: 'statMethod',
    component: 'JDictSelectTag',
    defaultValue:1,
    componentProps: {
      dictCode: 'metric_sta_method',
      type: 'radio',
      stringToNumber: true,
    }
  },
  {
    label: '',
    field: '',
    slot:'helpMessage',
    component: 'Input',
  },
  {
    label: '优秀',
    field: 'level1',
    suffix:'%，大于这个值为优秀',
    // colProps: {lg: 12},
    itemProps:{labelCol:{md: {span: 4},lg: {span: 4},},wrapperCol:{md: {span: 12},lg: {span: 12}}},
    component: 'InputNumber',
    componentProps:{
      placeholder:"大于等于0，小于等于100的值",
      max: 100, 
      min: 0,
    },
    dynamicRules: ({model,schema}) => {
      return [
             { required: true},
      ];
    },
 
  },
  {
    label: '良好',
    field: 'level2',
    suffix:'%，大于这个值为良好',
    // colProps: {lg: 12},
    itemProps:{labelCol:{md: {span: 4},lg: {span: 4},},wrapperCol:{md: {span: 12},lg: {span: 12}}},
    component: 'InputNumber',
    componentProps:{
      placeholder:"大于等于0，小于等于100的值",
      max: 100, 
      min: 0,
    },
    dynamicRules: ({model,schema}) => {
      return [
             { required: true},
      ];
    },
  },
  {
    label: '一般',
    field: 'level3',
    suffix:'%，大于这个值为一般',
    // colProps: {lg: 12},
    itemProps:{labelCol:{md: {span: 4},lg: {span: 4},},wrapperCol:{md: {span: 12},lg: {span: 12}}},
    component: 'InputNumber',
    componentProps:{
      placeholder:"大于等于0，小于等于100的值",
      max: 100, 
      min: 0,
    },
    dynamicRules: ({model,schema}) => {
      return [
             { required: true},
      ];
    },
  },
  {
    label: '较差',
    field: 'level4',
    suffix:'%，大于这个值为较差',
    // colProps: {lg: 12},
    itemProps:{labelCol:{md: {span: 4},lg: {span: 4},},wrapperCol:{md: {span: 12},lg: {span: 12}}},
    component: 'InputNumber',
    componentProps:{
      placeholder:"大于等于0，小于等于100的值",
      max: 100, 
      min: 0,
    },
    dynamicRules: ({model,schema}) => {
      return [
             { required: true},
      ];
    },
  },
  {
    label: '差',
    field: 'level5',
    suffix:'%，大于这个值时为差',
    // colProps: {lg: 12},
    itemProps:{labelCol:{md: {span: 4},lg: {span: 4},},wrapperCol:{md: {span: 12},lg: {span: 12}}},
    component: 'InputNumber',
    componentProps:{
      placeholder:"大于等于0，小于等于100的值",
      max: 100, 
      min: 0,
    },
    dynamicRules: ({model,schema}) => {
      return [
             { required: true},
      ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
    suffix:'%',
	  component: 'Input',
	  show: false
	},
];



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