This commit is contained in:
zyy 2019-08-16 16:19:14 +08:00
commit 7b22ab377e
11 changed files with 532 additions and 505 deletions

View File

@ -457,7 +457,6 @@ class SkinCode extends defaultStyle {
haveTextHSDA: true, // 是否需创建textHSDA对象 haveTextHSDA: true, // 是否需创建textHSDA对象
haveArrowText: true, // 是否需创建arrowText对象 haveArrowText: true, // 是否需创建arrowText对象
haveTrainBorder: false, // 是否需创建trainBorder对象 haveTrainBorder: false, // 是否需创建trainBorder对象
aspectRatio: 7/5, // 字体宽高比例用以拼接text是计算位置
textOffset: 4, // 字体偏移(用以控制字体据车头的距离) textOffset: 4, // 字体偏移(用以控制字体据车头的距离)
trainWidthMoreText: 8, // 计算列车长度时--列车长比text多出尺寸 trainWidthMoreText: 8, // 计算列车长度时--列车长比text多出尺寸
useSelfFormat: true, // 使用配置项的nameFormat useSelfFormat: true, // 使用配置项的nameFormat

View File

@ -423,7 +423,6 @@ class SkinCode extends defaultStyle {
haveTextHSDA: true, // 是否需创建textHSDA对象 haveTextHSDA: true, // 是否需创建textHSDA对象
haveArrowText: true, // 是否需创建arrowText对象 haveArrowText: true, // 是否需创建arrowText对象
haveTrainBorder: false, // 是否需创建trainBorder对象 haveTrainBorder: false, // 是否需创建trainBorder对象
aspectRatio: 7/5, // 字体宽高比例用以拼接text是计算位置
textOffset: 4, // 字体偏移(用以控制字体据车头的距离) textOffset: 4, // 字体偏移(用以控制字体据车头的距离)
trainWidthMoreText: 8, // 计算列车长度时--列车长比text多出尺寸 trainWidthMoreText: 8, // 计算列车长度时--列车长比text多出尺寸
useSelfFormat: true, // 使用配置项的nameFormat useSelfFormat: true, // 使用配置项的nameFormat

View File

@ -371,7 +371,6 @@ class SkinCode extends defaultStyle {
haveTextHSDA: false, // 是否需创建textHSDA对象 haveTextHSDA: false, // 是否需创建textHSDA对象
haveArrowText: true, // 是否需创建arrowText对象 haveArrowText: true, // 是否需创建arrowText对象
haveTrainBorder: false, // 是否需创建trainBorder对象 haveTrainBorder: false, // 是否需创建trainBorder对象
aspectRatio: 8/15, // 字体宽高比例用以拼接text是计算位置
textOffset: 1, // 字体偏移(用以控制字体据车头的距离) textOffset: 1, // 字体偏移(用以控制字体据车头的距离)
trainWidthMoreText: 2 // 计算列车长度时--列车长比text多出尺寸 trainWidthMoreText: 2 // 计算列车长度时--列车长比text多出尺寸
}, },

View File

@ -217,23 +217,23 @@ export default class TrainBody extends Group {
formatChangePosition(model, style) { formatChangePosition(model, style) {
if (this.nameFormat) { if (this.nameFormat) {
const arr = this.nameFormat.split(':'); const arr = this.nameFormat.split(':');
let fontNumber = 0; let widthText = 0;
arr.forEach(ele => { arr.forEach(ele => {
if (ele == 'targetCode') { if (ele == 'targetCode') {
this.textTrainNumber.setStyle('x', parseInt(model.point.x + fontNumber * model.fontSize * style.Train.common.aspectRatio + style.Train.common.textOffset) ); this.textTrainNumber.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset) );
fontNumber += (style.Train.trainNumber.targetCodePrefix || '').length; widthText += this.textTrainNumber.getBoundingRect().width;
this.add(this.textTrainNumber); this.add(this.textTrainNumber);
} else if (ele == 'serviceNumber') { } else if (ele == 'serviceNumber') {
this.textTrainServer.setStyle('x', parseInt(model.point.x + fontNumber * model.fontSize * style.Train.common.aspectRatio + style.Train.common.textOffset)); this.textTrainServer.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset));
fontNumber += (style.Train.trainServer.serviceNumberPrefix || '').length; widthText += this.textTrainServer.getBoundingRect().width;
this.add(this.textTrainServer); this.add(this.textTrainServer);
} else if (ele == 'tripNumber') { } else if (ele == 'tripNumber') {
this.textTrainTarget.setStyle('x', parseInt(model.point.x + fontNumber * model.fontSize * style.Train.common.aspectRatio + style.Train.common.textOffset)); this.textTrainTarget.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset));
fontNumber += (style.Train.trainTarget.tripNumberPrefix || '').length; widthText += this.textTrainTarget.getBoundingRect().width;
this.add(this.textTrainTarget); this.add(this.textTrainTarget);
} else if (ele == 'groupNumber') { } else if (ele == 'groupNumber') {
this.textTrainTargetNumber.setStyle('x', parseInt(model.point.x + fontNumber * model.fontSize * style.Train.common.aspectRatio + style.Train.common.textOffset)); this.textTrainTargetNumber.setStyle('x', parseInt(model.point.x + widthText + style.Train.common.textOffset));
fontNumber += (style.Train.trainTargetNumber.groupNumberPrefix || '').length; widthText += this.textTrainTargetNumber.getBoundingRect().width;
this.add(this.textTrainTargetNumber); this.add(this.textTrainTargetNumber);
} }
}); });

View File

@ -3,8 +3,8 @@ export function getBaseUrl() {
let BASE_API; let BASE_API;
if (process.env.NODE_ENV === 'development') { if (process.env.NODE_ENV === 'development') {
// BASE_API = 'https://joylink.club/jlcloud'; // BASE_API = 'https://joylink.club/jlcloud';
BASE_API = 'https://test.joylink.club/jlcloud'; // BASE_API = 'https://test.joylink.club/jlcloud';
// BASE_API = 'http://192.168.3.5:9000'; // 袁琪 BASE_API = 'http://192.168.3.5:9000'; // 袁琪
// BASE_API = 'http://192.168.3.6:9000'; // 旭强 // BASE_API = 'http://192.168.3.6:9000'; // 旭强
// BASE_API = 'http://192.168.3.4:9000' // 琰培 // BASE_API = 'http://192.168.3.4:9000' // 琰培
} else { } else {

View File

@ -45,20 +45,19 @@ export default {
left: 10, left: 10,
containLabel: true containLabel: true
}], }],
xAxis: [{ xAxis: {
type: 'value' type: 'value',
}], show: false
yAxis: [{ },
yAxis: {
type: 'category', type: 'category',
data: [], show: false,
axisLabel: { axisLabel: {
interval: 0, interval: 0,
rotate: 30 rotate: 30
}, },
splitLine: { data: []
show: false },
}
}],
series: [{ series: [{
type: 'bar', type: 'bar',
stack: 'chart', stack: 'chart',
@ -69,6 +68,7 @@ export default {
position: 'right' position: 'right'
} }
}, },
barWidth: 30,
tooltip: { tooltip: {
formatter: params => { return `${params.marker} ${params.name}: ${params.value}`; } formatter: params => { return `${params.marker} ${params.name}: ${params.value}`; }
}, },
@ -83,7 +83,7 @@ export default {
data: [] data: []
}] }]
}, },
mapName: '', mapName: null,
mapNameList: [], mapNameList: [],
permissionList: [], permissionList: [],
chart: null chart: null
@ -110,14 +110,16 @@ export default {
methods: { methods: {
initChart() { initChart() {
listUserPermision({pageSize: 9000, pageNum: 1}).then(resp => { listUserPermision({pageSize: 9000, pageNum: 1}).then(resp => {
this.permissionList = resp.data.list; this.permissionList = resp.data.list.filter(elem => { return parseInt(elem.status) > 0; });
this.mapNameList = [...new Set(this.permissionList.map(elem => { return elem.mapName; }))]; this.mapNameList = [...new Set(this.permissionList.map(elem => { return elem.mapName; })), ''];
this.$nextTick(() => { this.mapName = this.mapNameList[0] || ''; }); this.$nextTick(() => { this.mapName = this.mapNameList[0] || ''; });
}); });
this.chart = echarts.init(document.getElementById(this.id)); this.chart = echarts.init(document.getElementById(this.id));
this.chart.setOption(this.option); this.chart.setOption(this.option);
}, },
async loadExamData(mapName) { async loadExamData(mapName) {
this.option.title.text = '所属用户剩余权限分布图';
if (mapName) {
var data = {}; var data = {};
var list = this.permissionList.filter(elem => { return elem.mapName == mapName; }); var list = this.permissionList.filter(elem => { return elem.mapName == mapName; });
list.forEach(elem => { list.forEach(elem => {
@ -130,12 +132,19 @@ export default {
const keys = Object.keys(data); const keys = Object.keys(data);
const values = Object.values(data); const values = Object.values(data);
const sum = values.reduce((total, num) => total + num); const sum = keys.length > 0? values.reduce((total, num) => total + num) : 0;
this.option.title.text = '所属用户剩余权限分布图';
this.option.title.subtext = `权限总计${sum}`; this.option.title.subtext = `权限总计${sum}`;
this.option.yAxis[0].data = keys; this.option.xAxis.show = true;
this.option.yAxis.show = true;
this.option.yAxis.data = keys;
this.option.series[0].data = values; this.option.series[0].data = values;
this.option.series[1].data = keys.map(name => { return {name, value: data[name]}; }); this.option.series[1].data = keys.map(name => { return {name, value: data[name]}; });
} else {
this.option.xAxis.show = false;
this.option.yAxis.show = false;
this.option.title.subtext = `暂无数据`;
}
this.chart.setOption(this.option); this.chart.setOption(this.option);
} }
} }

View File

@ -1,13 +1,22 @@
<template> <template>
<el-dialog :title="title" :visible.sync="show" width="400px" :before-close="doClose" :zIndex="2000" :modal="false" <el-dialog
:close-on-click-modal="false" append-to-body v-dialogDrag> v-dialogDrag
<el-input placeholder="输入名称进行过滤" v-model="filterText" clearable> </el-input> :title="title"
<ul class="listBox" v-if="filterList.length"> :visible.sync="show"
<li class="listLi" v-for="item in filterList"> width="400px"
<el-radio v-model="selected" :label="item"><span>{{item.name}}</span></el-radio> :before-close="doClose"
:z-index="2000"
:modal="false"
:close-on-click-modal="false"
append-to-body
>
<el-input v-model="filterText" placeholder="输入名称进行过滤" clearable />
<ul v-if="filterList.length" class="listBox">
<li v-for="item in filterList" :key="item" class="listLi">
<el-radio v-model="selected" :label="item"><span>{{ item.name }}</span></el-radio>
</li> </li>
</ul> </ul>
<span class="tipLable" v-else> 暂无数据 </span> <span v-else class="tipLable"> 暂无数据 </span>
<span slot="footer" class="dialog-footer"> <span slot="footer" class="dialog-footer">
<el-button @click="doClose"> </el-button> <el-button @click="doClose"> </el-button>
<el-button type="primary" :loading="loading" @click="commit"> </el-button> <el-button type="primary" :loading="loading" @click="commit"> </el-button>
@ -16,10 +25,7 @@
</template> </template>
<script> <script>
import { DeviceMenu } from '@/scripts/ConstDic'; export default {
import { MapDeviceType, OperationEvent } from '@/scripts/ConstDic';
export default {
name: 'CmdNotice', name: 'CmdNotice',
data() { data() {
return { return {
@ -31,8 +37,8 @@
sourceList: [], sourceList: [],
filterText: '', filterText: '',
selected: '', selected: '',
loading: false, loading: false
} };
}, },
computed: { computed: {
show() { show() {
@ -40,7 +46,7 @@
}, },
filterList() { filterList() {
return this.sourceList.filter(p => p.name.indexOf(this.filterText) !== -1); return this.sourceList.filter(p => p.name.indexOf(this.filterText) !== -1);
}, }
}, },
methods: { methods: {
doShow(obj) { doShow(obj) {
@ -57,7 +63,7 @@
this.doClose(); this.doClose();
} }
} }
} };
</script> </script>

View File

@ -1,26 +1,26 @@
<template> <template>
<div> <div>
<pop-menu ref="popMenu" :menu="menu"></pop-menu> <pop-menu ref="popMenu" :menu="menu" />
<choose-role ref="chooseRole" @setDriver="setDriver"></choose-role> <choose-role ref="chooseRole" @setDriver="setDriver" />
</div> </div>
</template> </template>
<script> <script>
import PopMenu from '@/components/PopMenu'; import PopMenu from '@/components/PopMenu';
import ChooseRole from './chooseRole'; import ChooseRole from './chooseRole';
import { putUserRoles } from '@/api/chat'; import { putUserRoles } from '@/api/chat';
import { DeviceMenu } from '@/scripts/ConstDic'; import { DeviceMenu } from '@/scripts/ConstDic';
import { UrlConfig } from '@/router/index';
export default { export default {
name: 'operateMenu', name: 'OperateMenu',
components: { components: {
PopMenu, PopMenu,
ChooseRole ChooseRole
}, },
props: { props: {
group: { group: {
type: String type: String,
required: true
}, },
point: { point: {
type: Object, type: Object,
@ -37,7 +37,7 @@
driverMapDict: { driverMapDict: {
type: Object, type: Object,
required: true required: true
}, }
}, },
data() { data() {
return { return {
@ -52,7 +52,7 @@
handler: this.cancelDriver handler: this.cancelDriver
} }
] ]
} };
}, },
watch: { watch: {
'$store.state.menuOperation.menuCount': function (val) { '$store.state.menuOperation.menuCount': function (val) {
@ -68,10 +68,10 @@
}, },
methods: { methods: {
closeEvent() { closeEvent() {
let self = this; const self = this;
window.onclick = function (e) { window.onclick = function (e) {
self.doClose(); self.doClose();
} };
}, },
doShow(point) { doShow(point) {
this.closeEvent(); this.closeEvent();
@ -87,8 +87,8 @@
this.menuShow = false; this.menuShow = false;
}, },
chooseDriver() { chooseDriver() {
let arrs = Object.values(this.driverMapDict); const arrs = Object.values(this.driverMapDict);
let list = this.driverList.filter(elem => { const list = this.driverList.filter(elem => {
let ret = true; let ret = true;
arrs.forEach(item => { arrs.forEach(item => {
if (item.id == elem.id) { if (item.id == elem.id) {
@ -102,7 +102,7 @@
}, },
async setDriver(obj) { async setDriver(obj) {
if (obj && this.selected) { if (obj && this.selected) {
let params = [{ const params = [{
id: obj.id, id: obj.id,
nickName: obj.name, nickName: obj.name,
userRole: 'Driver', userRole: 'Driver',
@ -114,9 +114,9 @@
} }
}, },
async cancelDriver() { async cancelDriver() {
let data = this.driverMapDict[this.selected._code]; const data = this.driverMapDict[this.selected._code];
if (data) { if (data) {
let params = [{ const params = [{
id: data.id, id: data.id,
nickName: data.name, nickName: data.name,
userRole: 'Driver', userRole: 'Driver',
@ -131,5 +131,5 @@
this.$emit('refresh'); this.$emit('refresh');
} }
} }
} };
</script> </script>

View File

@ -46,7 +46,7 @@
/> />
<div style="float: right; margin-right: 15px;"> <div style="float: right; margin-right: 15px;">
<el-select <el-select
v-model="nor.stationCode" v-model="nor.deviceCode"
placeholder="请选择" placeholder="请选择"
size="mini" size="mini"
:disabled="userId != roomInfo.creatorId" :disabled="userId != roomInfo.creatorId"
@ -396,7 +396,7 @@ export default {
this.messageInfo('您被管理员踢出房间。', 'warning'); this.messageInfo('您被管理员踢出房间。', 'warning');
} else { } else {
param.userRole = ''; param.userRole = '';
param['stationCode'] = ''; param['deviceCode'] = '';
const arr = []; const arr = [];
arr.push(param); arr.push(param);
this.addrolesList(arr); // this.addrolesList(arr); //
@ -490,7 +490,7 @@ export default {
this.stationList.forEach(item => { this.stationList.forEach(item => {
item.disabled = false; item.disabled = false;
this.equipmentList.forEach(nor => { this.equipmentList.forEach(nor => {
if (item.code == nor.stationCode) { if (item.code == nor.deviceCode) {
item.disabled = true; item.disabled = true;
} }
}); });
@ -549,7 +549,7 @@ export default {
async start() { async start() {
let flag = true; let flag = true;
this.equipmentList.forEach(item => { this.equipmentList.forEach(item => {
if (!item.stationCode) { if (!item.deviceCode) {
flag = false; flag = false;
} }
}); });
@ -600,13 +600,13 @@ export default {
id: val.id, id: val.id,
nickName: val.nickName, nickName: val.nickName,
userRole: 'Attendant', userRole: 'Attendant',
stationCode: val.stationCode deviceCode: val.deviceCode
}]; }];
putUserRoles(params, this.$route.query.group); putUserRoles(params, this.$route.query.group);
this.stationList.forEach(item => { this.stationList.forEach(item => {
item.disabled = false; item.disabled = false;
this.equipmentList.forEach(nor => { this.equipmentList.forEach(nor => {
if (item.code == nor.stationCode) { if (item.code == nor.deviceCode) {
item.disabled = true; item.disabled = true;
} }
}); });
@ -693,7 +693,7 @@ export default {
this.stationList.forEach(item => { this.stationList.forEach(item => {
item.disabled = false; item.disabled = false;
this.equipmentList.forEach(nor => { this.equipmentList.forEach(nor => {
if (item.code == nor.stationCode) { if (item.code == nor.deviceCode) {
item.disabled = true; item.disabled = true;
} }
}); });
@ -723,7 +723,7 @@ export default {
id: item.id, id: item.id,
nickName: item.nickName, nickName: item.nickName,
userRole: 'Audience', userRole: 'Audience',
stationCode: '' deviceCode: ''
}]; }];
putUserRoles(params, this.$route.query.group); putUserRoles(params, this.$route.query.group);
}, },

View File

@ -1,18 +1,18 @@
<template> <template>
<div class="jointRoomMenu"> <div class="jointRoomMenu">
<pop-menu ref="popMenu" :menu="menu"></pop-menu> <pop-menu ref="popMenu" :menu="menu" />
</div> </div>
</template> </template>
<script> <script>
import PopMenu from '@/components/PopMenu'; import PopMenu from '@/components/PopMenu';
import { DeviceMenu } from '@/scripts/ConstDic'; import { DeviceMenu } from '@/scripts/ConstDic';
import { putJointTrainingUserkicked } from '@/api/chat'; import { putJointTrainingUserkicked } from '@/api/chat';
export default { export default {
name: 'TrainingOperateMenu', name: 'TrainingOperateMenu',
components: { components: {
PopMenu, PopMenu
}, },
props: { props: {
point: { point: {
@ -31,10 +31,10 @@
{ {
label: '踢出房间', label: '踢出房间',
handler: this.kicked handler: this.kicked
},
],
userId: '',
} }
],
userId: ''
};
}, },
watch: { watch: {
'$store.state.menuOperation.menuCount': function (val) { '$store.state.menuOperation.menuCount': function (val) {
@ -51,10 +51,10 @@
}, },
methods: { methods: {
closeEvent() { closeEvent() {
let self = this; const self = this;
window.onclick = function (e) { window.onclick = function (e) {
self.doClose(); self.doClose();
} };
}, },
doShow(point) { doShow(point) {
this.closeEvent(); this.closeEvent();
@ -75,9 +75,11 @@
}, },
async kicked() { async kicked() {
try { try {
let res = await putJointTrainingUserkicked(this.clickUserId, this.$route.query.group); await putJointTrainingUserkicked(this.clickUserId, this.$route.query.group);
} catch (error) { } } catch (error) {
console.error(error);
} }
} }
} }
};
</script> </script>

View File

@ -1,42 +1,52 @@
<template> <template>
<!-- 聊天窗口 --> <!-- 聊天窗口 -->
<div class="train-chat"> <div class="train-chat">
<audio ref="audio" style="display: none;"></audio> <audio ref="audio" style="display: none;" />
<div class="chatContent" ref="content"> <div ref="content" class="chatContent">
<ul class="newsList"> <ul class="newsList">
<div v-for="(nor, index) in textList" :key="index" style="margin-top: 5px;"> <div v-for="(nor, index) in textList" :key="index" style="margin-top: 5px;">
<li v-if="nor.self" style="position: relative"> <li v-if="nor.self" style="position: relative">
<div class="userName" style="position: absolute; right: 4px; top: 4px; font-size: 14px;"> <div class="userName" style="position: absolute; right: 4px; top: 4px; font-size: 14px;">
{{nor.chatTime}} {{nor.userName}}</div> {{ nor.chatTime }} {{ nor.userName }}</div>
<div class="news"> <div class="news">
<span>{{nor.value}}</span> <span>{{ nor.value }}</span>
</div> </div>
<div class="yuyin" v-if="nor.voice" @click="playAudio(nor)"> <div v-if="nor.voice" class="yuyin" @click="playAudio(nor)">
<i class="el-icon-caret-right"></i> <i class="el-icon-caret-right" />
</div> </div>
</li> </li>
<li v-if="nor.other" style="position: relative"> <li v-if="nor.other" style="position: relative">
<div class="userName" style="position: absolute; left: 12px; top: 4px; font-size: 14px;"> <div class="userName" style="position: absolute; left: 12px; top: 4px; font-size: 14px;">
{{nor.userName}} {{nor.chatTime}}</div> {{ nor.userName }} {{ nor.chatTime }}</div>
<div class="answers"> <div class="answers">
<span>{{nor.value}}</span> <span>{{ nor.value }}</span>
</div> </div>
<div class="yuyin1" v-if="nor.voice" @click="playAudio(nor)"> <div v-if="nor.voice" class="yuyin1" @click="playAudio(nor)">
<i class="el-icon-caret-right"></i> <i class="el-icon-caret-right" />
</div> </div>
</li> </li>
<li v-if="nor.join" style="font-size: 12px; text-align: center;">{{nor.roomTip}}</li> <li v-if="nor.join" style="font-size: 12px; text-align: center;">{{ nor.roomTip }}</li>
</div> </div>
</ul> </ul>
</div> </div>
<div class="footChat"> <div class="footChat">
<div class="inputBox"> <div class="inputBox">
<textarea id="dope" v-model="text" style="width: 99%;height: 47px; border: none;outline: none;" name="" <textarea
rows="" cols=""></textarea> id="dope"
v-model="text"
style="width: 99%;height: 47px; border: none;outline: none;"
name=""
rows=""
cols=""
/>
<button class="sendBtn" @click="sendText()">发送文字</button> <button class="sendBtn" @click="sendText()">发送文字</button>
<div class="sendBtn yuyin_start zIndex1" :style="{background: background}" @mousedown="startRecording()" <div
@mouseup="stopRecording()">{{speak}}</div> class="sendBtn yuyin_start zIndex1"
<div class="sendBtn yuyin_start zIndex2" :style="{background: background}" v-show="sending"> :style="{background: background}"
@mousedown="startRecording()"
@mouseup="stopRecording()"
>{{ speak }}</div>
<div v-show="sending" class="sendBtn yuyin_start zIndex2" :style="{background: background}">
发送中...</div> 发送中...</div>
</div> </div>
</div> </div>
@ -44,16 +54,15 @@
</template> </template>
<script> <script>
import Vue from 'vue'; import HZRecorder from '@/utils/HZRecorder';
import HZRecorder from '@/utils/HZRecorder'; import { getHistoryVoice, chatWithText, chatWithAudio } from '@/api/chat';
import { postDataBd, postDataXf, getHistoryVoice, chatWithText, chatWithAudio, putJointTrainingSimulationEntrance } from '@/api/chat';
import StompClient from '@/utils/sock';
export default { export default {
name: 'trainChat', name: 'TrainChat',
props: { props: {
groupRoom: { groupRoom: {
type: String, type: String,
required: true
} }
}, },
data() { data() {
@ -66,15 +75,15 @@
speak: '按住说话', speak: '按住说话',
sending: false, sending: false,
background: '', background: '',
userId: '', userId: ''
} };
}, },
watch: { watch: {
'$store.state.socket.chatContentList': function (val) { // '$store.state.socket.chatContentList': function (val) { //
if (val.chatInfo) { if (val.chatInfo) {
this.handelTextList(val); this.handelTextList(val);
} }
}, }
}, },
async mounted() { async mounted() {
this.userId = this.$store.state.user.id; this.userId = this.$store.state.user.id;
@ -84,13 +93,15 @@
// //
async sendText() { async sendText() {
if (!this.text.trim()) { if (!this.text.trim()) {
alert('内容为空,不可发送!') alert('内容为空,不可发送!');
this.text = ''; this.text = '';
} else { } else {
try { try {
let res = await chatWithText(this.text, this.groupRoom); await chatWithText(this.text, this.groupRoom);
this.text = ''; this.text = '';
} catch (error) { } } catch (error) {
console.error(error);
}
} }
}, },
// //
@ -113,10 +124,10 @@
if (this.recorders) { if (this.recorders) {
this.recorders.stop(); this.recorders.stop();
var fd = new FormData(); var fd = new FormData();
fd.append("file", this.recorders.getBlob()); fd.append('file', this.recorders.getBlob());
let res = await chatWithAudio(fd, this.$route.query.group).catch(error => { await chatWithAudio(fd, this.$route.query.group).catch(error => {
this.sending = false; this.sending = false;
let message = JSON.parse(error.message); const message = JSON.parse(error.message);
if (message.err_no == 3301) { if (message.err_no == 3301) {
this.$message({ this.$message({
showClose: true, showClose: true,
@ -161,13 +172,13 @@
async getHistory(obj, node, data) { async getHistory(obj, node, data) {
this.textList = []; this.textList = [];
try { try {
let res = await getHistoryVoice(this.code); const res = await getHistoryVoice(this.code);
res.data.forEach(item => { res.data.forEach(item => {
let isSelf = false; let isSelf = false;
if (item.userId == this.userId) { if (item.userId == this.userId) {
isSelf = true; isSelf = true;
} }
let param = { const param = {
join: false, join: false,
value: item.message, value: item.message,
self: isSelf, self: isSelf,
@ -175,30 +186,32 @@
src: item.isAudio ? `${process.env.VOICE_API}/jlcloud/audio/${item.audioPath}` : '', src: item.isAudio ? `${process.env.VOICE_API}/jlcloud/audio/${item.audioPath}` : '',
other: !isSelf, other: !isSelf,
userName: item.nickName, userName: item.nickName,
chatTime: item.chatTime, chatTime: item.chatTime
} };
this.handelTextList(param); this.handelTextList(param);
}) });
} catch (error) { } } catch (error) {
console.error(error);
}
}, },
// list // list
handelTextList(params) { handelTextList(params) {
if (!params.inSimulation) { if (!params.inSimulation) {
this.textList.push(params); this.textList.push(params);
this.textList.sort((a, b) => { this.textList.sort((a, b) => {
return a.date - b.date return a.date - b.date;
}) });
} }
this.sending = false; this.sending = false;
this.$store.dispatch('socket/setChatContentList', {}) this.$store.dispatch('socket/setChatContentList', {});
this.$nextTick(() => { this.$nextTick(() => {
if (this.$refs.content) { if (this.$refs.content) {
this.$refs.content.scrollTop = this.$refs.content.scrollHeight; this.$refs.content.scrollTop = this.$refs.content.scrollHeight;
} }
}) });
},
} }
} }
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">