Browse Source

右上消息bug wsbug

asd26269546 1 year ago
parent
commit
46b0180ef2
6 changed files with 28 additions and 14 deletions
  1. 1 1
      .env.development
  2. 1 1
      .env.production
  3. 1 1
      .env.staging
  4. 3 2
      src/components/byTable/index.vue
  5. 20 7
      src/components/notice/index.vue
  6. 2 2
      src/utils/request.js

+ 1 - 1
.env.development

@@ -7,6 +7,6 @@ VITE_APP_ENV = 'development'
 # 若依管理系统/开发环境
 VITE_APP_BASE_API = '/dev-api'
 
-VITE_APP_WS_API = '/test-api'
+VITE_APP_WS_API = ':20001/test-api'
 
 VITE_APP_IP = '121.37.194.75'

+ 1 - 1
.env.production

@@ -7,7 +7,7 @@ VITE_APP_ENV = 'production'
 # 若依管理系统/生产环境
 VITE_APP_BASE_API = '/prod-api'
 
-VITE_APP_WS_API = '/prod-api'
+VITE_APP_WS_API = ':9898/prod-api'
 
 VITE_APP_IP = '139.159.251.109'
 

+ 1 - 1
.env.staging

@@ -7,7 +7,7 @@ VITE_APP_ENV = 'staging'
 # 若依管理系统/生产环境
 VITE_APP_BASE_API = '/test-api'
 
-VITE_APP_WS_API = '/test-api'
+VITE_APP_WS_API = ':20001/test-api'
 
 # 是否在打包时开启压缩,支持 gzip 和 brotli
 VITE_BUILD_COMPRESS = gzip

+ 3 - 2
src/components/byTable/index.vue

@@ -73,7 +73,7 @@
       </li>
     </ul>
   </div>
-  <div class="table-list-container by-table">
+  <div class="table-list-container by-table" v-loading="loading">
     <!-- v-if="!hideHeader" -->
     <header v-if="false" class="header">
       <h2>{{ title }}</h2>
@@ -157,7 +157,7 @@
 
       <el-table
         ref="hocElTable"
-        v-loading="loading"
+        
         :data="source"
         v-if="!hideTable"
         style="width: 100%"
@@ -454,6 +454,7 @@ export default defineComponent({
       return isFn(fn);
     };
     const searchFn = (val) => {
+      if(props.loading) return;
       proxy.$emit(
         "getList",
         Object.assign(props.filterParams, {

+ 20 - 7
src/components/notice/index.vue

@@ -51,11 +51,15 @@
 			<div class="notice-table" @click.stop  v-loading="loading" >
 				<div class="tabs">
 					<ul>
-						<li style="padding-left: 0; border: none" @click="pushInfoReq.whetherFlow = '';getPushInfo()" :class="pushInfoReq.whetherFlow === '' ? 'active' : ''">
-							全部({{pushInfoReq.total}})
+						<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>
-						<li  @click="pushInfoReq.whetherFlow = 1;getPushInfo()" :class="pushInfoReq.whetherFlow === 1 ? 'active' : ''">流程</li>
-						<li  @click="pushInfoReq.whetherFlow = 0;getPushInfo()" :class="pushInfoReq.whetherFlow === 0 ? 'active' : ''">业务</li>
 					</ul>
 					<!-- <div class="more">查看更多&gt;</div> -->
 				</div>
@@ -85,7 +89,12 @@
 					</el-table-column>
 				</el-table>
 				<div >
-					<el-pagination style="text-align: center;" :page-size="5" layout="prev, pager, next" :total="pushInfoReq.total" @current-change="handlePageChange" />
+					<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">
 					<!-- <el-button plain disabled>点击清空</el-button> -->
@@ -181,7 +190,7 @@ const confirm = () => {
 
 const socketInit = () => {
 	window.ws = new WebSocket(
-		'ws://'+ import.meta.env.VITE_APP_IP +':20001'+ import.meta.env.VITE_APP_WS_API +'/webStock/' +
+		'ws://'+ import.meta.env.VITE_APP_IP + import.meta.env.VITE_APP_WS_API +'/webStock/' +
 			getToken()
 		// 'ws://192.168.1.97:8300/webStock/' + window.localStorage.getItem('token')
 	)
@@ -240,11 +249,15 @@ const handlePageChange = (val) => {
 }
 
 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 = pushInfoReq.value.whetherFlow === '' ? res.total : pushInfoReq.value.total
+		pushInfoReq.value.total = res.total
 		console.log(pushInfoReq)
 		setTimeout(() => {
 			loading.value = false

+ 2 - 2
src/utils/request.js

@@ -64,7 +64,7 @@ service.interceptors.request.use(config => {
       const s_url = sessionObj.url; // 请求地址
       const s_data = sessionObj.data; // 请求数据
       const s_time = sessionObj.time; // 请求时间
-      const interval = 1000; // 间隔时间(ms),小于此时间视为重复提交
+      const interval = 300; // 间隔时间(ms),小于此时间视为重复提交
       if (s_data === requestObj.data && requestObj.time - s_time < interval && s_url === requestObj.url) {
         const message = '数据正在处理,请勿重复提交';
         // console.warn(`[${s_url}]: ` + message)
@@ -88,7 +88,7 @@ service.interceptors.response.use(res => {
     // 获取错误信息
     const msg = errorCode[code] || res.data.msg || errorCode['default']
     // 二进制数据则直接返回
-    if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') {
+    if (res.request.responseType === 'blob' || res.request.responseType === 'arraybuffer') { 
       return res.data
     }
     if (code === 401) {