From 4641a877cd6a94e4d35dca7f7f14bc1443e2d2ad Mon Sep 17 00:00:00 2001
From: luobisheng <727299681@qq.com>
Date: 星期二, 29 十一月 2022 17:59:55 +0800
Subject: [PATCH] 上传处置类型修改

---
 src/utils/helper.js |  134 ++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 127 insertions(+), 7 deletions(-)

diff --git a/src/utils/helper.js b/src/utils/helper.js
index 3b6dda5..d79cabf 100644
--- a/src/utils/helper.js
+++ b/src/utils/helper.js
@@ -1,12 +1,13 @@
+import myrequest from './request'
 // 娣辨嫹璐�
-function deepClone(obj){
+export function deepClone(obj) {
     let objClone = Array.isArray(obj) ? [] : {};
-    if(obj && typeof obj === 'object' && obj != null){
-        for(let key in obj){
-            if(obj.hasOwnProperty(key)){
-                if(obj[key] && typeof obj[key] === 'object'){
+    if (obj && typeof obj === 'object') {
+        for (let key in obj) {
+            if (obj.hasOwnProperty(key)) {
+                if (obj[key] && typeof obj[key] === 'object') {
                     objClone[key] = deepClone(obj[key]);
-                }else{
+                } else {
                     objClone[key] = obj[key];
                 }
             }
@@ -14,4 +15,123 @@
     }
     return objClone;
 }
-export {deepClone};
\ No newline at end of file
+// 璁$畻闄愬埗鏃堕棿
+export function computeTime(time2) {
+    const t1 = new Date();
+    const t2 = new Date(time2);
+    return filterTime(t2.getTime() - t1.getTime());
+}
+// 鑾峰彇瀛楀吀琛�
+export async function getTypeList(level, code) {
+    let arr;
+    await myrequest({
+        method: 'get',
+        url: `sccg/dict/query_type?level=${level}&typeCode=${code}`
+    })
+        .then(res => {
+            arr = res.data;
+        })
+    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锛氳姹傚ご涓枃浠剁殑鍚嶅瓧
+// 榛樿涓嶇敤淇敼锛岀洿鎺ュ皢杩斿洖鐨剅es浼犲叆鍗冲彲
+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');
+    const tokenHead = sessionStorage.getItem('tokenHead');
+    if (token && tokenHead) {
+        return tokenHead + token;
+    }
+}
+// 鑾峰彇骞存湀鏃ユ椂鍒嗙
+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) {
+        return '宸查�炬湡';
+    }
+    let dd = Math.floor(time / 24 / 60 / 60 / 1000),
+        hh = Math.floor(time / 60 / 60 / 1000 - dd * 24),
+        mi = Math.floor(time / 60 / 1000 - dd * 24 * 60 - hh * 60);
+    return addDay(fillTime(dd)) + addHour(fillTime(hh)) + addMin(fillTime(mi));
+}
+function fillTime(num) {
+    if (num < 10) {
+        return '0' + num;
+    }
+    return num;
+}
+function addDay(str) {
+    str = parseFloat(str);
+    if (str < 0) {
+        return;
+    }
+    return str + '澶�'
+}
+function addHour(str) {
+    str = parseFloat(str);
+    if (str < 0) {
+        return;
+    }
+    return str + '灏忔椂'
+}
+function addMin(str) {
+    str = parseFloat(str);
+    if (str < 0) {
+        return;
+    }
+    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' }
+]

--
Gitblit v1.8.0