吉安感知网项目-前端
张含笑
2026-01-09 edaf70cb7f0c4e7c997ddab584b3b05798d58528
packages/utils/common/index.js
@@ -5,3 +5,21 @@
      max ? { max, message: `长度不超过${max}`, trigger } : {},
   ]
}
export function getDictLabel(value, dictList) {
   return dictList.find(item => item.dictKey === value)?.dictValue || value || '-'
}
export function blobDownload(res) {
   const disposition = res.headers?.['content-disposition'] || res.headers?.['Content-Disposition']
   const encodedName = disposition.split('filename=')[1]
   const filename = decodeURIComponent(encodedName)
   const elink = document.createElement('a')
   elink.download = filename
   elink.style.display = 'none'
   const blob = new Blob([res.data])
   elink.href = URL.createObjectURL(blob)
   document.body.appendChild(elink)
   elink.click()
   document.body.removeChild(elink)
}