import { BasicColumn, FormSchema } from '/@/components/Table';

//列表数据
export const columns: BasicColumn[] = [
  {
   title: '文件编号',
   align:"left",
   dataIndex: 'complianeNo',
   width:100,
   resizable:true,
   sorter: true,
  },
  {
   title: '文件名称',
   align:"left",
   dataIndex: 'fileName',
   width:450,
   resizable:true,
   sorter: true,
  },
  {
   title: '适用范围',
   align:"left",
   dataIndex: 'applyRangeNamestr',
   width:100,
   resizable:true,
   sorter: true,
  },
  {
   title: '标签',
   align:"left",
   dataIndex: 'labelNames',
   width:200,
   resizable:true,
   sorter: true,
  },
  {
   title: '发布单位',
   align:"left",
   dataIndex: 'issued',
   width:200,
   resizable:true,
   sorter: true,
  },
  {
   title: '发布日期',
   align:"center",
   dataIndex: 'issuedTime',
   customRender:({text}) =>{
     return !text?"":(text.length>10?text.substr(0,10):text)
   },
   width:100,
   resizable:true,
   sorter: true,
  },
  {
   title: '状态',
   align:"center",
   dataIndex: 'statusName',
   width:80,
   resizable:true,
   sorter: true,
  },
];
//列表数据
export const querycolumn: BasicColumn[] = [
  {
   title: '文件编号',
   align:"left",
   dataIndex: 'complianeNo',
  },
  {
   title: '文件名称',
   align:"left",
   dataIndex: 'fileName'
  },
  {
    title: '文件类型',
    align:"left",
    dataIndex: 'complianeClass',
  },
  {
   title: '适用范围',
   align:"left",
   dataIndex: 'applyRangeName'
  },
  {
   title: '发布单位',
   align:"left",
   dataIndex: 'issued'
  },
  {
   title: '发布日期',
   align:"left",
   dataIndex: 'issuedTime',
   customRender:({text}) =>{
     return !text?"":(text.length>10?text.substr(0,10):text)
   },
  },
  {
   title: '状态',
   align:"left",
   dataIndex: 'statusName'
  },
];

export const cfSearchFormSchema: FormSchema[] = [
	{
      label: "文件名称",
      field: 'fileName',
      component: 'Input',
      colProps: {span: 6},
 	},
	{
      label: "适用范围",
      field: 'applyRangeCode',
      component: 'Input',
      colProps: {span: 6},
 	},
   {
    label: "标签",
    field: 'lableName',
    component: 'Input',
    colProps: {span: 6},
 },
	{
      label: "状态",
      field: 'status',
      component: 'Input',
      colProps: {span: 6},
 	},
  {
    label: "发文单位",
    field: 'issued',
    component: 'Input',
    colProps: {span: 6},
 },
 {
  label: '发布日期',
  field: 'rangeIssuedTime',
  component: 'RangePicker',
  componentProps: {
    valueType: 'Date'
  },
  colProps: { span: 8 },
}
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '文件编号',
    field: 'complianeNo',
    component: 'Input',
    dynamicDisabled: true,
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
  },
  {
    label: '文件名称',
    field: 'fileName',
    component: 'Input',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请输入文件名称!'},
      ];
    },
  },
  {
    label: '适用范围',
    field: 'applyRangeCodestr',
    component: 'JSelectMultiple',
    componentProps:{
      dictCode: "applyrange"
    },
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请选择适用范围!'},
      ];
    },
  },
  {
    label: '标签',
    field: 'labelCodestr',
    component: 'StSelectLable',//'JSelectUser',//
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
    dynamicRules: ({model,schema}) => {
      return [
          { required: true, message: '请选择标签!'},
      ];
    },
    ifShow: ({ values }) => {
      return values.complianeClass == '5';
    },
  },
  {
    label: '发文号',
    field: 'docNo',
    component: 'Input',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请输入发文号!'},
      ];
    },
  },
  {
    label: '发布单位',
    field: 'issued',
    component: 'Input',
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请输入发布单位!'},
      ];
    },
  },
  {
    label: '发布日期',
    field: 'issuedTime',
    component: 'DatePicker',
    componentProps: {
      format: 'YYYY-MM-DD'
    },
    colProps: {lg: 12},
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 6},},wrapperCol:{xs: {span: 24},sm: {span: 18},}},
    dynamicRules: ({model,schema}) => {
      return [
             { required: true, message: '请选择发布日期!'},
      ];
    },
  },
  {
    label: '状态',
    field: 'status',
    component: 'JSearchSelect',
    ifShow: false,
    componentProps:{
      dict: "filestatus"
    },
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 10},}},
    // dynamicRules: ({model,schema}) => {
    //   return [
    //          { required: true, message: '请选择发布状态!'},
    //   ];
    // },
  },
  {
    label: '备注说明',
    field: 'complianeDesc',
    component: 'InputTextArea',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
    componentProps: {
      rows: 5
    }
  },
  {
    field: 'fileUploadPath',
    component: 'JUpload',
    label: '附件',
    itemProps:{labelCol:{xs: {span: 24},sm: {span: 3},},wrapperCol:{xs: {span: 24},sm: {span: 21},}},
    componentProps: { maxCount: 1,desText:"支持扩展名: .rar .zip .doc .docx .pdf .jpg..."},
  },
  {
    label: '',
    field: 'complianeClass',
    component: 'Input',
    show: false
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];



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