mission-details.vue 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  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.recordTime }}</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. import pdcaSetting from './pdcaSetting.js'
  67. export default {
  68. computed: {
  69. ...mapState({
  70. missionDetails: state => state.mission.missionDetails
  71. }),
  72. // 进度长度
  73. taskStepLength() {
  74. return (this.missionDetails.pfmTaskCirculationList || []).length - 1;
  75. },
  76. // 获取底部按钮
  77. taskBtn() {
  78. const { buttonDisplayFlag, pfmTaskCirculationList, taskType, checkResult } = this.missionDetails;
  79. if(buttonDisplayFlag == 1 && pfmTaskCirculationList && pfmTaskCirculationList.length > 0) {
  80. let task = null;
  81. if(taskType == 1) { // 状态为1比较特殊,需要再比较checkResult
  82. task = taskTypeList.find(item => (item.taskType == taskType && item.checkResult == checkResult));
  83. }else {
  84. task = taskTypeList.find(item => item.taskType == taskType);
  85. }
  86. return task ? task.btnList : []
  87. }else {
  88. return [];
  89. }
  90. }
  91. },
  92. data() {
  93. return {
  94. // 任务id
  95. taskId: '',
  96. // 跳转详情信息
  97. linkTaskDetails: null
  98. }
  99. },
  100. onLoad({ taskId }){
  101. this.taskId = taskId;
  102. },
  103. created() {
  104. this.getMissionDetails();
  105. },
  106. methods: {
  107. // 获取改善任务列表
  108. getMissionDetails(data) {
  109. this.$store.dispatch({
  110. type: 'mission/commActions',
  111. payload: {
  112. key: "getMissionDetails",
  113. data: {taskId: this.taskId}
  114. }
  115. });
  116. },
  117. // 点击右侧按钮
  118. clickBtn(currentInfo, btnInfo) {
  119. if(btnInfo.componentName){ // 有组件名,则跳转页面
  120. if(btnInfo.componentName === 'pdca'){
  121. const { taskType, needApproveFlag } = this.missionDetails;
  122. if(taskType === 13 || taskType === 15){ // 制定改善方案中(需要回显暂存过的数据)
  123. if(needApproveFlag){// 需要审核(pdca)
  124. btnInfo= { ...btnInfo, ...pdcaSetting['editPdcaBtnInfo'], isEdit: true };
  125. }else {
  126. btnInfo= { ...btnInfo, ...pdcaSetting['editPBtnInfo'], isEdit: true };
  127. }
  128. }else {
  129. if(needApproveFlag){ // 需要审核(pdca)
  130. btnInfo= { ...btnInfo, ...pdcaSetting['pdcaBtnInfo'] };
  131. }else {
  132. btnInfo= { ...btnInfo, ...pdcaSetting['pBtnInfo'] };
  133. }
  134. }
  135. }
  136. uni.navigateTo({
  137. url: `/pages/mission-action/mission-action?details=${encodeURIComponent(JSON.stringify({...currentInfo, ...btnInfo}))}`
  138. });
  139. }else { // 直接调接口
  140. let requestParams = {};
  141. btnInfo.params.map(item => {
  142. if(item.valueKey){
  143. requestParams[item.paramsKey] = (
  144. item.isOutvalueKey
  145. ? this.missionDetails
  146. : currentInfo
  147. )[item.valueKey];
  148. }
  149. })
  150. this.comTaskCirculation(requestParams);
  151. }
  152. },
  153. // 查看详情
  154. goToDetails(currentInfo, detailInfo) {
  155. if(detailInfo.navigateUrl){ // 跳转其他页面(如查核项详情) 目前hasAnyData都为false
  156. const {navigateUrl, key, isOutvalueKey, hasAnyData} = detailInfo;
  157. uni.navigateTo({
  158. url: `${detailInfo.navigateUrl}?id=${(isOutvalueKey ? this.missionDetails : currentInfo)[detailInfo.key]}`
  159. });
  160. }else {
  161. uni.navigateTo({
  162. url: `/pages/mission-action/mission-action?details=${encodeURIComponent(JSON.stringify({...currentInfo, ...detailInfo}))}`
  163. });
  164. }
  165. },
  166. /***
  167. * 解析显示对应的内容
  168. * @param {Object} obj 当前遍历的任务
  169. * @param {Boolean} isLink 是否需要跳转页面(查看详情)
  170. * @param {String} rowKey 任务流程中的key
  171. */
  172. getContext(obj, isLink, rowKey){
  173. let currentTypeTask = null;
  174. if(obj.taskType == 1) {
  175. const { checkResult } = this.missionDetails;
  176. currentTypeTask = taskTypeList.find(item => (item.taskType == obj.taskType && item.checkResult == checkResult)) || {};
  177. }else {
  178. currentTypeTask = taskTypeList.find(item => item.taskType == obj.taskType) || {};
  179. }
  180. if(isLink) {
  181. return currentTypeTask[rowKey];
  182. }else {
  183. const { hasJoin, name, key} = currentTypeTask[rowKey] || {};
  184. if(hasJoin) { // 需要删除*并替换
  185. return name ? name.replace(/x/g, (obj[key] || '')) : ''
  186. }else {
  187. return name || '';
  188. }
  189. }
  190. },
  191. // 公共改善任务接口
  192. comTaskCirculation(data) {
  193. this.$store.dispatch({
  194. type: 'mission/commActions',
  195. payload: {
  196. key: "comTaskCirculation",
  197. data
  198. }
  199. }).then(data1 => {
  200. if(!data1){
  201. this.getMissionDetails();
  202. }
  203. });
  204. }
  205. },
  206. components: {
  207. listItem
  208. }
  209. }
  210. </script>
  211. <style lang="less">
  212. .mission-details-page {
  213. height: 100%;
  214. padding-top: 15rpx;
  215. .scroll-y {
  216. height: 100%;
  217. .mission-plan {
  218. .label {
  219. margin-top: 25rpx;
  220. margin-bottom: 15rpx;
  221. height: 20rpx;
  222. line-height: 20rpx;
  223. padding-left: 25rpx;
  224. text {
  225. font-size: 20rpx;
  226. color: #666F80;
  227. }
  228. }
  229. .plan-box {
  230. padding: 25rpx;
  231. background-color: #fff;
  232. .row {
  233. display: flex;
  234. .col {
  235. .title {
  236. display: flex;
  237. align-items: center;
  238. margin-bottom: 15rpx;
  239. height: 25rpx;
  240. >text {
  241. font-size: 22.5rpx;
  242. color: #292C33;
  243. }
  244. }
  245. .sub-box {
  246. display: flex;
  247. flex-direction: column;
  248. .sub-title {
  249. display: flex;
  250. align-items: center;
  251. margin-bottom: 15rpx;
  252. height: 20rpx;
  253. &:last-child {
  254. margin-bottom: 34.37rpx;
  255. }
  256. >text {
  257. font-size: 20rpx;
  258. color: #666E80;
  259. }
  260. }
  261. }
  262. &:first-child {
  263. display: flex;
  264. flex-direction: column;
  265. align-items: center;
  266. margin-right: 15rpx;
  267. width: 25rpx;
  268. .plan-icon {
  269. margin-bottom: 17.5rpx;
  270. width: 25rpx;
  271. height: 25rpx;
  272. }
  273. .line {
  274. width: 5rpx;
  275. height: 75rpx;
  276. background-color: #E6EAF2;
  277. }
  278. }
  279. &:last-child {
  280. position: relative;
  281. flex: 1;
  282. .link-view {
  283. position: absolute;
  284. top: 0;
  285. right: 0;
  286. >text {
  287. font-size: 17.5rpx;
  288. color: #3377FF;
  289. }
  290. .blue-arr {
  291. margin-left: 10rpx;
  292. width: 8.12rpx;
  293. height: 15.62rpx;
  294. }
  295. }
  296. }
  297. }
  298. }
  299. .btn-group {
  300. display: flex;
  301. justify-content: space-between;
  302. padding: 0 25rpx;
  303. }
  304. .btn-one {
  305. justify-content: center;
  306. }
  307. }
  308. }
  309. }
  310. }
  311. </style>