situationsCenter.vue 13 KB

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