index.js 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. import { createStore } from "vuex";
  2. import api from "apis/fetch.js";
  3. const store = createStore({
  4. state: {
  5. isLogin: false,
  6. currentTabText: "运输安全管理中心",
  7. cargoOwnerInfo: {
  8. cargoOwnerName: "货主王",
  9. cargo: "石油焦",
  10. tons: "30000",
  11. shipRoute: "秦皇岛-上海",
  12. contractId: 1,
  13. data: [
  14. {
  15. title: "货种",
  16. text: "煤炭",
  17. icon: "cargo",
  18. },
  19. {
  20. title: "吨位",
  21. text: "30",
  22. unit: "吨",
  23. icon: "ship",
  24. },
  25. {
  26. title: "航线",
  27. text: "秦皇岛-上海",
  28. icon: "hangxian",
  29. },
  30. ],
  31. },
  32. shipInfo: {
  33. shipOwnerName: "船东王",
  34. shipOwnerId: "898980000000000909",
  35. shipName: "航海家998",
  36. icon: "china",
  37. mmsi: "410999888",
  38. length: 100,
  39. width: 30,
  40. data: [
  41. {
  42. title: "MMSI",
  43. text: "410998998",
  44. icon: "ship-fill",
  45. },
  46. {
  47. title: "船长",
  48. text: "30",
  49. unit: "米",
  50. icon: "ship-length",
  51. },
  52. {
  53. title: "船宽",
  54. text: "18",
  55. unit: "米",
  56. icon: "ship-width",
  57. },
  58. ],
  59. },
  60. damInfo: {
  61. data: [
  62. {
  63. title: "上游前往三峡数量",
  64. text: "0",
  65. unit: "艘",
  66. icon: "ship-fill",
  67. },
  68. {
  69. title: "三峡等闸船舶数量",
  70. text: "0",
  71. unit: "艘",
  72. icon: "dam",
  73. },
  74. {
  75. title: "预计等待时间",
  76. text: "0",
  77. unit: "分",
  78. icon: "clock",
  79. },
  80. ],
  81. },
  82. capacity: {
  83. status: 0,
  84. shipOwner: "王船东",
  85. company: "船王公司",
  86. cargoOwner: "货主王",
  87. cargoStatus: 0,
  88. },
  89. numbers: [],
  90. },
  91. mutations: {
  92. changeLogin(state, b) {
  93. state.isLogin = b;
  94. },
  95. changeTab(state, text) {
  96. state.currentTabText = text;
  97. },
  98. setCargoOwner(state, info) {
  99. state.cargoOwnerInfo = info;
  100. },
  101. setShipInfo(state, info) {
  102. state.shipInfo = info;
  103. },
  104. setNumbers(state, numbers) {
  105. state.numbers = numbers;
  106. },
  107. setDamInfo(state, nums) {
  108. state.damInfo.data[0].text = nums.upstreamShipNum;
  109. state.damInfo.data[1].text = nums.waitingShipNum;
  110. state.damInfo.data[2].text = nums.estimatedWaitingTime;
  111. },
  112. },
  113. actions: {
  114. Login({ commit }, userInfo) {
  115. return new Promise((resolve, reject) => {
  116. localStorage.setItem("id", 1);
  117. commit("changeLogin", true);
  118. resolve(1);
  119. });
  120. },
  121. LogOut({ commit }) {
  122. return new Promise((resolve, reject) => {
  123. commit("changeLogin", false);
  124. localStorage.removeItem("id");
  125. resolve(0);
  126. });
  127. },
  128. GetSanxiaInfo({ commit }) {
  129. api.getSanxiaInfo().then((e) => {
  130. commit("setDamInfo", e.data.result);
  131. });
  132. },
  133. GetNumbers({ commit, state }, type) {
  134. return new Promise((resolve, reject) => {
  135. let arr1 = [
  136. { icon: "loading", title: "装货中船舶数量", num: 22033 },
  137. { icon: "transit", title: "运输中船舶数量", num: 12312 },
  138. { icon: "unloading", title: "卸货中船舶数量", num: 87655 },
  139. ];
  140. let arr2 = [
  141. { icon: "ship-fill-2", title: "装货中船舶数量", num: 16090 },
  142. { icon: "ship-line", title: "运输中船舶数量", num: 20090 },
  143. ];
  144. resolve(type ? arr1 : arr2);
  145. });
  146. },
  147. },
  148. });
  149. export default store;