吉安感知网项目-前端
chenyao
2026-01-09 ebd0ec4f51288042b6fc5bf714b1febbb63cfacc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
export function fieldRules(required, max) {
    const trigger = ['blur', 'change']
    return [
        required ? { required: true, message: max ? '请输入' : '请选择', trigger } : {},
        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)
}