import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { stringIsNull } from '/@/utils/common/compUtils';
//列表数据
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:120
   },
   {
    title: '执行人',
    align:"center",
    dataIndex: 'execUserName',
    width:100
   },
   {
    title: '审核标志',
    align:"center",
    dataIndex: 'approveFlag',
    customRender:({text}) =>{
      let m = {"0":"未开始","1":"待审核","2":"已驳回","3":"已完成"}
      return m[text]
    },
    width:100
   }
];
//表单数据
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,
  },
  {
    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',
    dynamicRules: ({values}) => {
      if(values.showFooter){        
        return [        
             { required: true, message: '请选择实际开始日期'},
        ];
      }
      return [];
    },
  },
  {
    label: '实际结束日期',
    field: 'endDate',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    component: 'DatePicker',
    dynamicRules: ({values}) => {
      if(values.showFooter){        
        return [        
             { required: true, message: '请选择实际结束日期'},
        ];
      }
      return [];
    },
  },
  {
    label: '整改情况描述',
    field: 'rectifyDes',
    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 [];
    },
  },
  
  {
    label: '相关附件',
    field: 'fileUploadPath',
    component: 'JUpload',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
    componentProps: { buttonVisible: true,
      desText:"支持扩展名: .rar .zip .doc .docx .pdf .jpg..."},
    show: ({ values }) => {
        return values.showFooter;
    }
  },
  {
    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..."},
      show: ({ values }) => {
        if(values.showFooter){
                return false;
        }
        return true;
      }
  },
  {
    label: '审核意见',
    field: 'approveDesList',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
    component: 'InputTextArea',
    dynamicDisabled: true,
    show: ({ values }) => {
      if(!stringIsNull(values.approveDesList)&&values.approveDesList!=""){
        return true
      }
      return false;
    }
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
  {
	  label: '',
	  field: 'problemTaskId',
	  component: 'Input',
	  show: false
	},
  {
    label: '',
    field: 'showFooter',
    component: 'Input',
    show: false,
  },
];

//查询数据
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: "excuteFlag"
    },
    colProps: {lg: 6},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
 },
];

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