import { BasicColumn, FormSchema } from '/@/components/Table';
//列表数据
export const columns: BasicColumn[] = [
   {
    title: '分类名称',
    align: 'left',
    dataIndex: 'classifyName',
    width:150,
   },
   {
    title: '等级',
    align: 'left',
    dataIndex: 'level',
    customRender:({text}) =>{
      return !text?"":text+"级"
    },
    width:150,
   },
   {
    title: '备注说明',
    align: 'left',
    dataIndex: 'classifyDesc',
    width:200,
   },
   {
    title: '更新时间',
    align: 'left',
    dataIndex: 'updatedTime',
    width:140,
    // customRender:({text}) =>{
    //   return !text?"":(text.length>10?text.substr(0,10):text)
    // },
   },
  
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "分类名称",
    field: "classifyName",
    component: 'JInput',
    colProps: {span: 6},
   },
{
    label: "等级",
    field: "level",
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'lablelevel',
      placeholder: '请选择等级',
     },
    colProps: {span: 6},
   },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '一级领域名称',
    field: 'fclassifyName',
    component: 'Input',
    dynamicDisabled: true,
    show: ({ values }) => {
      if(values && values.level==="2"){
        return true
      }
      return false;
    }
  },
  {
    label: '等级',
    field: 'level',
    defaultValue: '1',
    dynamicDisabled: true,
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'lablelevel',
      placeholder: '请选择等级',
     },
    dynamicRules: ({model,schema}) => {
          return [
                 { required: true, message: '请选择等级!'},
          ];
     },
  },
  {
    label: '分类名称',
    field: 'classifyName',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请输入分类名称!'},
      ];
 },
  },
  {
    label: '分类说明',
    field: 'classifyDesc',
    component: 'InputTextArea',
    componentProps: {
      rows: 5
    }
  },
  {
    label: '',
    field: 'upperClassifyCode',
    component: 'Input',
    show: false,
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];


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