| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197 |
- import { createStore } from "vuex";
- import api from "apis/fetch.js";
- import _ from "lodash";
- const store = createStore({
- state: {
- isLogin: false,
- currentTabText: "运输安全管理中心",
- cargoOwnerInfo: {
- cargoOwnerName: "",
- contractId: 1,
- data: [
- {
- title: "货种",
- text: "",
- icon: "cargo",
- },
- {
- title: "吨位",
- text: "",
- unit: "吨",
- icon: "ship",
- },
- {
- title: "航线",
- text: "",
- icon: "hangxian",
- },
- ],
- },
- 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",
- },
- ],
- },
- damInfo: {
- data: [
- {
- title: "上游前往三峡数量",
- text: "0",
- unit: "艘",
- icon: "ship-fill",
- },
- {
- title: "三峡等闸船舶数量",
- text: "0",
- unit: "艘",
- icon: "dam",
- },
- {
- title: "预计等待时间",
- text: "0",
- unit: "分",
- icon: "clock",
- },
- ],
- },
- capacity: {
- id: 1,
- shipownerName: "",
- shipownerCompany: "",
- cargoowner: "",
- shipStatus: 0,
- },
- numbers: [],
- },
- mutations: {
- changeLogin(state, b) {
- state.isLogin = b;
- },
- changeTab(state, text) {
- state.currentTabText = text;
- },
- setNumbers(state, numbers) {
- state.numbers = numbers;
- },
- setDamInfo(state, nums) {
- state.damInfo.data[0].text = nums.upstreamShipNum;
- state.damInfo.data[1].text = nums.waitingShipNum;
- state.damInfo.data[2].text = nums.estimatedWaitingTime;
- },
- setManageShipDetail(state, data) {
- let { cargoownerDetail, capacityDetail, shipDetail } = data;
- state.cargoOwnerInfo.cargoOwnerName = cargoownerDetail.cargoowner;
- state.cargoOwnerInfo.data[0].text = cargoownerDetail.cargo;
- state.cargoOwnerInfo.data[1].text = cargoownerDetail.tons;
- state.cargoOwnerInfo.data[2].text =
- cargoownerDetail.loadPort + " - " + cargoownerDetail.dischargePort;
- state.shipInfo.shipName = shipDetail.shipName;
- state.shipInfo.imgs = shipDetail.exhibitImgs;
- state.shipInfo.shipOwnerName = shipDetail.shipownerName;
- state.shipInfo.shipOwnerId = shipDetail.shipownerIdcard;
- state.shipInfo.data[0].text = shipDetail.shipMmsi;
- state.shipInfo.data[1].text = shipDetail.shipLength;
- state.shipInfo.data[2].text = shipDetail.shipBreadth;
- state.capacity = capacityDetail;
- },
- setTradeShipDetail(state, data) {
- state.shipInfo.shipName = data.shipName;
- state.shipInfo.shipOwnerName = data.shipownerName;
- state.shipInfo.shipOwnerId = data.shipownerIdcard;
- state.shipInfo.data[0].text = data.shipMmsi;
- state.shipInfo.data[1].text = data.shipLength;
- state.shipInfo.data[2].text = data.shipBreadth;
- },
- },
- actions: {
- Login({ commit }, userInfo) {
- return new Promise((resolve, reject) => {
- localStorage.setItem("id", 1);
- commit("changeLogin", true);
- resolve(1);
- });
- },
- LogOut({ commit }) {
- return new Promise((resolve, reject) => {
- commit("changeLogin", false);
- localStorage.removeItem("id");
- resolve(0);
- });
- },
- GetSanxiaInfo({ commit }) {
- api.getSanxiaInfo().then((e) => {
- commit("setDamInfo", e.data.result);
- });
- },
- GetNumbers({ commit, state }) {
- let t = state.currentTabText == "运输安全管理中心";
- if (t) {
- api.getShipStatusCount().then((e) => {
- let { result } = e.data;
- state.numbers = [
- {
- icon: "loading",
- title: "装货中船舶数量",
- num: result.loadingShipCount,
- },
- {
- icon: "transit",
- title: "运输中船舶数量",
- num: result.transitShipCount,
- },
- {
- icon: "unloading",
- title: "卸货中船舶数量",
- num: result.unloadingShipCount,
- },
- ];
- });
- } else {
- api.getShipTracksCount().then((e) => {
- let { result } = e.data;
- state.numbers = [
- { icon: "ship-fill-2", title: "船舶数量", num: result.shipNum },
- { icon: "ship-line", title: "轨迹数量", num: result.trackNum },
- ];
- });
- }
- },
- GetManageShipDetail({ commit }, shipId) {
- api.getManageShipDetail({ shipId }).then((e) => {
- commit("setManageShipDetail", e.data.result);
- });
- },
- GetTradeShipDetail({ commit }, shipId) {
- api.getTradeShipDetail({ shipId }).then((e) => {
- commit("setTradeShipDetail", e.data.result);
- });
- },
- },
- });
- export default store;
|