| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151 |
- import { createStore } from "vuex";
- import api from "apis/fetch.js";
- const store = createStore({
- state: {
- isLogin: false,
- currentTabText: "运输安全管理中心",
- cargoOwnerInfo: {
- cargoOwnerName: "货主王",
- cargo: "石油焦",
- tons: "30000",
- shipRoute: "秦皇岛-上海",
- contractId: 1,
- data: [
- {
- title: "货种",
- text: "煤炭",
- icon: "cargo",
- },
- {
- title: "吨位",
- text: "30",
- unit: "吨",
- icon: "ship",
- },
- {
- title: "航线",
- text: "秦皇岛-上海",
- icon: "hangxian",
- },
- ],
- },
- shipInfo: {
- shipOwnerName: "船东王",
- shipOwnerId: "898980000000000909",
- shipName: "航海家998",
- icon: "china",
- mmsi: "410999888",
- length: 100,
- width: 30,
- data: [
- {
- title: "MMSI",
- text: "410998998",
- icon: "ship-fill",
- },
- {
- title: "船长",
- text: "30",
- unit: "米",
- icon: "ship-length",
- },
- {
- title: "船宽",
- text: "18",
- 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: {
- status: 0,
- shipOwner: "王船东",
- company: "船王公司",
- cargoOwner: "货主王",
- cargoStatus: 0,
- },
- numbers: [],
- },
- mutations: {
- changeLogin(state, b) {
- state.isLogin = b;
- },
- changeTab(state, text) {
- state.currentTabText = text;
- },
- setCargoOwner(state, info) {
- state.cargoOwnerInfo = info;
- },
- setShipInfo(state, info) {
- state.shipInfo = info;
- },
- 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;
- },
- },
- 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 }, type) {
- return new Promise((resolve, reject) => {
- let arr1 = [
- { icon: "loading", title: "装货中船舶数量", num: 22033 },
- { icon: "transit", title: "运输中船舶数量", num: 12312 },
- { icon: "unloading", title: "卸货中船舶数量", num: 87655 },
- ];
- let arr2 = [
- { icon: "ship-fill-2", title: "装货中船舶数量", num: 16090 },
- { icon: "ship-line", title: "运输中船舶数量", num: 20090 },
- ];
- resolve(type ? arr1 : arr2);
- });
- },
- },
- });
- export default store;
|