mission.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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.init(true);
  98. this.refTimer = setInterval(() => {
  99. this.isInitWs = websocket.ws ? false : true;
  100. this.init(this.isInitWs);
  101. }, 3 * 60 * 1000);
  102. },
  103. onShow() {
  104. this.init(true);
  105. },
  106. beforeDestroy() {
  107. // 关闭ws连接
  108. websocket.close();
  109. clearInterval(this.refTimer);
  110. },
  111. methods: {
  112. toggleBtn() {
  113. let flag = !this.showCloseList;
  114. this.showCloseList = flag;
  115. this.btnSetting = {
  116. icon: flag ? 'up-icon' : 'down-icon',
  117. name: flag ? '收起历史任务' : '展示历史任务'
  118. }
  119. },
  120. init(isInitWs) {
  121. this.isInitWs = isInitWs;
  122. this.getMissionList()
  123. },
  124. // 获取改善任务列表
  125. getMissionList(data) {
  126. this.$store.dispatch({
  127. type: 'mission/commActions',
  128. payload: {
  129. key: "getMissionList",
  130. data
  131. }
  132. }).then(data => {
  133. if(data) {
  134. // this.improvingTaskList = data.improvingTaskResponses || [];
  135. this.improvingTaskList2 = data.improvingTaskResponses || [];
  136. this.completeTaskList = data.improveCompleteResponses || [];
  137. console.log('this.completeTaskList',this.completeTaskList.length);
  138. let hiId = uni.getStorageSync('hiId');
  139. let user = uni.getStorageSync('id');
  140. let permission = uni.getStorageSync('nowPermission');
  141. this.isInitWs && this.initWebsocket(hiId,user,permission);
  142. this.permission = permission;
  143. if(this.checkIndex == 2){
  144. let list = [];
  145. this.improvingTaskList2.map(item=>{
  146. if(item.tackCare){
  147. list.push(item)
  148. }
  149. })
  150. this.list = list;
  151. this.improvingTaskList = list;
  152. }
  153. }
  154. });
  155. /** 请求参数 data
  156. * situationId: 情境id 当管路员或者查核者通过情境进入任务列表时 必传
  157. * checkItemId 单位负责人通过 查核要点进入改善任务列表时 必传
  158. */
  159. },
  160. initWebsocket(hiId,user,permission) {
  161. websocket.url = wsURL(hiId, user, permission);
  162. websocket.createWebSocket(this.resolverWsData.bind(this));
  163. },
  164. // 解析websocket返回数据
  165. resolverWsData(type) {
  166. let types = JSON.parse(type);
  167. switch (types.type) {
  168. case "TO_READ":
  169. this.messageType = true;
  170. break;
  171. default:
  172. this.messageType = false;
  173. break;
  174. }
  175. },
  176. toMessagePage(){
  177. // this.messageType = false;
  178. uni.navigateTo({
  179. url: `/pages/messages/messages?pathName=messages`
  180. });
  181. },
  182. // messStatus(){
  183. // let num = 1;
  184. // let timer = setInterval(()=>{
  185. // this.$store.dispatch({
  186. // type: "calendar/commActions",
  187. // payload: {
  188. // key: "messagesList",
  189. // data: {
  190. // pageNum: num,
  191. // pageSize: 100,
  192. // },
  193. // },
  194. // }).then((res)=>{
  195. // if(res && res.list.length == 0){
  196. // clearInterval(timer)
  197. // }else if(res && res.list.length != 0){
  198. // res.list.map((item)=>{
  199. // if(!item.readStatus){
  200. // this.messageType = true;
  201. // return;
  202. // }
  203. // })
  204. // }
  205. // })
  206. // num++;
  207. // },100)
  208. // }
  209. cheangeRadioIndex(index){
  210. this.checkIndex = index;
  211. if(this.checkIndex == 1){
  212. this.improvingTaskList = this.improvingTaskList2;
  213. }else{
  214. this.improvingTaskList = this.list;
  215. }
  216. },
  217. },
  218. components: {
  219. listItem
  220. },
  221. }
  222. </script>
  223. <style lang="less">
  224. .mission-page {
  225. height: 100%;
  226. padding-top: 15rpx;
  227. .message-remind{
  228. width: 62.5rpx;
  229. height: 62.5rpx;
  230. position: fixed;
  231. top: 6.25rpx;
  232. right: 6.25rpx;
  233. background: rgba(255, 255, 255, 0.95);
  234. border-radius: 50%;
  235. z-index: 2;
  236. image{
  237. margin-left: 17.5rpx;
  238. margin-top: 16.87rpx;
  239. width: 27.5rpx;
  240. height: 28.75rpx;
  241. }
  242. }
  243. .radio-group{
  244. margin: 12.5rpx 25rpx;
  245. width: calc(100% - 50rpx);
  246. border: 0.62rpx solid #3377ff;
  247. border-radius: 25rpx;
  248. font-size: 22.5rpx;
  249. line-height: 50rpx;
  250. color: #3377ff;
  251. overflow: hidden;
  252. text{
  253. width: 50%;
  254. display: inline-block;
  255. text-align: center;
  256. }
  257. }
  258. .scroll-y {
  259. height: calc(100% - 180rpx);
  260. .completed-box {
  261. .btn-box {
  262. display: flex;
  263. justify-content: center;
  264. margin-bottom: 25rpx;
  265. height: 50rpx;
  266. .btn {
  267. display: flex;
  268. justify-content: center;
  269. align-items: center;
  270. width: 225rpx;
  271. height: 50rpx;
  272. border-radius: 37.5rpx;
  273. border: 1.25rpx solid #98A1B3;
  274. .icon {
  275. margin-right: 6.25rpx;
  276. width: 21.25rpx;
  277. height: 12.5rpx;
  278. }
  279. .text {
  280. font-size: 22.5rpx;
  281. color: #98A1B3;
  282. }
  283. }
  284. }
  285. }
  286. }
  287. }
  288. </style>