mission.vue 8.0 KB

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