123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101 |
- import http from '@/request/index.js';
- export const state = {
- houseData: [], //库房数据
- houseSelectData: {
- houseName: "",
- houseId: ""
- },
- homeAwaitData: {},
- userData: {},
- messData: []
- };
- export const mutations = {
- setHouseData(state, data) {
- state.houseData = data
- },
- setHouseName(state, data) {
- state.houseSelectData = data
- },
- setUserData(state, data) {
- state.userData = data
- },
- setAwaitData(state, data) {
- state.homeAwaitData = data
- },
- setMessData(state, data) {
- state.messData = data
- },
- }
- export const actions = {
- getHomeAwaitData({
- commit,
- rootState
- }, data) {
- return new Promise((resolve, reject) => {
- http('home.getAwaitData', data, '加载中').then(res => {
- if (res.success == true) {
- commit('setAwaitData', res.data);
- }
- }).catch(e => {
- reject(e)
- })
- })
- },
- getHouseData({
- dispatch,
- commit,
- rootState
- }, data) {
- return new Promise((resolve, reject) => {
- http('home.getRoomData', data, '加载中').then(res => {
- if (res.success == true) {
- res.data.length > 0 && res.data.forEach((item) => {
- item['text'] = item.stroomName;
- item['value'] = item.id;
- })
- commit('setHouseName', {
- houseName: res.data[0].stroomName,
- houseId: res.data[0].id
- });
- dispatch('getHomeAwaitData', {
- stroomId: res.data[0].id
- })
- commit('setHouseData', res.data);
- } else {
- commit('setHouseData', []);
- }
- }).catch(e => {
- reject(e)
- })
- })
- },
- getUserData({
- commit,
- rootState
- }, data) {
- return new Promise((resolve, reject) => {
- http('home.getUserData', data, '加载中').then(res => {
- if (res.success == true) {
- commit('setUserData', res.data.userContext);
- }
- }).catch(e => {
- reject(e)
- })
- })
- },
- getMessData({
- commit,
- rootState
- }, data) {
- return new Promise((resolve, reject) => {
- http('home.getMessageData', data, '加载中').then(res => {
- if (res.success == true) {
- resolve(res);
- commit('setMessData', res.data.records);
- }
- }).catch(e => {
- reject(e)
- })
- })
- },
- }
|