Kaynağa Gözat

finish_login

Xiaopeng Zhang 3 ay önce
ebeveyn
işleme
167ddef2b3
6 değiştirilmiş dosya ile 87 ekleme ve 53 silme
  1. 2 2
      src/AI.js
  2. 6 3
      src/AIService.js
  3. 6 6
      src/App2.js
  4. 3 3
      src/Home2.js
  5. 10 5
      src/Service.js
  6. 60 34
      src/SimpleService.js

+ 2 - 2
src/AI.js

@@ -362,8 +362,8 @@ export default function AI() {
 
 
   const handleDelete = () => {
-    Service.deleteFiles(itemRef.current).then(x=> {
-      SimpleService.generateFiles2().then(x=>{
+    SimpleService.deleteFiles(itemRef.current, navigate).then(x=> {
+      SimpleService.generateFiles2(navigate).then(x=>{
         setDetail(x.map(y=>{return {'id': y[0], 'ID': y[0], '名称': y[1], '创建时间': y[2], '操作': y[0]};}));
       });
     });

+ 6 - 3
src/AIService.js

@@ -105,7 +105,8 @@ class AIService{
         const response = await fetch(this.ip().concat( "/frequency/"), {
             method : "POST",
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             body: JSON.stringify(
                 {
@@ -128,7 +129,8 @@ class AIService{
         const response = await fetch(this.ip().concat( "/zujia/"), {
             method : "POST",
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             body: JSON.stringify(
                 {
@@ -151,7 +153,8 @@ class AIService{
         const response = await fetch(this.ip().concat( "/tuijian/"), {
             method : "POST",
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             body: JSON.stringify(
                 {

+ 6 - 6
src/App2.js

@@ -888,7 +888,7 @@ function a11yProps(index) {
           let id = itemId.match(regex)[0];     
           setValue("1");
           //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
-          SimpleService.generateZygczgj(location["id"], id).then(x=>{
+          SimpleService.generateZygczgj(location["id"], id, navigate).then(x=>{
                   setZygczgjData(x);
                   setNest(false);
                   setQingdan(false);
@@ -912,7 +912,7 @@ function a11yProps(index) {
           let id = itemId.match(regex)[0];     
           setValue("1");
           //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
-          SimpleService.generateZanliejine2(location["id"], id).then(x=>{
+          SimpleService.generateZanliejine2(location["id"], id, navigate).then(x=>{
                   //setDetail(x);
                   setZljeData(x);
                   setNest(false);
@@ -937,7 +937,7 @@ function a11yProps(index) {
           let id = itemId.match(regex)[0];     
           setValue("1");
           //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
-          SimpleService.generateJirigong2(location["id"], id).then(x=>{
+          SimpleService.generateJirigong2(location["id"], id, navigate).then(x=>{
                   setJrgData(x);
                   setNest(false);
                   setQingdan(false);
@@ -961,7 +961,7 @@ function a11yProps(index) {
           let id = itemId.match(regex)[0];     
           setValue("1");
           //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
-          SimpleService.generateZongchengbaofuwufei2(location["id"], id).then(x=>{
+          SimpleService.generateZongchengbaofuwufei2(location["id"], id, navigate).then(x=>{
                   setZcbfwfData(x);
                   setNest(false);
                   setQingdan(false);
@@ -985,7 +985,7 @@ function a11yProps(index) {
           let id = itemId.match(regex)[0];     
           setValue("1");
           //setColumnHeaders(["序号", "名称", "取费基数", "计算基础", "金额", "类别"]);
-          SimpleService.generateFabaorengongyingcailiao2(location["id"], id).then(x=>{
+          SimpleService.generateFabaorengongyingcailiao2(location["id"], id, navigate).then(x=>{
                   setFbrgyclData(x);
                   setNest(false);
                   setQingdan(false);
@@ -1060,7 +1060,7 @@ function a11yProps(index) {
 
           Service.setQufei(x);
           });
-          SimpleService.generateJiagongcai(location["id"]).then(x=>{
+          SimpleService.generateJiagongcai(location["id"], navigate).then(x=>{
 
             Service.setJiagongcai(x);
             });

+ 3 - 3
src/Home2.js

@@ -48,7 +48,7 @@ export default function Home2() {
       itemRef.current = id;
       /*
       console.log(id);
-      SimpleService.deleteFiles(id).then(x=> {
+      SimpleService.deleteFiles(id, navigate).then(x=> {
         SimpleService.generateFiles2(navigate).then(x=>{
           setDetail(x.map(y=>{return {'id': y[0], 'ID': y[0], '名称': y[1], '创建时间': y[2], '操作': y[0]};}));
         });
@@ -163,7 +163,7 @@ export default function Home2() {
          console.log(event.target.files);
          const fd = new FormData();
          fd.append('file', event.target.files[0]);
-         SimpleService.uploadFile(fd).then(x=>{
+         SimpleService.uploadFile(fd, navigate).then(x=>{
             console.log("uploaded");
             SimpleService.generateFiles2(navigate).then(x=>{
               setDetail(x.map(y=>{return {'id': y[0], 'ID': y[0], '名称': y[1], '创建时间': y[2], '操作': y[0]};}));
@@ -258,7 +258,7 @@ export default function Home2() {
 
 
   const handleDelete = () => {
-    SimpleService.deleteFiles(itemRef.current).then(x=> {
+    SimpleService.deleteFiles(itemRef.current, navigate).then(x=> {
       SimpleService.generateFiles2(navigate).then(x=>{
         setDetail(x.map(y=>{return {'id': y[0], 'ID': y[0], '名称': y[1], '创建时间': y[2], '操作': y[0]};}));
       });

+ 10 - 5
src/Service.js

@@ -224,7 +224,8 @@ class Service{
             const response = await fetch(this.ip().concat("/qingdanmingxi/"), {
                 method : "POST",
                 headers: {
-                    "Content-type": "application/json"
+                    "Content-type": "application/json",
+                    'Authorization': `Bearer ${this.token_}`
                 },
                 body: JSON.stringify(
                     {
@@ -249,7 +250,8 @@ class Service{
         const response = await fetch(this.ip().concat("/qingdanmingxi/"), {
             method : "POST",
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             body: JSON.stringify(
                 {
@@ -343,7 +345,8 @@ class Service{
         const response = await fetch(this.ip().concat( "/save/"), {
             method : "POST",
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             body: JSON.stringify(
                 {
@@ -366,7 +369,8 @@ class Service{
         const response = await fetch(this.ip().concat( "/savedjcs/"), {
             method : "POST",
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             body: JSON.stringify(
                 {
@@ -402,7 +406,8 @@ class Service{
         const response = await fetch(this.ip().concat( "/tiaojia/"), {
             method : "POST",
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             body: JSON.stringify(
                 {

+ 60 - 34
src/SimpleService.js

@@ -57,14 +57,16 @@ class SimpleService{
 
    
 
-    async uploadFile(fd) {
+    async uploadFile(fd, navigate) {
+        fd.append("token", this.token_);
         const response = await fetch(this.ip().concat( "/upload/"), {
             method : "POST",
             body : fd
         });
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+           if (response.status == 401) {
+               navigate("/editor/signin");
+           }
         } else {
             const data = await response.json();
             return data;
@@ -202,11 +204,13 @@ class SimpleService{
         }
     }
 
-    async generateZygczgj(name, id) {
+    async generateZygczgj(name, id, navigate) {
         const response = await fetch(this.ip().concat( "/zygczgj/"), {
             method : "POST",
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
+
             },
             body: JSON.stringify({
                 name: name,
@@ -214,8 +218,9 @@ class SimpleService{
             })
         });
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+             if (response.status == 401) {
+                 navigate("/editor/signin");
+             }
         } else {
             const data = await response.json();
             return data;
@@ -225,11 +230,12 @@ class SimpleService{
 
 
 
-    async generateZongchengbaofuwufei2(name, id) {
+    async generateZongchengbaofuwufei2(name, id, navigate) {
         const response = await fetch(this.ip().concat( "/zongchengbaofuwufei2/"), {
             method : "POST",
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             body: JSON.stringify({
                 name: name,
@@ -237,19 +243,21 @@ class SimpleService{
             })
         });
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+           if (response.status == 401) {
+               navigate("/editor/signin");
+           }
         } else {
             const data = await response.json();
             return data;
         }
     }
 
-    async generateFabaorengongyingcailiao2(name, id) {
+    async generateFabaorengongyingcailiao2(name, id, navigate) {
         const response = await fetch(this.ip().concat( "/fabaorengongyingcailiao2/"), {
             method : "POST",
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             body: JSON.stringify({
                 name: name,
@@ -257,8 +265,9 @@ class SimpleService{
             })
         });
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+          if (response.status == 401) {
+              navigate("/editor/signin");
+          }
         } else {
             const data = await response.json();
             return data;
@@ -270,11 +279,12 @@ class SimpleService{
 
 
 
-    async generateJirigong2(name, id) {
+    async generateJirigong2(name, id, navigate) {
         const response = await fetch(this.ip().concat("/jirigong2/"), {
             method : "POST",
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             body: JSON.stringify({
                 name: name,
@@ -282,8 +292,9 @@ class SimpleService{
             })
         });
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+           if (response.status == 401) {
+               navigate("/editor/signin");
+           }
         } else {
             const data = await response.json();
             return data;
@@ -291,11 +302,12 @@ class SimpleService{
     }
 
 
-    async generateZanliejine2(name, id) {
+    async generateZanliejine2(name, id, navigate) {
         const response = await fetch(this.ip().concat( "/zanliejine2/"), {
             method : "POST",
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             body: JSON.stringify({
                 name: name,
@@ -303,8 +315,9 @@ class SimpleService{
             })
         });
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+             if (response.status == 401) {
+                  navigate("/editor/signin");
+             }
         } else {
             const data = await response.json();
             return data;
@@ -420,11 +433,12 @@ async generateQingdanTuijian(name, bh, bt, bm) {
             return data;
         }
     }
-    async deleteFiles(id) {
+    async deleteFiles(id, navigate) {
         const response = await fetch(this.ip().concat( "/deleteFile/"), {
             method : "POST",
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             body: JSON.stringify(
                 {
@@ -434,8 +448,9 @@ async generateQingdanTuijian(name, bh, bt, bm) {
             )
         });
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+            if (response.status == 401) {
+                navigate("/editor/signin");
+            }
         } else {
             const data = await response.json();
             return data;
@@ -582,11 +597,12 @@ async generateQingdanTuijian(name, bh, bt, bm) {
     }
 
 
-    async generateJiagongcai(name) {
+    async generateJiagongcai(name, navigate) {
         const response = await fetch(this.ip().concat( "/jiagongcai/"), {
             method : "POST",
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             body: JSON.stringify(
                 {
@@ -596,8 +612,9 @@ async generateQingdanTuijian(name, bh, bt, bm) {
             )
         });
         if (!response.ok) {
-            //const error = await response.json();
-            console.error('error');
+          if (response.status == 401) {
+            navigate("/editor/signin");
+          }
         } else {
             const data = await response.json();
             return data;
@@ -609,7 +626,8 @@ async generateQingdanTuijian(name, bh, bt, bm) {
         const response = await fetch(this.ip().concat( "/applyFL/"), {
             method : "POST",
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             body: JSON.stringify(
                 {
@@ -628,7 +646,14 @@ async generateQingdanTuijian(name, bh, bt, bm) {
     }
 
     async download(id) {
-        const response = await fetch(this.ip().concat( "/download/").concat(id.toString()));
+        const response = await fetch(this.ip().concat( "/download/").concat(id.toString()),
+           {
+                method: "GET",
+                headers : {
+                'Authorization': `Bearer ${this.token_}`
+                          }
+           }
+        );
 
         if (!response.ok) {
             //const error = await response.json();
@@ -646,7 +671,8 @@ async generateQingdanTuijian(name, bh, bt, bm) {
         const response = await fetch(this.ip().concat( "/updatezjcs/"), {
             method : "POST",
             headers: {
-                "Content-type": "application/json"
+                "Content-type": "application/json",
+                'Authorization': `Bearer ${this.token_}`
             },
             body: JSON.stringify(
                 {