situationsCenter.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426
  1. <template>
  2. <view class="situationsCenter-page">
  3. <view class="calender-remind" @click="toMessagePage">
  4. <image :src="`/static/message-${messageType? 'unread':'read'}.png`"></image>
  5. </view>
  6. <view class="situation-list">
  7. <view class="search-box">
  8. <view class="search-model" @click="openSearchBar" v-show="isSearchBoxShow">
  9. <image class="search-pic" src="/static/search.png"></image>
  10. </view>
  11. <view class="search-bar" v-show="isSearchBarShow">
  12. <view class="search-item">
  13. <image class="search-pic" src="/static/search.png"></image>
  14. <image class="text-clear" @click="valueEmpty" src="/static/text-clear.png"></image>
  15. <input class="searh-input" v-model="inputValue" @confirm="searchByKeywords($event)" placeholder="搜索项目" placeholder-style="font-weight: 400,color: #A1A7B3" />
  16. </view>
  17. <text class="cancel-text" @click="closeSearchBar">取消</text>
  18. </view>
  19. </view>
  20. <scroll-view class="scroll-box" scroll-y="true" @scrolltolower="toLower" lower-threshold="184">
  21. <view class="content">
  22. <view class="situation" v-for="(item,index) in situationList" :key="item.id" @click="gotoDetail(item.situationID)">
  23. <image class="situation-topic" :src="`/static/${item.topic ? 'situation-case' : 'situation-system'}.png`"></image>
  24. <view class="title">
  25. <text class="title-name">{{item.name}}</text>
  26. </view>
  27. <view class="check-group">
  28. <text class="group-text">
  29. {{nowPermission==2?'剩余'+item.toDistributeCount+'个待分配':item.checkGroupName}}</text>
  30. </view>
  31. <view class="row">
  32. <image class="situation-check" src="/static/situation-check.png"></image>
  33. <text class="text">{{item.checkStatus}}</text>
  34. </view>
  35. <view class="row">
  36. <image class="situation-time" src="/static/situation-time.png"></image>
  37. <text class="text">{{item.nextCheckTime}}</text>
  38. </view>
  39. </view>
  40. </view>
  41. </scroll-view>
  42. </view>
  43. <view v-if="nowPermission == 1" class="situaions-add" @click="gotoCreate">
  44. <image class="add-pic" src="/static/situation-add.png"></image>
  45. </view>
  46. <tm-tabbar :permission="nowPermission" />
  47. </view>
  48. </template>
  49. /**
  50. * 情境中心
  51. */
  52. <script>
  53. import websocket from "../../utils/ws.js"; //引入websocket
  54. export default {
  55. data() {
  56. return {
  57. page:1,//页数
  58. inputValue:'',
  59. nowPermission:'',
  60. isSearchBarShow:false,//搜索栏是否可见
  61. isSearchBoxShow:true,//搜索图标是否可见
  62. situationList:[],//情境卡片列表
  63. totalCount:'',//返回数据的总条数
  64. refTimer: null,
  65. isInitWs: null,
  66. messageType: null,
  67. }
  68. },
  69. created: function() {
  70. this.nowPermission=uni.getStorageSync('nowPermission');
  71. this.init(true);
  72. this.refTimer = setInterval(() => {
  73. this.isInitWs = websocket.ws ? false : true;
  74. this.init(this.isInitWs);
  75. }, 3 * 60 * 1000);
  76. // this.messStatus();
  77. },
  78. beforeDestroy() {
  79. // 关闭ws连接
  80. websocket.close();
  81. clearInterval(this.refTimer);
  82. },
  83. // watch:{
  84. // "$route":{
  85. // handler(route){
  86. // this.messStatus();
  87. // }
  88. // }
  89. // },
  90. methods: {
  91. openSearchBar(){
  92. this.isSearchBarShow=true;
  93. this.isSearchBoxShow=false;
  94. },
  95. closeSearchBar(){
  96. this.isSearchBarShow=false;
  97. this.isSearchBoxShow=true;
  98. },
  99. valueEmpty(){
  100. this.inputValue='';
  101. },
  102. gotoCreate(){
  103. uni.navigateTo({
  104. url: '/pages/creatingSituations/creatingSituations'
  105. });
  106. },
  107. gotoDetail(id){
  108. uni.navigateTo({
  109. url: `/pages/situationDetail/situationDetail?situationId=${id}`
  110. });
  111. },
  112. getSituationList(data, callback) {
  113. this.$store.dispatch({
  114. type: 'situationsCenter/commActions',
  115. payload: {
  116. data,
  117. key: 'situationList'
  118. }
  119. }).then((data)=> {
  120. if(data) callback(data);
  121. });
  122. },
  123. searchByKeywords(event){
  124. let data = {
  125. pageNum:1,
  126. pageSize:10,
  127. keyword:event.target.value,
  128. };
  129. this.getSituationList(data,(data)=>{
  130. this.situationList = [];
  131. this.createSituationList(data.list);
  132. });
  133. },
  134. createSituationList(list=[]) {
  135. list.map((item,index)=>{
  136. this.situationList.push({
  137. name:item.name,
  138. checkStatus:item.checkStatus,
  139. nextCheckTime:item.nextCheckTime,
  140. checkGroupName:item.checkGroupName,
  141. topic:item.topic==0?true:false,
  142. situationID:item.id,
  143. toDistributeCount:item.toDistributeCount,
  144. });
  145. });
  146. },
  147. toLower(){
  148. uni.showToast({
  149. title:'加载中....',
  150. icon:'loading',
  151. duration:2000
  152. });
  153. let count=this.situationList.length;
  154. if(this.totalCount!=count){
  155. this.page++;
  156. let data = {
  157. pageNum:this.page,
  158. pageSize:10
  159. };
  160. this.getSituationList(data,(data)=>{
  161. this.createSituationList(data.list);
  162. let hiId = uni.getStorageSync("hiId");
  163. let user = uni.getStorageSync("id");
  164. let permission = uni.getStorageSync("nowPermission");
  165. this.isInitWs && this.initWebsocket(hiId, user, permission);
  166. });
  167. } else {
  168. uni.showToast({
  169. title:'没有更多数据了',
  170. icon:'none',
  171. duration:1000
  172. });
  173. }
  174. },
  175. toMessagePage() {
  176. // this.messageType = false;
  177. uni.navigateTo({
  178. url: `/pages/messages/messages`,
  179. });
  180. },
  181. init(isInitWs) {
  182. this.isInitWs = isInitWs;
  183. this.initSituationList();
  184. },
  185. initWebsocket(hiId, user, permission) {
  186. websocket.url = `ws://192.168.1.45:8088/imed/pfm/websocket/${hiId}/${user}/${permission}`;
  187. websocket.createWebSocket(this.resolverWsData.bind(this));
  188. },
  189. // 解析websocket返回数据
  190. resolverWsData(type) {
  191. let types = JSON.parse(type);
  192. switch (types.type) {
  193. case "TO_READ":
  194. this.messageType = true;
  195. break;
  196. default:
  197. this.messageType = false;
  198. break;
  199. }
  200. },
  201. initSituationList(){
  202. let data = {
  203. pageNum:1,
  204. pageSize:10
  205. };
  206. this.getSituationList(data, (data)=>{
  207. this.totalCount=data.totalCount;
  208. this.createSituationList(data.list);
  209. let hiId = uni.getStorageSync("hiId");
  210. let user = uni.getStorageSync("id");
  211. let permission = uni.getStorageSync("nowPermission");
  212. this.isInitWs && this.initWebsocket(hiId, user, permission);
  213. });
  214. },
  215. // messStatus(){
  216. // let num = 1;
  217. // let timer = setInterval(()=>{
  218. // this.$store.dispatch({
  219. // type: "calendar/commActions",
  220. // payload: {
  221. // key: "messagesList",
  222. // data: {
  223. // pageNum: num,
  224. // pageSize: 100,
  225. // },
  226. // },
  227. // }).then((res)=>{
  228. // if(res && res.list.length == 0){
  229. // clearInterval(timer)
  230. // }else if(res && res.list.length != 0){
  231. // res.list.map((item)=>{
  232. // if(!item.readStatus){
  233. // this.messageType = true;
  234. // return;
  235. // }
  236. // })
  237. // }
  238. // })
  239. // num++;
  240. // },200)
  241. // }
  242. }
  243. }
  244. </script>
  245. <style lang="less">
  246. .situationsCenter-page{
  247. height: 100%;
  248. .calender-remind {
  249. width: 62.5rpx;
  250. height: 62.5rpx;
  251. position: fixed;
  252. right: 25rpx;
  253. background: rgba(255, 255, 255, 0.95);
  254. border-radius: 50%;
  255. z-index: 2;
  256. image {
  257. margin-left: 17.5rpx;
  258. margin-top: 16.87rpx;
  259. width: 27.5rpx;
  260. height: 28.75rpx;
  261. }
  262. }
  263. .situation-list{
  264. position: relative;
  265. height: 100%;
  266. .search-box{
  267. position: fixed;
  268. left: 25rpx;
  269. top: 0rpx;
  270. z-index: 2;
  271. .search-model{
  272. height: 62.5rpx;
  273. width: 62.5rpx;
  274. background-color: #FFFFFF;
  275. text-align: center;
  276. border-radius: 50%;
  277. box-shadow: 0px 10px 10px 0px rgba(217, 221, 228, 0.5);
  278. border: 1px solid #E6EAF2;
  279. opacity: 0.85;
  280. .search-pic{
  281. width: 27.5rpx;
  282. height: 27.5rpx;
  283. margin-top: 17.5rpx;
  284. }
  285. }
  286. .search-bar{
  287. background-color: #FFFFFF;
  288. width: 700rpx;
  289. height: 62.5rpx;
  290. top: 31.25rpx;
  291. position: absolute;
  292. z-index: 2;
  293. .search-item{
  294. background-color: #FFFFFF;
  295. width: 593.75rpx;
  296. height: 62.5rpx;
  297. float: left;
  298. border-radius: 6.25rpx;
  299. border: 1.25rpx solid #F0F2F7;
  300. .search-pic{
  301. width: 21.87rpx;
  302. height: 21.87rpx;
  303. margin-left:12.5rpx ;
  304. margin-top: 20.62rpx;
  305. float: left;
  306. }
  307. .searh-input{
  308. background-color: #FFFFFF;
  309. width: 525rpx;
  310. height: 55rpx;
  311. font-size: 22.5rpx;
  312. float: right;
  313. margin-top: 3.75rpx;
  314. margin-left: 3.12rpx;
  315. }
  316. .text-clear{
  317. width: 21.87rpx;
  318. height: 21.87rpx;
  319. float: right;
  320. margin-top: 20.62rpx;
  321. margin-right: 6.25rpx;
  322. }
  323. }
  324. .cancel-text{
  325. font-size: 22.5rpx;
  326. line-height: 62.5rpx;
  327. color: #A1A7B3;
  328. margin-right: 31.25rpx;
  329. float: right;
  330. }
  331. }
  332. }
  333. .scroll-box{
  334. width: 100%;
  335. height: calc(100% - 87.5rpx);
  336. .content{
  337. display: flex;
  338. flex-flow: row wrap;
  339. padding-bottom: 25rpx;
  340. .situation{
  341. height: 187.5rpx;
  342. width: 337.5rpx;
  343. background: #FFFFFF;
  344. box-shadow: 0px 6px 20px 0px rgba(0, 13, 51, 0.1);
  345. border-radius: 8px;
  346. margin-left: 25rpx;
  347. margin-top: 25rpx;
  348. .situation-topic{
  349. width: 62.5rpx;
  350. height: 25rpx;
  351. float: right;
  352. }
  353. .title{
  354. height: 22.5rpx;
  355. margin-left: 20rpx;
  356. margin-top: 25rpx;
  357. display: flex;
  358. align-items: center;
  359. .title-name{
  360. font-size: 22.5rpx;
  361. font-family: SourceHanSansCN-Bold, SourceHanSansCN;
  362. font-weight: bold;
  363. color: #292C33;
  364. }
  365. }
  366. .check-group{
  367. margin-left: 20rpx;
  368. margin-top: 15rpx;
  369. margin-bottom: 25rpx;
  370. height: 17.5rpx;
  371. display: flex;
  372. align-items: center;
  373. .group-text{
  374. font-size: 17.5rpx;
  375. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  376. font-weight: 400;
  377. color: #666E80;
  378. }
  379. }
  380. .row{
  381. margin-left: 20rpx;
  382. margin-bottom: 17.5rpx;
  383. display: flex;
  384. align-items: center;
  385. height: 20rpx;
  386. .situation-check{
  387. width: 20rpx;
  388. height: 20rpx;
  389. }
  390. .situation-time{
  391. width: 20rpx;
  392. height: 20rpx;
  393. }
  394. .text{
  395. font-size: 20rpx;
  396. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  397. font-weight: 400;
  398. color: #292C33;
  399. margin-left: 11.25rpx;
  400. }
  401. }
  402. }
  403. }
  404. }
  405. }
  406. .situaions-add{
  407. position: fixed;
  408. right: 25rpx;
  409. bottom: 130rpx;
  410. .add-pic{
  411. width: 75rpx;
  412. height: 75rpx;
  413. }
  414. }
  415. }
  416. </style>