wl
2023-01-09 1e07cfd8ac6c3e31e94c0ea98dcff61db51e49d1
src/utils/helper.js
@@ -2,7 +2,7 @@
// 深拷贝
export function deepClone(obj) {
    let objClone = Array.isArray(obj) ? [] : {};
    if (obj && typeof obj === 'object' && obj != null) {
    if (obj && typeof obj === 'object') {
        for (let key in obj) {
            if (obj.hasOwnProperty(key)) {
                if (obj[key] && typeof obj[key] === 'object') {
@@ -33,6 +33,38 @@
        })
    return arr;
}
// 获取字典表2
export async function getCodeList(code){
    let arr;
    await myrequest({
        method: 'get',
        url: `/sccg/dict/queryByCode?code=${code}`
    })
        .then(res => {
            arr = res.data;
        })
    return arr;
}
// data: 文件, contentDisposition:请求头中文件的名字
// 默认不用修改,直接将返回的res传入即可
export function downloadFile(res) {
    const blob = new Blob([res.data], { type: 'application/octet-stream' });
    const fileName = res.contentDisposition.split(`''`)[1];
    if (window.navigator && window.navigator.msSaveBlob) {
        window.navigator.msSaveBlob(blob, fileName);
    } else {
        const link = document.createElement('a');
        link.style.display = 'none';
        link.href = window.URL.createObjectURL(blob);
        link.download = decodeURI(fileName);
        document.body.appendChild(link);
        link.click();
        window.URL.revokeObjectURL(link.href);
        document.body.removeChild(link);
    }
}
// 获取token
export function getToken() {
    const token = sessionStorage.getItem('token');
@@ -40,7 +72,17 @@
    if (token && tokenHead) {
        return tokenHead + token;
    }
    return;
}
// 获取年月日时分秒
export function getNowDate(time){
    const result = new Date(time);
    let yy = result.getFullYear(),
    mm = result.getMonth()+1,
    dd = result.getDate(),
    hh = result.getHours(),
    mi = result.getMinutes(),
    ss = result.getSeconds()
    return yy+'-'+ fillTime(mm)+'-'+fillTime(dd)+" "+fillTime(hh)+':'+fillTime(mi) + ':' + fillTime(ss);
}
function filterTime(time) {
    if (time < 0) {
@@ -78,3 +120,23 @@
    }
    return str + '分钟'
}
export const EVENT_SOURCE = [
    { label: '视频巡查', value: 1 },
    { label: '人工上报', value: 2 }
]
export const CATEGOTY = [
    { label: '违规', value: 1 },
    { label: '违建', value: 2 }
]
export const RESOURCE_TYPE = [
    { label: '上报', value: '01' },
    { label: '处置', value: '02' }
]
export const RESOURCE_OPTIONS = [
    { label: '人工上报', value: 2 },
    { label: '视频巡查', value: 1 }
]