import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '问题项',
    align:"center",
    dataIndex: 'problemItem',
    width:150
   },
   {
    title: '整改策略',
    align:"center",
    dataIndex: 'strategy',
    customRender:({text}) =>{
      let m = {"0001":"立即整改","0002":"短期整改","0003":"长期整改"}
      return m[text]
    },
    width:150
   },
   {
    title: '整改方案',
    align:"center",
    dataIndex: 'programme',
    width:150
   },
   {
    title: '计划开始日期',
    align:"center",
    dataIndex: 'planStartDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
    width:130
   },
   {
    title: '计划结束日期',
    align:"center",
    dataIndex: 'planEndDate',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text)
    },
    width:130
   },
   {
    title: '执行部门',
    align:"center",
    dataIndex: 'execDepName',
    width:100
   },
   {
    title: '执行人',
    align:"center",
    dataIndex: 'execUserName',
    width:100
   },
   {
    title: '审核标志',
    align:"center",
    dataIndex: 'approveFlag',
    customRender:({text}) =>{
      let m = {"1":"待审核","2":"已驳回","3":"已通过"}
      return m[text]
    },
    width:100
   }
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "问题项",
    field: 'problemItem',
    component: 'Input',
    colProps: {span: 6},
 },
 {
  label: '整改策略',
  field: 'strategy',
  component: 'JSearchSelect',
  componentProps:{
    dict: "programme"
  },
  colProps: {lg: 6},
  itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
},
{
  label: "状态",
  field: 'approveFlag',
  component: 'JSearchSelect',
  componentProps:{
    dict: "approveFlag"
  },
  colProps: {lg: 6},
  itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
},
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '问题项',
    field: 'problemItem',
    component: 'Input',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
    dynamicDisabled: true,
  },
  {
    label: '整改方案',
    field: 'programme',
    component: 'InputTextArea',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
    dynamicDisabled: true,
    componentProps: {
      rows: 5
    }
  },
  {
    label: '整改策略',
    field: 'strategy',
    component: 'JSearchSelect',
    componentProps:{
      dict: "programme"
    },
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    dynamicDisabled: true,
  },
  {
    label: '最晚完成时间',
    field: 'lateFinishTime',
    component: 'DatePicker',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    dynamicDisabled: true,
  },
  {
    label: '执行部门',
    field: 'execDepName',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    component: 'Input',
    dynamicDisabled: true,
  },
  {
    label: '执行人',
    field: 'execUserName',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    component: 'Input',
    dynamicDisabled: true,
  },
  {
    label: '审核部门',
    field: 'approveDepName',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    component: 'Input',
    dynamicDisabled: true,

  },
  {
    label: '审核人',
    field: 'approveUserName',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
     component: 'Input',
     dynamicDisabled: true,

  },
  {
    label: '计划开始日期',
    field: 'planStartDate',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    component: 'DatePicker',
    dynamicDisabled: true,

  },
  {
    label: '计划结束日期',
    field: 'planEndDate',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    component: 'DatePicker',
    dynamicDisabled: true,

  },
  {
    label: '实际开始日期',
    field: 'startDate',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    component: 'DatePicker',
    dynamicDisabled: true,

  },
  {
    label: '实际结束日期',
    field: 'endDate',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    component: 'DatePicker',
    dynamicDisabled: true,

  },
  {
    label: '整改情况描述',
    field: 'rectifyDes',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
    component: 'InputTextArea',
    dynamicDisabled: true,
    componentProps: {
      rows: 5
    }

  },
  {
    label: '相关附件',
    field: 'fileUploadPath',
    component: 'JUpload',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
    componentProps: { buttonVisible:false, desText:"支持扩展名: .rar .zip .doc .docx .pdf .jpg..."},
    dynamicDisabled: true,
  },
  {
    label: '审核结果',
    field: 'approveFlag',
    component: 'RadioGroup',
    componentProps: {
      options: [
        { label: '通过', value: '3' },
        { label: '驳回', value: '2' },
      ],
    },
    dynamicRules: ({values}) => {
      if(values.showFooter){        
        return [        
             { required: true, message: '请选择审核结果'},
        ];
      }
      return [];
    },
  },
  {
    label: '审核意见',
    field: 'approveDes',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
    component: 'InputTextArea',
    dynamicRules: ({values}) => {
      if(values.showFooter){        
        return [        
             { required: true, message: '请选择审核意见'},
        ];
      }
      return [];
    },
    componentProps: {
      rows: 5
    },
    show: ({ values }) => {
        return values.showFooter;
    }
  },
  {
    label: '审核意见',
    field: 'approveDesList',
    component: 'InputTextArea',
    dynamicDisabled: true,
    componentProps: {
      rows: 5
    },
    show: ({ values }) => {
      if(values.showFooter){
              return false;
      }
      return true;
    }
  }, 

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



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