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",
    sorter: true,
    dataIndex: 'taskYear',
    width :50,
   },
   {
    title: '评估表名称',
    align:"center",
    sorter: true,
    dataIndex: 'taskName',
    width :100,
   },
   {
    title: '备注说明',
    align:"center",
    dataIndex: 'remark',
    width :100,
   },
   {
    title: '责任部门',
    align:"center",
    dataIndex: 'dutyDept_dictText',
    width :100,
   },
   {
    title: '填报截至日期',
    align:"center",
    dataIndex: 'taskEndtime',
    width :100,
    customRender: ({ text }) => {
        return !text?"":(text.length>10?text.substr(0,10):text)
       },
   },
   {
    title: '状态',
    align:"center",
    dataIndex: 'rateTaskstatus',
    width :50,
    customRender: ({ text }) => {
      const color = text == '7' ? 'red' : text == '8' ? 'green' : '';
      return render.renderTag(render.renderDict(text, 'rate_taskStatus'), color);
    },
   },
  
   /** 
    *  {
    title: '任务id',
    align:"center",
    dataIndex: 'rateTaskId',
	  show: false
   },
   {
    title: '评估规则',
    align:"center",
    dataIndex: 'ruleId'
   },
   {
    title: '评估人',
    align:"center",
    dataIndex: 'rateUser'
   },
   {
    title: '评估部门',
    align:"center",
    dataIndex: 'rateDept'
   },
   
   
   {
    title: '是否审批',
    align:"center",
    dataIndex: 'rateApprove_dictText'
   },
   
   {
    title: '责任人',
    align:"center",
    dataIndex: 'dutyUser'
   },
   {
    title: '审核人',
    align:"center",
    dataIndex: 'approveuser'
   },
   */
];
//查询数据
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: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入年度!'},
          ];
     },
  },
  {
    label: '评估表名称',
    field: 'taskName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入评估表名称!'},
          ];
     },
  },
  {
    label: '评估规则',
    field: 'ruleId',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入评估规则!'},
          ];
     },
  },
  {
    label: '评估人',
    field: 'rateUser',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入评估人!'},
          ];
     },
  },
  {
    label: '评估部门',
    field: 'rateDept',
    component: 'Input',
  },
  {
    label: '填报截至日期',
    field: 'taskEndtime',
    component: 'DatePicker',
    componentProps: {
       showTime: true,
       valueFormat: 'YYYY-MM-DD HH:mm:ss'
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入填报截至日期!'},
          ];
     },
  },
  {
    label: '备注说明',
    field: 'remark',
    component: 'InputTextArea',
  },
  {
    label: '是否审批',
    field: 'rateApprove',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"rate_approve"
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请输入是否审批!'},
          ];
     },
  },
  {
    label: '状态',
    field: 'rateTaskstatus',
    component: 'JDictSelectTag',
    componentProps:{
        dictCode:"rate_taskStatus"
     },
  },
  {
    label: '责任人',
    field: 'dutyUser',
    component: 'Input',
  },
  {
    label: '责任部门',
    field: 'dutyDept',
    component: 'Input',
  },
  {
    label: '审核人',
    field: 'approveuser',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



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