mission.vue 7.8 KB

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