import { formatUpdateUserName } from '@/utils/audit';

export const vehicleTypeDic = [
  { label: '车辆', value: '车辆' },
  { label: '船舶', value: '船舶' },
];

export const changeItemDic = [
  { label: '所有人变更', value: '所有人变更' },
  { label: '挂靠变更', value: '挂靠变更' },
  { label: '经营范围变更', value: '经营范围变更' },
  { label: '车牌号变更', value: '车牌号变更' },
  { label: '其他', value: '其他' },
];

export const option = {
  height: 'auto',
  calcHeight: 32,
  dialogWidth: 980,
  labelPosition: 'right',
  tip: false,
  searchShow: true,
  searchMenuSpan: 24,
  searchIcon: true,
  searchIndex: 4,
  searchMenuPosition: 'right',
  border: true,
  index: true,
  indexLabel: '序号',
  viewBtn: true,
  selection: true,
  dialogClickModal: false,
  menuWidth: 180,
  menuFixed: 'right',
  column: [
    {
      label: '车船类型',
      prop: 'vehicleType',
      type: 'radio',
      minWidth: 110,
      dicData: vehicleTypeDic,
      value: '车辆',
      search: true,
      rules: [{ required: true, message: '请选择车船类型', trigger: 'change' }],
    },
    {
      label: '车牌号/船号',
      prop: 'vehicleNo',
      slot: true,
      formslot: true,
      search: true,
      minWidth: 140,
      placeholder: '输入车牌号/船号模糊查询选择',
      rules: [{ max: 30, message: '最多 30 个字符', trigger: 'blur' }],
    },
    {
      label: '变更事项',
      prop: 'changeItem',
      type: 'select',
      dicData: changeItemDic,
      minWidth: 180,
      rules: [{ required: true, message: '请选择变更事项', trigger: 'change' }],
    },
    {
      label: '变更内容',
      prop: 'changeContent',
      type: 'textarea',
      minRows: 4,
      span: 24,
      search: true,
      minWidth: 260,
      overHidden: true,
      rules: [
        { required: true, message: '请输入变更内容', trigger: 'blur' },
        { max: 200, message: '最多 200 个字符', trigger: 'blur' },
      ],
    },
    {
      label: '备注',
      prop: 'remark',
      type: 'textarea',
      minRows: 4,
      span: 24,
      minWidth: 180,
      overHidden: true,
      rules: [{ max: 200, message: '最多 200 个字符', trigger: 'blur' }],
    },
    {
      label: '附件',
      prop: 'attachments',
      span: 24,
      minWidth: 100,
      slot: true,
      formslot: true,
    },
    {
      label: '创建时间',
      prop: 'createTime',
      sortable: true,
      type: 'date',
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
      display: false,
      minWidth: 170,
    },
    {
      label: '创建时间',
      prop: 'createTimeRange',
      type: 'date',
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
      searchRange: true,
      search: true,
      hide: true,
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
    },
    {
      label: '组织',
      prop: 'createDept',
      type: 'tree',
      dicData: [],
      props: {
        label: 'title',
        value: 'id',
      },
      checkStrictly: true,
      search: true,
      hide: true,
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
    },
    {
      label: '更新人',
      prop: 'updateUserName',
      formatter: formatUpdateUserName,
      addDisplay: false,
      editDisplay: false,
      display: false,
      minWidth: 180,
    },
    {
      label: '更新时间',
      prop: 'updateTime',
      sortable: true,
      type: 'datetime',
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      addDisplay: false,
      editDisplay: false,
      display: false,
      minWidth: 170,
    },
  ],
};

export const excelOption = {
  labelPosition: 'right',
  submitBtn: false,
  emptyBtn: false,
  column: [
    {
      label: '模板上传',
      prop: 'excelFile',
      type: 'upload',
      drag: true,
      loadText: '模板上传中，请稍等',
      span: 24,
      propsHttp: {
        res: 'data',
      },
      tip: '请上传 .xls,.xlsx 标准格式文件',
      action: '/blade-transport/transport-change-record/import-transport-change-record',
    },
    {
      label: '模板下载',
      prop: 'excelTemplate',
      formslot: true,
      span: 24,
    },
  ],
};
