situationsCenter.vue 10 KB

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