wzg 2 лет назад
Родитель
Сommit
51ab666cd0

+ 9 - 1
src/apis/config.js

@@ -13,7 +13,7 @@ axios.interceptors.response.use(
   }
 );
 export const $http = function (url, data) {
-  return axios({
+  let result = axios({
     method: data ? "post" : "get",
     url: baseurl + url,
     data: {
@@ -22,6 +22,14 @@ export const $http = function (url, data) {
     },
     withCredentials: true,
   });
+  if (result.data.status != 0) {
+    ElNotification.error({
+      title: "错误",
+      duration: 3000,
+      message: result.data.msg,
+    });
+  }
+  return result;
 };
 
 export default { baseurl, uploadUrl, $http };

+ 1 - 1
src/components/PicTimeline.vue

@@ -85,7 +85,7 @@ export default {
 
     async function auditMedia(mediaId, a, index, mediaType) {
       //   console.log(mediaId, a, index, mediaType);
-      let res = await api.auditMedia({
+      let { data } = await api.auditMedia({
         mediaId,
         audit: a,
       });

+ 3 - 3
src/components/RemoteSearch.vue

@@ -41,12 +41,12 @@ export default {
     const getSelectList = _.debounce(
       async (queryString, cb) => {
         if (!queryString) return;
-        let res = await api[props.api]({
+        let { data } = await api[props.api]({
           ...props.params,
           term: queryString,
         });
-        if (res.data.status == 0) {
-          cb(res.data.result);
+        if (data.status == 0) {
+          cb(data.result);
         }
       },
       1000,

+ 3 - 3
src/components/RemoteSelect.vue

@@ -53,12 +53,12 @@ export default {
       async (term) => {
         if (options.value.length) return;
         loading.value = true;
-        let res = await api[props.api]({
+        let { data } = await api[props.api]({
           ...props.params,
           term: "",
         });
-        if (res.data.status == 0) {
-          options.value = res.data.result;
+        if (data.status == 0) {
+          options.value = data.result;
         } else {
           options.value = [];
         }

+ 2 - 2
src/layout/Header.vue

@@ -179,7 +179,7 @@ async function cloudLogin() {
   getAbledVersions();
 }
 async function getAbledVersions() {
-  let res = await v
+  let { data } = await v
     .aggregate()
     .match({ deleted: __.neq(true) })
     .sort({
@@ -187,7 +187,7 @@ async function getAbledVersions() {
     })
     .limit(10)
     .end();
-  timelineData.value = res.data;
+  timelineData.value = data;
 }
 
 const size = 20;

+ 2 - 2
src/utils/downloadBlobFile.js

@@ -7,8 +7,8 @@ function downloadBlobFile(url, data, name, type) {
       responseType: "blob",
       data,
     })
-      .then((res) => {
-        let blob = new Blob([res.data], {
+      .then(({ data }) => {
+        let blob = new Blob([data], {
           type: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8",
         });
         let downloadElement = document.createElement("a");

+ 2 - 2
src/views/index/Login.vue

@@ -81,8 +81,8 @@ function check() {
   // form.value.validate((valid) => {});
 }
 async function login() {
-  // let res = await cloudConfig.doc("18ed09686196068205eeb77612d641c6").get();
-  // let { version } = res.data[0];
+  // let {data} = await cloudConfig.doc("18ed09686196068205eeb77612d641c6").get();
+  // let { version } = data[0];
   // localStorage.setItem("version", version);
   form.value.validate(async (valid) => {
     if (valid) {

+ 6 - 6
src/views/marineManage/marineNotice.vue

@@ -74,14 +74,14 @@ let tableData = ref([]);
 let total = ref(0);
 async function getShippingNoticeList(page) {
   currentPage.value = page || currentPage.value;
-  let res = await api.getShippingNoticeList({
+  let { data } = await api.getShippingNoticeList({
     currentPage: currentPage.value,
     size: 10,
     term: term.value,
   });
-  if (res.data.status == 0) {
-    tableData.value = res.data.result;
-    total.value = res.data.total;
+  if (data.status == 0) {
+    tableData.value = data.result;
+    total.value = data.total;
   } else {
     tableData.value = [];
     total.value = 0;
@@ -107,9 +107,9 @@ function openFile(baseURL, suffixName) {
     withCredentials: true,
     timeout: 36000,
     responseType: "blob",
-  }).then((res) => {
+  }).then(({ data }) => {
     if (suffixName.toLowerCase() == "pdf") {
-      const blob = new window.Blob([res.data], {
+      const blob = new window.Blob([data], {
         type: "application/pdf",
       });
       const href = URL.createObjectURL(blob);

+ 4 - 4
src/views/shipManage/shipList.vue

@@ -154,14 +154,14 @@ let tableData = ref([]);
 let total = ref(0);
 async function getShipList(page) {
   currentPage.value = page || currentPage.value;
-  let res = await api.getShipList({
+  let { data } = await api.getShipList({
     currentPage: currentPage.value,
     size: 10,
     term: term.value,
   });
-  if (res.data.status == 0) {
-    tableData.value = res.data.result;
-    total.value = res.data.total;
+  if (data.status == 0) {
+    tableData.value = data.result;
+    total.value = data.total;
   } else {
     tableData.value = [];
     total.value = 0;

+ 9 - 9
src/views/shipOwnerManage/shipOwnerList.vue

@@ -149,18 +149,18 @@ async function addShipOwner() {
   form.value.validate(async (valid) => {
     if (valid) {
       let { userName, shipname, mmsi, phone } = ruleForm.value;
-      let res = await api.addShipOwner({
+      let { data } = await api.addShipOwner({
         userName,
         shipname,
         mmsi,
         phone,
       });
-      console.log(res);
-      if (res.data.status == 0) {
+      console.log({ data });
+      if (data.status == 0) {
         ElNotification.success({
           title: "添加成功",
           duration: 0,
-          message: `${userName}:${res.data.msg}`,
+          message: `${userName}:${data.msg}`,
           type: "success",
         });
         resetForm();
@@ -169,7 +169,7 @@ async function addShipOwner() {
         ElNotification.error({
           title: "失败",
           duration: 3000,
-          message: res.data.msg,
+          message: data.msg,
         });
       }
     } else {
@@ -183,14 +183,14 @@ let tableData = ref([]);
 let total = ref(0);
 async function getShipOwnerList(page) {
   currentPage.value = page || currentPage.value;
-  let res = await api.getShipOwnerList({
+  let { data } = await api.getShipOwnerList({
     currentPage: currentPage.value,
     size: 10,
     term: term.value,
   });
-  if (res.data.status == 0) {
-    tableData.value = res.data.result;
-    total.value = res.data.total;
+  if (data.status == 0) {
+    tableData.value = data.result;
+    total.value = data.total;
   } else {
     tableData.value = [];
     total.value = 0;

+ 4 - 4
src/views/shipSecurityManage/checkShipExamineList.vue

@@ -171,15 +171,15 @@ let total = ref(0);
 let type = ref(1);
 async function getSecurityCheckShipList(page) {
   currentPage.value = page || currentPage.value;
-  let res = await api.getSecurityCheckShipList({
+  let { data } = await api.getSecurityCheckShipList({
     currentPage: currentPage.value,
     size: 10,
     term: term.value,
     type: type.value,
   });
-  if (res.data.status == 0) {
-    tableData.value = res.data.result;
-    total.value = res.data.total;
+  if (data.status == 0) {
+    tableData.value = data.result;
+    total.value = data.total;
   } else {
     tableData.value = [];
     total.value = 0;

+ 4 - 4
src/views/shipSecurityManage/checkShipList.vue

@@ -77,14 +77,14 @@ let tableData = ref([]);
 let total = ref(0);
 async function getSecurityCheckList(page) {
   currentPage.value = page || currentPage.value;
-  let res = await api.getSecurityCheckList({
+  let { data } = await api.getSecurityCheckList({
     currentPage: currentPage.value,
     size: 10,
     term: term.value,
   });
-  if (res.data.status == 0) {
-    tableData.value = res.data.result;
-    total.value = res.data.total;
+  if (data.status == 0) {
+    tableData.value = data.result;
+    total.value = data.total;
   } else {
     tableData.value = [];
     total.value = 0;

+ 4 - 4
src/views/shipSecurityManage/shipCheckHistoryList.vue

@@ -103,15 +103,15 @@ let total = ref(0);
 let type = ref(3);
 async function getSecurityCheckShipList(page) {
   currentPage.value = page || currentPage.value;
-  let res = await api.getSecurityCheckShipList({
+  let { data } = await api.getSecurityCheckShipList({
     currentPage: currentPage.value,
     size: 10,
     term: term.value,
     type: type.value,
   });
-  if (res.data.status == 0) {
-    tableData.value = res.data.result;
-    total.value = res.data.total;
+  if (data.status == 0) {
+    tableData.value = data.result;
+    total.value = data.total;
   } else {
     tableData.value = [];
     total.value = 0;

+ 4 - 4
src/views/shipSecurityManage/shipCheckTemplateDetail.vue

@@ -198,14 +198,14 @@ async function addSecurityTemplate() {
         items,
         id,
       };
-      let res = await api[
+      let { data } = await api[
         id ? "updateSecurityTemplate" : "addSecurityTemplate"
       ](postData);
-      if (res.data.status == 0) {
+      if (data.status == 0) {
         ElNotification.success({
           title: id ? "更新成功" : "添加成功",
           duration: 1500,
-          message: `${securityCheckName}:${res.data.msg}`,
+          message: `${securityCheckName}:${data.msg}`,
           type: "success",
         });
         router.replace("/shipSecurityManage/shipCheckTemplateList");
@@ -213,7 +213,7 @@ async function addSecurityTemplate() {
         ElNotification.error({
           title: "失败",
           duration: 2000,
-          message: res.data.msg,
+          message: data.msg,
         });
       }
     } else {

+ 4 - 4
src/views/shipSecurityManage/shipCheckTemplateList.vue

@@ -102,14 +102,14 @@ let tableData = ref([]);
 let total = ref(0);
 async function getSecurityTemplateList(page) {
   currentPage.value = page || currentPage.value;
-  let res = await api.getSecurityTemplateList({
+  let { data } = await api.getSecurityTemplateList({
     currentPage: currentPage.value,
     size: 10,
     term: term.value,
   });
-  if (res.data.status == 0) {
-    tableData.value = res.data.result;
-    total.value = res.data.total;
+  if (data.status == 0) {
+    tableData.value = data.result;
+    total.value = data.total;
   } else {
     tableData.value = [];
     total.value = 0;