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: 'majorName'
  },
  {
    title: '专业代码',
    align: "center",
    dataIndex: 'majorCode'
  },
  {
    title: '学历层次',
    align: "center",
    dataIndex: 'educationalLevel',
    customRender:({text}) => {
      return  render.renderCategoryTree(text,'educational_level')
    },
  },
  {
    title: '专业图标',
    align: "center",
    dataIndex: 'majorIcon'
  },
  {
    title: '学制',
    align: "center",
    dataIndex: 'semester'
  },
  {
    title: '所属一级学科',
    align: "center",
    //dataIndex: 'firstLevelDiscipline'
    dataIndex:'firstLevelDiscipline_dictText'
  },
  {
    title: '设立日期',
    align: "center",
    dataIndex: 'establishmentDate',
    customRender: ({text}) => {
      return !text ? "" : (text.length > 10 ? text.substr(0, 10) : text)
    },
  },
  {
    title: '专业描述',
    align: "center",
    dataIndex: 'majorDesc'
  },
  {
    title: '培养方案',
    align: "center",
    dataIndex: 'cultivationDirection'
  },
  {
    title: '主要课程',
    align: "center",
    dataIndex: 'mainCourses'
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [];
//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '专业名称',
    field: 'majorName',
    component: 'Input',
  },
  {
    label: '专业代码',
    field: 'majorCode',
    component: 'Input',
  },
  {
    label: '学历层次',
    field: 'educationalLevel',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: 'educational_level',
      //pcode:"", //TODO back和事件未添加，暂时有问题
    },
  },
  {
    label: '专业图标',
    field: 'majorIcon',
    component: 'Input',
  },
  {
    label: '学制',
    field: 'semester',
    component: 'Input',
  },
  {
    label: '所属一级学科',
    field: 'firstLevelDiscipline',
    component: 'JSearchSelect',
    colProps: { sm: 24 },
    componentProps: {
      dict: 'yx_first_level_disciplines,disciplines_name,id',
    },
    dynamicRules: () => {
      return [{ required: true, message: '请选择一级学科类型!' }];
    },

  },
  {
    label: '设立日期',
    field: 'establishmentDate',
    component: 'DatePicker',
  },
  {
    label: '专业描述',
    field: 'majorDesc',
    component: 'Input',
  },
  {
    label: '培养方案',
    field: 'cultivationDirection',
    component: 'Input',
  },
  {
    label: '主要课程',
    field: 'mainCourses',
    component: 'Input',
  },
  // TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false
  },
];


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