situationsCenter.vue 12 KB

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