situationsCenter.vue 13 KB

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