import {
  auditColumns,
  createCrudOption,
  nodeOptions,
  processStatusOptions,
  selectRule,
  textRule,
} from './common';

export const config = {
  title: '过程配置',
  permission: 'process_config',
  exportUrl: '/blade-transport/process-config/export-process-config',
  exportName: '过程配置',
  enableAllDept: true,
  actions: ['copy', 'enable', 'disable'],
  statusProp: 'status',
  statusTextProp: 'statusName',
  deleteStatus: [0, 2],
};

export const option = {
  ...createCrudOption([
    {
      label: '',
      prop: 'basicInfo',
      formslot: true,
      span: 24,
      hide: true,
    },
    {
      label: '配置名称',
      prop: 'configName',
      search: true,
      searchOrder: 6,
      searchSpan: 6,
      searchPlaceholder: '请输入',
      span: 12,
      minWidth: 150,
      addDisplay: false,
      editDisplay: false,
      rules: textRule('配置名称', 100, true),
    },
    {
      label: '配置编号',
      prop: 'configCode',
      search: true,
      searchOrder: 4,
      searchSpan: 6,
      searchPlaceholder: '请输入',
      minWidth: 130,
      addDisplay: false,
      editDisplay: false,
      editDisabled: true,
    },
    {
      label: '项目',
      prop: 'projectNames',
      formslot: true,
      search: true,
      searchOrder: 5,
      searchType: 'input',
      searchSpan: 6,
      searchPlaceholder: '请输入',
      type: 'textarea',
      minRows: 2,
      span: 12,
      minWidth: 180,
      dicData: [],
      filterable: true,
      addDisplay: false,
      editDisplay: false,
      rules: textRule('项目', 1000, true),
    },
    {
      label: '过程节点',
      prop: 'includedNodes',
      type: 'select',
      multiple: true,
      dicData: nodeOptions,
      minWidth: 260,
      overHidden: false,
      slot: true,
      addDisplay: false,
      editDisplay: false,
      rules: selectRule('过程节点'),
    },
    {
      label: '默认运输完成天数',
      prop: 'defaultFinishDays',
      formslot: true,
      type: 'number',
      min: 0,
      max: 999,
      span: 12,
      minWidth: 170,
      addDisplay: false,
      editDisplay: false,
    },
    {
      label: '备注',
      prop: 'remark',
      type: 'textarea',
      minRows: 4,
      span: 24,
      minWidth: 180,
      addDisplay: false,
      editDisplay: false,
      maxlength: 500,
      showWordLimit: true,
      rules: textRule('备注', 500),
    },
    {
      label: '组织',
      prop: 'deptName',
      minWidth: 150,
      addDisplay: false,
      editDisplay: false,
    },
    ...auditColumns
      .filter(column => ['updateTime', 'createTime'].includes(column.prop))
      .map(column => ({ ...column, minWidth: 190 }))
      .sort(
        (first, second) =>
          ['updateTime', 'createTime'].indexOf(first.prop) -
          ['updateTime', 'createTime'].indexOf(second.prop)
      ),
    {
      label: '项目ID集合',
      prop: 'projectIds',
      hide: true,
      display: false,
      addDisplay: false,
      editDisplay: false,
      rules: textRule('项目ID集合', 1000, true),
    },
    {
      label: '状态',
      prop: 'status',
      type: 'select',
      search: true,
      searchOrder: 1,
      searchSpan: 6,
      searchPlaceholder: '请选择',
      dicData: processStatusOptions,
      slot: true,
      hide: true,
      fixed: false,
      addDisplay: false,
      editDisplay: false,
    },
    {
      label: '组织',
      prop: 'searchDeptId',
      searchProp: 'deptId',
      type: 'select',
      search: true,
      searchOrder: 2,
      searchSpan: 6,
      searchPlaceholder: '请选择',
      hide: true,
      display: false,
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
      dicData: [],
      filterable: true,
    },
    {
      label: '',
      prop: 'nodeConfigJson',
      formslot: true,
      span: 24,
      hide: true,
    },
  ]),
  saveBtnText: '保存',
  updateBtnText: '保存',
  dialogTop: '10px',
  dialogWidth: '96%',
  menuWidth: 220,
};
