|
@@ -3,61 +3,160 @@
|
|
|
<el-dialog title="系统公告" v-model="value" width="460px" :align-center="true" :before-close="handleClose">
|
|
|
<div class="title"></div>
|
|
|
<div class="text-content" v-if="data.length > 0" style="margin-top: 10px">
|
|
|
- {{ data[index].content }}
|
|
|
+ <h3>{{ data[index].title }}</h3>
|
|
|
+ {{ data[index].businessData }}
|
|
|
</div>
|
|
|
<template #footer>
|
|
|
- <span class="dialog-footer"> </span>
|
|
|
+ <span class="dialog-footer">
|
|
|
+ <el-button size="small" @click="index--" :disabled="data.length < 2 || index == 0">上一条</el-button>
|
|
|
+ <el-button size="small" @click="index++" :disabled="data.length == index + 1">下一条</el-button>
|
|
|
+ <el-button type="primary" size="small" :disabled="data.length == 0 || data[index].isRead" @click="confirm">确认已读</el-button>
|
|
|
+ </span>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
<div class="notice-table-warp" :class="modelValue ? 'notice-table-warp-open' : ''" @click.stop="closeNoticeTableModal">
|
|
|
- <div class="notice-table" @click.stop>
|
|
|
+ <div class="notice-table" @click.stop v-loading="loading">
|
|
|
<div class="tabs">
|
|
|
<ul>
|
|
|
- <li style="padding-left: 0; border: none" @click="tableTagType = 1" :class="tableTagType == 1 ? 'active' : ''">全部(0)</li>
|
|
|
- <li @click="tableTagType = 2" :class="tableTagType == 2 ? 'active' : ''">待办(0)</li>
|
|
|
- <li @click="tableTagType = 3" :class="tableTagType == 3 ? 'active' : ''">通知(0)</li>
|
|
|
+ <li
|
|
|
+ style="padding-left: 0; border: none"
|
|
|
+ @click="
|
|
|
+ pushInfoReq.whetherFlow = '';
|
|
|
+ getPushInfoInit();
|
|
|
+ "
|
|
|
+ :class="pushInfoReq.whetherFlow === '' ? 'active' : ''">
|
|
|
+ 全部<span v-if="pushInfoReq.whetherFlow === ''">({{ pushInfoReq.total }})</span>
|
|
|
+ </li>
|
|
|
+ <li
|
|
|
+ @click="
|
|
|
+ pushInfoReq.whetherFlow = 1;
|
|
|
+ getPushInfoInit();
|
|
|
+ "
|
|
|
+ :class="pushInfoReq.whetherFlow === 1 ? 'active' : ''">
|
|
|
+ 流程<span v-if="pushInfoReq.whetherFlow === 1">({{ pushInfoReq.total }})</span>
|
|
|
+ </li>
|
|
|
+ <li
|
|
|
+ @click="
|
|
|
+ pushInfoReq.whetherFlow = 0;
|
|
|
+ getPushInfoInit();
|
|
|
+ "
|
|
|
+ :class="pushInfoReq.whetherFlow === 0 ? 'active' : ''">
|
|
|
+ 业务<span v-if="pushInfoReq.whetherFlow === 0">({{ pushInfoReq.total }})</span>
|
|
|
+ </li>
|
|
|
</ul>
|
|
|
- <div class="more">查看更多></div>
|
|
|
+ <div class="more" @click="toDealWith({ businessType: 'hisMsg' })">查看更多></div>
|
|
|
</div>
|
|
|
- <el-table :data="noticeData" style="width: 100%">
|
|
|
- <el-table-column prop="date" label="标题内容" width="250"> </el-table-column>
|
|
|
- <el-table-column prop="name" label="类型" width="120"> </el-table-column>
|
|
|
+ <el-table :data="noticeData" style="width: 100%" @row-click="rowClick">
|
|
|
+ <el-table-column prop="title" label="标题内容" width="250">
|
|
|
+ <template #default="scope">
|
|
|
+ <el-tooltip class="box-item" effect="dark" :content="scope.row.title" placement="top">
|
|
|
+ <div class="noticeData-title">{{ scope.row.title }}</div>
|
|
|
+ </el-tooltip>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="businessType" label="类型" width="120">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ scope.row.businessType === 0 ? "流程" : "业务" }}</span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column prop="address" label="操作">
|
|
|
<template #default="scope">
|
|
|
- <span style="cursor: pointer">未读</span>
|
|
|
+ <span style="cursor: pointer; color: #0084ff" @click.stop="readFn(scope)">已读</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
- <div class="notice-btn-box" style="margin-top: 20px">
|
|
|
- <el-button plain disabled>点击清空</el-button>
|
|
|
- <el-button type="primary" disabled>全部已读</el-button>
|
|
|
+ <div v-if="noticeData && noticeData.length > 0">
|
|
|
+ <el-pagination
|
|
|
+ style="text-align: center"
|
|
|
+ :page-size="5"
|
|
|
+ layout="prev, pager, next"
|
|
|
+ :current-page="pushInfoReq.pageNum"
|
|
|
+ :total="pushInfoReq.total"
|
|
|
+ @current-change="handlePageChange" />
|
|
|
+ </div>
|
|
|
+ <div class="notice-btn-box" style="margin-top: 20px" v-if="noticeData && noticeData.length > 0">
|
|
|
+ <el-button type="primary" @click="allReadFn" v-if="noticeData.length != 0">全部已读</el-button>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
<script setup>
|
|
|
+import { ElMessageBox, ElNotification, ElMessage } from "element-plus";
|
|
|
import { getToken } from "@/utils/auth";
|
|
|
+
|
|
|
+const { proxy } = getCurrentInstance();
|
|
|
defineProps({
|
|
|
modelValue: {
|
|
|
type: Object,
|
|
|
default: false,
|
|
|
},
|
|
|
});
|
|
|
-const emit = defineEmits(["update:modelValue"]);
|
|
|
+const emit = defineEmits(["update:modelValue"], "changeNum");
|
|
|
const closeNoticeTableModal = () => {
|
|
|
emit("update:modelValue", false);
|
|
|
};
|
|
|
-const tableTagType = ref(1);
|
|
|
let noticeData = ref([]);
|
|
|
let index = ref(0);
|
|
|
let data = ref([]);
|
|
|
let value = ref(false);
|
|
|
+const rowClick = (row) => {
|
|
|
+ commonRead([row.id]);
|
|
|
+ toDealWith(row);
|
|
|
+};
|
|
|
+const toDealWith = (item) => {
|
|
|
+ let urlConfig = {
|
|
|
+ 0: "DealWith",
|
|
|
+ 5: "Claim",
|
|
|
+ 6: "Abnormal",
|
|
|
+ hisMsg: "hisMsg",
|
|
|
+ };
|
|
|
+ proxy.$router.push({
|
|
|
+ name: urlConfig[item.businessType],
|
|
|
+ });
|
|
|
+};
|
|
|
+const allReadFn = () => {
|
|
|
+ ElMessageBox.confirm("此操作将会把所有未读消息标记为已读,是否继续?", "提示", {
|
|
|
+ confirmButtonText: "确定",
|
|
|
+ cancelButtonText: "取消",
|
|
|
+ type: "warning",
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ let arr = [];
|
|
|
+ noticeData.value.filter((item) => {
|
|
|
+ arr.push(item.id);
|
|
|
+ });
|
|
|
+ commonRead(arr);
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ ElMessage({
|
|
|
+ type: "info",
|
|
|
+ message: "已取消操作",
|
|
|
+ });
|
|
|
+ });
|
|
|
+};
|
|
|
+const readFn = (item) => {
|
|
|
+ commonRead([item.row.id]);
|
|
|
+};
|
|
|
+const commonRead = (ids, type) => {
|
|
|
+ proxy.post("/pushInfo/read", { idList: ids }).then(() => {
|
|
|
+ ElMessage({
|
|
|
+ message: "已读成功",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+ if (type == "confirm") {
|
|
|
+ data.value[index].isRead = true;
|
|
|
+ } else {
|
|
|
+ getPushInfo();
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+const confirm = () => {
|
|
|
+ value.value = false;
|
|
|
+ commonRead([data.value[index.value].id], "confirm");
|
|
|
+};
|
|
|
const socketInit = () => {
|
|
|
- window.ws = new WebSocket(
|
|
|
- "ws://" + import.meta.env.VITE_APP_IP + ":20001" + import.meta.env.VITE_APP_WS_API + "/webStock/" + getToken()
|
|
|
- // 'ws://192.168.1.97:8300/webStock/' + window.localStorage.getItem('token')
|
|
|
- );
|
|
|
+ window.ws = new WebSocket("ws://" + import.meta.env.VITE_APP_IP + import.meta.env.VITE_APP_WS_API + "/webStock/" + getToken());
|
|
|
//申请一个WebSocket对象,参数是服务端地址,同http协议使用http://开头一样,WebSocket协议的url使用ws://开头,另外安全的WebSocket协议使用wss://开头
|
|
|
window.ws.onopen = function () {
|
|
|
//当WebSocket创建成功时,触发onopen事件
|
|
@@ -66,20 +165,72 @@ const socketInit = () => {
|
|
|
window.ws.onmessage = function (e) {
|
|
|
//当客户端收到服务端发来的消息时,触发onmessage事件,参数e.data包含server传递过来的数据
|
|
|
//在data.value前面插入
|
|
|
- console.log(JSON.parse(e.data).data);
|
|
|
- data.value.unshift({ title: "最新公告", content: JSON.parse(e.data).data });
|
|
|
- index.value = 0;
|
|
|
- value.value = true;
|
|
|
+ const res = JSON.parse(e.data);
|
|
|
+ if (res.type == 1) {
|
|
|
+ index.value = 0;
|
|
|
+ data.value = res.list;
|
|
|
+ if (res.list.length > 0) value.value = true;
|
|
|
+ }
|
|
|
+ if (res.type == 2) {
|
|
|
+ emit("changeNum", res.count * 1);
|
|
|
+ getPushInfo();
|
|
|
+ }
|
|
|
+ if (res.type == 3) {
|
|
|
+ ElNotification({
|
|
|
+ title: "提示",
|
|
|
+ message: res.title,
|
|
|
+ position: "bottom-right",
|
|
|
+ duration: 0,
|
|
|
+ });
|
|
|
+ }
|
|
|
};
|
|
|
window.ws.onclose = function (e) {
|
|
|
//当客户端收到服务端发送的关闭连接请求时,触发onclose事件
|
|
|
- console.log("close");
|
|
|
+ console.log(e, "close");
|
|
|
};
|
|
|
window.ws.onerror = function (e) {
|
|
|
//如果出现连接、处理、接收、发送数据失败的时候触发onerror事件
|
|
|
- console.log(error);
|
|
|
+ console.log(e, "error");
|
|
|
};
|
|
|
};
|
|
|
+let pushInfoReq = ref({
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 5,
|
|
|
+ pushRead: 0,
|
|
|
+ type: "",
|
|
|
+ total: 0,
|
|
|
+ whetherFlow: "",
|
|
|
+});
|
|
|
+const handlePageChange = (val) => {
|
|
|
+ pushInfoReq.value.pageNum = val;
|
|
|
+ getPushInfo();
|
|
|
+};
|
|
|
+const loading = ref(false);
|
|
|
+const getPushInfoInit = () => {
|
|
|
+ pushInfoReq.value.pageNum = 1;
|
|
|
+ getPushInfo();
|
|
|
+};
|
|
|
+const getPushInfo = () => {
|
|
|
+ loading.value = true;
|
|
|
+ proxy.post("/pushInfo/page", pushInfoReq.value).then((res) => {
|
|
|
+ noticeData.value = res.rows;
|
|
|
+ pushInfoReq.value.total = res.total;
|
|
|
+ setTimeout(() => {
|
|
|
+ loading.value = false;
|
|
|
+ proxy
|
|
|
+ .post("/pushInfo/page", {
|
|
|
+ pageNum: 1,
|
|
|
+ pageSize: 5,
|
|
|
+ pushRead: 0,
|
|
|
+ type: "",
|
|
|
+ whetherFlow: "",
|
|
|
+ })
|
|
|
+ .then((res) => {
|
|
|
+ emit("changeNum", res.total * 1);
|
|
|
+ });
|
|
|
+ }, 500);
|
|
|
+ });
|
|
|
+};
|
|
|
socketInit();
|
|
|
const handleClose = () => {
|
|
|
value.value = false;
|
|
@@ -98,7 +249,6 @@ const handleClose = () => {
|
|
|
opacity: 0;
|
|
|
display: none;
|
|
|
}
|
|
|
-
|
|
|
.notice-table-warp-open {
|
|
|
opacity: 1;
|
|
|
display: block;
|
|
@@ -146,6 +296,13 @@ const handleClose = () => {
|
|
|
}
|
|
|
</style>
|
|
|
<style>
|
|
|
+.noticeData-title {
|
|
|
+ width: 100%;
|
|
|
+ overflow: hidden;
|
|
|
+ text-overflow: ellipsis;
|
|
|
+ white-space: nowrap;
|
|
|
+ cursor: pointer;
|
|
|
+}
|
|
|
.commons-notice .el-table__row {
|
|
|
height: 50px;
|
|
|
}
|