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:"left",
    sorter: true,
    dataIndex: 'taskYear',
    width :50,
   },
   {
    title: '评估表名称',
    align:"left",
    sorter: true,
    dataIndex: 'taskName',
    width :100,
   },
   {
    title: '备注说明',
    align:"left",
    dataIndex: 'remark',
    width :180,
   }, 
   {
    title: '评估人',
    align:"left",
    dataIndex: 'rateUser_dictText',
    width :80,
   },
   {
    title: '得分',
    align:"center",
    dataIndex: 'ratescore',
    width :80,
   },
    /** 
   {
    title: '评估规则',
    align:"left",
    dataIndex: 'rulename',
    width :100,
   }, 
  

   {
    title: '评估部门',
    align:"left",
    dataIndex: 'rateDept_dictText',
    width :80,
   }, 
   {
    title: '填报截至日期',
    align:"left",
    dataIndex: 'taskEndtime',
    width :80,
   },

   {
    title: '填报得分',
    align:"center",
    dataIndex: 'inputscore'
   },
   
   
   {
    title: '是否审批',
    align:"left",
    dataIndex: 'rateApprove_dictText',
    width :50,
   }, */
   {
    title: '创建时间',
    align:"left",
    sorter: true,
    dataIndex: 'createTime',
    width :80,
   },
   {
    title: '状态',
    align:"left",
    dataIndex: 'rateTaskstatus',
    width :50,
    customRender: ({ text }) => {
      const color = text == '11' ? 'red' : text == '13' ? 'green' : 'blue';
      return render.renderTag(render.renderDict(text, 'rate_taskStatus'), color);
    },
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
	{
      label: "年度",
      field: 'taskYear',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "评估表",
      field: 'taskName',
      component: 'Input',
      colProps: {span: 6},
 	},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '年度',
    field: 'taskYear',
    component: 'DatePicker',
    componentProps: {
      picker: 'year',
      valueFormat: 'YYYY',
    },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入年度!'},
          ];
     },
  },
  {
    label: '评估表名称',
    field: 'taskName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入评估表名称!'},
          ];
     },
  },
  {
    label: '评估规则',
    field: 'ruleId',
    required: false,
    component: 'JSelectRateRule',
    componentProps: {
      rowKey: 'id',
      labelKey: 'rulename',
    },
  },
  {
    label: '评估人',
    field: 'rateUser',
    component: 'JSelectUserByDept',
    componentProps:{
        labelKey:'realname',
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入评估人!'},
          ];
     },
  }, /** 
  {
    label: '评估部门',
    field: 'rateDept',
     component: 'JSelectDept',
  },*/
  {
    label: '填报截至日期',
    field: 'taskEndtime',
    component: 'DatePicker',
    componentProps: {
       //showTime: true,
       valueFormat: 'YYYY-MM-DD'
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入填报截至日期!'},
          ];
     },
  },
  {
    label: '备注说明',
    field: 'remark',
    component: 'InputTextArea',
  },
  {
    field: 'rateApprove',
    label: '是否审批',
    component: 'Switch',
      componentProps: {
        //开关大小，可选值：default small
        size:'default',
        //非选中时的内容
        unCheckedChildren:'否',
        //非选中时的值
        unCheckedValue:'0',
        //选中时的内容
        checkedChildren:'是',
        //选中时的值
        checkedValue:'1',
        defaultValue: '1',
        //是否禁用
        disabled: false
      },
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请输入是否审批!'},
      ];
 },
  },
 /** 
  {
    label: '状态',
    field: 'rateTaskstatus',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"rate_taskStatus"
     },
  }, */
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



/**
 * 角色用户Columns
 */
 export const userColumns = [
  {
    title: '领域',
    align:"left",
    sorter: true,
    dataIndex: 'ratedomain',
    width :100,
   },
   {
    title: '子领域',
    align:"left",
    sorter: true,
    dataIndex: 'sondomain',
    width :140,
   },
   {
    title: '评估要素',
    align:"left",
    dataIndex: 'keyitem',
    width :180,
   }, 
   {
    title: '分值',
    align:"left",
    dataIndex: 'keyitemscore',
    width :50,
   }, 
   {
    title: '得分',
    align:"left",
    dataIndex: 'inputscore',
    width :50,
   }, 
];




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