situationsCenter.vue 13 KB

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