situationsCenter.vue 13 KB

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