mission-details.vue 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <view class="mission-details-page">
  3. <scroll-view class="scroll-y" scroll-y="true">
  4. <list-item :isDetails="true" :task="missionDetails" />
  5. <view class="mission-plan">
  6. <view class="label">
  7. <text>改善进度</text>
  8. </view>
  9. <view class="plan-box">
  10. <template v-for="(item, i) in missionDetails.pfmTaskCirculationList || []">
  11. <view class="row" :key="i">
  12. <view class="col">
  13. <image
  14. class="plan-icon"
  15. :src="`/static/${i === taskStepLength ? 'check-radio' : 'check-no'}.png`">
  16. </image>
  17. <view class="line" v-show="i != taskStepLength"></view>
  18. </view>
  19. <view class="col">
  20. <view class="title">
  21. <text>{{ getContext(item, false, 'row1') }}</text>
  22. </view>
  23. <view class="sub-box">
  24. <view class="sub-title">
  25. <text>{{ getContext(item, false, 'row2') }}</text>
  26. </view>
  27. <view class="sub-title">
  28. <text>{{ item.createTime }}</text>
  29. </view>
  30. </view>
  31. <template v-if="getContext(item, true, 'selectDetails')">
  32. <view class="link-view"
  33. @click="goToDetails(item, getContext(item, true, 'selectDetails'))"
  34. >
  35. <text>{{ getContext(item, true, 'selectDetails').name }}</text>
  36. <image class="blue-arr" src="/static/blue-arrow.png"></image>
  37. </view>
  38. </template>
  39. </view>
  40. </view>
  41. <view :class="['btn-group', taskBtn.length === 1 ?'btn-one' : '']"
  42. v-if="missionDetails.buttonDisplayFlag == 1
  43. && missionDetails.pfmTaskCirculationList
  44. && i == missionDetails.pfmTaskCirculationList.length - 1"
  45. >
  46. <template v-for="(btn, i1) in taskBtn">
  47. <tm-button
  48. :key="i1"
  49. :type="taskBtn.length === 1 ? 'default' : ( i1 === 0 ? 'default' : 'pramary')"
  50. :btnText="btn.name"
  51. @btnClick="clickBtn(item, btn)"
  52. />
  53. </template>
  54. </view>
  55. </template>
  56. </view>
  57. </view>
  58. </scroll-view>
  59. </view>
  60. </template>
  61. <script>
  62. // 改善任务
  63. import { mapState } from "vuex";
  64. import listItem from '../mission/components/list-item.vue';
  65. import taskTypeList from './setting.js';
  66. export default {
  67. computed: {
  68. ...mapState({
  69. missionDetails: state => state.mission.missionDetails
  70. }),
  71. // 进度长度
  72. taskStepLength() {
  73. return (this.missionDetails.pfmTaskCirculationList || []).length - 1;
  74. },
  75. // 获取底部按钮
  76. taskBtn() {
  77. const { buttonDisplayFlag, pfmTaskCirculationList, taskType, checkResult } = this.missionDetails;
  78. if(buttonDisplayFlag == 1 && pfmTaskCirculationList && pfmTaskCirculationList.length > 0) {
  79. let task = null;
  80. if(taskType == 1) { // 状态为1比较特殊,需要再比较checkResult
  81. task = taskTypeList.find(item => (item.taskType == taskType && item.checkResult == checkResult));
  82. }else {
  83. task = taskTypeList.find(item => item.taskType == taskType);
  84. }
  85. return task ? task.btnList : []
  86. }else {
  87. return [];
  88. }
  89. }
  90. },
  91. data() {
  92. return {
  93. // 任务id
  94. taskId: '',
  95. // 跳转详情信息
  96. linkTaskDetails: null
  97. }
  98. },
  99. onLoad({ taskId }){
  100. this.taskId = taskId;
  101. },
  102. created() {
  103. this.getMissionDetails();
  104. },
  105. methods: {
  106. // 获取改善任务列表
  107. getMissionDetails(data) {
  108. this.$store.dispatch({
  109. type: 'mission/commActions',
  110. payload: {
  111. key: "getMissionDetails",
  112. data: {taskId: this.taskId}
  113. }
  114. });
  115. },
  116. // 点击右侧按钮
  117. clickBtn(currentInfo, btnInfo) {
  118. if(btnInfo.componentName){ // 有组件名,则跳转页面
  119. uni.navigateTo({
  120. url: `/pages/mission-action/mission-action?details=${encodeURIComponent(JSON.stringify({...currentInfo, ...btnInfo}))}`
  121. });
  122. }else { // 直接调接口
  123. let requestParams = {};
  124. btnInfo.params.map(item => {
  125. if(item.valueKey){
  126. requestParams[item.paramsKey] = (
  127. item.isOutvalueKey
  128. ? this.missionDetails
  129. : currentInfo
  130. )[item.valueKey];
  131. }
  132. })
  133. this.comTaskCirculation(requestParams);
  134. }
  135. },
  136. // 查看详情
  137. goToDetails(currentInfo, detailInfo) {
  138. uni.navigateTo({
  139. url: `/pages/mission-action/mission-action?details=${encodeURIComponent(JSON.stringify({...currentInfo, ...detailInfo}))}`
  140. });
  141. },
  142. /***
  143. * 解析显示对应的内容
  144. * @param {Object} obj 当前遍历的任务
  145. * @param {Boolean} isLink 是否需要跳转页面(查看详情)
  146. * @param {String} rowKey 任务流程中的key
  147. */
  148. getContext(obj, isLink, rowKey){
  149. let currentTypeTask = null;
  150. if(obj.taskType == 1) {
  151. const { checkResult } = this.missionDetails;
  152. currentTypeTask = taskTypeList.find(item => (item.taskType == obj.taskType && item.checkResult == checkResult)) || {};
  153. }else {
  154. currentTypeTask = taskTypeList.find(item => item.taskType == obj.taskType) || {};
  155. }
  156. if(isLink) {
  157. return currentTypeTask[rowKey];
  158. }else {
  159. const { hasJoin, name, key} = currentTypeTask[rowKey] || {};
  160. if(hasJoin) { // 需要删除*并替换
  161. return name ? name.replace(/x/g, (obj[key] || '')) : ''
  162. }else {
  163. return name || '';
  164. }
  165. }
  166. },
  167. // 公共改善任务接口
  168. comTaskCirculation(data) {
  169. this.$store.dispatch({
  170. type: 'mission/commActions',
  171. payload: {
  172. key: "comTaskCirculation",
  173. data
  174. }
  175. }).then(data1 => {
  176. if(!data1){
  177. this.getMissionDetails();
  178. }
  179. });
  180. }
  181. },
  182. components: {
  183. listItem
  184. }
  185. }
  186. </script>
  187. <style lang="less">
  188. .mission-details-page {
  189. height: 100%;
  190. padding-top: 15rpx;
  191. .scroll-y {
  192. height: 100%;
  193. .mission-plan {
  194. .label {
  195. margin-top: 25rpx;
  196. margin-bottom: 15rpx;
  197. height: 20rpx;
  198. line-height: 20rpx;
  199. padding-left: 25rpx;
  200. text {
  201. font-size: 20rpx;
  202. color: #666F80;
  203. }
  204. }
  205. .plan-box {
  206. padding: 25rpx;
  207. background-color: #fff;
  208. .row {
  209. display: flex;
  210. .col {
  211. .title {
  212. display: flex;
  213. align-items: center;
  214. margin-bottom: 15rpx;
  215. height: 25rpx;
  216. >text {
  217. font-size: 22.5rpx;
  218. color: #292C33;
  219. }
  220. }
  221. .sub-box {
  222. display: flex;
  223. flex-direction: column;
  224. .sub-title {
  225. display: flex;
  226. align-items: center;
  227. margin-bottom: 15rpx;
  228. height: 20rpx;
  229. &:last-child {
  230. margin-bottom: 34.37rpx;
  231. }
  232. >text {
  233. font-size: 20rpx;
  234. color: #666E80;
  235. }
  236. }
  237. }
  238. &:first-child {
  239. display: flex;
  240. flex-direction: column;
  241. align-items: center;
  242. margin-right: 15rpx;
  243. width: 25rpx;
  244. .plan-icon {
  245. margin-bottom: 17.5rpx;
  246. width: 25rpx;
  247. height: 25rpx;
  248. }
  249. .line {
  250. width: 5rpx;
  251. height: 75rpx;
  252. background-color: #E6EAF2;
  253. }
  254. }
  255. &:last-child {
  256. position: relative;
  257. flex: 1;
  258. .link-view {
  259. position: absolute;
  260. top: 0;
  261. right: 0;
  262. >text {
  263. font-size: 17.5rpx;
  264. color: #3377FF;
  265. }
  266. .blue-arr {
  267. margin-left: 10rpx;
  268. width: 8.12rpx;
  269. height: 15.62rpx;
  270. }
  271. }
  272. }
  273. }
  274. }
  275. .btn-group {
  276. display: flex;
  277. justify-content: space-between;
  278. padding: 0 25rpx;
  279. }
  280. .btn-one {
  281. justify-content: center;
  282. }
  283. }
  284. }
  285. }
  286. }
  287. </style>