situationsCenter.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483
  1. <template>
  2. <view class="situationsCenter-page">
  3. <!-- <app-update url="123" ref="appUpdate" ></app-update> -->
  4. <view class="calender-remind" @click="toMessagePage">
  5. <image
  6. :src="`/static/message-${messageType ? 'unread' : 'read'}.png`"
  7. ></image>
  8. </view>
  9. <view class="situation-list">
  10. <view class="search-box">
  11. <view
  12. class="search-model"
  13. @click="openSearchBar"
  14. v-show="isSearchBoxShow"
  15. >
  16. <image class="search-pic" src="/static/search.png"></image>
  17. </view>
  18. <view class="search-bar" v-show="isSearchBarShow">
  19. <view class="search-item">
  20. <image class="search-pic" src="/static/search.png"></image>
  21. <image
  22. class="text-clear"
  23. @click="valueEmpty"
  24. src="/static/text-clear.png"
  25. ></image>
  26. <input
  27. class="searh-input"
  28. v-model="inputValue"
  29. @confirm="searchByKeywords($event)"
  30. placeholder="搜索项目"
  31. placeholder-style="font-weight: 400,color: #A1A7B3"
  32. />
  33. </view>
  34. <text class="cancel-text" @click="closeSearchBar">取消</text>
  35. </view>
  36. </view>
  37. <scroll-view
  38. class="scroll-box"
  39. scroll-y="true"
  40. @scrolltolower="toLower"
  41. lower-threshold="184"
  42. >
  43. <view class="content" :style="{height: situationList.length === 0 ? '100%' : 'auto'}">
  44. <view
  45. class="situation"
  46. v-for="(item, index) in situationList"
  47. :key="item.id"
  48. @click="gotoDetail(item.situationID)"
  49. >
  50. <image
  51. class="situation-topic"
  52. :src="`/static/${
  53. item.topic ? 'situation-case' : 'situation-system'
  54. }.png`"
  55. ></image>
  56. <view class="title">
  57. <text class="title-name">{{ item.name }}</text>
  58. </view>
  59. <view class="check-group">
  60. <text class="group-text">
  61. {{
  62. nowPermission == 2
  63. ? "剩余" + (item.toDistributeCount || 0) + "个待分配"
  64. : item.checkGroupName
  65. }}</text
  66. >
  67. </view>
  68. <view class="row">
  69. <image
  70. class="situation-check"
  71. src="/static/situation-check.png"
  72. ></image>
  73. <text class="text">{{ item.checkStatus }}</text>
  74. </view>
  75. <view class="row">
  76. <image
  77. class="situation-time"
  78. src="/static/situation-time.png"
  79. ></image>
  80. <text class="text">{{ item.nextCheckTime }}</text>
  81. </view>
  82. </view>
  83. <tm-no-data v-if="situationList.length === 0"
  84. :textArr="['还没有情境', '快点击右下方按钮新建一个吧']" />
  85. </view>
  86. </scroll-view>
  87. </view>
  88. <view v-if="nowPermission == 1" class="situaions-add" @click="gotoCreate">
  89. <image class="add-pic" src="/static/situation-add.png"></image>
  90. </view>
  91. <tm-tabbar :permission="nowPermission" />
  92. </view>
  93. </template>
  94. /**
  95. * 情境中心
  96. */
  97. <script>
  98. import websocket from "../../utils/ws.js"; //引入websocket
  99. import {wsURL} from "../../utils/requestUrl.js";
  100. // import appUpdate from "@/components/app-update/app-update.vue"
  101. export default {
  102. data() {
  103. return {
  104. page: 1, //页数
  105. inputValue: "",
  106. nowPermission: "",
  107. isSearchBarShow: false, //搜索栏是否可见
  108. isSearchBoxShow: true, //搜索图标是否可见
  109. situationList: [], //情境卡片列表
  110. totalCount: "", //返回数据的总条数
  111. refTimer: null,
  112. isInitWs: null,
  113. messageType: null,
  114. num: 1,
  115. // showUpdatePop:false,
  116. timer: null,
  117. // ws接口参数
  118. initParams: {}
  119. };
  120. },
  121. // components:{appUpdate},
  122. created: function () {
  123. this.nowPermission = uni.getStorageSync("nowPermission");
  124. this.init(true);
  125. this.refTimer = setInterval(() => {
  126. this.isInitWs = websocket.ws ? false : true;
  127. const {hiId, user, permission} = this.initParams;
  128. this.isInitWs && this.initWebsocket(hiId, user, permission);
  129. }, 3 * 60 * 1000);
  130. // this.messStatus();
  131. },
  132. beforeDestroy() {
  133. // 关闭ws连接
  134. websocket.close();
  135. clearInterval(this.refTimer);
  136. clearTimeout(this.timer);
  137. },
  138. mounted() {
  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: 15,
  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: 15,
  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 = wsURL(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: 15,
  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>