situationsCenter.vue 10 KB

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