提交 57982d24 编写于 作者: lyf's avatar lyf

修改vuex

上级 274bd541
......@@ -13,10 +13,14 @@
v-loadmore="getOldMSGHistory"
class="center BSListWraper"
>
<section class="c-header">
<section
v-if="JSON.stringify(currentChat) == '{}'"
class="c-header"
>
<div class="header-line">
<div class="c-header-l">
<span class="num">{{ currentChat.diagnoseLogId }}</span>
<span class="num">{{
currentChat.diagnoseLogId }}</span>
<span class="dep">&nbsp;{{ currentChat.department }}</span>
</div>
<div class="c-header-edit">
......@@ -832,7 +836,6 @@
content = {};
signature = '';
msgIndex = -1;
if (item.type.toLowerCase() == 'custom') {
content = JSON.parse(item.content);
if (content.bizType == -1 || content.bizType == 27) {
......
<template>
<div class="livebox">
<div class="top">
<div class="top-left">
<div
v-if="JSON.stringify(currentChat) == '{}'"
class="top-left"
>
<div class="time-message">
<p class="msg-img">
<img :src="currentChat.diagnoseType == 2 ? im_text : im_video">
......@@ -288,8 +291,6 @@
}
if (memberList && memberList.length) {
memberList.forEach((item) => {
if (item.role == 4) {
}
// 在当前群组中的角色 1: 问诊医生 2: 接诊医生 3: 居民 4: 其他
if (item.role == 1) {
this.memberList[0] = item;
......@@ -350,7 +351,6 @@
// 创建trtcClient
clientLogin() {
if (Number(this.currentChat.diagnoseType) === 3) {
console.log('问诊类型', this.currentChat.diagnoseType);
return false;
}
const obj = {
......
import { router, store } from '@pica-cli/vue-cli-plugin-pica-cli-plugin/auto';
import '@/router';
console.log('router, store, vueApp: ', router, store);
\ No newline at end of file
console.log('router, store ', router, store);
\ No newline at end of file
......@@ -6,16 +6,17 @@ import getters from './getters';
import state from './state';
import mutations from './mutations/index';
import actions from './actions/index';
console.log('socket---', socket);
console.log('--init---', state, mutations, getters, actions);
Vue.use(Vuex);
export default new Vuex.Store({
state,
getters,
mutations,
actions,
modules: {
common,
socket
},
modules:{
socket,
common
}
});
......@@ -20,7 +20,7 @@ const common = {
changeToken({ commit }, tokenData) {
commit('CHANGE_TOKEN', tokenData);
},
changeTime({ commit }) {
changeTime({ commit }, tokenData) {
commit('SET_TIME', tokenData);
},
......
// ES6 import
import store from '../';
console.log('store---', store);
import io from 'socket.io-client';
const _VM = this;
const socketTimer = null;
export default {
const socket = {
namespaced: true,
state: {
socketClient: null,
},
actions: {
initSocket ({ commit }, payload) {
initSocket(context, payload) {
console.log('payload--', payload);
const socketClient = io.connect(payload.url, {
query: {
......@@ -19,7 +14,7 @@ export default {
// reconnection: false,
});
console.log('-=-=-initSocket次数', socketClient);
commit('SET_SOCKET', socketClient);
context.commit('SET_SOCKET', socketClient);
socketClient.on('connect', (socket) => {
console.log('socket 链接成功', socket, socketClient);
});
......@@ -33,34 +28,35 @@ export default {
});
socketClient.on('diagnose_push_event', (socket) => {
console.log('diagnose_push_event---', socket);
const {list, allSize, countRespList} = socket;
console.log('--_VM', _VM.$route);
store.commit('updateCurrentDiagList', list);
store.commit('updateAllSize', allSize);
store.commit('updateCurrentCalList', countRespList);
const { list, allSize, countRespList } = socket;
context.commit('updateCurrentDiagList', list);
context.commit('updateAllSize', allSize);
context.commit('updateCurrentCalList', countRespList);
});
socketClient.on('diagnose_call_push_event', (socket) => {
console.log('diagnose_call_push_event---', socket);
const l = store.state.noticeList;
if(l.length >= 5) {
const l = context.state.noticeList;
if (l.length >= 5) {
l.shift();
}
l.push(socket);
const n = {notifyIndex: l.length, ...socket};
store.commit('updateNoticeList', l);
console.log('--_VM', _VM);
const {path} = _VM.$route;
const n = { notifyIndex: l.length, ...socket };
context.commit('updateNoticeList', l);
console.log('n--------', n);
const operateUserId = store.state.soketQuest.operateUserId ? store.state.soketQuest.operateUserId : '';
if(path && String(path).indexOf('workbench') > -1 && n.operateUserId == operateUserId) {
store.commit('socket/SET_NOTIFY', n);
const { path } = window._VM.$route;
const operateUserId = context.state.soketQuest.operateUserId
? context.state.soketQuest.operateUserId
: '';
if (
path &&
String(path).indexOf('workbench') > -1 &&
n.operateUserId == operateUserId
) {
context.commit('socket/SET_NOTIFY', context, n);
}
});
socketClient.on('ping', function () {
console.log('[E] 心跳请求已发出 →', socketClient);
if(socketTimer) {
clearInterval(socketTimer);
}
});
// 收到
socketClient.on('pong', function (socket) {
......@@ -85,22 +81,24 @@ export default {
SET_SOCKET: (state, payload) => {
window.socketClient = payload;
state.socketClient = payload;
console.log(state);
},
SET_NOTIFY: (state, payload) => {
SET_NOTIFY: (state, context, payload) => {
console.log('--payload', payload);
const doms = document.getElementsByClassName('el-notification');
if (doms.length >= 5) return;
const h = _VM.$createElement;
const h = window._VM.$createElement;
const t = payload.department ? `问诊单${payload.diagnoseLogId}(${payload.department})` : `问诊单${payload.diagnoseLogId}`;
const t = payload.department
? `问诊单${payload.diagnoseLogId}(${payload.department})`
: `问诊单${payload.diagnoseLogId}`;
// userCallKfStatus 医助呼叫
// doctorCallKfStatus 医生呼叫
const name = payload.userCallKfStatus == 1 ? payload.userName : payload.doctorName;
const cn = _VM.$notify({
const name =
payload.userCallKfStatus == 1 ? payload.userName : payload.doctorName;
const cn = window._VM.$notify({
title: t,
message: h('p', [
h('i', {style: 'color: teal;'}, `${name}正在呼叫你`),
h('i', { style: 'color: teal;' }, `${name}正在呼叫你`),
h(
'el-button',
......@@ -109,15 +107,16 @@ export default {
on: {
click: function () {
console.log('----state', state);
if(state.showChat) {
_VM.$message({
message: '不可同时进入多个诊室,请先退出已进入的诊室,再试。',
if (state.showChat) {
window._VM.$message({
message:
'不可同时进入多个诊室,请先退出已进入的诊室,再试。',
type: 'warning',
duration:1000
duration: 1000,
});
return false;
}
store.dispatch('gotoInquiry', payload);
context.dispatch('gotoInquiry', payload);
cn.close();
},
},
......@@ -126,12 +125,12 @@ export default {
),
]),
onClose: function () {
console.log('--onClose', payload );
console.log('--onClose', payload);
},
duration: 5000,
position: 'top-right',
});
}
},
},
};
export default socket;
......@@ -10,10 +10,10 @@ export default {
changeRawCurrentCalList(state, obj) {
// console.log("obj",obj)
const index = state.RawCurrentCalList.findIndex(val => {
const index = state.RawCurrentCalList.findIndex((val) => {
return val.status == obj.status;
});
if(index > -1) {
if (index > -1) {
state.RawCurrentCalList[index] = obj;
state.currentCalList[index].is_dot = false;
}
......@@ -23,19 +23,19 @@ export default {
},
updateCurrentCalList(state, obj) {
const NewData = obj;
if(state.RawCurrentCalList.length == 0) {
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,
};
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;
},
......@@ -59,6 +59,7 @@ export default {
state.noticeList = obj;
},
updateIsSuperAdmin(state, obj) {
console.log('obj------', obj);
state.isSuperAdmin = obj;
},
};
......@@ -5,7 +5,9 @@ const state = {
allSize: 0,
currentCalList: {},
RawCurrentCalList: [],
currentChat: {},
currentChat: {
diagnoseType:1
},
currentAdvice: {},
soketQuest: {},
noticeList: [],
......
......@@ -148,7 +148,7 @@
},
watch: {
isSuperAdmin(newdata, olddata) {
console.log('newdata---', newdata);
console.log('newdata---', newdata, this.isSuperAdmin);
if (newdata !== olddata && newdata.userID) {
console.log('-isSuperAdminisSuperAdmin', newdata);
const s = storejs.get('soketQuest');
......@@ -169,18 +169,18 @@
},
},
created() {
},
mounted() {
console.log('this.isSuperAdmin.userID----------', this.isSuperAdmin);
const s = storejs.get('soketQuest');
const t = s ? s.returnStatus : 1;
this.tabPosition = t;
const d = s ? s.dateTime : new Date().format('yyyy-MM-dd');
this.searchParam.dateTime = d;
const id =
s && s.operateUserId ? s.operateUserId : this.isSuperAdmin.userID;
this.operateUserId = id;
},
mounted() {
console.log('this.isSuperAdmin', this.isSuperAdmin);
const id = s && s.operateUserId ? s.operateUserId : this.isSuperAdmin.userID;
this.operateUserId = id;
},
methods: {
tabChange(val) {
......
......@@ -94,6 +94,7 @@
i.isSuper = false;
}
});
console.log('i------------', this.$store);
this.$store.commit('updateIsSuperAdmin', i);
this.items = vueMenuDtos;
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册