修复群消息为到底部,添加删除群及修改群信息
This commit is contained in:
parent
260bd5a5d9
commit
a3f524e345
|
|
@ -10,7 +10,7 @@ export const updateDeviceService = (data) => {
|
||||||
return request.post('/device/update_device', params, { "headers": { 'token': data.token } });
|
return request.post('/device/update_device', params, { "headers": { 'token': data.token } });
|
||||||
}
|
}
|
||||||
|
|
||||||
export const deleteDeviceService = (data) => {
|
export const deleteGroupService = (data) => {
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
for (let key in data) {
|
for (let key in data) {
|
||||||
params.append(key, data[key])
|
params.append(key, data[key])
|
||||||
|
|
@ -39,4 +39,19 @@ export const getGroupListService = (data) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export const getGroupReqService = (data) => {
|
||||||
|
const params = new URLSearchParams();
|
||||||
|
for (let d in data) {
|
||||||
|
params.append(d, data[d]);
|
||||||
|
}
|
||||||
|
// request.headers["Content-Type"] = "application/json";
|
||||||
|
request.defaults.headers["token"] = data.token.value;
|
||||||
|
return request.post('/im/get_group', params, {
|
||||||
|
headers: {
|
||||||
|
'token': data.token, // 将 token 替换为您的令牌值
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -75,6 +75,7 @@ export const GetUserInfoService = (Data) => {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//删除好友或者群组
|
||||||
export const DelFGService =(Data) =>{
|
export const DelFGService =(Data) =>{
|
||||||
const params = new URLSearchParams();
|
const params = new URLSearchParams();
|
||||||
for (let key in Data) {
|
for (let key in Data) {
|
||||||
|
|
|
||||||
|
|
@ -1,142 +1,213 @@
|
||||||
<template>
|
<template>
|
||||||
<el-container class="layout-container-demo" style="height: 700px;width: 1000px;">
|
<el-container
|
||||||
<el-aside width="200px">
|
class="layout-container-demo"
|
||||||
<el-input
|
style="height: 700px; width: 1000px"
|
||||||
placeholder="请输入用户姓名"
|
>
|
||||||
v-model="searchName"
|
<el-aside width="200px">
|
||||||
@input="filterUsers"
|
<el-input
|
||||||
></el-input>
|
placeholder="请输入用户姓名"
|
||||||
<el-scrollbar>
|
v-model="searchName"
|
||||||
<el-menu :default-openeds="['1', '3']">
|
@input="filterUsers"
|
||||||
<el-sub-menu index="1">
|
></el-input>
|
||||||
<template #title>
|
<el-scrollbar>
|
||||||
<el-icon>
|
<el-menu :default-openeds="['1', '3']">
|
||||||
<message />
|
<el-sub-menu index="1">
|
||||||
</el-icon>联系人
|
<template #title>
|
||||||
</template>
|
<el-icon>
|
||||||
<el-scrollbar height="300px">
|
<message /> </el-icon
|
||||||
<el-menu-item-group v-for="user in filteredUsers" :key="user.id">
|
>联系人
|
||||||
<el-menu-item :index="String(user.id)" @click="handleGetMessage(user.id)" style="height: 40px;">
|
</template>
|
||||||
{{ user.name }}
|
<el-scrollbar height="300px">
|
||||||
<span v-if="hasUnreadMsg[user.id]" class="unread-dot"></span>
|
<el-menu-item-group v-for="user in filteredUsers" :key="user.id">
|
||||||
</el-menu-item>
|
<el-menu-item
|
||||||
</el-menu-item-group>
|
:index="String(user.id)"
|
||||||
</el-scrollbar>
|
@click="handleGetMessage(user.id)"
|
||||||
</el-sub-menu>
|
style="height: 40px"
|
||||||
<el-sub-menu index="2">
|
>
|
||||||
<template #title>
|
{{ user.name }}
|
||||||
<el-icon><icon-menu /></el-icon>
|
<span v-if="hasUnreadMsg[user.id]" class="unread-dot"></span>
|
||||||
群组
|
</el-menu-item>
|
||||||
</template>
|
</el-menu-item-group>
|
||||||
<el-scrollbar height="200px">
|
|
||||||
<el-menu-item-group v-for="item in groupList" :key="item.ID">
|
|
||||||
<!-- <template #title>Group 1</template> -->
|
|
||||||
<el-menu-item :index="String(item.GroupName)" @click="handleGetGroupMessage(item.ID)">{{ item.GroupName
|
|
||||||
}}</el-menu-item>
|
|
||||||
<span v-if="hasUnreadMsg[`g_${item.ID}`]" class="unread-dot"></span>
|
|
||||||
<!-- <el-menu-item index="2-2">Option 2</el-menu-item> -->
|
|
||||||
</el-menu-item-group>
|
|
||||||
</el-scrollbar>
|
|
||||||
|
|
||||||
</el-sub-menu>
|
|
||||||
</el-menu>
|
|
||||||
</el-scrollbar>
|
</el-scrollbar>
|
||||||
</el-aside>
|
</el-sub-menu>
|
||||||
|
<el-sub-menu index="2">
|
||||||
|
<template #title>
|
||||||
|
<el-icon><icon-menu /></el-icon>
|
||||||
|
群组
|
||||||
|
</template>
|
||||||
|
<el-scrollbar height="200px">
|
||||||
|
<el-menu-item-group v-for="item in groupList" :key="item.ID">
|
||||||
|
<!-- <template #title>Group 1</template> -->
|
||||||
|
<el-menu-item
|
||||||
|
:index="String(item.GroupName)"
|
||||||
|
@click="handleGetGroupMessage(item.ID)"
|
||||||
|
>{{ item.GroupName }}</el-menu-item
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
v-if="hasUnreadMsg[`g_${item.ID}`]"
|
||||||
|
class="unread-dot"
|
||||||
|
></span>
|
||||||
|
<!-- <el-menu-item index="2-2">Option 2</el-menu-item> -->
|
||||||
|
</el-menu-item-group>
|
||||||
|
</el-scrollbar>
|
||||||
|
</el-sub-menu>
|
||||||
|
</el-menu>
|
||||||
|
</el-scrollbar>
|
||||||
|
</el-aside>
|
||||||
|
|
||||||
<el-container width="800px">
|
<el-container width="800px">
|
||||||
<el-header style="text-align: right; font-size: 12px">
|
<el-header style="text-align: right; font-size: 12px">
|
||||||
<div class="toolbar">
|
<div class="toolbar">
|
||||||
<el-button
|
<el-button type="primary" size="mini" @click.prevent="getHistory()"
|
||||||
type="primary"
|
>历史消息</el-button
|
||||||
size="mini"
|
>
|
||||||
@click.prevent="getHistory()"
|
<el-button
|
||||||
>历史消息</el-button
|
type="primary"
|
||||||
>
|
size="mini"
|
||||||
<el-button
|
@click.prevent="handleMenuSelect('/videoList')"
|
||||||
type="primary"
|
>返回</el-button
|
||||||
size="mini"
|
>
|
||||||
@click.prevent="handleMenuSelect('/videoList')"
|
<el-text class="mx-1" type="primary"
|
||||||
>返回</el-button
|
>目前:{{ cur_user_name }}</el-text
|
||||||
>
|
>
|
||||||
<el-text class="mx-1" type="primary" >目前:{{ cur_user_name }}</el-text>
|
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<span style=" margin-right: 10px;margin-left: 10px;">{{ username }}</span>
|
<span style="margin-right: 10px; margin-left: 10px">{{
|
||||||
<el-avatar size="default" fit="fit"> {{ username }} </el-avatar>
|
username
|
||||||
</div>
|
}}</span>
|
||||||
</div>
|
<el-avatar size="default" fit="fit"> {{ username }} </el-avatar>
|
||||||
</el-header>
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-header>
|
||||||
|
|
||||||
<el-main style="margin-top: 1px;">
|
<el-main style="margin-top: 1px">
|
||||||
<el-scrollbar class="chat-room" id="chat-room" ref="chatRoom" height="600px" style="margin-top: 1px" always>
|
<el-scrollbar
|
||||||
<div v-for="item in MsgList" :key="item.ID"
|
class="chat-room"
|
||||||
style="margin-top: 10px;margin-bottom: 20px;">
|
id="chat-room"
|
||||||
<!-- 左边 -->
|
ref="chatRoom"
|
||||||
<div v-if="uid == item.ToUserID && item.FromUserID == cur_user_id && cur_group_id==0" style="margin-left: 10px;margin-bottom: 8px;">
|
height="600px"
|
||||||
<el-row class="row-bg" type="flex" align="middle">
|
style="margin-top: 1px"
|
||||||
<el-avatar size="default" fit="fit">{{ cur_user_name }}</el-avatar>
|
always
|
||||||
<span style="margin-left: 10px">{{ formatTime(item.CreatedAt) }}</span>
|
>
|
||||||
</el-row>
|
<div
|
||||||
|
v-for="item in MsgList"
|
||||||
|
:key="item.ID"
|
||||||
|
style="margin-top: 10px; margin-bottom: 20px"
|
||||||
|
>
|
||||||
|
<!-- 左边 -->
|
||||||
|
<div
|
||||||
|
v-if="
|
||||||
|
uid == item.ToUserID &&
|
||||||
|
item.FromUserID == cur_user_id &&
|
||||||
|
cur_group_id == 0
|
||||||
|
"
|
||||||
|
style="margin-left: 10px; margin-bottom: 8px"
|
||||||
|
>
|
||||||
|
<el-row class="row-bg" type="flex" align="middle">
|
||||||
|
<el-avatar size="default" fit="fit">{{
|
||||||
|
cur_user_name
|
||||||
|
}}</el-avatar>
|
||||||
|
<span style="margin-left: 10px"
|
||||||
|
>{{ cur_user_name }} : {{ formatTime(item.CreatedAt) }}</span
|
||||||
|
>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
<el-row>
|
<el-row>
|
||||||
<el-col :span="1000" :offset="1" class="msg" >
|
<el-col :span="1000" :offset="1" class="msg">
|
||||||
{{ item.Msg }}
|
{{ item.Msg }}
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</div>
|
|
||||||
<div v-if="cur_group_id !=0 && uid != item.FromUserID" style="margin-left: 10px;margin-bottom: 8px;">
|
|
||||||
<el-row class="row-bg" type="flex" align="middle">
|
|
||||||
<el-avatar size="default" fit="fit">{{ item.name}}</el-avatar>
|
|
||||||
<span style="margin-left: 10px">{{ formatTime(item.CreatedAt) }}</span>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="1000" :offset="1" class="msg" >
|
|
||||||
{{ item.Msg }}
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</div>
|
|
||||||
<!-- 右边 -->
|
|
||||||
<div v-if="uid == item.FromUserID && item.ToUserID == cur_user_id" style="margin-right: 10px;margin-bottom: 8px;">
|
|
||||||
<el-row class="row-bg" type="flex" justify="end" align="middle">
|
|
||||||
<span style="margin-right: 10px">{{ formatTime(item.CreatedAt)}}</span>
|
|
||||||
<el-avatar size="default" fit="fit"> {{ tokenData.username }} </el-avatar>
|
|
||||||
</el-row>
|
|
||||||
|
|
||||||
<el-row justify="end">
|
|
||||||
<el-col :span="1000" class="msg2" style="margin-right: 20px;">
|
|
||||||
{{ item.Msg }}
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</el-scrollbar>
|
|
||||||
</el-main>
|
|
||||||
<el-row class="row-bg" type="flex" justify="space-around" align="middle">
|
|
||||||
<el-col :span="20">
|
|
||||||
<el-input type="text" style="width: 100%" autofocus @keyup.enter="handleSendBtnClick"
|
|
||||||
placeholder="请输入消息按Enter发送" v-model="currentMsg"></el-input>
|
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :span="2">
|
</el-row>
|
||||||
<el-button class="sendBtn" @click="handleSendBtnClick" type="primary" size="default">
|
</div>
|
||||||
发送
|
<div
|
||||||
</el-button>
|
v-if="cur_group_id != 0 && uid != item.FromUserID"
|
||||||
|
style="margin-left: 10px; margin-bottom: 8px"
|
||||||
|
>
|
||||||
|
<el-row class="row-bg" type="flex" align="middle">
|
||||||
|
<el-avatar size="default" fit="fit">{{ item.name }}</el-avatar>
|
||||||
|
<span style="margin-left: 10px"
|
||||||
|
>{{ item.name }} : {{ formatTime(item.CreatedAt) }}</span
|
||||||
|
>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-row>
|
||||||
|
<el-col :span="1000" :offset="1" class="msg">
|
||||||
|
{{ item.Msg }}
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-container>
|
</div>
|
||||||
|
<!-- 右边 -->
|
||||||
|
<div
|
||||||
|
v-if="uid == item.FromUserID && item.ToUserID == cur_user_id"
|
||||||
|
style="margin-right: 10px; margin-bottom: 8px"
|
||||||
|
>
|
||||||
|
<el-row class="row-bg" type="flex" justify="end" align="middle">
|
||||||
|
<span style="margin-right: 10px">
|
||||||
|
{{ tokenData.username }} :
|
||||||
|
{{ formatTime(item.CreatedAt) }}</span
|
||||||
|
>
|
||||||
|
<el-avatar size="default" fit="fit">
|
||||||
|
{{ tokenData.username }}
|
||||||
|
</el-avatar>
|
||||||
|
</el-row>
|
||||||
|
|
||||||
|
<el-row justify="end">
|
||||||
|
<el-col :span="1000" class="msg2" style="margin-right: 20px">
|
||||||
|
{{ item.Msg }}
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-scrollbar>
|
||||||
|
</el-main>
|
||||||
|
<el-row class="row-bg" type="flex" justify="space-around" align="middle">
|
||||||
|
<el-col :span="20">
|
||||||
|
<el-input
|
||||||
|
type="text"
|
||||||
|
style="width: 100%"
|
||||||
|
autofocus
|
||||||
|
@keyup.enter="handleSendBtnClick"
|
||||||
|
placeholder="请输入消息按Enter发送"
|
||||||
|
v-model="currentMsg"
|
||||||
|
></el-input>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="2">
|
||||||
|
<el-button
|
||||||
|
class="sendBtn"
|
||||||
|
@click="handleSendBtnClick"
|
||||||
|
type="primary"
|
||||||
|
size="default"
|
||||||
|
>
|
||||||
|
发送
|
||||||
|
</el-button>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
</el-container>
|
</el-container>
|
||||||
|
</el-container>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { inject } from "vue";
|
import { inject } from "vue";
|
||||||
import { getFriendListService } from "@/api/chat.js";
|
import { getFriendListService } from "@/api/chat.js";
|
||||||
import { getMessageService} from "@/api/chat.js";
|
import { getMessageService } from "@/api/chat.js";
|
||||||
import {sendMessageService} from "@/api/chat.js";
|
import { sendMessageService } from "@/api/chat.js";
|
||||||
import { ElAvatar, ElDropdown, ElDropdownItem, ElDropdownMenu, ElIcon, ElMenu, ElMenuItem, ElMenuItemGroup, ElScrollbar, ElRow, ElCol, ElButton } from 'element-plus'
|
import {
|
||||||
import { Menu as IconMenu, Message, Setting } from '@element-plus/icons-vue'
|
ElAvatar,
|
||||||
|
ElDropdown,
|
||||||
|
ElDropdownItem,
|
||||||
|
ElDropdownMenu,
|
||||||
|
ElIcon,
|
||||||
|
ElMenu,
|
||||||
|
ElMenuItem,
|
||||||
|
ElMenuItemGroup,
|
||||||
|
ElScrollbar,
|
||||||
|
ElRow,
|
||||||
|
ElCol,
|
||||||
|
ElButton,
|
||||||
|
} from "element-plus";
|
||||||
|
import { Menu as IconMenu, Message, Setting } from "@element-plus/icons-vue";
|
||||||
import router from "@/router/index.js";
|
import router from "@/router/index.js";
|
||||||
import {ElMessage} from "element-plus";
|
import { ElMessage } from "element-plus";
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
data() {
|
data() {
|
||||||
|
|
@ -151,18 +222,18 @@ export default {
|
||||||
},
|
},
|
||||||
username: localStorage.getItem("username"),
|
username: localStorage.getItem("username"),
|
||||||
userList: [],
|
userList: [],
|
||||||
filteredUsers: [], // 过滤后的用户列表
|
filteredUsers: [], // 过滤后的用户列表
|
||||||
to_user_id:0,
|
to_user_id: 0,
|
||||||
cur_user_id:0,
|
cur_user_id: 0,
|
||||||
cur_group_id:0,
|
cur_group_id: 0,
|
||||||
msg_type:1,
|
msg_type: 1,
|
||||||
searchName: '', // 搜索框内容
|
searchName: "", // 搜索框内容
|
||||||
history_cnt: 1,
|
history_cnt: 1,
|
||||||
|
|
||||||
cur_user_name: "",
|
cur_user_name: "",
|
||||||
eventSource: null, // 事件源
|
eventSource: null, // 事件源
|
||||||
uid: localStorage.getItem("userId"),
|
uid: localStorage.getItem("userId"),
|
||||||
currentMsg:"",
|
currentMsg: "",
|
||||||
MsgList: [],
|
MsgList: [],
|
||||||
groupList: [],
|
groupList: [],
|
||||||
hasUnreadMsg: {}, // 未读消息, key为用户id,value为true/false
|
hasUnreadMsg: {}, // 未读消息, key为用户id,value为true/false
|
||||||
|
|
@ -172,109 +243,109 @@ export default {
|
||||||
// methods 是一些用来更改状态与触发更新的函数
|
// methods 是一些用来更改状态与触发更新的函数
|
||||||
// 它们可以在模板中作为事件处理器绑定
|
// 它们可以在模板中作为事件处理器绑定
|
||||||
methods: {
|
methods: {
|
||||||
async handleSelectUser(){
|
async handleSelectUser() {
|
||||||
let result = {};
|
let result = {};
|
||||||
try {
|
try {
|
||||||
result = await getFriendListService(this.tokenData);
|
result = await getFriendListService(this.tokenData);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
let data = result.data;
|
let data = result.data;
|
||||||
this.userList=data.friends;
|
this.userList = data.friends;
|
||||||
for(let i = 0; i < data.friends.length; i++){
|
for (let i = 0; i < data.friends.length; i++) {
|
||||||
this.hasUnreadMsg[data.friends[i].id] = false;
|
this.hasUnreadMsg[data.friends[i].id] = false;
|
||||||
}
|
}
|
||||||
this.groupList=data.groups;
|
this.groupList = data.groups;
|
||||||
},
|
},
|
||||||
filterUsers() {
|
filterUsers() {
|
||||||
this.filteredUsers = this.userList.filter(user => {
|
this.filteredUsers = this.userList.filter((user) => {
|
||||||
return user.name.toLowerCase().includes(this.searchName.toLowerCase());
|
return user.name.toLowerCase().includes(this.searchName.toLowerCase());
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getHistory() {
|
getHistory() {
|
||||||
this.history_cnt++
|
this.history_cnt++;
|
||||||
this.handleGetMessage(this.cur_user_id);
|
this.handleGetMessage(this.cur_user_id);
|
||||||
},
|
},
|
||||||
async handleGetGroupMessage(id){
|
async handleGetGroupMessage(id) {
|
||||||
this.cur_group_id=id;
|
this.cur_group_id = id;
|
||||||
this.cur_user_id=0;
|
this.cur_user_id = 0;
|
||||||
this.to_user_id=0;
|
this.to_user_id = 0;
|
||||||
this.msg_type=2;
|
this.msg_type = 2;
|
||||||
this.hasUnreadMsg["g_"+id]=false;
|
this.hasUnreadMsg["g_" + id] = false;
|
||||||
let result={}
|
let result = {};
|
||||||
try {
|
try {
|
||||||
let req={
|
let req = {
|
||||||
token: localStorage.getItem("token"),
|
token: localStorage.getItem("token"),
|
||||||
ip: localStorage.getItem("ip"),
|
ip: localStorage.getItem("ip"),
|
||||||
userId: localStorage.getItem("userId"),
|
userId: localStorage.getItem("userId"),
|
||||||
username: localStorage.getItem("username"),
|
username: localStorage.getItem("username"),
|
||||||
group_id:id,
|
group_id: id,
|
||||||
index:this.history_cnt,
|
index: this.history_cnt,
|
||||||
type:2,
|
type: 2,
|
||||||
}
|
};
|
||||||
result = await getMessageService(req);
|
result = await getMessageService(req);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
let data = result.data;
|
let data = result.data;
|
||||||
if(data === undefined || data === null){
|
if (data === undefined || data === null) {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: "无消息!",
|
message: "无消息!",
|
||||||
type: "error",
|
type: "error",
|
||||||
})
|
});
|
||||||
this.MsgList=[]
|
this.MsgList = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
data.sort((a, b) => {
|
data.sort((a, b) => {
|
||||||
const dateA = new Date(a.CreatedAt);
|
const dateA = new Date(a.CreatedAt);
|
||||||
const dateB = new Date(b.CreatedAt);
|
const dateB = new Date(b.CreatedAt);
|
||||||
|
|
||||||
// 返回时间差,用于排序
|
// 返回时间差,用于排序
|
||||||
return dateA - dateB;
|
return dateA - dateB;
|
||||||
});
|
});
|
||||||
this.MsgList=data;
|
this.MsgList = data;
|
||||||
if(this.history_cnt <=2){
|
if (this.history_cnt <= 2) {
|
||||||
this.scrollToBottom();
|
this.scrollToBottom();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async handleGetMessage(id){
|
async handleGetMessage(id) {
|
||||||
let result = {};
|
let result = {};
|
||||||
if(this.to_user_id!=id){
|
if (this.to_user_id != id) {
|
||||||
this.history_cnt = 2;
|
this.history_cnt = 2;
|
||||||
|
}
|
||||||
|
this.to_user_id = id;
|
||||||
|
this.cur_user_id = id;
|
||||||
|
this.cur_group_id = 0;
|
||||||
|
this.msg_type = 1;
|
||||||
|
console.log("uid:", this.uid, "\tcur_user_id:", this.cur_user_id);
|
||||||
|
for (let i = 0; i < this.userList.length; i++) {
|
||||||
|
if (this.userList[i].id === id) {
|
||||||
|
this.cur_user_name = this.userList[i].name;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
this.to_user_id=id;
|
}
|
||||||
this.cur_user_id=id;
|
this.hasUnreadMsg[id] = false;
|
||||||
this.cur_group_id=0;
|
|
||||||
this.msg_type=1;
|
|
||||||
console.log("uid:",this.uid,"\tcur_user_id:",this.cur_user_id)
|
|
||||||
for(let i=0; i<this.userList.length; i++){
|
|
||||||
if(this.userList[i].id === id){
|
|
||||||
this.cur_user_name=this.userList[i].name;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.hasUnreadMsg[id] = false;
|
|
||||||
try {
|
try {
|
||||||
let req={
|
let req = {
|
||||||
token: localStorage.getItem("token"),
|
token: localStorage.getItem("token"),
|
||||||
ip: localStorage.getItem("ip"),
|
ip: localStorage.getItem("ip"),
|
||||||
userId: localStorage.getItem("userId"),
|
userId: localStorage.getItem("userId"),
|
||||||
username: localStorage.getItem("username"),
|
username: localStorage.getItem("username"),
|
||||||
from_user_id:id,
|
from_user_id: id,
|
||||||
to_user_id:localStorage.getItem("userId"),
|
to_user_id: localStorage.getItem("userId"),
|
||||||
index:this.history_cnt,
|
index: this.history_cnt,
|
||||||
type:this.msg_type,
|
type: this.msg_type,
|
||||||
}
|
};
|
||||||
result = await getMessageService(req);
|
result = await getMessageService(req);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
let data = result.data;
|
let data = result.data;
|
||||||
if(data === undefined){
|
if (data === undefined) {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: "消息获取失败!",
|
message: "消息获取失败!",
|
||||||
type: "error",
|
type: "error",
|
||||||
})
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//data sort by created time
|
//data sort by created time
|
||||||
|
|
@ -288,29 +359,29 @@ export default {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
data.sort((a, b) => {
|
data.sort((a, b) => {
|
||||||
const dateA = new Date(a.CreatedAt);
|
const dateA = new Date(a.CreatedAt);
|
||||||
const dateB = new Date(b.CreatedAt);
|
const dateB = new Date(b.CreatedAt);
|
||||||
|
|
||||||
// 返回时间差,用于排序
|
// 返回时间差,用于排序
|
||||||
return dateA - dateB;
|
return dateA - dateB;
|
||||||
});
|
});
|
||||||
this.MsgList=data;
|
this.MsgList = data;
|
||||||
if(this.history_cnt <=2){
|
if (this.history_cnt <= 2) {
|
||||||
this.scrollToBottom();
|
this.scrollToBottom();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
formatTime(time){
|
formatTime(time) {
|
||||||
let date = new Date(time);
|
let date = new Date(time);
|
||||||
// 提取年、月、日、时、分、秒
|
// 提取年、月、日、时、分、秒
|
||||||
const year = date.getFullYear();
|
const year = date.getFullYear();
|
||||||
const month = ('0' + (date.getMonth() + 1)).slice(-2); // 月份是从0开始的,所以要加1
|
const month = ("0" + (date.getMonth() + 1)).slice(-2); // 月份是从0开始的,所以要加1
|
||||||
const day = ('0' + date.getDate()).slice(-2);
|
const day = ("0" + date.getDate()).slice(-2);
|
||||||
const hour = ('0' + date.getHours()).slice(-2);
|
const hour = ("0" + date.getHours()).slice(-2);
|
||||||
const minute = ('0' + date.getMinutes()).slice(-2);
|
const minute = ("0" + date.getMinutes()).slice(-2);
|
||||||
const second = ('0' + date.getSeconds()).slice(-2);
|
const second = ("0" + date.getSeconds()).slice(-2);
|
||||||
|
|
||||||
// 重新组合并返回格式化的日期时间字符串
|
// 重新组合并返回格式化的日期时间字符串
|
||||||
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
return `${year}-${month}-${day} ${hour}:${minute}:${second}`;
|
||||||
},
|
},
|
||||||
|
|
||||||
connectWebSocket() {
|
connectWebSocket() {
|
||||||
|
|
@ -335,12 +406,12 @@ export default {
|
||||||
this.socket = new WebSocket(socketUrl);
|
this.socket = new WebSocket(socketUrl);
|
||||||
//打开事件
|
//打开事件
|
||||||
this.socket.onopen = function () {
|
this.socket.onopen = function () {
|
||||||
this.loading=false
|
this.loading = false;
|
||||||
//alert("连接成功");
|
//alert("连接成功");
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: "连接成功",
|
message: "连接成功",
|
||||||
type: "success",
|
type: "success",
|
||||||
})
|
});
|
||||||
};
|
};
|
||||||
this.socket.onerror = (error) => {
|
this.socket.onerror = (error) => {
|
||||||
console.error("WebSocket Error:", error);
|
console.error("WebSocket Error:", error);
|
||||||
|
|
@ -351,7 +422,7 @@ export default {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: "连接已关闭",
|
message: "连接已关闭",
|
||||||
type: "error",
|
type: "error",
|
||||||
})
|
});
|
||||||
};
|
};
|
||||||
// 浏览器端收消息,获得从服务端发送过来的文本消息
|
// 浏览器端收消息,获得从服务端发送过来的文本消息
|
||||||
this.socket.onmessage = async function (msg) {
|
this.socket.onmessage = async function (msg) {
|
||||||
|
|
@ -360,120 +431,127 @@ export default {
|
||||||
// console.log("收到数据====" + data);
|
// console.log("收到数据====" + data);
|
||||||
// 如果服务器端发送过来的json数据
|
// 如果服务器端发送过来的json数据
|
||||||
console.log("data.type:", data.type);
|
console.log("data.type:", data.type);
|
||||||
if (data.type == "msg") { // 如果是消息类型,解密消息内容
|
if (data.type == "msg") {
|
||||||
// console.log("收到数据====" + JSON.stringify(msg.data));
|
// 如果是消息类型,解密消息内容
|
||||||
|
// console.log("收到数据====" + JSON.stringify(msg.data));
|
||||||
console.log("msg_:", data.data);
|
console.log("msg_:", data.data);
|
||||||
let msg_data=JSON.parse(data.data)
|
let msg_data = JSON.parse(data.data);
|
||||||
_this.MsgList.push(msg_data);
|
_this.MsgList.push(msg_data);
|
||||||
if(_this.cur_user_id != msg_data.FromUserID || _this.cur_group_id != msg_data.GroupID){
|
if (
|
||||||
if(msg_data.GroupID===0){
|
_this.cur_user_id != msg_data.FromUserID &&
|
||||||
_this.hasUnreadMsg[msg_data.FromUserID] = true;
|
_this.cur_group_id != msg_data.GroupID
|
||||||
}else{
|
) {
|
||||||
_this.hasUnreadMsg["g_"+msg_data.GroupID] = true;
|
if (msg_data.GroupID === 0) {
|
||||||
}
|
_this.hasUnreadMsg[msg_data.FromUserID] = true;
|
||||||
}else{
|
} else {
|
||||||
|
_this.hasUnreadMsg["g_" + msg_data.GroupID] = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
_this.scrollToBottom();
|
_this.scrollToBottom();
|
||||||
}
|
}
|
||||||
|
|
||||||
//console.log("msglist:", _this.MsgList);
|
//console.log("msglist:", _this.MsgList);
|
||||||
// 构建消息内容
|
// 构建消息内容
|
||||||
}else if (data.type == "check") {
|
} else if (data.type == "check") {
|
||||||
//alert("对方已下线");
|
//alert("对方已下线");
|
||||||
console.log(data.type)
|
console.log(data.type);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async connectSSE(){
|
async connectSSE() {
|
||||||
if (!!window.EventSource) {
|
if (!!window.EventSource) {
|
||||||
this.eventSource = new EventSource("https://gep.ljsea.xyz/im/sse_msg?token="+this.tokenData.token);
|
this.eventSource = new EventSource(
|
||||||
let this_=this
|
"https://gep.ljsea.xyz/im/sse_msg?token=" + this.tokenData.token
|
||||||
this.eventSource.onopen = function(event) {
|
);
|
||||||
console.log("连接已建立!");
|
let this_ = this;
|
||||||
};
|
this.eventSource.onopen = function (event) {
|
||||||
this.eventSource.onmessage = function(event) {
|
console.log("连接已建立!");
|
||||||
console.log(event.data);
|
|
||||||
let msg = JSON.parse(event.data);
|
|
||||||
if(msg.type !=="check"){
|
|
||||||
alert(msg);
|
|
||||||
this_.MsgList.push(msg);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
this.eventSource.onerror = (error) => {
|
|
||||||
//重新连接
|
|
||||||
this.connectSSE();
|
|
||||||
if (this.eventSource.readyState === EventSource.CLOSED) {
|
|
||||||
//console.log('Connection was closed by the server.');
|
|
||||||
ElMessage({
|
|
||||||
message: "连接已关闭!:"+error,
|
|
||||||
type: "error",
|
|
||||||
})
|
|
||||||
|
|
||||||
|
|
||||||
// Optionally, try to reconnect
|
|
||||||
} else {
|
|
||||||
//console.error('EventSource failed:', error);
|
|
||||||
ElMessage({
|
|
||||||
message: "连接失败!服务器无法实时推送消息!",
|
|
||||||
type: "error",
|
|
||||||
})
|
|
||||||
// Handle error
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}else{
|
this.eventSource.onmessage = function (event) {
|
||||||
|
console.log(event.data);
|
||||||
|
let msg = JSON.parse(event.data);
|
||||||
|
if (msg.type !== "check") {
|
||||||
|
alert(msg);
|
||||||
|
this_.MsgList.push(msg);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.eventSource.onerror = (error) => {
|
||||||
|
//重新连接
|
||||||
|
this.connectSSE();
|
||||||
|
if (this.eventSource.readyState === EventSource.CLOSED) {
|
||||||
|
//console.log('Connection was closed by the server.');
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: "您的浏览器不支持SSE!",
|
message: "连接已关闭!:" + error,
|
||||||
type: "error",
|
type: "error",
|
||||||
})
|
});
|
||||||
}
|
|
||||||
|
// Optionally, try to reconnect
|
||||||
|
} else {
|
||||||
|
//console.error('EventSource failed:', error);
|
||||||
|
ElMessage({
|
||||||
|
message: "连接失败!服务器无法实时推送消息!",
|
||||||
|
type: "error",
|
||||||
|
});
|
||||||
|
// Handle error
|
||||||
|
}
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
ElMessage({
|
||||||
|
message: "您的浏览器不支持SSE!",
|
||||||
|
type: "error",
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
scrollToBottom() {
|
scrollToBottom() {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
const scrollbar = this.$refs.chatRoom.$el.querySelector('.el-scrollbar__wrap');
|
const scrollbar = this.$refs.chatRoom.$el.querySelector(
|
||||||
if (scrollbar) {
|
".el-scrollbar__wrap"
|
||||||
scrollbar.scrollTop = scrollbar.scrollHeight;
|
);
|
||||||
}
|
if (scrollbar) {
|
||||||
});
|
scrollbar.scrollTop = scrollbar.scrollHeight;
|
||||||
},
|
}
|
||||||
async handleSendBtnClick(){
|
});
|
||||||
if(this.currentMsg =="" || this.currentMsg === null){
|
},
|
||||||
|
async handleSendBtnClick() {
|
||||||
|
if (this.currentMsg == "" || this.currentMsg === null) {
|
||||||
ElMessage.error("消息不能为空!");
|
ElMessage.error("消息不能为空!");
|
||||||
return
|
return;
|
||||||
}
|
}
|
||||||
let result = {};
|
let result = {};
|
||||||
try {
|
try {
|
||||||
let req={
|
let req = {
|
||||||
token: localStorage.getItem("token"),
|
token: localStorage.getItem("token"),
|
||||||
ip: localStorage.getItem("ip"),
|
ip: localStorage.getItem("ip"),
|
||||||
userId: localStorage.getItem("userId"),
|
userId: localStorage.getItem("userId"),
|
||||||
username: localStorage.getItem("username"),
|
username: localStorage.getItem("username"),
|
||||||
from_user_id:localStorage.getItem("userId"),
|
from_user_id: localStorage.getItem("userId"),
|
||||||
to_user_id:this.to_user_id,
|
to_user_id: this.to_user_id,
|
||||||
group_id:this.cur_group_id,
|
group_id: this.cur_group_id,
|
||||||
msg:this.currentMsg,
|
msg: this.currentMsg,
|
||||||
type:this.msg_type,
|
type: this.msg_type,
|
||||||
}
|
};
|
||||||
result = await sendMessageService(req);
|
result = await sendMessageService(req);
|
||||||
if(result.code !==0){
|
if (result.code !== 0) {
|
||||||
ElMessage({
|
ElMessage({
|
||||||
message: "消息发送失败!",
|
message: "消息发送失败!",
|
||||||
type: "error",
|
type: "error",
|
||||||
})
|
});
|
||||||
}
|
|
||||||
let msg={
|
|
||||||
ID:result.Data,
|
|
||||||
FromUserID:localStorage.getItem("userId"),
|
|
||||||
ToUserID:this.to_user_id,
|
|
||||||
GroupID:this.cur_group_id,
|
|
||||||
Msg:this.currentMsg,
|
|
||||||
CreatedAt:new Date(),
|
|
||||||
}
|
}
|
||||||
|
let msg = {
|
||||||
|
ID: result.Data,
|
||||||
|
FromUserID: localStorage.getItem("userId"),
|
||||||
|
ToUserID: this.to_user_id,
|
||||||
|
GroupID: this.cur_group_id,
|
||||||
|
Msg: this.currentMsg,
|
||||||
|
CreatedAt: new Date(),
|
||||||
|
};
|
||||||
this.MsgList.push(msg);
|
this.MsgList.push(msg);
|
||||||
this.scrollToBottom();
|
this.scrollToBottom();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
this.currentMsg="";
|
this.currentMsg = "";
|
||||||
},
|
},
|
||||||
async getIpClient() {
|
async getIpClient() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -513,7 +591,7 @@ export default {
|
||||||
// console.log("mounted");
|
// console.log("mounted");
|
||||||
await this.getIpClient();
|
await this.getIpClient();
|
||||||
await this.handleSelectUser();
|
await this.handleSelectUser();
|
||||||
this.filteredUsers=this.userList;
|
this.filteredUsers = this.userList;
|
||||||
//await this.connectSSE();
|
//await this.connectSSE();
|
||||||
this.connectWebSocket();
|
this.connectWebSocket();
|
||||||
this.handleGetMessage(this.userList[0].id);
|
this.handleGetMessage(this.userList[0].id);
|
||||||
|
|
@ -528,65 +606,65 @@ export default {
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
.layout-container-demo .el-header {
|
.layout-container-demo .el-header {
|
||||||
position: relative;
|
position: relative;
|
||||||
/* background-color: var(--el-color-primary-light-7); */
|
/* background-color: var(--el-color-primary-light-7); */
|
||||||
color: var(--el-text-color-primary);
|
color: var(--el-text-color-primary);
|
||||||
}
|
}
|
||||||
|
|
||||||
.layout-container-demo .el-aside {
|
.layout-container-demo .el-aside {
|
||||||
color: var(--el-text-color-primary);
|
color: var(--el-text-color-primary);
|
||||||
/* background: var(--el-color-primary-light-8); */
|
/* background: var(--el-color-primary-light-8); */
|
||||||
}
|
}
|
||||||
|
|
||||||
.layout-container-demo .el-menu {
|
.layout-container-demo .el-menu {
|
||||||
border-right: none;
|
border-right: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layout-container-demo .el-main {
|
.layout-container-demo .el-main {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.layout-container-demo .toolbar {
|
.layout-container-demo .toolbar {
|
||||||
display: inline-flex;
|
display: inline-flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
right: 5px;
|
right: 5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.msg {
|
.msg {
|
||||||
background-color: #73d1f3;
|
background-color: #73d1f3;
|
||||||
/* box-shadow: rgba(18, 23, 45, 0.6) 0px 8px 24px; */
|
/* box-shadow: rgba(18, 23, 45, 0.6) 0px 8px 24px; */
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
line-height: 16px;
|
line-height: 16px;
|
||||||
/* width: auto; */
|
/* width: auto; */
|
||||||
/* max-width: 330px; */
|
/* max-width: 330px; */
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.msg2 {
|
.msg2 {
|
||||||
background-color: #12B7F5;
|
background-color: #12b7f5;
|
||||||
/* box-shadow: rgba(18, 23, 45, 0.6) 0px 8px 24px; */
|
/* box-shadow: rgba(18, 23, 45, 0.6) 0px 8px 24px; */
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
font-size: 18px;
|
font-size: 18px;
|
||||||
line-height: 16px;
|
line-height: 16px;
|
||||||
/* width: auto; */
|
/* width: auto; */
|
||||||
/* max-width: 330px; */
|
/* max-width: 330px; */
|
||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
color: white;
|
color: white;
|
||||||
}
|
}
|
||||||
.unread-dot {
|
.unread-dot {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
width: 8px;
|
width: 8px;
|
||||||
height: 8px;
|
height: 8px;
|
||||||
background-color: red;
|
background-color: red;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
transform: translate(50%, -50%);
|
transform: translate(50%, -50%);
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ import { addDeviceService } from "@/api/device.js";
|
||||||
import { deleteDeviceService } from "@/api/device.js";
|
import { deleteDeviceService } from "@/api/device.js";
|
||||||
import { getFriendListService } from "@/api/chat.js";
|
import { getFriendListService } from "@/api/chat.js";
|
||||||
import { addGroupService} from "@/api/chat.js";
|
import { addGroupService} from "@/api/chat.js";
|
||||||
import {sendMessageService} from "@/api/chat.js";
|
import {DelFGService} from "@/api/user.js";
|
||||||
import { updateDeviceService } from "@/api/device.js";
|
import { updateDeviceService } from "@/api/device.js";
|
||||||
import router from "@/router/index.js";
|
import router from "@/router/index.js";
|
||||||
import { ElMessage } from 'element-plus';
|
import { ElMessage } from 'element-plus';
|
||||||
|
|
@ -43,12 +43,10 @@ export default {
|
||||||
},
|
},
|
||||||
updateForm: {
|
updateForm: {
|
||||||
id:0,
|
id:0,
|
||||||
device_name: "",
|
group_name: "",
|
||||||
device_ip: "",
|
group_info: "",
|
||||||
device_status: "",
|
group_type: "",
|
||||||
device_info: "",
|
group_icon:"",
|
||||||
device_location: "",
|
|
||||||
device_type: "",
|
|
||||||
auth_id: -1,
|
auth_id: -1,
|
||||||
token: localStorage.getItem("token"),
|
token: localStorage.getItem("token"),
|
||||||
},
|
},
|
||||||
|
|
@ -103,7 +101,7 @@ export default {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
//设置设备重启
|
//邀请好友加入群组
|
||||||
async inviteUser(index) {
|
async inviteUser(index) {
|
||||||
var id = this.tableData[index].ID;
|
var id = this.tableData[index].ID;
|
||||||
var restart_data = {
|
var restart_data = {
|
||||||
|
|
@ -116,7 +114,6 @@ export default {
|
||||||
try {
|
try {
|
||||||
var d_re = await restartDeviceService(restart_data);
|
var d_re = await restartDeviceService(restart_data);
|
||||||
if (d_re.code == 0) {
|
if (d_re.code == 0) {
|
||||||
//alert("重启成功");
|
|
||||||
ElMessage.success('重启成功');
|
ElMessage.success('重启成功');
|
||||||
} else {
|
} else {
|
||||||
alert("操作失败");
|
alert("操作失败");
|
||||||
|
|
@ -126,20 +123,17 @@ export default {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
playRealVp(index) {
|
|
||||||
var id = this.tableData[index].ID;
|
async deleteGroup(index) {
|
||||||
localStorage.setItem("realvp_device_id", id);
|
|
||||||
router.push("/deviceRealVP");
|
|
||||||
},
|
|
||||||
async deleteDevice(index) {
|
|
||||||
var id = this.tableData[index].ID;
|
var id = this.tableData[index].ID;
|
||||||
var delete_data = {
|
var delete_data = {
|
||||||
id: id,
|
group_id: id,
|
||||||
|
type:3,//删除群组
|
||||||
userId: this.tokenData.userId,
|
userId: this.tokenData.userId,
|
||||||
token: this.tokenData.token,
|
token: this.tokenData.token,
|
||||||
};
|
};
|
||||||
try {
|
try {
|
||||||
var d_re = await deleteGroupService(delete_data);
|
var d_re = await DelFGService(delete_data);
|
||||||
if (d_re.code == 0) {
|
if (d_re.code == 0) {
|
||||||
//alert("删除成功");
|
//alert("删除成功");
|
||||||
ElMessage.success('删除成功');
|
ElMessage.success('删除成功');
|
||||||
|
|
@ -153,15 +147,13 @@ export default {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async updateButtonDevice(index) {
|
async updateButtonGroup(index) {
|
||||||
var id = this.tableData[index].ID;
|
var id = this.tableData[index].ID;
|
||||||
this.group_id = id;
|
this.group_id = id;
|
||||||
this.updateForm.device_name = this.tableData[index].DeviceName;
|
this.updateForm.group_name = this.tableData[index].GroupName;
|
||||||
this.updateForm.device_ip = this.tableData[index].DeviceIP;
|
this.updateForm.group_info = this.tableData[index].GroupInfo;
|
||||||
this.updateForm.device_status = this.tableData[index].DeviceStatus;
|
this.updateForm.group_type = this.tableData[index].GroupType;
|
||||||
this.updateForm.device_info = this.tableData[index].DeviceInfo;
|
this.updateForm.group_icon = this.tableData[index].GroupIcon;
|
||||||
this.updateForm.device_location = this.tableData[index].DeviceLocation;
|
|
||||||
this.updateForm.device_type = this.tableData[index].DeviceType;
|
|
||||||
this.updateForm.auth_id = this.tableData[index].AuthID;
|
this.updateForm.auth_id = this.tableData[index].AuthID;
|
||||||
this.updateForm.id = id;
|
this.updateForm.id = id;
|
||||||
this.updateDialogVisible= true;
|
this.updateDialogVisible= true;
|
||||||
|
|
@ -197,26 +189,7 @@ export default {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
async restartAllDevice() {
|
|
||||||
var restart_data = {
|
|
||||||
id: id,
|
|
||||||
ip: this.ip,
|
|
||||||
option: "all",
|
|
||||||
userId: this.tokenData.userId,
|
|
||||||
token: this.tokenData.token,
|
|
||||||
};
|
|
||||||
try {
|
|
||||||
var d_re = await restartDeviceService(restart_data);
|
|
||||||
if (d_re.code == 0) {
|
|
||||||
//alert("重启成功");
|
|
||||||
ElMessage.success("重启成功");
|
|
||||||
} else {
|
|
||||||
alert("操作失败");
|
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
console.log(e);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
async inviteFriendAddGroup(index){
|
async inviteFriendAddGroup(index){
|
||||||
var id = this.FriendsGList[index].id;
|
var id = this.FriendsGList[index].id;
|
||||||
let req={
|
let req={
|
||||||
|
|
@ -416,7 +389,7 @@ export default {
|
||||||
<el-form-item>
|
<el-form-item>
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="updateDialogVisible"
|
v-model="updateDialogVisible"
|
||||||
title="修改设备"
|
title="修改群信息"
|
||||||
width="50%"
|
width="50%"
|
||||||
:before-close="handleClose"
|
:before-close="handleClose"
|
||||||
>
|
>
|
||||||
|
|
@ -427,29 +400,20 @@ export default {
|
||||||
:rules="updateFormRules"
|
:rules="updateFormRules"
|
||||||
label-width="70px"
|
label-width="70px"
|
||||||
>
|
>
|
||||||
<el-form-item label="设备名称" prop="device_name">
|
<el-form-item label="名称" prop="group_name">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="updateForm.device_name"
|
v-model="updateForm.group_name"
|
||||||
autocomplete="on"
|
autocomplete="on"
|
||||||
></el-input>
|
></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="设备IP" prop="device_ip">
|
<el-form-item label="群信息" prop="group_info">
|
||||||
<el-input v-model="updateForm.device_ip"></el-input>
|
<el-input v-model="updateForm.group_info"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="设备状态" prop="device_status">
|
<el-form-item label="群类型" prop="group_type">
|
||||||
<el-select v-model="updateForm.device_status">
|
<el-input v-model="updateForm.group_type"></el-input>
|
||||||
<el-option label="在线" value="在线"></el-option>
|
|
||||||
<el-option label="离线" value="离线"></el-option>
|
|
||||||
</el-select>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item label="设备类型" prop="device_type">
|
<el-form-item label="群Icon" prop="group_icon">
|
||||||
<el-input v-model="updateForm.device_type"></el-input>
|
<el-input v-model="updateForm.group_icon"></el-input>
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="设备位置" prop="device_location">
|
|
||||||
<el-input v-model="updateForm.device_location"></el-input>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item label="设备信息" prop="device_info">
|
|
||||||
<el-input v-model="updateForm.device_info"></el-input>
|
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
</el-form>
|
</el-form>
|
||||||
<!-- 底部区域 -->
|
<!-- 底部区域 -->
|
||||||
|
|
@ -458,7 +422,7 @@ export default {
|
||||||
<el-button @click="updateDialogVisible = false"
|
<el-button @click="updateDialogVisible = false"
|
||||||
>取消</el-button
|
>取消</el-button
|
||||||
>
|
>
|
||||||
<el-button type="primary" @click="updateDevice()"
|
<el-button type="primary" @click="updateGroup()"
|
||||||
>确定</el-button
|
>确定</el-button
|
||||||
>
|
>
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -579,13 +543,13 @@ export default {
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click.prevent="updateButtonDevice(scope.$index)"
|
@click.prevent="updateButtonGroup(scope.$index)"
|
||||||
>修改</el-button
|
>修改</el-button
|
||||||
>
|
>
|
||||||
<el-button
|
<el-button
|
||||||
type="primary"
|
type="primary"
|
||||||
size="mini"
|
size="mini"
|
||||||
@click.prevent="deleteDevice(scope.$index)"
|
@click.prevent="deleteGroup(scope.$index)"
|
||||||
>删除</el-button
|
>删除</el-button
|
||||||
>
|
>
|
||||||
<!-- <el-button type="danger" size="mini">删除</el-button> -->
|
<!-- <el-button type="danger" size="mini">删除</el-button> -->
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue