集成websocket
This commit is contained in:
parent
8516efd1c8
commit
2e07ea8a71
47
web/src/api/business/chat/chat.js
Normal file
47
web/src/api/business/chat/chat.js
Normal file
@ -0,0 +1,47 @@
|
||||
import request from '@/utils/request'
|
||||
|
||||
export function getChatPage(params) {
|
||||
return request({
|
||||
url: '/admin/chat/page',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
export function getChatList(params) {
|
||||
return request({
|
||||
url: '/admin/chat/list',
|
||||
method: 'get',
|
||||
params
|
||||
})
|
||||
}
|
||||
|
||||
export function addChat(data) {
|
||||
return request({
|
||||
url: '/admin/chat/add',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function editChat(data) {
|
||||
return request({
|
||||
url: '/admin/chat/update',
|
||||
method: 'post',
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteChat(copyId) {
|
||||
return request({
|
||||
url: '/admin/chat/delete/' + copyId,
|
||||
method: 'get'
|
||||
})
|
||||
}
|
||||
|
||||
export function getAuthorChatList() {
|
||||
return request({
|
||||
url: '/admin/chat/authorList',
|
||||
method: 'get'
|
||||
})
|
||||
}
|
141
web/src/views/business/chat/addChat.vue
Normal file
141
web/src/views/business/chat/addChat.vue
Normal file
@ -0,0 +1,141 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-dialog
|
||||
:close-on-click-modal="false"
|
||||
top="8vh"
|
||||
width="40%"
|
||||
:visible.sync="dialogVisible"
|
||||
center
|
||||
@close="handleCancel"
|
||||
>
|
||||
<div class="el-dialog-div">
|
||||
<el-form
|
||||
:rules="rules"
|
||||
ref="dataForm"
|
||||
:model="temp"
|
||||
label-position="right"
|
||||
label-width="120px"
|
||||
style="height: 90%;"
|
||||
>
|
||||
|
||||
<el-form-item label="消息id" prop="chatId" class="is-required">
|
||||
<el-input v-model="temp.chatId" placeholder="消息id" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="消息发送者" prop="fromId" class="is-required">
|
||||
<el-input v-model="temp.fromId" placeholder="消息发送者" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="消息发送者" prop="fromName" class="is-required">
|
||||
<el-input v-model="temp.fromName" placeholder="消息发送者" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="接收者" prop="toId" class="is-required">
|
||||
<el-input v-model="temp.toId" placeholder="接收者" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="接收者" prop="toName" class="is-required">
|
||||
<el-input v-model="temp.toName" placeholder="接收者" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="0文字 1图片 2语音 3视频" prop="messageType" class="is-required">
|
||||
<el-input v-model="temp.messageType" placeholder="0文字 1图片 2语音 3视频" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="0发送 1已读" prop="messageStatus" class="is-required">
|
||||
<el-input v-model="temp.messageStatus" placeholder="0发送 1已读" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="内容" prop="content" class="is-required">
|
||||
<el-input v-model="temp.content" placeholder="内容" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="资源地址" prop="resourceUrl" class="is-required">
|
||||
<el-input v-model="temp.resourceUrl" placeholder="资源地址" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="0正常 1删除" prop="deleted" class="is-required">
|
||||
<el-input v-model="temp.deleted" placeholder="0正常 1删除" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="创建时间" prop="createTime" class="is-required">
|
||||
<el-input v-model="temp.createTime" placeholder="创建时间" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="ip地址" prop="ipAddress" class="is-required">
|
||||
<el-input v-model="temp.ipAddress" placeholder="ip地址" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="真实ip地址" prop="ipRealAddress" class="is-required">
|
||||
<el-input v-model="temp.ipRealAddress" placeholder="真实ip地址" />
|
||||
</el-form-item>
|
||||
|
||||
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="handleCancel">取 消</el-button>
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {addChat} from "@/api/business/chat/chat";
|
||||
import {setRequiredFields} from "@/utils";
|
||||
const requiredFields = []
|
||||
export default {
|
||||
name: "addForm",
|
||||
data() {
|
||||
return {
|
||||
rules: setRequiredFields(requiredFields),
|
||||
dialogVisible: false,
|
||||
temp: {
|
||||
chatId:'',
|
||||
fromId:'',
|
||||
fromName:'',
|
||||
toId:'',
|
||||
toName:'',
|
||||
messageType:'',
|
||||
messageStatus:'',
|
||||
content:'',
|
||||
resourceUrl:'',
|
||||
deleted:'',
|
||||
createTime:'',
|
||||
ipAddress:'',
|
||||
ipRealAddress:'',
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open() {
|
||||
this.dialogVisible = true
|
||||
},
|
||||
submit() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
addChat(this.temp).then(response =>{
|
||||
this.handleCancel()
|
||||
this.$emit('ok', response.data)
|
||||
})
|
||||
} else {
|
||||
console.log('error submit!!');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
handleCancel() {
|
||||
//初始化
|
||||
this.temp = this.$options.data().temp
|
||||
this.dialogVisible = false
|
||||
this.$refs['dataForm'].resetFields();
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
313
web/src/views/business/chat/copyList.vue
Normal file
313
web/src/views/business/chat/copyList.vue
Normal file
@ -0,0 +1,313 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
|
||||
<div class="filter-container">
|
||||
<el-input
|
||||
v-model="listQuery.keyword"
|
||||
size="small"
|
||||
placeholder="请输入关键词"
|
||||
clearable
|
||||
class="filter-item"
|
||||
style="width: 200px;margin-left: 10px;"
|
||||
/>
|
||||
<el-button-group style="margin-left: 10px;">
|
||||
<el-button
|
||||
size="small"
|
||||
class="filter-item"
|
||||
type="primary"
|
||||
icon="el-icon-search"
|
||||
@click="search"
|
||||
>
|
||||
搜索
|
||||
</el-button>
|
||||
<el-button
|
||||
size="small"
|
||||
class="filter-item"
|
||||
type="primary"
|
||||
icon="el-icon-refresh"
|
||||
@click="refresh"
|
||||
>
|
||||
重置
|
||||
</el-button>
|
||||
</el-button-group>
|
||||
<el-button
|
||||
size="small"
|
||||
class="filter-item"
|
||||
type="primary"
|
||||
icon="el-icon-plus"
|
||||
style="margin-left: 10px;"
|
||||
@click="add"
|
||||
>
|
||||
新增
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<el-table
|
||||
v-loading="listLoading"
|
||||
:data="list"
|
||||
element-loading-text="Loading"
|
||||
border
|
||||
fit
|
||||
height="100%"
|
||||
class="table-container"
|
||||
highlight-current-row
|
||||
>
|
||||
|
||||
<el-table-column
|
||||
label="序号"
|
||||
width="150"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
{{ scope.$index+1 }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="消息id"
|
||||
width="160"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.chatId }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="消息发送者"
|
||||
width="160"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.fromId }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="消息发送者"
|
||||
width="160"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.fromName }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="接收者"
|
||||
width="160"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.toId }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="接收者"
|
||||
width="160"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.toName }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="0文字 1图片 2语音 3视频"
|
||||
width="160"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.messageType }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="0发送 1已读"
|
||||
width="160"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.messageStatus }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="内容"
|
||||
width="160"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.content }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="资源地址"
|
||||
width="160"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.resourceUrl }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="0正常 1删除"
|
||||
width="160"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.deleted }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
width="160"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.createTime }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="ip地址"
|
||||
width="160"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.ipAddress }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column
|
||||
label="真实ip地址"
|
||||
width="160"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
{{ scope.row.ipRealAddress }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
|
||||
<el-table-column
|
||||
fixed="right"
|
||||
label="操作"
|
||||
width="200"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-button-group>
|
||||
<el-button
|
||||
type="primary"
|
||||
icon="el-icon-edit"
|
||||
size="mini"
|
||||
@click="edit(scope)"
|
||||
>
|
||||
修改
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
icon="el-icon-delete"
|
||||
size="mini"
|
||||
@click="del(scope)"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</el-button-group>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination
|
||||
:total="total"
|
||||
:page.sync="listQuery.page"
|
||||
:limit.sync="listQuery.limit"
|
||||
@pagination="fetchData"
|
||||
/>
|
||||
|
||||
<add-form ref="addForm" @ok="addOk" />
|
||||
<edit-form ref="editForm" @ok="editOk" />
|
||||
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import {getChatPage,deleteChat} from "@/api/business/chat/chat";
|
||||
import {deepClone,success} from "@/utils";
|
||||
|
||||
import confirm from "@/utils/confirm";
|
||||
import Pagination from '@/components/Pagination'
|
||||
import addForm from "@/views/business/chat/addChat";
|
||||
import editForm from "@/views/business/chat/editChat";
|
||||
|
||||
export default {
|
||||
name: 'copy',
|
||||
components: {addForm,editForm,Pagination},
|
||||
data() {
|
||||
return {
|
||||
total: 0,
|
||||
list: [],
|
||||
listLoading: true,
|
||||
listQuery: {
|
||||
page: 1,
|
||||
limit: 50,
|
||||
keyword: ''
|
||||
},
|
||||
temp: {},
|
||||
}
|
||||
},
|
||||
created() {
|
||||
this.fetchData()
|
||||
},
|
||||
methods: {
|
||||
search() {
|
||||
this.fetchData()
|
||||
},
|
||||
refresh() {
|
||||
this.listQuery = this.$options.data().listQuery
|
||||
this.fetchData()
|
||||
},
|
||||
fetchData() {
|
||||
this.listLoading = true
|
||||
getChatPage(this.listQuery).then(response => {
|
||||
const { records, total } = response.data
|
||||
this.list = records
|
||||
this.total = total
|
||||
this.listLoading = false
|
||||
})
|
||||
},
|
||||
add(){
|
||||
this.$refs.addForm.open()
|
||||
},
|
||||
addOk(){
|
||||
this.fetchData()
|
||||
},
|
||||
edit(scope) {
|
||||
const temp = deepClone(scope.row)
|
||||
this.$refs.editForm.open(temp)
|
||||
},
|
||||
editOk(){
|
||||
this.fetchData()
|
||||
},
|
||||
del(scope) {
|
||||
confirm("确定要删除吗?").then(res=>{
|
||||
if(res){
|
||||
deleteChat(scope.row.copyId).then(response => {
|
||||
console.log(response)
|
||||
success('删除成功')
|
||||
this.fetchData()
|
||||
})
|
||||
}
|
||||
})
|
||||
},
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
142
web/src/views/business/chat/editChat.vue
Normal file
142
web/src/views/business/chat/editChat.vue
Normal file
@ -0,0 +1,142 @@
|
||||
<template>
|
||||
<div>
|
||||
<el-dialog
|
||||
:close-on-click-modal="false"
|
||||
top="8vh"
|
||||
width="40%"
|
||||
:visible.sync="dialogVisible"
|
||||
center
|
||||
@close="handleCancel"
|
||||
>
|
||||
<div class="el-dialog-div">
|
||||
<el-form
|
||||
:rules="rules"
|
||||
ref="dataForm"
|
||||
:model="temp"
|
||||
label-position="right"
|
||||
label-width="120px"
|
||||
style="height: 90%;"
|
||||
>
|
||||
|
||||
<el-form-item label="消息id" prop="chatId" class="is-required">
|
||||
<el-input v-model="temp.chatId" placeholder="消息id" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="消息发送者" prop="fromId" class="is-required">
|
||||
<el-input v-model="temp.fromId" placeholder="消息发送者" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="消息发送者" prop="fromName" class="is-required">
|
||||
<el-input v-model="temp.fromName" placeholder="消息发送者" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="接收者" prop="toId" class="is-required">
|
||||
<el-input v-model="temp.toId" placeholder="接收者" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="接收者" prop="toName" class="is-required">
|
||||
<el-input v-model="temp.toName" placeholder="接收者" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="0文字 1图片 2语音 3视频" prop="messageType" class="is-required">
|
||||
<el-input v-model="temp.messageType" placeholder="0文字 1图片 2语音 3视频" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="0发送 1已读" prop="messageStatus" class="is-required">
|
||||
<el-input v-model="temp.messageStatus" placeholder="0发送 1已读" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="内容" prop="content" class="is-required">
|
||||
<el-input v-model="temp.content" placeholder="内容" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="资源地址" prop="resourceUrl" class="is-required">
|
||||
<el-input v-model="temp.resourceUrl" placeholder="资源地址" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="0正常 1删除" prop="deleted" class="is-required">
|
||||
<el-input v-model="temp.deleted" placeholder="0正常 1删除" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="创建时间" prop="createTime" class="is-required">
|
||||
<el-input v-model="temp.createTime" placeholder="创建时间" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="ip地址" prop="ipAddress" class="is-required">
|
||||
<el-input v-model="temp.ipAddress" placeholder="ip地址" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="真实ip地址" prop="ipRealAddress" class="is-required">
|
||||
<el-input v-model="temp.ipRealAddress" placeholder="真实ip地址" />
|
||||
</el-form-item>
|
||||
|
||||
</el-form>
|
||||
</div>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="handleCancel">取 消</el-button>
|
||||
<el-button type="primary" @click="submit">确 定</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { editChat } from "@/api/business/chat/chat";
|
||||
import {setRequiredFields} from "@/utils";
|
||||
const requiredFields = []
|
||||
|
||||
export default {
|
||||
name: "editForm",
|
||||
data() {
|
||||
return {
|
||||
rules: setRequiredFields(requiredFields),
|
||||
dialogVisible: false,
|
||||
temp: {
|
||||
chatId:'',
|
||||
fromId:'',
|
||||
fromName:'',
|
||||
toId:'',
|
||||
toName:'',
|
||||
messageType:'',
|
||||
messageStatus:'',
|
||||
content:'',
|
||||
resourceUrl:'',
|
||||
deleted:'',
|
||||
createTime:'',
|
||||
ipAddress:'',
|
||||
ipRealAddress:'',
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
open(row) {
|
||||
this.temp = this.$options.data().temp
|
||||
this.temp = row
|
||||
this.dialogVisible = true
|
||||
},
|
||||
submit() {
|
||||
this.$refs['dataForm'].validate((valid) => {
|
||||
if (valid) {
|
||||
editChat(this.temp).then(response => {
|
||||
this.handleCancel()
|
||||
this.$emit('ok', response.data)
|
||||
})
|
||||
} else {
|
||||
console.log('error submit!!');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
},
|
||||
handleCancel() {
|
||||
//初始化
|
||||
this.temp = this.$options.data().temp
|
||||
this.dialogVisible = false
|
||||
this.$refs['dataForm'].resetFields()
|
||||
}
|
||||
},
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
Loading…
x
Reference in New Issue
Block a user