wzh 3 лет назад
Родитель
Сommit
28c01bd6c7
1 измененных файлов с 66 добавлено и 1 удалено
  1. 66 1
      src/store/index.js

+ 66 - 1
src/store/index.js

@@ -127,7 +127,8 @@ const store = createStore({
       state.cargoOwnerInfo.data[0].text = cargoownerDetail.cargo;
       state.cargoOwnerInfo.data[1].text = cargoownerDetail.tons;
       state.cargoOwnerInfo.data[2].text =
-        cargoownerDetail.loadPort + " - " + cargoownerDetail.dischargePort;
+        cargoownerDetail.loadPort ||
+        "" + " - " + (cargoownerDetail.dischargePort || "");
       state.shipInfo.shipName = shipDetail.shipName;
       state.exhibitImgs = shipDetail.exhibitImgs;
       state.shipInfo.shipOwnerName = shipDetail.shipownerName;
@@ -150,6 +151,68 @@ const store = createStore({
     setShipsCache(state, ships) {
       state.shipsCache = ships;
     },
+    clearShipInfo(state) {
+      state.shipInfo = {
+        shipOwnerName: "",
+        shipOwnerId: "",
+        shipName: "",
+        icon: "china",
+        mmsi: "",
+        length: 0,
+        width: 0,
+        imgs: [],
+        data: [
+          {
+            title: "MMSI",
+            text: "",
+            icon: "ship-fill",
+          },
+          {
+            title: "船长",
+            text: "",
+            unit: "米",
+            icon: "ship-length",
+          },
+          {
+            title: "船宽",
+            text: "",
+            unit: "米",
+            icon: "ship-width",
+          },
+        ],
+      };
+      state.exhibitImgs = [];
+
+      state.capacity = {};
+
+      state.voyages = [];
+
+      state.certificates = [];
+    },
+    clearCargoOwnerInfo(state) {
+      cargoOwnerInfo = {
+        cargoOwnerName: "",
+        contractId: 1,
+        data: [
+          {
+            title: "货种",
+            text: "",
+            icon: "cargo",
+          },
+          {
+            title: "吨位",
+            text: "",
+            unit: "吨",
+            icon: "ship",
+          },
+          {
+            title: "航线",
+            text: "",
+            icon: "hangxian",
+          },
+        ],
+      };
+    },
   },
   actions: {
     Login({ commit }, userInfo) {
@@ -205,6 +268,7 @@ const store = createStore({
       }
     },
     GetManageShipDetail({ commit }, shipId) {
+      commit("clearShipInfo");
       return new Promise((resolve, reject) => {
         api.getManageShipDetail({ shipId }).then((e) => {
           commit("setManageShipDetail", e.data.result);
@@ -213,6 +277,7 @@ const store = createStore({
       });
     },
     GetTradeShipDetail({ commit }, shipId) {
+      commit("clearShipInfo");
       return new Promise((resolve, reject) => {
         api.getTradeShipDetail({ shipId }).then((e) => {
           commit("setTradeShipDetail", e.data.result);