import store from '@/store'

// 藏品信息键值对的映射
export const goodsChangeObj = {
  name: '藏品名称',
  namePrimitive: '原名',
  dictNum: '藏品编号名称',
  num: '藏品编号',
  dictAge: '年代',
  dictTexture: '文物质地',
  ageSpecific: '具体年代',
  dictGoodType: '文物类别',
  pcs: '实际数量',
  dictLevel: '文物级别',
  size: '外形尺寸',
  sizeSpecific: '具体尺寸',
  dictQualityScope: '质量范围',
  quality: '具体质量',
  complete: '完残程度',
  repair: '保存状态',
  dictCheckInScope: '入藏时间范围',
  checkInYear: '入藏年度',
  author: '著者',
  vision: '版本',
  onFile: '存卷',
  description: '来源说明',
  remark: '备注',
  display: '展示状态',
  thumb: '藏品图片',
  fileIds: '附件信息'
} as any
// 状态的筛选
export const statusObj = {
  0: '待办理', //草稿中
  1: '待审核', //待审核
  2: '审核不通过', //审核不通过
  3: '已完成' //审核通过
} as any

// 入库出库的状态筛选
export const storageStatusObj = {
  '0': '未入库',
  temp: '待审核通过',
  in: '已入库 ',
  out: '已出库'
} as any

// 藏品总账，操作记录
export const logTypeObj = {
  in: '入库管理',
  out: '出库管理',
  move: '藏品移库',
  edit: '藏品修改'
} as any
// 藏品总账，操作记录跳转
export const logTypeOpenObj = {
  in: '#/object/3/look?k=1&d=null&id=', //入库管理的查看
  out: '#/object/4/look?k=1&d=null&id=', //出库管理的查看
  move: '#/stores/3/look?k=1&d=null&id=', //藏品移库的查看
  edit: '#/object/5/look?k=1&d=null&id=' //藏品修改的查看
} as any

// 出库管理状态的筛选
export const statusObjCK = {
  0: '待办理', //草稿中
  1: '待审核', //待审核
  2: '审核不通过', //审核不通过
  3: '待归还', //审核通过
  4: '已归还' //审核通过
} as any

export const statusObjCK2 = {
  0: '待办理', //草稿中
  1: '待审核', //待审核
  2: '审核不通过', //审核不通过
  3: '已完成（待归还）', //审核通过
  4: '已完成（已归还）' //审核通过
} as any

// 根据入库管理的选中id来改变字段
export const obj3InStorage = (data: string) => {
  let txt = ''
  if (data) {
    const arr = store.getState().stores1Store.infoList
    const ids = data.split(',')

    if (ids[0]) {
      arr.forEach((v1: any) => {
        if (v1.id === Number(ids[0])) {
          txt += v1.name
          if (ids[1]) {
            v1.children.forEach((v2: any) => {
              if (v2.id === Number(ids[1])) {
                txt += '/' + v2.name
                if (ids[2]) {
                  v2.children.forEach((v3: any) => {
                    if (v3.id === Number(ids[2])) txt += '/' + v3.name
                  })
                }
              }
            })
          }
        }
      })
    }
  }
  return txt
}
