提交 5733472a 编写于 作者: lyf's avatar lyf

重写store

上级 57982d24
......@@ -14,7 +14,6 @@
class="center BSListWraper"
>
<section
v-if="JSON.stringify(currentChat) == '{}'"
class="c-header"
>
<div class="header-line">
......@@ -454,7 +453,7 @@
},
computed: {
...mapState({
currentChat: 'currentChat',
currentChat: (state) => state.assign.main.currentChat,
}),
canSend() {
return !!this.sendText;
......@@ -495,7 +494,9 @@
},
},
created() {},
created() {
console.log('diagnoseLogId', this.currentChat);
},
mounted() {
cacheMap = {};
......
......@@ -2,7 +2,6 @@
<div class="livebox">
<div class="top">
<div
v-if="JSON.stringify(currentChat) == '{}'"
class="top-left"
>
<div class="time-message">
......@@ -180,7 +179,7 @@
},
computed: {
...mapState({
currentChat: 'currentChat',
currentChat: (state) => state.assign.main.currentChat,
}),
diagnoseType() {
switch (this.currentChat.diagnoseType) {
......@@ -205,7 +204,9 @@
}
},
},
created() {},
created() {
console.log('diagnoseType--', this.diagnoseType);
},
beforeDestroy() {
this.clearTime();
......
......@@ -136,7 +136,7 @@
mounted() {},
computed: {
...mapState({
currentAdvice: 'currentAdvice',
currentAdvice: (state) => state.assign.main.currentAdvice,
}),
musicList() {
const i = this.currentAdvice && this.currentAdvice.illnessAudioUrls ? this.currentAdvice.illnessAudioUrls : [];
......
......@@ -236,8 +236,8 @@
computed: {
...mapState({
showChat: 'showChat',
showAdvice: 'showAdvice',
showChat: (state) => state.assign.main.showChat,
showAdvice: (state) => state.assign.main.showAdvice,
}),
diagnoseType() {
switch (this.item.diagnoseType) {
......
import { router, store } from '@pica-cli/vue-cli-plugin-pica-cli-plugin/auto';
import '@/router';
console.log('router, store ', router, store);
\ No newline at end of file
console.log('router ', router);
console.log('store ', store);
\ No newline at end of file
import { opAck } from '@/api/diagnosis';
export default {
gotoInquiry({ commit }, current) {
if (current.imTeamId) {
const params = {
teamIdList: [current.imTeamId]
};
opAck(params).then(res => {
if (res.code == '000000') {
commit('updateShowChat', true);
commit('updateCurrentChat', current);
}
}).catch(err => {
_VM.$message({
message: err.message,
type: 'warning',
duration: 1000
});
});
}
},
};
\ No newline at end of file
const getters = {
_token: state => state.common._token,
isFromAssignTask: state => state.common.isFromAssignTask,
time:state => state.common.time,
};
export default getters;
import Vue from 'vue';
import Vuex from 'vuex';
import common from './modules/common';
import socket from './modules/socket';
import getters from './getters';
import state from './state';
import mutations from './mutations/index';
import actions from './actions/index';
// import getters from './root/getters';
// import state from './root/state';
// import mutations from './root/mutations';
// import actions from './root/actions';
// export default {
// state:{
// ...state
// },
// getters:{
// ...getters
// },
// mutations:{
// ...mutations
// },
// actions:{
// ...actions
// },
console.log('--init---', state, mutations, getters, actions);
Vue.use(Vuex);
export default new Vuex.Store({
state,
getters,
mutations,
actions,
modules:{
socket,
common
}
});
// };
......@@ -5,6 +5,11 @@ const common = {
isFromAssignTask: false,
time:null,
},
getters: {
_token: state => state.common._token,
isFromAssignTask: state => state.common.isFromAssignTask,
time:state => state.common.time,
},
mutations: {
CHANGE_TOKEN: (state, data) => {
state._token = data;
......@@ -26,5 +31,4 @@ const common = {
}
};
console.log('common', common);
export default common;
import { opAck } from '@/api/diagnosis';
import storejs from 'storejs';
const main = {
namespaced: true,
state: {
currentDiagList: [],
allSize: 0,
currentCalList: {},
RawCurrentCalList: [],
currentChat: {
diagnoseType: 1,
diagnoseLogId: '',
department: '',
},
currentAdvice: {},
soketQuest: {},
noticeList: [],
showChat: false,
showAdvice: false,
isSuperAdmin: {
isSuper: false,
userID: '',
},
},
mutations: {
updateCurrentDiagList(state, obj) {
state.currentDiagList = obj;
},
updateAllSize(state, allSize) {
state.allSize = allSize;
},
// 改变原数据
changeRawCurrentCalList(state, obj) {
// console.log("obj",obj)
const index = state.RawCurrentCalList.findIndex((val) => {
return val.status == obj.status;
});
if (index > -1) {
state.RawCurrentCalList[index] = obj;
state.currentCalList[index].is_dot = false;
}
},
clearRawCurrentCalList(state) {
state.RawCurrentCalList = [];
},
updateCurrentCalList(state, obj) {
const NewData = obj;
if (state.RawCurrentCalList.length == 0) {
state.RawCurrentCalList = obj;
}
const RawData = state.RawCurrentCalList;
for (let i = 0; i < NewData.length; i++) {
let is_dot = false;
if (RawData.length > 0) {
is_dot = NewData[i].count > RawData[i].count ? true : false;
}
NewData[i] = {
...NewData[i],
is_dot: is_dot,
};
}
state.currentCalList = NewData;
},
updateCurrentChat(state, obj) {
state.currentChat = obj;
},
updateCurrentAdvice(state, obj) {
state.currentAdvice = obj;
},
updateSoketQuest(state, obj) {
storejs.set('soketQuest', obj);
state.soketQuest = obj;
},
updateShowChat(state, obj) {
state.showChat = obj;
},
updateShowAdvice(state, obj) {
state.showAdvice = obj;
},
updateNoticeList(state, obj) {
state.noticeList = obj;
},
updateIsSuperAdmin(state, obj) {
console.log('obj---------', obj);
state.isSuperAdmin = obj;
},
},
actions: {
gotoInquiry({ commit }, current) {
if (current.imTeamId) {
const params = {
teamIdList: [current.imTeamId],
};
opAck(params)
.then((res) => {
if (res.code == '000000') {
commit('updateShowChat', true);
commit('updateCurrentChat', current);
}
})
.catch((err) => {
this.$message({
message: err.message,
type: 'warning',
duration: 1000,
});
});
}
},
},
};
export default main;
import common from './common';
import main from './main';
import socket from './socket';
export default {
common,
main,
socket
};
\ No newline at end of file
import storejs from 'storejs';
export default {
updateCurrentDiagList(state, obj) {
state.currentDiagList = obj;
},
updateAllSize(state, allSize) {
state.allSize = allSize;
},
// 改变原数据
changeRawCurrentCalList(state, obj) {
// console.log("obj",obj)
const index = state.RawCurrentCalList.findIndex((val) => {
return val.status == obj.status;
});
if (index > -1) {
state.RawCurrentCalList[index] = obj;
state.currentCalList[index].is_dot = false;
}
},
clearRawCurrentCalList(state) {
state.RawCurrentCalList = [];
},
updateCurrentCalList(state, obj) {
const NewData = obj;
if (state.RawCurrentCalList.length == 0) {
state.RawCurrentCalList = obj;
}
const RawData = state.RawCurrentCalList;
for (let i = 0; i < NewData.length; i++) {
let is_dot = false;
if (RawData.length > 0) {
is_dot = NewData[i].count > RawData[i].count ? true : false;
}
NewData[i] = {
...NewData[i],
is_dot: is_dot,
};
}
state.currentCalList = NewData;
},
updateCurrentChat(state, obj) {
state.currentChat = obj;
},
updateCurrentAdvice(state, obj) {
state.currentAdvice = obj;
},
updateSoketQuest(state, obj) {
storejs.set('soketQuest', obj);
state.soketQuest = obj;
},
updateShowChat(state, obj) {
state.showChat = obj;
},
updateShowAdvice(state, obj) {
state.showAdvice = obj;
},
updateNoticeList(state, obj) {
state.noticeList = obj;
},
updateIsSuperAdmin(state, obj) {
console.log('obj------', obj);
state.isSuperAdmin = obj;
},
};
/* 内存数据状态 */
const state = {
currentDiagList: [],
allSize: 0,
currentCalList: {},
RawCurrentCalList: [],
currentChat: {
diagnoseType:1
},
currentAdvice: {},
soketQuest: {},
noticeList: [],
showChat: false,
showAdvice: false,
isSuperAdmin: {
isSuper: false,
userID: ''
}
};
export default state;
\ No newline at end of file
......@@ -139,11 +139,11 @@
},
computed: {
...mapState({
allSize: 'allSize',
currentDiagList: 'currentDiagList',
currentCalList: 'currentCalList',
soketQuest: 'soketQuest',
isSuperAdmin: 'isSuperAdmin',
allSize: (state) => state.assign.main.allSize,
currentDiagList: (state) => state.assign.main.currentDiagList,
currentCalList: (state) => state.assign.main.currentCalList,
soketQuest:(state) => state.assign.main.soketQuest,
isSuperAdmin:(state) => state.assign.main.isSuperAdmin,
}),
},
watch: {
......
......@@ -73,11 +73,11 @@
},
computed: {
...mapState({
showChat: 'showChat',
currentChat: 'currentChat',
showAdvice:'showAdvice'
showChat: (state) => state.assign.main.showChat,
currentChat: (state) => state.assign.main.currentChat,
showAdvice:(state) => state.assign.main.showAdvice,
}),
...mapGetters(['_token'])
...mapGetters('common',['_token'])
},
created() {
vm = this;
......
......@@ -83,7 +83,6 @@
};
const u = this.getSocketUrl(BUILD_ENV);
storejs.set('initSocketInfo', { url: u, userId: userId });
console.log('1111');
this.$store.dispatch('socket/initSocket', { url: u, userId: userId });
vueMenuDtos.map((item) => {
if (item.index.indexOf('administrators') > -1) {
......@@ -94,9 +93,8 @@
i.isSuper = false;
}
});
console.log('i------------', this.$store);
this.$store.commit('updateIsSuperAdmin', i);
console.log('updateIsSuperAdmin----', this.$store.state);
this.$store.commit('main/updateIsSuperAdmin', i);
this.items = vueMenuDtos;
sessionStorage.setItem(
'ADMIN_IM_CENTER_NAVS',
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册