Merge branch 'test' of https://git.code.tencent.com/lian-cbtc/jl-client into test
This commit is contained in:
commit
88b9ac889c
@ -94,10 +94,10 @@ export default {
|
||||
doorList: [],
|
||||
memberData: {},
|
||||
treeData: [{
|
||||
labelName: '行调',
|
||||
labelName: 'NCC调度',
|
||||
children: []
|
||||
}, {
|
||||
labelName: 'NCC调度',
|
||||
labelName: '行调',
|
||||
children: []
|
||||
}, {
|
||||
labelName: '车站值班员',
|
||||
@ -197,14 +197,14 @@ export default {
|
||||
val.forEach(item => {
|
||||
const device = this.$store.getters['map/getDeviceByCode'](item.deviceCode);
|
||||
switch (item.type) {
|
||||
case 'DISPATCHER':
|
||||
this.memberData[item.id].labelName = '行调' + (item.name || '');
|
||||
dispatcherList.push(this.memberData[item.id]);
|
||||
break;
|
||||
case 'NCC_DISPATCHER':
|
||||
this.memberData[item.id].labelName = 'NCC调度' + (item.name || '');
|
||||
nccDispatcherList.push(this.memberData[item.id]);
|
||||
break;
|
||||
case 'DISPATCHER':
|
||||
this.memberData[item.id].labelName = '行调' + (item.name || '');
|
||||
dispatcherList.push(this.memberData[item.id]);
|
||||
break;
|
||||
case 'ELECTRIC_DISPATCHER':
|
||||
this.memberData[item.id].labelName = '电力调度' + (item.name || '');
|
||||
electricDispatcherList.push(this.memberData[item.id]);
|
||||
@ -277,13 +277,13 @@ export default {
|
||||
}
|
||||
});
|
||||
this.treeData = [{
|
||||
labelName: '行调',
|
||||
id: 'dispatcher',
|
||||
children: dispatcherList
|
||||
}, {
|
||||
labelName: 'NCC调度',
|
||||
id: 'nccDispatcher',
|
||||
children: nccDispatcherList
|
||||
}, {
|
||||
labelName: '行调',
|
||||
id: 'dispatcher',
|
||||
children: dispatcherList
|
||||
}, {
|
||||
labelName: '车站值班员',
|
||||
id: 'stationSupervisor',
|
||||
|
@ -39,7 +39,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="middleMain">
|
||||
<div v-for="(item, index) in chatList" :ref="'dom'+index" :key="index" class="row pointer" :class="{active: item.id === id || (privateChatId && privateChatId == getPrivateChatId(item))}" @click="groupClick(item)" @contextmenu.prevent.stop="showMenu($event,item)">
|
||||
<div v-for="(item, index) in groupList" :ref="'dom'+index" :key="index" class="row pointer" :class="{active: item.id === id || (privateChatId && privateChatId == getPrivateChatId(item))}" @click="groupClick(item)" @contextmenu.prevent.stop="showMenu($event,item)">
|
||||
<div v-show="false" class="groupIcon">
|
||||
<img :src="getImgUrl(item.imageUrl)" alt="">
|
||||
</div>
|
||||
@ -77,7 +77,8 @@ import ChatContent from './chatContent';
|
||||
import EditGroup from './editGroup';
|
||||
import AddressBook from './addressBook';
|
||||
import PopMenu from '@/components/PopMenu';
|
||||
import DialogMember from './dialogMember.vue';
|
||||
import DialogMember from './dialogMember';
|
||||
import { objectIsEqual } from '@/utils/date';
|
||||
export default {
|
||||
name: 'ChatDialog',
|
||||
components: {
|
||||
@ -111,8 +112,7 @@ export default {
|
||||
id: 0, // 当前的群组id
|
||||
privateChatId: '', // 私聊角色id
|
||||
memberTreeData: [],
|
||||
menu: [], // 右键菜单
|
||||
noIdChatList: [] // 临时加的私聊,没有id
|
||||
menu: [] // 右键菜单
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@ -136,13 +136,6 @@ export default {
|
||||
});
|
||||
return n;
|
||||
},
|
||||
chatList() {
|
||||
const list = JSON.parse(JSON.stringify(this.groupList));
|
||||
this.noIdChatList.forEach(item => {
|
||||
list.splice(item.sortIndex, 0, item);
|
||||
});
|
||||
return list;
|
||||
},
|
||||
activeMessageList() {
|
||||
let list = [];
|
||||
const find = this.groupList.find(item => {
|
||||
@ -174,11 +167,7 @@ export default {
|
||||
watch: {
|
||||
'$store.state.socket.simulationReset': function (val) { // 仿真重置
|
||||
if (val) {
|
||||
this.id = 0;
|
||||
this.privateChatId = '';
|
||||
this.$store.dispatch('socket/resetConversationGroup');
|
||||
this.groupList = [];
|
||||
this.noIdChatList = [];
|
||||
this.initGroupList();
|
||||
}
|
||||
},
|
||||
'$store.state.socket.conversationGroup.MESSAGE': function(val) {
|
||||
@ -200,8 +189,15 @@ export default {
|
||||
this.$message.success(`${val.messageTips}`);
|
||||
}
|
||||
if (val.id) {
|
||||
this.groupList.push({...val, messageList: [], imageUrl: ''});
|
||||
this.removeNoIdItem();
|
||||
const findIndex = this.groupList.findIndex(ii => {
|
||||
return val.id == ii.id || (val.type == 'PRIVATE_CHAT' && ii.type == 'PRIVATE_CHAT' && this.isEqualMember(ii.memberList, val.memberList));
|
||||
});
|
||||
const obj = {...val, messageList: [], imageUrl: ''};
|
||||
if (findIndex > -1) {
|
||||
this.groupList.splice(findIndex, 1, obj);
|
||||
} else {
|
||||
this.groupList.push(obj);
|
||||
}
|
||||
}
|
||||
},
|
||||
'$store.state.socket.conversationGroup.UPDATE_NAME': function(val) {
|
||||
@ -242,8 +238,14 @@ export default {
|
||||
totalUnread() {
|
||||
this.$emit('setTotalUnread', this.totalUnread);
|
||||
},
|
||||
myMemberId() {
|
||||
this.getGroupList();
|
||||
myMemberId: {
|
||||
handler(val) {
|
||||
this.initGroupList();
|
||||
if (val) {
|
||||
this.getGroupList();
|
||||
}
|
||||
},
|
||||
immediate: true
|
||||
},
|
||||
memberList () {
|
||||
this.getTreeData();
|
||||
@ -254,9 +256,9 @@ export default {
|
||||
created() {
|
||||
this.getTreeData();
|
||||
this.getBaseInfo();
|
||||
this.getGroupList();
|
||||
},
|
||||
beforeDestroy() {
|
||||
this.initGroupList();
|
||||
this.handleClose();
|
||||
},
|
||||
methods: {
|
||||
@ -364,14 +366,13 @@ export default {
|
||||
},
|
||||
sendPrivateMsg(item) {
|
||||
this.privateChatId = item.id;
|
||||
const findIndex = this.chatList.findIndex(ii => {
|
||||
const findIndex = this.groupList.findIndex(ii => {
|
||||
return ii.type == 'PRIVATE_CHAT' && ii.memberList.find(m => {
|
||||
return m.memberId == item.id;
|
||||
});
|
||||
});
|
||||
let index = findIndex;
|
||||
if (findIndex < 0) {
|
||||
const sortIndex = this.chatList.length;
|
||||
const obj = {
|
||||
creatorId: this.myMemberId,
|
||||
leaderId: this.myMemberId,
|
||||
@ -379,33 +380,22 @@ export default {
|
||||
{memberId: this.myMemberId, connect: false, role: 'Leader'},
|
||||
{memberId: item.id, connect: false, role: 'Leader'}
|
||||
],
|
||||
sortIndex: sortIndex,
|
||||
messageList: [],
|
||||
name: item.labelName,
|
||||
type: 'PRIVATE_CHAT'
|
||||
};
|
||||
this.noIdChatList.push(obj);
|
||||
index = sortIndex;
|
||||
this.groupList.push(obj);
|
||||
index = this.groupList.length - 1;
|
||||
}
|
||||
this.scrollTop(index);
|
||||
this.id = 0;
|
||||
this.tabActive = 0;
|
||||
},
|
||||
removeNoIdItem() {
|
||||
const list = [];
|
||||
this.noIdChatList.forEach(item => {
|
||||
const find = this.groupList.find(ii => {
|
||||
return ii.type == 'PRIVATE_CHAT' && ii.memberList[0].memberId == item.memberList[0].memberId && ii.memberList[1].memberId == item.memberList[1].memberId;
|
||||
});
|
||||
if (!find) {
|
||||
list.push(item);
|
||||
} else {
|
||||
if (this.privateChatId && this.privateChatId == this.getPrivateChatId(find)) {
|
||||
this.groupClick(find);
|
||||
}
|
||||
}
|
||||
});
|
||||
this.noIdChatList = list;
|
||||
initGroupList() {
|
||||
this.id = 0;
|
||||
this.privateChatId = '';
|
||||
this.$store.dispatch('socket/resetConversationGroup');
|
||||
this.groupList = [];
|
||||
},
|
||||
getTreeData() {
|
||||
const val = this.memberList;
|
||||
@ -431,14 +421,14 @@ export default {
|
||||
val.forEach(item => {
|
||||
const device = this.$store.getters['map/getDeviceByCode'](item.deviceCode);
|
||||
switch (item.type) {
|
||||
case 'DISPATCHER':
|
||||
this.memberData[item.id].labelName = '行调' + (item.name || '');
|
||||
dispatcherList.push(this.memberData[item.id]);
|
||||
break;
|
||||
case 'NCC_DISPATCHER':
|
||||
this.memberData[item.id].labelName = 'NCC调度' + (item.name || '');
|
||||
nccDispatcherList.push(this.memberData[item.id]);
|
||||
break;
|
||||
case 'DISPATCHER':
|
||||
this.memberData[item.id].labelName = '行调' + (item.name || '');
|
||||
dispatcherList.push(this.memberData[item.id]);
|
||||
break;
|
||||
case 'ELECTRIC_DISPATCHER':
|
||||
this.memberData[item.id].labelName = '电力调度' + (item.name || '');
|
||||
electricDispatcherList.push(this.memberData[item.id]);
|
||||
@ -509,13 +499,13 @@ export default {
|
||||
}
|
||||
});
|
||||
this.memberTreeData = [{
|
||||
labelName: '行调',
|
||||
id: 'dispatcher',
|
||||
children: dispatcherList
|
||||
}, {
|
||||
labelName: 'NCC调度',
|
||||
id: 'nccDispatcher',
|
||||
children: nccDispatcherList
|
||||
}, {
|
||||
labelName: '行调',
|
||||
id: 'dispatcher',
|
||||
children: dispatcherList
|
||||
}, {
|
||||
labelName: '车站值班员',
|
||||
id: 'stationSupervisor',
|
||||
@ -625,9 +615,9 @@ export default {
|
||||
let name = '';
|
||||
if (item.type == 'PRIVATE_CHAT') {
|
||||
let mId = '';
|
||||
if (item.memberList[0].memberId == this.myMemberId) {
|
||||
if (item.memberList[0].memberId == this.myMemberId && item.memberList[1]) {
|
||||
mId = item.memberList[1].memberId;
|
||||
} else if (item.memberList[1].memberId == this.myMemberId) {
|
||||
} else {
|
||||
mId = item.memberList[0].memberId;
|
||||
}
|
||||
const node = this.memberData[mId];
|
||||
@ -692,11 +682,19 @@ export default {
|
||||
},
|
||||
getGroupList() {
|
||||
getGroupList(this.groupId).then(res => {
|
||||
this.groupList = res.data;
|
||||
res.data.forEach(item => {
|
||||
const findIndex = this.groupList.findIndex(ii => {
|
||||
return item.id == ii.id || (item.type == 'PRIVATE_CHAT' && ii.type == 'PRIVATE_CHAT' && this.isEqualMember(ii.memberList, item.memberList));
|
||||
});
|
||||
if (findIndex > -1) {
|
||||
this.groupList.splice(findIndex, 1, item);
|
||||
} else {
|
||||
this.groupList.push(item);
|
||||
}
|
||||
});
|
||||
if (this.groupList && this.groupList[0] && !this.id && !this.privateChatId) {
|
||||
this.id = this.groupList[0].id;
|
||||
}
|
||||
this.removeNoIdItem();
|
||||
});
|
||||
},
|
||||
getImgUrl(url) {
|
||||
@ -711,6 +709,17 @@ export default {
|
||||
filterClick(index) {
|
||||
this.filterActive = index;
|
||||
},
|
||||
isEqualMember(list1, list2) {
|
||||
const m1 = {};
|
||||
const m2 = {};
|
||||
list1.forEach(item => {
|
||||
m1[item.memberId] = item.memberId;
|
||||
});
|
||||
list2.forEach(item => {
|
||||
m2[item.memberId] = item.memberId;
|
||||
});
|
||||
return objectIsEqual(m1, m2);
|
||||
},
|
||||
groupClick(item) {
|
||||
this.id = item.id || 0;
|
||||
if (item.type == 'GROUP_CHAT') {
|
||||
@ -722,12 +731,11 @@ export default {
|
||||
},
|
||||
getPrivateChatId(item) {
|
||||
let pId = '';
|
||||
if (item.type == 'PRIVATE_CHAT' && item.leaderId == this.myMemberId) {
|
||||
const find = item.memberList.find(ii => {
|
||||
return ii.memberId != this.myMemberId;
|
||||
});
|
||||
if (find) {
|
||||
pId = find.memberId;
|
||||
if (item.type == 'PRIVATE_CHAT') {
|
||||
if (item.memberList[0].memberId == this.myMemberId && item.memberList[1]) {
|
||||
pId = item.memberList[1].memberId;
|
||||
} else {
|
||||
pId = item.memberList[0].memberId;
|
||||
}
|
||||
}
|
||||
return pId;
|
||||
|
Loading…
Reference in New Issue
Block a user