situationsCenter.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500
  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="5"
  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: 300,
  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. console.log('toLower');
  208. uni.showToast({
  209. title: "加载中....",
  210. icon: "loading",
  211. duration: 2000,
  212. });
  213. let count = this.situationList.length;
  214. console.log(this.totalCount,count);
  215. if (this.totalCount != count) {
  216. this.page++;
  217. let data = {
  218. pageNum: this.page,
  219. pageSize: 300,
  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: 300,
  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. top:20rpx;
  324. right: 25rpx;
  325. background: rgba(255, 255, 255, 0.95);
  326. border-radius: 50%;
  327. z-index: 2;
  328. image {
  329. margin-left: 17.5rpx;
  330. margin-top: 16.87rpx;
  331. width: 27.5rpx;
  332. height: 28.75rpx;
  333. }
  334. }
  335. .search-box {
  336. position: fixed;
  337. top:20rpx;
  338. left: 25rpx;
  339. z-index: 2;
  340. .search-model {
  341. height: 62.5rpx;
  342. width: 62.5rpx;
  343. background-color: #ffffff;
  344. text-align: center;
  345. border-radius: 50%;
  346. box-shadow: 0px 10px 10px 0px rgba(217, 221, 228, 0.5);
  347. border: 1px solid #e6eaf2;
  348. opacity: 0.85;
  349. .search-pic {
  350. width: 27.5rpx;
  351. height: 27.5rpx;
  352. margin-top: 17.5rpx;
  353. }
  354. }
  355. .search-bar {
  356. background-color: #ffffff;
  357. width: 700rpx;
  358. height: 62.5rpx;
  359. top:0rpx;
  360. position: absolute;
  361. z-index: 2;
  362. .search-item {
  363. background-color: #ffffff;
  364. width: 593.75rpx;
  365. height: 62.5rpx;
  366. float: left;
  367. border-radius: 6.25rpx;
  368. border-right: 1.25rpx solid #f0f2f7;;
  369. .search-pic {
  370. width: 21.87rpx;
  371. height: 21.87rpx;
  372. margin-left: 12.5rpx;
  373. margin-top: 20.62rpx;
  374. float: left;
  375. }
  376. .searh-input {
  377. background-color: #ffffff;
  378. width: 525rpx;
  379. height: 55rpx;
  380. font-size: 22.5rpx;
  381. float: right;
  382. margin-top: 3.75rpx;
  383. margin-left: 3.12rpx;
  384. }
  385. .text-clear {
  386. width: 21.87rpx;
  387. height: 21.87rpx;
  388. float: right;
  389. margin-top: 20.62rpx;
  390. margin-right: 6.25rpx;
  391. }
  392. }
  393. .cancel-text {
  394. font-size: 22.5rpx;
  395. line-height: 62.5rpx;
  396. color: #a1a7b3;
  397. margin-right: 31.25rpx;
  398. float: right;
  399. }
  400. }
  401. }
  402. .situation-list {
  403. position: relative;
  404. height: 100%;
  405. .scroll-box {
  406. width: 100%;
  407. height: calc(100% - 87.5rpx);
  408. .content {
  409. display: flex;
  410. flex-flow: row wrap;
  411. padding-bottom: 100rpx;
  412. .situation {
  413. height: 187.5rpx;
  414. width: 337.5rpx;
  415. background: #ffffff;
  416. box-shadow: 0px 6px 20px 0px rgba(0, 13, 51, 0.1);
  417. border-radius: 8px;
  418. margin-left: 25rpx;
  419. margin-top: 25rpx;
  420. .situation-topic {
  421. width: 62.5rpx;
  422. height: 25rpx;
  423. float: right;
  424. }
  425. .title {
  426. height: 22.5rpx;
  427. margin-left: 20rpx;
  428. margin-top: 25rpx;
  429. display: flex;
  430. align-items: center;
  431. .title-name {
  432. width: 300rpx;
  433. font-size: 22.5rpx;
  434. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  435. font-weight: bold;
  436. color: #292c33;
  437. overflow:hidden; //超出的文本隐藏
  438. text-overflow:ellipsis; //溢出用省略号显示
  439. white-space:nowrap; //溢出不换行
  440. }
  441. }
  442. .check-group {
  443. margin-left: 20rpx;
  444. margin-top: 15rpx;
  445. margin-bottom: 25rpx;
  446. height: 17.5rpx;
  447. display: flex;
  448. align-items: center;
  449. .group-text {
  450. font-size: 17.5rpx;
  451. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  452. font-weight: 400;
  453. color: #666e80;
  454. }
  455. }
  456. .row {
  457. margin-left: 20rpx;
  458. margin-bottom: 17.5rpx;
  459. display: flex;
  460. align-items: center;
  461. height: 20rpx;
  462. .situation-check {
  463. width: 20rpx;
  464. height: 20rpx;
  465. }
  466. .situation-time {
  467. width: 20rpx;
  468. height: 20rpx;
  469. }
  470. .text {
  471. font-size: 20rpx;
  472. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  473. font-weight: 400;
  474. color: #292c33;
  475. margin-left: 11.25rpx;
  476. }
  477. }
  478. }
  479. }
  480. }
  481. }
  482. .situaions-add {
  483. position: fixed;
  484. right: 25rpx;
  485. bottom: 130rpx;
  486. .add-pic {
  487. width: 75rpx;
  488. height: 75rpx;
  489. }
  490. }
  491. }
  492. </style>