situationsCenter.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730
  1. <template>
  2. <view class="situationsCenter-page">
  3. <tmNavbar @onsearchChange="onsearchChangehandle" :is-back="false" @checkMessage="checkMessageHandle"
  4. :titleMod="nowPermission == 6||nowPermission == 4||nowPermission ==7||nowPermission == 8?'Filter':'Normal'"
  5. :filterKeys="filterKeys" :isShowFilter="true" :messageStatus="true" :isShowSearch="true"
  6. @filterClick="filterClickHandle" :title="pageTitle" title-color="#292C33"></tmNavbar>
  7. <view class="situation-list">
  8. <scroll-view class="scroll-box" scroll-y="true" @scrolltolower="toLower" lower-threshold="5">
  9. <view class="content" :style="[situationList.length === 0 ?{height:'100%'}:{}]">
  10. <view class="situation" v-for="(item) in situationList" :key="item.id"
  11. @click="gotoDetail(item.situationID?item.situationID:item.id,item.systemSituationType,item)">
  12. <!-- 左上角类型角标图片(系统/个案/自查督查) -->
  13. <image class="type-badge" :src="typeBadgeSrc(item.systemSituationType)" />
  14. <!-- 右上角组徽标(图标 + 组名) -->
  15. <view class="group-badge">
  16. <image class="group-icon" src="/static/images/zu_text.png" />
  17. <text class="group-text">{{ item.checkGroupName }}</text>
  18. </view>
  19. <view class="title">
  20. <text class="title-name">{{ item.name }}</text>
  21. <!-- 状态角标:在标题行右侧,且仅自查督查时显示 -->
  22. <view v-if="item.systemSituationType == 2 && nowPermission != 1" :class="['status-badge', statusClass(item)]">{{ situationStatusName(item) }}</view>
  23. </view>
  24. <view class="check-group">
  25. <text class="group-text-a">{{ planText(item) }}</text>
  26. <image class="improve-btn" src="/static/images/quwanshan_btn.png" @click.stop="gotoImprove(item)" />
  27. </view>
  28. </view>
  29. <tm-no-data v-if="situationList.length === 0" :textArr="['还没有情境', '快点击右下方按钮新建一个吧']" />
  30. </view>
  31. </scroll-view>
  32. </view>
  33. <view v-if="nowPermission == 1" class="situaions-add" @click="gotoCreate">
  34. <image class="add-pic" src="/static/situation-add.png"></image>
  35. </view>
  36. <tm-tabbar :permission="nowPermission" />
  37. </view>
  38. </template>
  39. /**
  40. * 情境中心
  41. */
  42. <script>
  43. import websocket from "../../utils/ws.js"; //引入websocket
  44. import tmNavbar from "@/components/tm-navbar/tm-navbar.vue";
  45. import {
  46. wsURL
  47. } from "../../utils/requestUrl.js";
  48. // import appUpdate from "@/components/app-update/app-update.vue"
  49. export default {
  50. components: {
  51. tmNavbar
  52. },
  53. data() {
  54. return {
  55. page: 1, //页数
  56. inputValue: "",
  57. nowPermission: "",
  58. isSearchBarShow: false, //搜索栏是否可见
  59. isSearchBoxShow: true, //搜索图标是否可见
  60. situationList: [], //情境卡片列表
  61. copied_situationList: [], //复制情境卡片列表 用于筛选
  62. totalCount: "", //返回数据的总条数
  63. refTimer: null,
  64. isInitWs: null,
  65. messageType: null,
  66. num: 1,
  67. pageTitle: '情境中心',
  68. // showUpdatePop:false,
  69. timer: null,
  70. // ws接口参数
  71. initParams: {},
  72. };
  73. },
  74. // components:{appUpdate},
  75. created: function() {
  76. this.nowPermission = uni.getStorageSync("nowPermission");
  77. this.init(true);
  78. this.refTimer = setInterval(() => {
  79. this.isInitWs = websocket.ws ? false : true;
  80. const {
  81. hiId,
  82. user,
  83. permission
  84. } = this.initParams;
  85. this.isInitWs && this.initWebsocket(hiId, user, permission);
  86. }, 3 * 60 * 1000);
  87. // this.messStatus();
  88. },
  89. beforeDestroy() {
  90. // 关闭ws连接
  91. websocket.close();
  92. clearInterval(this.refTimer);
  93. clearTimeout(this.timer);
  94. },
  95. computed: {
  96. statusBarHeight() {
  97. const {
  98. statusBarHeight
  99. } = uni.getSystemInfoSync();
  100. return statusBarHeight;
  101. },
  102. filterKeys() {
  103. const list = [{
  104. text: '全部',
  105. checked: true,
  106. key: '0'
  107. },
  108. {
  109. text: '已完成',
  110. checked: false,
  111. key: '6'
  112. },
  113. {
  114. text: '进行中',
  115. checked: false,
  116. key: '2'
  117. },
  118. {
  119. text: '待分配',
  120. checked: false,
  121. key: '4'
  122. }
  123. ];
  124. return list;
  125. // const modify = (key) => {
  126. // const _list = list.map(a => {
  127. // if (a.key == key) {
  128. // return {
  129. // ...a,
  130. // checked: true
  131. // }
  132. // } else {
  133. // return {
  134. // ...a,
  135. // checked: false
  136. // }
  137. // }
  138. // });
  139. // return _list;
  140. // }
  141. // if (this.nowPermission == 6) {
  142. // //职能科室负责人
  143. // return modify(1);
  144. // }
  145. // if (this.nowPermission == 6) {
  146. // //职能科室负责人
  147. // return modify(4);
  148. // }
  149. }
  150. },
  151. mounted() {
  152. },
  153. methods: {
  154. // 是否需要展示“去完善”按钮:当查核计划或下次查核缺失时
  155. needImprove(item) {
  156. // 分配权限卡片不展示“去完善”
  157. if (this.nowPermission == 2) return false;
  158. // 计划值:自查督查用 checkPlanCount/checkStatus,其他用 checkStatus
  159. const hasPlan = (item.systemSituationType == 2)
  160. ? (typeof item.checkPlanCount === 'number' ? item.checkPlanCount > 0 : !!item.checkStatus)
  161. : !!item.checkStatus;
  162. const hasNext = !!item.nextCheckTime;
  163. return !(hasPlan && hasNext);
  164. },
  165. planText(item) {
  166. // 统一生成“查核计划 | 下次查核”的展示文案:
  167. // 仅对“查核计划”的值进行“到次为止”的截取,“下次查核”保留展示
  168. const clipToCi = (text) => {
  169. // 截取到包含“次”的位置(含“次”),若没有“次”则原样返回
  170. try {
  171. const str = String(text || '');
  172. const idx = str.indexOf('次');
  173. return idx >= 0 ? str.slice(0, idx + 1) : str;
  174. } catch (e) { return text; }
  175. }
  176. // 1)分配权限优先显示“剩余待分配”
  177. if (this.nowPermission == 2) {
  178. return `剩余${item.toDistributeCount || 0}个待分配`;
  179. }
  180. // 2)自查督查类型展示“第N/次”,并展示“下次查核”
  181. if (item.systemSituationType == 2) {
  182. const times = (typeof item.checkPlanCount === 'number' ? item.checkPlanCount : parseInt(item.checkStatus, 10)) || 0;
  183. const planVal = `第${times}/次`;
  184. const next = item.nextCheckTime ? `下次查核:${item.nextCheckTime}` : '下次查核:--';
  185. return `查核计划:${clipToCi(planVal)} | ${next}`;
  186. }
  187. // 3)其他类型:截取“查核计划”到“次”,并展示“下次查核”
  188. const planRaw = item.checkStatus ? String(item.checkStatus) : '暂无计划';
  189. const next = item.nextCheckTime ? `下次查核:${item.nextCheckTime}` : '下次查核:--';
  190. return `查核计划:${clipToCi(planRaw)} | ${next}`;
  191. },
  192. typeBadgeSrc(type) {
  193. // 根据类型返回左上角角标图片路径
  194. if (type === 1) return '/static/images/xitongzhuizong.png';
  195. if (type === 0) return '/static/images/gean.png';
  196. if (type === 2) return '/static/images/zichaducha.png';
  197. return '/static/images/xitongzhuizong.png';
  198. },
  199. statusClass(item) {
  200. // 根据情境状态返回样式类名
  201. if (item.situationStatus == 2) return 'doing';
  202. if (item.situationStatus == 6) return 'complete';
  203. if (item.situationStatus == 4) return 'wait';
  204. if (item.situationStatus == 5) return 'complete';
  205. return '';
  206. },
  207. filterClickHandle(filterData) {
  208. if (filterData.key != 0) {
  209. const _situationList = this.copied_situationList.filter(item => item.situationStatus == Number(
  210. filterData.key));
  211. this.situationList = _situationList;
  212. }else{
  213. this.situationList = this.copied_situationList
  214. }
  215. },
  216. situationStatusName(item) {
  217. if (item.situationStatus == 2) {
  218. return '进行中'
  219. }
  220. if (item.situationStatus == 6) {
  221. return '全部完成'
  222. }
  223. if (item.situationStatus == 4) {
  224. return '待分配'
  225. }
  226. if (item.situationStatus == 5) {
  227. return '已完成'
  228. }
  229. return null
  230. },
  231. situationTypeName(item, type) {
  232. if (item.systemSituationType == 0) {
  233. return type == 1 ? '个案' : 'Mark case'
  234. }
  235. if (item.systemSituationType == 1) {
  236. return type == 1 ? '系统' : 'Mark system'
  237. }
  238. if (item.systemSituationType == 2) {
  239. return type == 1 ? '自查督查' : 'Mark zichaducha'
  240. }
  241. },
  242. getClass(item) {
  243. if (item.situationStatus == 2) {
  244. return 'topMark doing'
  245. }
  246. if (item.situationStatus == 6) {
  247. return 'topMark complete'
  248. }
  249. if (item.situationStatus == 4) {
  250. return 'topMark wait'
  251. }
  252. if (item.situationStatus == 5) {
  253. return 'topMark complete'
  254. }
  255. return 'topMark'
  256. },
  257. onsearchChangehandle(keywords) {
  258. this.searchByKeywords(keywords);
  259. },
  260. openSearchBar() {
  261. this.isSearchBarShow = true;
  262. this.isSearchBoxShow = false;
  263. },
  264. checkMessageHandle() {
  265. //查看消息
  266. uni.navigateTo({
  267. url: `/pages/messages/messages`,
  268. });
  269. },
  270. closeSearchBar() {
  271. this.isSearchBarShow = false;
  272. this.isSearchBoxShow = true;
  273. },
  274. valueEmpty() {
  275. this.inputValue = "";
  276. },
  277. gotoCreate() {
  278. uni.navigateTo({
  279. url: "/pages/creatingSituations/creatingSituations",
  280. });
  281. },
  282. gotoImprove(item) {
  283. // 去完善:进入创建页编辑模式,先回显数据,再从第一步重走
  284. const id = item.situationID ? item.situationID : item.id;
  285. const systemSituationType = item.systemSituationType;
  286. const name = item.name || '';
  287. let url = `/pages/creatingSituations/creatingSituations?id=${id}&type=PUT&from=improve`;
  288. if (systemSituationType == 2) {
  289. // 自查督查:仅走管理员路线(MULTI),不再附带 planSet
  290. url += `&systemSituationType=${systemSituationType}&themeName=${encodeURIComponent(name)}&situationId=${id}`;
  291. }
  292. uni.navigateTo({ url });
  293. },
  294. gotoDetail(id, systemSituationType, item) {
  295. console.log(this.situationList);
  296. console.log({id, systemSituationType, item});
  297. this.$store.commit({
  298. type: 'situationsCenter/comChangeState',
  299. key: 'currentSelectedSituation',
  300. data: item
  301. });
  302. uni.navigateTo({
  303. url: `/pages/situationDetail/situationDetail?situationId=${id}&systemSituationType=${systemSituationType}`,
  304. });
  305. },
  306. getSituationList(data, callback) {
  307. this.$store
  308. .dispatch({
  309. type: "situationsCenter/commActions",
  310. payload: {
  311. data,
  312. key: "situationList",
  313. },
  314. })
  315. .then((data) => {
  316. if (data) callback(data);
  317. });
  318. },
  319. searchByKeywords(keywords) {
  320. let data = {
  321. pageNum: 1,
  322. pageSize: 300,
  323. keyword: keywords,
  324. };
  325. this.getSituationList(data, (data) => {
  326. this.situationList = [];
  327. this.createSituationList(data.list);
  328. });
  329. },
  330. createSituationList(list = []) {
  331. list.map((item, index) => {
  332. this.situationList.push({
  333. name: item.name,
  334. checkStatus: item.checkStatus,
  335. nextCheckTime: item.nextCheckTime,
  336. systemSituationType: item.systemSituationType,
  337. //systemSituationType == 0 普通 1 自查督查
  338. checkGroupName: item.systemSituationType != 2 ? item.checkGroupName : (item
  339. .department.map(v => v.deptClassName)).join(','),
  340. topic: item.topic == 0 ? true : false,
  341. situationStatus: item.situationStatus,
  342. situationID: item.id,
  343. toDistributeCount: item.toDistributeCount,
  344. });
  345. });
  346. },
  347. toLower() {
  348. uni.showToast({
  349. title: "加载中....",
  350. icon: "loading",
  351. duration: 2000,
  352. });
  353. let count = this.situationList.length;
  354. if (this.totalCount != count) {
  355. this.page++;
  356. let data = {
  357. pageNum: this.page,
  358. pageSize: 300,
  359. };
  360. // this.getSituationList(data, (data) => {
  361. // this.createSituationList(data.list);
  362. // let hiId = uni.getStorageSync("hiId");
  363. // let user = uni.getStorageSync("id");
  364. // let permission = uni.getStorageSync("nowPermission");
  365. // this.initParams = {
  366. // hiId,
  367. // user,
  368. // permission
  369. // };
  370. // this.isInitWs && this.initWebsocket(hiId, user, permission);
  371. // });
  372. } else {
  373. uni.showToast({
  374. title: "没有更多数据了",
  375. icon: "none",
  376. duration: 1000,
  377. });
  378. }
  379. },
  380. // toMessagePage() {
  381. // // this.messageType = false;
  382. // uni.navigateTo({
  383. // url: `/pages/messages/messages`,
  384. // });
  385. // },
  386. init(isInitWs) {
  387. this.isInitWs = isInitWs;
  388. this.initSituationList();
  389. },
  390. initWebsocket(hiId, user, permission) {
  391. websocket.url = wsURL(hiId, user, permission);
  392. websocket.createWebSocket(this.resolverWsData.bind(this));
  393. },
  394. // 解析websocket返回数据
  395. resolverWsData(type) {
  396. let types = JSON.parse(type);
  397. switch (types.type) {
  398. case "TO_READ":
  399. this.messageType = true;
  400. break;
  401. default:
  402. this.messageType = false;
  403. break;
  404. }
  405. },
  406. initSituationList() {
  407. let data = {
  408. pageNum: 1,
  409. pageSize: 300,
  410. };
  411. this.getSituationList(data, (data) => {
  412. this.totalCount = data.totalCount;
  413. this.createSituationList(data.list);
  414. this.copied_situationList = data.list;
  415. let hiId = uni.getStorageSync("hiId");
  416. let user = uni.getStorageSync("id");
  417. let permission = uni.getStorageSync("nowPermission");
  418. this.initParams = {
  419. hiId,
  420. user,
  421. permission
  422. };
  423. this.isInitWs && this.initWebsocket(hiId, user, permission);
  424. });
  425. },
  426. // messStatus(){
  427. // let num = 1;
  428. // let timer = setInterval(()=>{
  429. // this.$store.dispatch({
  430. // type: "calendar/commActions",
  431. // payload: {
  432. // key: "messagesList",
  433. // },
  434. // }).then((res)=>{
  435. // if(res && res.list.length == 0){
  436. // clearInterval(timer)
  437. // }else if(res && res.list.length != 0){
  438. // res.list.map((item)=>{
  439. // if(!item.readStatus){
  440. // this.messageType = true;
  441. // return;
  442. // }
  443. // })
  444. // }
  445. // })
  446. // num++;
  447. // },200)
  448. // }
  449. },
  450. };
  451. </script>
  452. <style lang="less" scoped>
  453. .situationsCenter-page {
  454. height: 100%;
  455. .navbar {
  456. background-color: #ffffff;
  457. }
  458. .calender-remind {
  459. width: 62.5rpx;
  460. height: 62.5rpx;
  461. position: fixed;
  462. top: 20rpx;
  463. right: 25rpx;
  464. background: rgba(255, 255, 255, 0.95);
  465. border-radius: 50%;
  466. z-index: 2;
  467. image {
  468. margin-left: 17.5rpx;
  469. margin-top: 16.87rpx;
  470. width: 27.5rpx;
  471. height: 28.75rpx;
  472. }
  473. }
  474. .search-box {
  475. position: fixed;
  476. top: 20rpx;
  477. left: 25rpx;
  478. z-index: 2;
  479. .search-model {
  480. height: 62.5rpx;
  481. width: 62.5rpx;
  482. background-color: #ffffff;
  483. text-align: center;
  484. border-radius: 50%;
  485. box-shadow: 0px 10px 10px 0px rgba(217, 221, 228, 0.5);
  486. border: 1px solid #e6eaf2;
  487. opacity: 0.85;
  488. .search-pic {
  489. width: 27.5rpx;
  490. height: 27.5rpx;
  491. margin-top: 17.5rpx;
  492. }
  493. }
  494. .search-bar {
  495. background-color: #ffffff;
  496. width: 700rpx;
  497. height: 62.5rpx;
  498. top: 0rpx;
  499. position: absolute;
  500. z-index: 2;
  501. .search-item {
  502. background-color: #ffffff;
  503. width: 593.75rpx;
  504. height: 62.5rpx;
  505. float: left;
  506. border-radius: 6.25rpx;
  507. border-right: 1.25rpx solid #f0f2f7;
  508. ;
  509. .search-pic {
  510. width: 21.87rpx;
  511. height: 21.87rpx;
  512. margin-left: 12.5rpx;
  513. margin-top: 20.62rpx;
  514. float: left;
  515. }
  516. .searh-input {
  517. background-color: #ffffff;
  518. width: 525rpx;
  519. height: 55rpx;
  520. font-size: 22.5rpx;
  521. float: right;
  522. margin-top: 3.75rpx;
  523. margin-left: 3.12rpx;
  524. }
  525. .text-clear {
  526. width: 21.87rpx;
  527. height: 21.87rpx;
  528. float: right;
  529. margin-top: 20.62rpx;
  530. margin-right: 6.25rpx;
  531. }
  532. }
  533. .cancel-text {
  534. font-size: 22.5rpx;
  535. line-height: 62.5rpx;
  536. color: #a1a7b3;
  537. margin-right: 31.25rpx;
  538. float: right;
  539. }
  540. }
  541. }
  542. .situation-list {
  543. position: relative;
  544. height: 100%;
  545. .scroll-box {
  546. width: 100%;
  547. height: calc(100% - 87.5rpx);
  548. .content {
  549. display: flex;
  550. flex-flow: column nowrap;
  551. padding-bottom: 100rpx;
  552. .situation {
  553. position: relative;
  554. height: 187.5rpx;
  555. width: 700rpx;
  556. background: #ffffff;
  557. box-shadow: 0px 6px 20px 0px rgba(0, 13, 51, 0.1);
  558. border-radius: 8px;
  559. margin-left: 25rpx;
  560. margin-right: 25rpx;
  561. margin-top: 25rpx;
  562. // overflow: hidden;
  563. /* 左上角类型角标图片样式 */
  564. .type-badge {
  565. position: absolute;
  566. top: 0rpx;
  567. left: 0rpx;
  568. width: 480rpx;
  569. height: 40rpx;
  570. z-index: 1;
  571. }
  572. /* 右上角组徽标样式(图标 + 文字) */
  573. .group-badge {
  574. position: absolute;
  575. top: 8rpx;
  576. right: 8rpx;
  577. display: flex;
  578. align-items: center;
  579. padding: 4rpx 10rpx;
  580. background: #F2F5FA;
  581. border-radius: 10rpx;
  582. max-width: 220rpx;
  583. }
  584. .group-icon {
  585. width: 22rpx;
  586. height: 22rpx;
  587. margin-right: 6rpx;
  588. }
  589. .group-text {
  590. font-size: 18rpx;
  591. color: #7A8599;
  592. max-width: 190rpx;
  593. overflow: hidden;
  594. text-overflow: ellipsis;
  595. white-space: nowrap;
  596. }
  597. /* 标题行右侧的状态角标 */
  598. .status-badge {
  599. margin-left: auto;
  600. padding: 3rpx 10rpx;
  601. font-size: 13.75rpx;
  602. color: #FFFFFF;
  603. border-radius: 10rpx;
  604. }
  605. .status-badge.doing { background-color: rgba(255, 204, 102, 1); }
  606. .status-badge.wait { background-color: rgba(102, 179, 255, 1); }
  607. .status-badge.complete { background-color: rgba(173, 184, 204, 1); }
  608. .situation-topic {
  609. width: 62.5rpx;
  610. height: 25rpx;
  611. float: right;
  612. }
  613. .title {
  614. margin-left: 20rpx;
  615. margin-top: 70rpx;
  616. display: flex;
  617. align-items: center;
  618. height: 50rpx !important;
  619. .title-name {
  620. font-size: 40rpx !important;
  621. &>span {
  622. display: inline-block;
  623. width: 300rpx;
  624. color: #292c33;
  625. overflow: hidden; //超出的文本隐藏
  626. text-overflow: ellipsis; //溢出用省略号显示
  627. white-space: nowrap; //溢出不换行
  628. }
  629. }
  630. }
  631. .check-group {
  632. margin-left: 20rpx;
  633. margin-top: 15rpx;
  634. margin-bottom: 25rpx;
  635. height: 17.5rpx;
  636. display: flex;
  637. align-items: center;
  638. .group-text-a {
  639. font-size: 22rpx;
  640. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  641. font-weight: 400;
  642. color: #666e80;
  643. overflow: hidden;
  644. text-overflow: ellipsis;
  645. white-space: nowrap;
  646. }
  647. /* 去完善按钮样式:与文案同一行右侧显示 */
  648. .improve-btn {
  649. margin-left: auto;
  650. width: 120rpx;
  651. height: 45rpx;
  652. margin-right: 20rpx;
  653. }
  654. }
  655. }
  656. }
  657. }
  658. }
  659. .situaions-add {
  660. position: fixed;
  661. right: 25rpx;
  662. bottom: 130rpx;
  663. .add-pic {
  664. width: 75rpx;
  665. height: 75rpx;
  666. }
  667. }
  668. }
  669. </style>