situationsCenter.vue 13 KB

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