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",
    dataIndex: 'code',
    width:60,
    sorter: true,
    resizable:true
   },
   {
    title: '模板名称',
    align:"left",
    dataIndex: 'nm',
    width:120,
    sorter: true,
    resizable:true
   },
   {
    title: '报送方式',
    dataIndex: 'btp',
    width: 80,
    sorter: true,
    resizable:true,
    customRender: ({ text }) => {
      return render.renderDict(text, 'tpl_btp');
    },
    ifShow:false,
   },
   {
    title: '报告类型',
    dataIndex: 'tp',
    width: 70,
    sorter: true,
    resizable:true,
    customRender: ({ text }) => {
      return render.renderDict(text, 'report_tp');
    },
    filters:[
      {text:"年报模板",value:"1"},
      {text:"季报模板",value:"2"},
      {text:"月报模板",value:"3"},
    ]

   },
   {
    title: '创建时间',
    align:"center",
    sorter: true,
    dataIndex: 'createdTime',
    resizable:true,
    width:120,
    ifShow:false,
   },
   {
    title: '版本',
    align:"left",
    dataIndex: 'version',
    sorter: true,
    width: 60,
    resizable:true,
   },
   {
    title: '生效年度',
    align:"center",
    dataIndex: 'vyear',
    sorter: true,
    width: 60,
    resizable:true,
    customRender: ({ text }) => {
      return !text?"":(text.length>4?text.substr(0,4):text)
    },
   },
   {
    title: '节点数',
    align:"center",
    dataIndex: 'childNum',
    resizable:true,
    width:60,
    sorter: true,
   },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: '名称',
    field: 'nm',
    component: 'Input',
  },
  {
    label: '分类',
    field: 'tp',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'report_tp',
      placeholder: '请选择',
      stringToNumber: true,
    },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '编号',
    field: 'code',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请输入编号!'},
      ];
    },
  },
  {
    label: '名称',
    field: 'nm',
    component: 'Input',
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请输入模板名称!'},
             { max: 60, message: '最大输入字数为60' } 
      ];
    },
  },
  {
    label: '报送方式',
    field: 'btp',
    component: 'JDictSelectTag',
    required:true,
    componentProps: {
      dictCode: 'tpl_btp',
      placeholder: '请选择',
      stringToNumber: true,
    }
  },
  {
    label: '分类',
    field: 'tp',
    component: 'JDictSelectTag',
    componentProps: {
      dictCode: 'report_tp',
      placeholder: '请选择',
      stringToNumber: true,
    },
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请选择分类!'},
      ];
    },
  },
  {
    label: '生效年度',
    field: 'vyear',
    required: true,
    component: 'DatePicker',
    componentProps: {
      picker: 'year',
      valueFormat: 'YYYY'
    },
  },
  {
    label: '版本',
    field: 'version',
    component: 'Input',
    required: true,
  },
  {
    label: '模板文件路径',
    field: 'xmlfilePath',
    component: 'Input',
    required: false,
  },
  {
    label: '备注项目',
    field: 'des',
    component: 'InputTextArea',
    componentProps: {
      rows: 5,
      showCount: true,
      maxlength: 256,
    }
  },
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



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