mission-details.vue 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  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 || taskType == 3) { // 状态为1, 和3比较特殊,需要再比较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. // needApproveFlag: true 需要审核(p)只显示p
  123. if(taskType === 8){
  124. btnInfo= {
  125. ...btnInfo,
  126. ...pdcaSetting['pdcaBtnInfo'],
  127. pDisabled: true // plan内容禁用
  128. };
  129. } else if(taskType === 11){
  130. btnInfo= {
  131. ...btnInfo,
  132. ...pdcaSetting['pdcaBtnInfo'],
  133. pDisabled: needApproveFlag // plan内容是否禁用取决于needApproveFlag
  134. };
  135. }else if(taskType === 13){ // 制定改善方案p中(需要回显暂存过的数据)
  136. btnInfo= {
  137. ...btnInfo,
  138. ...pdcaSetting['editPBtnInfo'],
  139. isEdit: true
  140. };
  141. }else if(taskType === 15){ // 制定改善方案pdca中(需要回显暂存过的数据)
  142. btnInfo= {
  143. ...btnInfo,
  144. ...pdcaSetting['editPdcaBtnInfo'],
  145. isEdit: true,
  146. pDisabled: needApproveFlag
  147. };
  148. }else {
  149. // taskType === 4 || taskType === 6 || taskType === 7 || taskType === 9
  150. btnInfo= {
  151. ...btnInfo,
  152. ...pdcaSetting[needApproveFlag ? 'pBtnInfo' : 'pdcaBtnInfo']
  153. };
  154. }
  155. }
  156. uni.navigateTo({
  157. url: `/pages/mission-action/mission-action?details=${encodeURIComponent(JSON.stringify({...currentInfo, ...btnInfo}))}`
  158. });
  159. }else { // 直接调接口
  160. let requestParams = {};
  161. btnInfo.params.map(item => {
  162. if(item.valueKey){
  163. requestParams[item.paramsKey] = (
  164. item.isOutvalueKey
  165. ? this.missionDetails
  166. : currentInfo
  167. )[item.valueKey];
  168. }else if(item.value){
  169. requestParams[item.paramsKey] = item.value;
  170. }
  171. })
  172. this.comTaskCirculation(requestParams);
  173. }
  174. },
  175. // 查看详情
  176. goToDetails(currentInfo, detailInfo) {
  177. if(detailInfo.navigateUrl){ // 跳转其他页面(如查核项详情) 目前hasAnyData都为false
  178. const {navigateUrl, key, isOutvalueKey, hasAnyData} = detailInfo;
  179. uni.navigateTo({
  180. url: `${detailInfo.navigateUrl}?id=${(isOutvalueKey ? this.missionDetails : currentInfo)[detailInfo.key]}`
  181. });
  182. }else {
  183. uni.navigateTo({
  184. url: `/pages/mission-action/mission-action?details=${encodeURIComponent(JSON.stringify({...currentInfo, ...detailInfo}))}`
  185. });
  186. }
  187. },
  188. /***
  189. * 解析显示对应的内容
  190. * @param {Object} obj 当前遍历的任务
  191. * @param {Boolean} isLink 是否需要跳转页面(查看详情)
  192. * @param {String} rowKey 任务流程中的key
  193. */
  194. getContext(obj, isLink, rowKey){
  195. let currentTypeTask = null;
  196. if(obj.taskType == 1) {
  197. const { checkResult } = this.missionDetails;
  198. currentTypeTask = taskTypeList.find(item => (item.taskType == obj.taskType && item.checkResult == checkResult)) || {};
  199. }else {
  200. currentTypeTask = taskTypeList.find(item => item.taskType == obj.taskType) || {};
  201. }
  202. if(isLink) {
  203. return currentTypeTask[rowKey];
  204. }else {
  205. const { hasJoin, name, key, isOutvalueKey} = currentTypeTask[rowKey] || {};
  206. if(hasJoin) { // 需要删除*并替换
  207. return name ? name.replace(/x/g, (isOutvalueKey ? this.missionDetails : obj)[key] || '') : ''
  208. }else {
  209. return name || '';
  210. }
  211. }
  212. },
  213. // 公共改善任务接口
  214. comTaskCirculation(data) {
  215. this.$store.dispatch({
  216. type: 'mission/commActions',
  217. payload: {
  218. key: "comTaskCirculation",
  219. data
  220. }
  221. }).then(data1 => {
  222. if(data1){
  223. this.getMissionDetails();
  224. }
  225. });
  226. }
  227. },
  228. components: {
  229. listItem
  230. }
  231. }
  232. </script>
  233. <style lang="less">
  234. .mission-details-page {
  235. height: 100%;
  236. padding-top: 15rpx;
  237. .scroll-y {
  238. height: 100%;
  239. .mission-plan {
  240. .label {
  241. margin-top: 25rpx;
  242. margin-bottom: 15rpx;
  243. height: 20rpx;
  244. line-height: 20rpx;
  245. padding-left: 25rpx;
  246. text {
  247. font-size: 20rpx;
  248. color: #666F80;
  249. }
  250. }
  251. .plan-box {
  252. padding: 25rpx;
  253. background-color: #fff;
  254. .row {
  255. display: flex;
  256. .col {
  257. .title {
  258. display: flex;
  259. align-items: center;
  260. margin-bottom: 15rpx;
  261. height: 25rpx;
  262. >text {
  263. font-size: 22.5rpx;
  264. color: #292C33;
  265. }
  266. }
  267. .sub-box {
  268. display: flex;
  269. flex-direction: column;
  270. .sub-title {
  271. display: flex;
  272. align-items: center;
  273. margin-bottom: 15rpx;
  274. height: 20rpx;
  275. &:last-child {
  276. margin-bottom: 34.37rpx;
  277. }
  278. >text {
  279. font-size: 20rpx;
  280. color: #666E80;
  281. }
  282. }
  283. }
  284. &:first-child {
  285. display: flex;
  286. flex-direction: column;
  287. align-items: center;
  288. margin-right: 15rpx;
  289. width: 25rpx;
  290. .plan-icon {
  291. margin-bottom: 17.5rpx;
  292. width: 25rpx;
  293. height: 25rpx;
  294. }
  295. .line {
  296. width: 5rpx;
  297. height: 75rpx;
  298. background-color: #E6EAF2;
  299. }
  300. }
  301. &:last-child {
  302. position: relative;
  303. flex: 1;
  304. .link-view {
  305. position: absolute;
  306. top: 0;
  307. right: 0;
  308. >text {
  309. font-size: 17.5rpx;
  310. color: #3377FF;
  311. }
  312. .blue-arr {
  313. margin-left: 10rpx;
  314. width: 8.12rpx;
  315. height: 15.62rpx;
  316. }
  317. }
  318. }
  319. }
  320. }
  321. .btn-group {
  322. display: flex;
  323. justify-content: space-between;
  324. padding: 0 25rpx;
  325. }
  326. .btn-one {
  327. justify-content: center;
  328. }
  329. }
  330. }
  331. }
  332. }
  333. </style>