index.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import { createStore } from "vuex";
  2. import api from "apis/fetch.js";
  3. import _ from "lodash";
  4. const store = createStore({
  5. state: {
  6. isLogin: false,
  7. currentTabText: "运输安全管理中心",
  8. cargoOwnerInfo: {
  9. cargoOwnerName: "",
  10. contractId: 1,
  11. data: [
  12. {
  13. title: "货种",
  14. text: "",
  15. icon: "cargo",
  16. },
  17. {
  18. title: "吨位",
  19. text: "",
  20. unit: "吨",
  21. icon: "ship",
  22. },
  23. {
  24. title: "航线",
  25. text: "",
  26. icon: "hangxian",
  27. },
  28. ],
  29. },
  30. shipInfo: {
  31. shipOwnerName: "",
  32. shipOwnerId: "",
  33. shipName: "",
  34. icon: "china",
  35. mmsi: "",
  36. length: 0,
  37. width: 0,
  38. imgs: [],
  39. data: [
  40. {
  41. title: "MMSI",
  42. text: "",
  43. icon: "ship-fill",
  44. },
  45. {
  46. title: "船长",
  47. text: "",
  48. unit: "米",
  49. icon: "ship-length",
  50. },
  51. {
  52. title: "船宽",
  53. text: "",
  54. unit: "米",
  55. icon: "ship-width",
  56. },
  57. ],
  58. },
  59. damInfo: {
  60. data: [
  61. {
  62. title: "上游前往三峡数量",
  63. text: "0",
  64. unit: "艘",
  65. icon: "ship-fill",
  66. },
  67. {
  68. title: "三峡等闸船舶数量",
  69. text: "0",
  70. unit: "艘",
  71. icon: "dam",
  72. },
  73. {
  74. title: "预计等待时间",
  75. text: "0",
  76. unit: "分",
  77. icon: "clock",
  78. },
  79. ],
  80. },
  81. capacity: {
  82. id: 1,
  83. shipownerName: "",
  84. shipownerCompany: "",
  85. cargoowner: "",
  86. shipStatus: 0,
  87. },
  88. numbers: [],
  89. },
  90. mutations: {
  91. changeLogin(state, b) {
  92. state.isLogin = b;
  93. },
  94. changeTab(state, text) {
  95. state.currentTabText = text;
  96. },
  97. setNumbers(state, numbers) {
  98. state.numbers = numbers;
  99. },
  100. setDamInfo(state, nums) {
  101. state.damInfo.data[0].text = nums.upstreamShipNum;
  102. state.damInfo.data[1].text = nums.waitingShipNum;
  103. state.damInfo.data[2].text = nums.estimatedWaitingTime;
  104. },
  105. setManageShipDetail(state, data) {
  106. let { cargoownerDetail, capacityDetail, shipDetail } = data;
  107. state.cargoOwnerInfo.cargoOwnerName = cargoownerDetail.cargoowner;
  108. state.cargoOwnerInfo.data[0].text = cargoownerDetail.cargo;
  109. state.cargoOwnerInfo.data[1].text = cargoownerDetail.tons;
  110. state.cargoOwnerInfo.data[2].text =
  111. cargoownerDetail.loadPort + " - " + cargoownerDetail.dischargePort;
  112. state.shipInfo.shipName = shipDetail.shipName;
  113. state.shipInfo.imgs = shipDetail.exhibitImgs;
  114. state.shipInfo.shipOwnerName = shipDetail.shipownerName;
  115. state.shipInfo.shipOwnerId = shipDetail.shipownerIdcard;
  116. state.shipInfo.data[0].text = shipDetail.shipMmsi;
  117. state.shipInfo.data[1].text = shipDetail.shipLength;
  118. state.shipInfo.data[2].text = shipDetail.shipBreadth;
  119. state.capacity = capacityDetail;
  120. },
  121. setTradeShipDetail(state, data) {
  122. state.shipInfo.shipName = data.shipName;
  123. state.shipInfo.shipOwnerName = data.shipownerName;
  124. state.shipInfo.shipOwnerId = data.shipownerIdcard;
  125. state.shipInfo.data[0].text = data.shipMmsi;
  126. state.shipInfo.data[1].text = data.shipLength;
  127. state.shipInfo.data[2].text = data.shipBreadth;
  128. },
  129. },
  130. actions: {
  131. Login({ commit }, userInfo) {
  132. return new Promise((resolve, reject) => {
  133. localStorage.setItem("id", 1);
  134. commit("changeLogin", true);
  135. resolve(1);
  136. });
  137. },
  138. LogOut({ commit }) {
  139. return new Promise((resolve, reject) => {
  140. commit("changeLogin", false);
  141. localStorage.removeItem("id");
  142. resolve(0);
  143. });
  144. },
  145. GetSanxiaInfo({ commit }) {
  146. api.getSanxiaInfo().then((e) => {
  147. commit("setDamInfo", e.data.result);
  148. });
  149. },
  150. GetNumbers({ commit, state }) {
  151. let t = state.currentTabText == "运输安全管理中心";
  152. if (t) {
  153. api.getShipStatusCount().then((e) => {
  154. let { result } = e.data;
  155. state.numbers = [
  156. {
  157. icon: "loading",
  158. title: "装货中船舶数量",
  159. num: result.loadingShipCount,
  160. },
  161. {
  162. icon: "transit",
  163. title: "运输中船舶数量",
  164. num: result.transitShipCount,
  165. },
  166. {
  167. icon: "unloading",
  168. title: "卸货中船舶数量",
  169. num: result.unloadingShipCount,
  170. },
  171. ];
  172. });
  173. } else {
  174. api.getShipTracksCount().then((e) => {
  175. let { result } = e.data;
  176. state.numbers = [
  177. { icon: "ship-fill-2", title: "船舶数量", num: result.shipNum },
  178. { icon: "ship-line", title: "轨迹数量", num: result.trackNum },
  179. ];
  180. });
  181. }
  182. },
  183. GetManageShipDetail({ commit }, shipId) {
  184. api.getManageShipDetail({ shipId }).then((e) => {
  185. commit("setManageShipDetail", e.data.result);
  186. });
  187. },
  188. GetTradeShipDetail({ commit }, shipId) {
  189. api.getTradeShipDetail({ shipId }).then((e) => {
  190. commit("setTradeShipDetail", e.data.result);
  191. });
  192. },
  193. },
  194. });
  195. export default store;