mission.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  1. <template>
  2. <view class="mission-page">
  3. <view class="message-remind" @click="toMessagePage">
  4. <image :src="messageType?'/static/message-unread.png':'/static/message-read.png'" mode=""></image>
  5. </view>
  6. <view class="radio-group" v-if="permission == 1 || permission == 4">
  7. <text :style="checkIndex==1?{background:'#3377ff',color:'#fff'}:{background:'#F5F6FA',color:'#3377ff'}" @click="cheangeRadioIndex(1)">我的单位</text>
  8. <text :style="checkIndex==2?{background:'#3377ff',color:'#fff'}:{background:'#F5F6FA',color:'#3377ff'}" @click="cheangeRadioIndex(2)">待处理</text></view>
  9. <scroll-view class="scroll-y" scroll-y="true">
  10. <list-item
  11. v-for="(item, i) in improvingTaskList"
  12. :key="item.id"
  13. :task="item"
  14. />
  15. <tm-no-data v-show="improvingTaskList.length === 0 && !showCloseList"
  16. :textArr="['目前没有任务需要处理']" />
  17. <view class="completed-box"
  18. :style="{marginTop: improvingTaskList.length === 0 && !showCloseList ? '-50rpx' : 0}">
  19. <view class="btn-box" >
  20. <view class="btn" v-show="completeTaskList.length > 0" @click="toggleBtn">
  21. <image class="icon" :src="`/static/${btnSetting.icon}.png`"></image>
  22. <text class="text">
  23. {{ btnSetting.name }}
  24. </text>
  25. </view>
  26. </view>
  27. <template v-if="showCloseList">
  28. <list-item
  29. v-for="(item, i) in completeTaskList"
  30. :key="item.id"
  31. :task="item"
  32. :isComplete="true"
  33. />
  34. </template>
  35. </view>
  36. </scroll-view>
  37. <tm-tabbar />
  38. </view>
  39. </template>
  40. <script>
  41. // 任务列表
  42. import listItem from './components/list-item.vue';
  43. import websocket from '../../utils/ws.js';//引入websocket
  44. import {wsURL} from "../../utils/requestUrl.js";
  45. export default {
  46. data(){
  47. return {
  48. // 是否展开历史任务
  49. showCloseList: false,
  50. btnSetting: {
  51. icon: 'up-icon', // 图标名
  52. name: '展示历史任务' // 按钮显示名字
  53. },
  54. // 改善中任务
  55. improvingTaskList: [
  56. // {
  57. // appointFlag: false, // 已指派标志, 0 未指派 1已指派
  58. // checkGroupId: 1, // 查核组id
  59. // checkGroupName: "测试群组", // 查核组名称
  60. // checkId: 1,
  61. // checkItemId: 1, // 查核项目id
  62. // checkItemName: "测试点", // 查核项目名称
  63. // checkPlan: "第1/3次查核计划", // 查核计划
  64. // checkPointId: 1, // 查核要点id
  65. // checkPointName: "测试", // 查核要点名称(查核项)
  66. // createDate: "2021-02-03T01:44:09.000+0000", // 任务创建时间
  67. // createEmpId: 1, //创建人
  68. // createEmpName: "管理员", // 创建人姓名
  69. // delFlag: false,
  70. // deptId: 1, // 单位id
  71. // deptName: "测试部门", // 单位名称
  72. // desicion: "", // 改善工具:0,进行PDCA改善 1,暂不改善
  73. // endFlag: false, // 完结标识
  74. // id: 1, // 任务id
  75. // needApproveFlag: false, // 需要审核标志
  76. // recordTime: "2021-02-03 09:44:17", // 最终修改时间
  77. // situationId: 1, // 情景id
  78. // situationName: "测试情景", // 情景名称
  79. // taskType: 0, // 任务当前状态
  80. // updateTime: "2021-02-03T01:44:17.000+0000", // 修改时间 (发送时间)
  81. // improveEmpName: '', //改善人
  82. // improveEmpId: '', //改善人id
  83. // }
  84. ],
  85. // 历史任务
  86. completeTaskList: [],
  87. refTimer: null,
  88. isInitWs:null,
  89. messageType:null,
  90. checkIndex:2,
  91. improvingTaskList2:[],
  92. list:[],
  93. permission:'',
  94. }
  95. },
  96. created() {
  97. // this.getMissionList();
  98. this.init(true);
  99. this.refTimer = setInterval(() => {
  100. this.isInitWs = websocket.ws ? false : true;
  101. this.init(this.isInitWs);
  102. }, 3 * 60 * 1000);
  103. // this.messStatus();
  104. },
  105. beforeDestroy() {
  106. // 关闭ws连接
  107. websocket.close();
  108. clearInterval(this.refTimer);
  109. },
  110. // watch:{
  111. // "$route":{
  112. // handler(route){
  113. // this.messStatus();
  114. // }
  115. // }
  116. // },
  117. methods: {
  118. toggleBtn() {
  119. let flag = !this.showCloseList;
  120. this.showCloseList = flag;
  121. this.btnSetting = {
  122. icon: flag ? 'up-icon' : 'down-icon',
  123. name: flag ? '收起历史任务' : '展示历史任务'
  124. }
  125. },
  126. init(isInitWs) {
  127. this.isInitWs = isInitWs;
  128. this.getMissionList()
  129. },
  130. // 获取改善任务列表
  131. getMissionList(data) {
  132. this.$store.dispatch({
  133. type: 'mission/commActions',
  134. payload: {
  135. key: "getMissionList",
  136. data
  137. }
  138. }).then(data => {
  139. if(data) {
  140. // this.improvingTaskList = data.improvingTaskResponses || [];
  141. this.improvingTaskList2 = data.improvingTaskResponses || [];
  142. this.completeTaskList = data.improveCompleteResponses || [];
  143. let hiId = uni.getStorageSync('hiId');
  144. let user = uni.getStorageSync('id');
  145. let permission = uni.getStorageSync('nowPermission');
  146. this.isInitWs && this.initWebsocket(hiId,user,permission);
  147. this.permission = permission;
  148. if(this.checkIndex == 2){
  149. let list = [];
  150. this.improvingTaskList2.map(item=>{
  151. if(item.tackCare){
  152. list.push(item)
  153. }
  154. })
  155. this.list = list;
  156. this.improvingTaskList = list;
  157. }
  158. }
  159. });
  160. /** 请求参数 data
  161. * situationId: 情境id 当管路员或者查核者通过情境进入任务列表时 必传
  162. * checkItemId 单位负责人通过 查核要点进入改善任务列表时 必传
  163. */
  164. },
  165. initWebsocket(hiId,user,permission) {
  166. websocket.url = wsURL(hiId, user, permission);
  167. websocket.createWebSocket(this.resolverWsData.bind(this));
  168. },
  169. // 解析websocket返回数据
  170. resolverWsData(type) {
  171. let types = JSON.parse(type);
  172. switch (types.type) {
  173. case "TO_READ":
  174. this.messageType = true;
  175. break;
  176. default:
  177. this.messageType = false;
  178. break;
  179. }
  180. },
  181. toMessagePage(){
  182. // this.messageType = false;
  183. uni.navigateTo({
  184. url: `/pages/messages/messages`
  185. });
  186. },
  187. // messStatus(){
  188. // let num = 1;
  189. // let timer = setInterval(()=>{
  190. // this.$store.dispatch({
  191. // type: "calendar/commActions",
  192. // payload: {
  193. // key: "messagesList",
  194. // data: {
  195. // pageNum: num,
  196. // pageSize: 100,
  197. // },
  198. // },
  199. // }).then((res)=>{
  200. // if(res && res.list.length == 0){
  201. // clearInterval(timer)
  202. // }else if(res && res.list.length != 0){
  203. // res.list.map((item)=>{
  204. // if(!item.readStatus){
  205. // this.messageType = true;
  206. // return;
  207. // }
  208. // })
  209. // }
  210. // })
  211. // num++;
  212. // },100)
  213. // }
  214. cheangeRadioIndex(index){
  215. this.checkIndex = index;
  216. if(this.checkIndex == 1){
  217. this.improvingTaskList = this.improvingTaskList2;
  218. }else{
  219. this.improvingTaskList = this.list;
  220. }
  221. },
  222. },
  223. components: {
  224. listItem
  225. },
  226. }
  227. </script>
  228. <style lang="less">
  229. .mission-page {
  230. height: 100%;
  231. padding-top: 15rpx;
  232. .message-remind{
  233. width: 62.5rpx;
  234. height: 62.5rpx;
  235. position: fixed;
  236. top: 6.25rpx;
  237. right: 6.25rpx;
  238. background: rgba(255, 255, 255, 0.95);
  239. border-radius: 50%;
  240. z-index: 2;
  241. image{
  242. margin-left: 17.5rpx;
  243. margin-top: 16.87rpx;
  244. width: 27.5rpx;
  245. height: 28.75rpx;
  246. }
  247. }
  248. .radio-group{
  249. margin: 12.5rpx 25rpx;
  250. width: calc(100% - 50rpx);
  251. border: 0.62rpx solid #3377ff;
  252. border-radius: 25rpx;
  253. font-size: 22.5rpx;
  254. line-height: 50rpx;
  255. color: #3377ff;
  256. overflow: hidden;
  257. text{
  258. width: 50%;
  259. display: inline-block;
  260. text-align: center;
  261. }
  262. }
  263. .scroll-y {
  264. height: calc(100% - 176rpx);
  265. .completed-box {
  266. .btn-box {
  267. display: flex;
  268. justify-content: center;
  269. margin-bottom: 25rpx;
  270. height: 50rpx;
  271. .btn {
  272. display: flex;
  273. justify-content: center;
  274. align-items: center;
  275. width: 225rpx;
  276. height: 50rpx;
  277. border-radius: 37.5rpx;
  278. border: 1.25rpx solid #98A1B3;
  279. .icon {
  280. margin-right: 6.25rpx;
  281. width: 21.25rpx;
  282. height: 12.5rpx;
  283. }
  284. .text {
  285. font-size: 22.5rpx;
  286. color: #98A1B3;
  287. }
  288. }
  289. }
  290. }
  291. }
  292. }
  293. </style>