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

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

export const onlineStatusDic = [
  { label: '否', value: 0 },
  { label: '是', value: 1 },
];

export const option = {
  height: 'auto',
  calcHeight: 32,
  dialogWidth: 960,
  labelPosition: 'right',
  labelWidth: 'auto',
  searchLabelWidth: 160,
  tip: false,
  searchBtnText: '查询',
  emptyBtnText: '重置',
  saveBtnText: '提交',
  updateBtnText: '提交',
  searchShow: true,
  searchMenuSpan: 24,
  searchIcon: true,
  searchIndex: 4,
  searchMenuPosition: 'right',
  border: true,
  index: true,
  indexLabel: '序号',
  viewBtn: true,
  selection: true,
  dialogClickModal: false,
  menuWidth: 160,
  menuFixed: 'right',
  column: [
    {
      label: '车船类型',
      prop: 'vehicleType',
      type: 'radio',
      dicData: vehicleTypeDic,
      value: '车辆',
      search: true,
      searchOrder: 3,
      span: 24,
      order: 1,
      minWidth: 110,
      rules: [{ required: true, message: '请选择车船类型', trigger: 'change' }],
    },
    {
      label: '车牌号/船号',
      prop: 'vehicleNo',
      slot: true,
      formslot: true,
      search: true,
      searchOrder: 4,
      span: 12,
      order: 2,
      minWidth: 140,
      rules: [{ required: true, message: '请输入车牌号/船号', trigger: 'blur' }],
    },
    {
      label: '设备号',
      prop: 'equipmentCode',
      formslot: true,
      search: true,
      searchOrder: 2,
      span: 12,
      order: 3,
      minWidth: 150,
      rules: [{ required: true, message: '设备编号由系统生成', trigger: 'blur' }],
    },
    {
      label: '设备名称',
      prop: 'equipmentName',
      span: 12,
      order: 4,
      minWidth: 150,
      rules: [
        { required: true, message: '请输入设备名称', trigger: 'blur' },
        { max: 100, message: '最多 100 个字符', trigger: 'blur' },
      ],
    },
    {
      label: '出厂日期',
      prop: 'factoryDate',
      sortable: true,
      type: 'date',
      format: 'YYYY-MM-DD',
      valueFormat: 'YYYY-MM-DD',
      span: 12,
      order: 8,
      minWidth: 130,
    },
    {
      label: '设备品牌',
      prop: 'equipmentBrand',
      span: 12,
      order: 5,
      minWidth: 130,
      rules: [{ max: 50, message: '最多 50 个字符', trigger: 'blur' }],
    },
    {
      label: '设备类型',
      prop: 'equipmentType',
      type: 'select',
      dicData: [],
      span: 12,
      order: 6,
      minWidth: 130,
      rules: [{ max: 50, message: '最多 50 个字符', trigger: 'change' }],
    },
    {
      label: '规格型号',
      prop: 'specificationModel',
      span: 12,
      order: 7,
      minWidth: 150,
      rules: [{ max: 100, message: '最多 100 个字符', trigger: 'blur' }],
    },
    {
      label: '备注',
      prop: 'remark',
      type: 'textarea',
      minRows: 3,
      span: 24,
      order: 10,
      minWidth: 180,
      overHidden: true,
      rules: [{ max: 200, message: '最多 200 个字符', trigger: 'blur' }],
    },
    {
      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,
      viewDisplay: false,
      minWidth: 170,
    },
    {
      label: '创建时间',
      prop: 'createTime',
      sortable: true,
      type: 'datetime',
      format: 'YYYY-MM-DD HH:mm:ss',
      valueFormat: 'YYYY-MM-DD HH:mm:ss',
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
      minWidth: 170,
    },
    {
      label: '是否在线',
      prop: 'onlineStatus',
      type: 'select',
      dicData: onlineStatusDic,
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
      minWidth: 100,
    },
    {
      label: '原厂设备号',
      prop: 'originalEquipmentNo',
      span: 12,
      order: 9,
      hide: true,
      rules: [{ max: 100, message: '最多 100 个字符', trigger: 'blur' }],
    },
    {
      label: '附件',
      prop: 'attachments',
      slot: true,
      formslot: true,
      span: 24,
      order: 11,
      hide: true,
    },
    {
      label: '组织',
      prop: 'createDept',
      type: 'tree',
      dicData: [],
      props: { label: 'title', value: 'id' },
      checkStrictly: true,
      search: true,
      searchOrder: 1,
      hide: true,
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
    },
    {
      label: '更新人',
      prop: 'updateUserName',
      formatter: formatUpdateUserName,
      display: false,
      addDisplay: false,
      editDisplay: false,
      viewDisplay: false,
    },
  ],
};

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/equipment-ledger/import-equipment-ledger',
    },
    { label: '模板下载', prop: 'excelTemplate', formslot: true, span: 24 },
  ],
};
