From 3539a3d350c9d5fa51871fa44a2745474c721410 Mon Sep 17 00:00:00 2001
From: yangan <yangan0921@163.com>
Date: 星期一, 02 十二月 2024 17:36:25 +0800
Subject: [PATCH] feat:电子提煤单下载

---
 api/index.js |   90 ++++++++++++++++++++++++++++++++-------------
 1 files changed, 64 insertions(+), 26 deletions(-)

diff --git a/api/index.js b/api/index.js
index 540f8bb..ebcbdd2 100644
--- a/api/index.js
+++ b/api/index.js
@@ -1,53 +1,91 @@
-import {
-	fetch
-} from '@/api/request.js';
+import { fetch ,fetchId} from '@/api/request.js'
 
 const typeObj = {
-	headerGET: {
-		"Content-type": 'application/x-www-from-urlencoded'
-	},
-	headerPOST: {
-		"Content-type": 'application/x-www-from-urlencoded'
-	},
-	jsonPOST: {
-		"Content-type": 'application/json'
-	}
+	headerGET: { 'Content-type': 'application/x-www-from-urlencoded' },
+	headerPOST: { 'Content-type': 'application/x-www-from-urlencoded' },
+	jsonPOST: { 'Content-type': 'application/json' },
+	utfPOSt: { 'content-type': 'application/x-www-form-urlencoded;charset=utf-8' }
 }
 
 // 閫氱敤鎺ュ彛璇锋眰
 export const reqAll = (url, params, opt = {}) => {
-	opt.data = params;
-	opt.header = typeObj['headerPOST'];
+	opt.data = params
+	opt.header = typeObj['headerPOST']
 	return fetch(url, opt)
 }
-
+export const reqAllJson = (url, params, opt = {}) => {
+	opt.data = params
+	opt.header = typeObj['jsonPOST']
+	return fetch(url, opt)
+}
+// deltete璇锋眰
+export const reqDelete = (url, params, opt = {}) => {
+	opt.header = typeObj['headerGET']
+	opt.method = 'DELETE'
+	opt.data = params
+	return fetch(url, opt)
+}
 // get璇锋眰
 // urlParam鏄嫾鎺ヨ矾寰勭殑鍙傛暟
 export const reqGet = (url, params, opt = {}) => {
-	opt.header = typeObj['headerGET'];
-	opt.method = "GET";
-	opt.data = params;
+	opt.header = typeObj['headerGET']
+	opt.method = 'GET'
+	opt.data = params
 	return fetch(url, opt)
 }
-
+export const reqGetId = (url, params, opt = {}) => {
+    opt.header = typeObj['headerGET']
+    opt.method = 'GET'
+    opt.data = params
+    return fetchId(url, opt)
+}
 // post璇锋眰
 // urlType鏄寚瀹氭嫾鎺ヨ矾寰勮繕鏄紶json鏍煎紡鍙傛暟
 export const reqPost = (url, params, urlType, opt = {}) => {
-	opt.method = "POST";
+	opt.method = 'POST'
 	if (urlType == 'params') {
 		Object.keys(params).map(item => {
 			// 杩欓噷闈笉鑳界敤params.item锛岀偣杩愮畻绗﹀姞鏍囪瘑绗︾殑褰㈠紡鍙栧�硷紝鍥犱负item鏄疧bject.keys鐢熸垚鐨勬瘡涓�椤归敭閮芥槸瀛楃涓诧紝涓嶆槸鏍囪瘑绗︼紝鍙互鐢╗]鐨勫舰寮忚闂�
 			if (params[item] == null) {
-				params[item] = '';
+				params[item] = ''
 			}
 		})
-		opt.params = params;
-		opt.header = typeObj['headerPOST'];
+		opt.params = params
+		opt.header = typeObj['headerPOST']
 	} else if (urlType == 'json') {
-		opt.header = typeObj['jsonPOST'];
+		opt.header = typeObj['jsonPOST']
+		opt.data = params
+	} else if (urlType == 'utf8') {
+		opt.header = typeObj['utfPOSt']
+		opt.data = params
 	} else {
-		opt.data = params;
-		opt.header = typeObj['headerPOST'];
+		opt.data = params
+		opt.header = typeObj['headerPOST']
 	}
 	return fetch(url, opt, urlType)
 }
+//Put 璇锋眰
+
+export const reqPut = (url, params, urlType, opt = {}) => {
+    opt.method = 'Put'
+    if (urlType == 'params') {
+        Object.keys(params).map(item => {
+            // 杩欓噷闈笉鑳界敤params.item锛岀偣杩愮畻绗﹀姞鏍囪瘑绗︾殑褰㈠紡鍙栧�硷紝鍥犱负item鏄疧bject.keys鐢熸垚鐨勬瘡涓�椤归敭閮芥槸瀛楃涓诧紝涓嶆槸鏍囪瘑绗︼紝鍙互鐢╗]鐨勫舰寮忚闂�
+            if (params[item] == null) {
+                params[item] = ''
+            }
+        })
+        opt.params = params
+        opt.header = typeObj['headerPut']
+    } else if (urlType == 'json') {
+        opt.header = typeObj['jsonPut']
+        opt.data = params
+    } else if (urlType == 'utf8') {
+        opt.header = typeObj['utfPOSt']
+        opt.data = params
+    } else {
+        opt.data = params
+        opt.header = typeObj['headerPut']
+    }
+    return fetch(url, opt, urlType)
+}
\ No newline at end of file

--
Gitblit v1.9.1