situationsCenter.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459
  1. <template>
  2. <view class="situationsCenter-page">
  3. <view class="calender-remind" @click="toMessagePage">
  4. <image
  5. :src="
  6. messageType
  7. ? '/static/message-unread.png'
  8. : '/static/message-read.png'
  9. "
  10. mode=""
  11. ></image>
  12. </view>
  13. <view class="situation-list">
  14. <view class="search-box">
  15. <view class="search-model" @click="openSearchBar" v-show="isSearchBoxShow">
  16. <image class="search-pic" src="/static/search.png"></image>
  17. </view>
  18. <view class="search-bar" v-show="isSearchBarShow">
  19. <view class="search-item">
  20. <image class="search-pic" src="/static/search.png"></image>
  21. <image class="text-clear" @click="valueEmpty" src="/static/text-clear.png"></image>
  22. <input class="searh-input" v-model="inputValue" @confirm="searchByKeywords($event)" placeholder="搜索项目" placeholder-style="font-weight: 400,color: #A1A7B3" />
  23. </view>
  24. <text class="cancel-text" @click="closeSearchBar">取消</text>
  25. </view>
  26. </view>
  27. <scroll-view class="scroll-box" scroll-y="true" @scrolltolower="toLower" lower-threshold="184">
  28. <view class="content">
  29. <view class="situation" v-for="(item,index) in situationList" :key="item.id" @click="gotoDetail(item.situationID)">
  30. <image class="situation-topic" :src="`/static/${item.topic ? 'situation-case' : 'situation-system'}.png`"></image>
  31. <view class="title">
  32. <text class="title-name">{{item.name}}</text>
  33. </view>
  34. <view class="check-group">
  35. <text class="group-text">{{item.checkGroupName}}</text>
  36. </view>
  37. <view class="row">
  38. <image class="situation-check" src="/static/situation-check.png"></image>
  39. <text class="text">{{item.checkStatus}}</text>
  40. </view>
  41. <view class="row">
  42. <image class="situation-time" src="/static/situation-time.png"></image>
  43. <text class="text">{{item.nextCheckTime}}</text>
  44. </view>
  45. </view>
  46. </view>
  47. </scroll-view>
  48. </view>
  49. <view class="situaions-add" @click="gotoCreate">
  50. <image class="add-pic" src="/static/situation-add.png"></image>
  51. </view>
  52. <tm-tabbar :permission="nowPermission" />
  53. </view>
  54. </template>
  55. /**
  56. * 情境中心
  57. */
  58. <script>
  59. import websocket from "../../utils/ws.js"; //引入websocket
  60. export default {
  61. data() {
  62. return {
  63. page:1,//页数
  64. inputValue:'',
  65. nowPermission:'',
  66. isSearchBarShow:false,//搜索栏是否可见
  67. isSearchBoxShow:true,//搜索图标是否可见
  68. situationList:[],//情境卡片列表
  69. totalCount:'',//返回数据的总条数
  70. refTimer: null,
  71. isInitWs: null,
  72. messageType: null,
  73. }
  74. },
  75. created: function() {
  76. this.nowPermission=uni.getStorageSync('nowPermission');
  77. this.init(true);
  78. this.refTimer = setInterval(() => {
  79. this.isInitWs = websocket.ws ? false : true;
  80. this.init(this.isInitWs);
  81. }, 3 * 60 * 1000);
  82. this.messStatus();
  83. },
  84. beforeDestroy() {
  85. // 关闭ws连接
  86. websocket.close();
  87. clearInterval(this.refTimer);
  88. },
  89. watch:{
  90. "$route":{
  91. handler(route){
  92. this.messStatus();
  93. }
  94. }
  95. },
  96. methods: {
  97. openSearchBar(){
  98. this.isSearchBarShow=true;
  99. this.isSearchBoxShow=false;
  100. },
  101. closeSearchBar(){
  102. this.isSearchBarShow=false;
  103. this.isSearchBoxShow=true;
  104. },
  105. valueEmpty(){
  106. this.inputValue='';
  107. },
  108. gotoCreate(){
  109. uni.navigateTo({
  110. url: '/pages/creatingSituations/creatingSituations'
  111. });
  112. },
  113. gotoDetail(id){
  114. uni.navigateTo({
  115. url: `/pages/situationDetail/situationDetail?situationId=${id}`
  116. });
  117. },
  118. searchByKeywords(event){
  119. console.log(event);
  120. this.$store.dispatch({
  121. type: 'situationsCenter/commActions',
  122. payload: {
  123. key: 'situationList',
  124. data:{
  125. pageNum:1,
  126. pageSize:10,
  127. keyword:event.target.value,
  128. }
  129. }
  130. }).then((data)=>{
  131. if (data) {
  132. this.situationList=data.list.map((item,index)=>{
  133. return{
  134. name:item.name,
  135. checkStatus:item.checkStatus,
  136. nextCheckTime:item.nextCheckTime,
  137. checkGroupName:item.checkGroupName,
  138. topic:item.topic==0?true:false,
  139. }
  140. });
  141. }
  142. });
  143. },
  144. toLower(){
  145. uni.showToast({
  146. title:'加载中....',
  147. icon:'loading',
  148. duration:2000
  149. });
  150. let count=this.situationList.length;
  151. if(this.totalCount!=count){
  152. this.page++;
  153. this.$store.dispatch({
  154. type: 'situationsCenter/commActions',
  155. payload: {
  156. key: 'situationList',
  157. data:{
  158. pageNum:this.page,
  159. pageSize:10
  160. }
  161. }
  162. }).then((data) => {
  163. if (data) {
  164. this.situationList=data.list.map((item,index)=>{
  165. return{
  166. name:item.name,
  167. checkStatus:item.checkStatus,
  168. nextCheckTime:item.nextCheckTime,
  169. checkGroupName:item.checkGroupName,
  170. topic:item.topic==0?true:false,
  171. situationID:item.id,
  172. }
  173. });
  174. let hiId = uni.getStorageSync("hiId");
  175. let user = uni.getStorageSync("id");
  176. let permission = uni.getStorageSync("nowPermission");
  177. this.isInitWs && this.initWebsocket(hiId, user, permission);
  178. }
  179. });
  180. }
  181. else{
  182. uni.showToast({
  183. title:'没有更多数据了',
  184. icon:'none',
  185. duration:1000
  186. });
  187. }
  188. },
  189. toMessagePage() {
  190. // this.messageType = false;
  191. uni.navigateTo({
  192. url: `/pages/messages/messages`,
  193. });
  194. },
  195. init(isInitWs) {
  196. this.isInitWs = isInitWs;
  197. this.getSituationList();
  198. },
  199. initWebsocket(hiId, user, permission) {
  200. websocket.url = `ws://192.168.1.45:8088/imed/pfm/websocket/${hiId}/${user}/${permission}`;
  201. websocket.createWebSocket(this.resolverWsData.bind(this));
  202. },
  203. // 解析websocket返回数据
  204. resolverWsData(type) {
  205. let types = JSON.parse(type);
  206. switch (types.type) {
  207. case "TO_READ":
  208. this.messageType = true;
  209. break;
  210. default:
  211. this.messageType = false;
  212. break;
  213. }
  214. },
  215. getSituationList(){
  216. this.$store.dispatch({
  217. type: 'situationsCenter/commActions',
  218. payload: {
  219. key: 'situationList',
  220. data:{
  221. pageNum:1,
  222. pageSize:10
  223. }
  224. }
  225. }).then((data) => {
  226. if (data) {
  227. this.totalCount=data.totalCount;
  228. this.situationList=data.list.map((item,index)=>{
  229. return{
  230. name:item.name,
  231. checkStatus:item.checkStatus,
  232. nextCheckTime:item.nextCheckTime,
  233. checkGroupName:item.checkGroupName,
  234. topic:item.topic==0?true:false,
  235. situationID:item.id,
  236. }
  237. });
  238. let hiId = uni.getStorageSync("hiId");
  239. let user = uni.getStorageSync("id");
  240. let permission = uni.getStorageSync("nowPermission");
  241. this.isInitWs && this.initWebsocket(hiId, user, permission);
  242. }
  243. });
  244. },
  245. messStatus(){
  246. let num = 1;
  247. let timer = setInterval(()=>{
  248. this.$store.dispatch({
  249. type: "calendar/commActions",
  250. payload: {
  251. key: "messagesList",
  252. data: {
  253. pageNum: num,
  254. pageSize: 100,
  255. },
  256. },
  257. }).then((res)=>{
  258. if(res && res.list.length == 0){
  259. clearInterval(timer)
  260. }else if(res && res.list.length != 0){
  261. res.list.map((item)=>{
  262. if(!item.readStatus){
  263. this.messageType = true;
  264. return;
  265. }
  266. })
  267. }
  268. })
  269. num++;
  270. },200)
  271. }
  272. }
  273. }
  274. </script>
  275. <style lang="less">
  276. .situationsCenter-page{
  277. height: 100%;
  278. .calender-remind {
  279. width: 62.5rpx;
  280. height: 62.5rpx;
  281. position: fixed;
  282. right: 25rpx;
  283. background: rgba(255, 255, 255, 0.95);
  284. border-radius: 50%;
  285. z-index: 2;
  286. image {
  287. margin-left: 17.5rpx;
  288. margin-top: 16.87rpx;
  289. width: 27.5rpx;
  290. height: 28.75rpx;
  291. }
  292. }
  293. .situation-list{
  294. // display: flex;
  295. // flex-flow: row wrap;
  296. // margin-top: 12.5rpx;
  297. position: relative;
  298. .search-box{
  299. position: absolute;
  300. left: 25rpx;
  301. top: 0rpx;
  302. z-index: 2;
  303. .search-model{
  304. height: 62.5rpx;
  305. width: 62.5rpx;
  306. background-color: #FFFFFF;
  307. text-align: center;
  308. border-radius: 50%;
  309. box-shadow: 0px 10px 10px 0px rgba(217, 221, 228, 0.5);
  310. border: 1px solid #E6EAF2;
  311. opacity: 0.85;
  312. .search-pic{
  313. width: 27.5rpx;
  314. height: 27.5rpx;
  315. margin-top: 17.5rpx;
  316. }
  317. }
  318. .search-bar{
  319. background-color: #FFFFFF;
  320. width: 700rpx;
  321. height: 62.5rpx;
  322. top: 31.25rpx;
  323. position: absolute;
  324. z-index: 2;
  325. .search-item{
  326. background-color: #FFFFFF;
  327. width: 593.75rpx;
  328. height: 62.5rpx;
  329. float: left;
  330. border-radius: 6.25rpx;
  331. border: 1.25rpx solid #F0F2F7;
  332. .search-pic{
  333. width: 21.87rpx;
  334. height: 21.87rpx;
  335. margin-left:12.5rpx ;
  336. margin-top: 20.62rpx;
  337. float: left;
  338. }
  339. .searh-input{
  340. background-color: #FFFFFF;
  341. width: 525rpx;
  342. height: 55rpx;
  343. font-size: 22.5rpx;
  344. float: right;
  345. margin-top: 3.75rpx;
  346. margin-left: 3.12rpx;
  347. }
  348. .text-clear{
  349. width: 21.87rpx;
  350. height: 21.87rpx;
  351. float: right;
  352. margin-top: 20.62rpx;
  353. margin-right: 6.25rpx;
  354. }
  355. }
  356. .cancel-text{
  357. font-size: 22.5rpx;
  358. line-height: 62.5rpx;
  359. color: #A1A7B3;
  360. margin-right: 31.25rpx;
  361. float: right;
  362. }
  363. }
  364. }
  365. .scroll-box{
  366. height: 1072.5rpx;
  367. width: 750rpx;
  368. // margin-top: 25rpx;
  369. .content{
  370. display: flex;
  371. flex-flow: row wrap;
  372. .situation{
  373. height: 187.5rpx;
  374. width: 337.5rpx;
  375. background: #FFFFFF;
  376. box-shadow: 0px 6px 20px 0px rgba(0, 13, 51, 0.1);
  377. border-radius: 8px;
  378. margin-left: 25rpx;
  379. margin-top: 25rpx;
  380. .situation-topic{
  381. width: 62.5rpx;
  382. height: 25rpx;
  383. float: right;
  384. }
  385. .title{
  386. height: 22.5rpx;
  387. margin-left: 20rpx;
  388. margin-top: 25rpx;
  389. display: flex;
  390. align-items: center;
  391. .title-name{
  392. font-size: 22.5rpx;
  393. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  394. font-weight: bold;
  395. color: #292C33;
  396. }
  397. }
  398. .check-group{
  399. margin-left: 20rpx;
  400. margin-top: 15rpx;
  401. margin-bottom: 25rpx;
  402. height: 17.5rpx;
  403. display: flex;
  404. align-items: center;
  405. .group-text{
  406. font-size: 17.5rpx;
  407. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  408. font-weight: 400;
  409. color: #666E80;
  410. }
  411. }
  412. .row{
  413. margin-left: 20rpx;
  414. margin-bottom: 17.5rpx;
  415. display: flex;
  416. align-items: center;
  417. height: 20rpx;
  418. .situation-check{
  419. width: 20rpx;
  420. height: 20rpx;
  421. }
  422. .situation-time{
  423. width: 20rpx;
  424. height: 20rpx;
  425. }
  426. .text{
  427. font-size: 20rpx;
  428. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  429. font-weight: 400;
  430. color: #292C33;
  431. margin-left: 11.25rpx;
  432. }
  433. }
  434. }
  435. }
  436. }
  437. }
  438. .situaions-add{
  439. position: absolute;
  440. right: 25rpx;
  441. bottom: 130rpx;
  442. .add-pic{
  443. width: 75rpx;
  444. height: 75rpx;
  445. }
  446. }
  447. }
  448. </style>