mission-details.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440
  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 class="plan-icon"
  14. :src="`/static/${i === taskStepLength ? 'check-radio' : 'check-no'}.png`">
  15. </image>
  16. <view class="line" v-show="i != taskStepLength"></view>
  17. </view>
  18. <view class="col">
  19. <view class="title">
  20. <text>{{ getContext(item, false, 'row1') }}</text>
  21. </view>
  22. <view class="sub-box">
  23. <view class="sub-title">
  24. <text>{{ getContext(item, false, 'row2') }}</text>
  25. </view>
  26. <view class="sub-title">
  27. <text>{{ item.recordTime }}</text>
  28. </view>
  29. </view>
  30. <template v-if="getContext(item, true, 'selectDetails')">
  31. <view class="link-view"
  32. v-if="ifShowStepLinkBtn(item,i)"
  33. @click="goToDetails(item, getContext(item, true, 'selectDetails'))">
  34. <text>{{ getContext(item, true, 'selectDetails').name }}</text>
  35. <image class="blue-arr" src="/static/blue-arrow.png"></image>
  36. </view>
  37. </template>
  38. </view>
  39. </view>
  40. <view :class="['btn-group', taskBtn.length === 1 ?'btn-one' : '']" v-if="missionDetails.buttonDisplayFlag == 1
  41. && missionDetails.pfmTaskCirculationList
  42. && i == missionDetails.pfmTaskCirculationList.length - 1">
  43. <template v-for="(btn, i1) in taskBtn">
  44. <tm-button :key="i1"
  45. :type="taskBtn.length === 1 ? 'default' : ( i1 === 0 ? 'pramary' : 'default')"
  46. :btnText="btn.name" @btnClick="clickBtn(item, btn)" />
  47. </template>
  48. </view>
  49. </template>
  50. </view>
  51. </view>
  52. </scroll-view>
  53. <view class="bottomBtn" @click="goBack">返回改善任务列表</view>
  54. </view>
  55. </template>
  56. <script>
  57. // 改善任务
  58. import {
  59. mapState
  60. } from "vuex";
  61. import listItem from '../mission/components/list-item.vue';
  62. import taskTypeList from './setting.js';
  63. import pdcaSetting from './pdcaSetting.js'
  64. export default {
  65. computed: {
  66. ...mapState({
  67. missionDetails: state => state.mission.missionDetails
  68. }),
  69. // 进度长度
  70. taskStepLength() {
  71. return (this.missionDetails.pfmTaskCirculationList || []).length - 1;
  72. },
  73. // 获取底部按钮
  74. taskBtn() {
  75. const {
  76. buttonDisplayFlag,
  77. pfmTaskCirculationList,
  78. taskType,
  79. checkResult
  80. } = this.missionDetails;
  81. if (buttonDisplayFlag == 1 && pfmTaskCirculationList && pfmTaskCirculationList.length > 0) {
  82. let task = null;
  83. if (taskType == 1 || taskType == 3) { // 状态为1, 和3比较特殊,需要再比较checkResult
  84. task = taskTypeList.find(item => (item.taskType == taskType && item.checkResult == checkResult));
  85. } else {
  86. task = taskTypeList.find(item => item.taskType == taskType);
  87. }
  88. console.log({task});
  89. return task ? task.btnList : []
  90. } else {
  91. return [];
  92. }
  93. }
  94. },
  95. data() {
  96. return {
  97. // 任务id
  98. taskId: '',
  99. botBtnText: '',
  100. // 跳转详情信息,
  101. details:{},
  102. linkTaskDetails: null,
  103. ptName:''
  104. }
  105. },
  106. onLoad(option) {
  107. const {
  108. taskId,
  109. pathName
  110. } = option;
  111. this.taskId = taskId;
  112. //pathName == 'missionDetails' ? '返回改善任务列表' : '返回改善消息列表';
  113. },
  114. created() {
  115. this.getMissionDetails();
  116. },
  117. methods: {
  118. ifShowStepLinkBtn(item,i){
  119. //当为改善回复且已完成且是最后一步时不展示
  120. return !(this.missionDetails.endFlag == true && this.missionDetails.checkResult == 2 && i == (this.missionDetails.pfmTaskCirculationList.length) - 1)
  121. },
  122. goBack() {
  123. //解决page页面栈的重复,同伙返回道该页面
  124. const pages = getCurrentPages();
  125. for(let i = pages.length - 1;i>=0;i--){
  126. if(pages[i].route != pages[pages.length - 1].route){
  127. uni.navigateBack({
  128. delta:(pages.length - 1) - i
  129. });
  130. return;
  131. }
  132. }
  133. },
  134. // 获取改善任务列表
  135. getMissionDetails(data) {
  136. this.$store.dispatch({
  137. type: 'mission/commActions',
  138. payload: {
  139. key: "getMissionDetails",
  140. data: {
  141. taskId: this.taskId
  142. }
  143. }
  144. }).then((data)=>{
  145. // console.log({'details':data});
  146. if(data){
  147. this.details = data;
  148. }
  149. })
  150. },
  151. // 点击按钮
  152. clickBtn(currentInfo, btnInfo) {
  153. console.log({currentInfo, btnInfo});
  154. if (btnInfo.componentName) { // 有组件名,则跳转页面
  155. if (btnInfo.componentName === 'pdca') {
  156. const {
  157. taskType,
  158. needApproveFlag
  159. } = this.missionDetails;
  160. // needApproveFlag: true 需要审核(p)只显示p
  161. if (taskType === 8) {
  162. btnInfo = {
  163. ...btnInfo,
  164. ...pdcaSetting['pdcaBtnInfo'],
  165. pDisabled: true // plan内容禁用
  166. };
  167. } else if (taskType === 11) {
  168. btnInfo = {
  169. ...btnInfo,
  170. ...pdcaSetting[needApproveFlag ? 'pdcaBtnInfo' : 'pdcaBtnInfo2'],
  171. pDisabled: needApproveFlag // plan内容是否禁用取决于needApproveFlag
  172. };
  173. } else if (taskType === 13) { // 制定改善方案p中(需要回显暂存过的数据)
  174. btnInfo = {
  175. ...btnInfo,
  176. ...pdcaSetting['editPBtnInfo'],
  177. isEdit: true
  178. };
  179. } else if (taskType === 15) { // 制定改善方案pdca中(需要回显暂存过的数据)
  180. btnInfo = {
  181. ...btnInfo,
  182. ...pdcaSetting['editPdcaBtnInfo'],
  183. isEdit: true,
  184. pDisabled: needApproveFlag
  185. };
  186. } else {
  187. // taskType === 4 || taskType === 6 || taskType === 7 || taskType === 9
  188. btnInfo = {
  189. ...btnInfo,
  190. ...pdcaSetting[needApproveFlag ? 'pBtnInfo' : 'pdcaBtnInfo2']
  191. };
  192. }
  193. }
  194. uni.navigateTo({
  195. url: `/pages/mission-action/mission-action?ifSetImproveEmp=${this.missionDetails.improveEmpId}&details=${encodeURIComponent(JSON.stringify({...currentInfo, ...btnInfo}))}&improveType=${this.details.improveType}`
  196. });
  197. } else { // 直接调接口
  198. let requestParams = {
  199. improveType:this.missionDetails.improveType
  200. };
  201. btnInfo.params.map(item => {
  202. if (item.valueKey) {
  203. requestParams[item.paramsKey] = (
  204. item.isOutvalueKey ?
  205. this.missionDetails :
  206. currentInfo
  207. )[item.valueKey];
  208. } else if (item.value) {
  209. requestParams[item.paramsKey] = item.value;
  210. }
  211. })
  212. this.comTaskCirculation(requestParams);
  213. }
  214. },
  215. // 查看详情
  216. goToDetails(currentInfo, detailInfo) {
  217. console.log({currentInfo, detailInfo});
  218. if (detailInfo.navigateUrl) { // 跳转其他页面(如查核项详情) 目前hasAnyData都为false
  219. const {
  220. navigateUrl,
  221. key,
  222. isOutvalueKey,
  223. hasAnyData
  224. } = detailInfo;
  225. uni.navigateTo({
  226. url: `${detailInfo.navigateUrl}?id=${(isOutvalueKey ? this.missionDetails : currentInfo)[detailInfo.key]}&checkPointId=${this.missionDetails.checkPointId}&improveType=${this.details.improveType}`
  227. });
  228. } else {
  229. uni.navigateTo({
  230. url: `/pages/mission-action/mission-action?details=${encodeURIComponent(JSON.stringify({...currentInfo, ...detailInfo}))}&improveType=${this.details.improveType}`
  231. });
  232. }
  233. },
  234. /***
  235. * 解析显示对应的内容
  236. * @param {Object} obj 当前遍历的任务
  237. * @param {Boolean} isLink 是否需要跳转页面(查看详情)
  238. * @param {String} rowKey 任务流程中的key
  239. */
  240. getContext(obj, isLink, rowKey) {
  241. let currentTypeTask = null;
  242. if (obj.taskType == 1) {
  243. const {
  244. checkResult
  245. } = this.missionDetails;
  246. currentTypeTask = taskTypeList.find(item => (item.taskType == obj.taskType && item.checkResult ==
  247. checkResult)) || {};
  248. } else {
  249. currentTypeTask = taskTypeList.find(item => item.taskType == obj.taskType) || {};
  250. }
  251. if (isLink) {
  252. return currentTypeTask[rowKey];
  253. } else {
  254. const {
  255. hasJoin,
  256. name,
  257. key,
  258. isOutvalueKey
  259. } = currentTypeTask[rowKey] || {};
  260. if (hasJoin) { // 需要删除*并替换
  261. return name ? name.replace(/x/g, (isOutvalueKey ? this.missionDetails : obj)[key] || '') : ''
  262. } else {
  263. return name || '';
  264. }
  265. }
  266. checkResult='';
  267. },
  268. // 公共改善任务接口
  269. comTaskCirculation(data) {
  270. this.$store.dispatch({
  271. type: 'mission/commActions',
  272. payload: {
  273. key: "comTaskCirculation",
  274. data
  275. }
  276. }).then(data1 => {
  277. if (data1) {
  278. this.getMissionDetails();
  279. }
  280. });
  281. }
  282. },
  283. components: {
  284. listItem
  285. }
  286. }
  287. </script>
  288. <style lang="less">
  289. .mission-details-page {
  290. height: 100%;
  291. padding-top: 15rpx;
  292. .bottomBtn {
  293. position: fixed;
  294. bottom: 0;
  295. width: 100%;
  296. height: 75rpx;
  297. line-height: 75rpx;
  298. text-align: center;
  299. font-size: 22.5rpx;
  300. font-family: SourceHanSansCN-Normal, SourceHanSansCN;
  301. font-weight: 400;
  302. color: #FFFFFF;
  303. background: #3377FF;
  304. }
  305. .scroll-y {
  306. height: 100%;
  307. padding-bottom: 87.5rpx;
  308. .mission-plan {
  309. .label {
  310. margin-top: 25rpx;
  311. margin-bottom: 15rpx;
  312. height: 20rpx;
  313. line-height: 20rpx;
  314. padding-left: 25rpx;
  315. text {
  316. font-size: 20rpx;
  317. color: #666F80;
  318. }
  319. }
  320. .plan-box {
  321. padding: 25rpx;
  322. background-color: #fff;
  323. .row {
  324. display: flex;
  325. .col {
  326. .title {
  327. display: flex;
  328. align-items: center;
  329. margin-bottom: 15rpx;
  330. height: 25rpx;
  331. >text {
  332. font-size: 22.5rpx;
  333. color: #292C33;
  334. }
  335. }
  336. .sub-box {
  337. display: flex;
  338. flex-direction: column;
  339. .sub-title {
  340. display: flex;
  341. align-items: center;
  342. margin-bottom: 15rpx;
  343. height: 20rpx;
  344. &:last-child {
  345. margin-bottom: 34.37rpx;
  346. }
  347. >text {
  348. font-size: 20rpx;
  349. color: #666E80;
  350. }
  351. }
  352. }
  353. &:first-child {
  354. display: flex;
  355. flex-direction: column;
  356. align-items: center;
  357. margin-right: 15rpx;
  358. width: 25rpx;
  359. .plan-icon {
  360. margin-bottom: 17.5rpx;
  361. width: 25rpx;
  362. height: 25rpx;
  363. }
  364. .line {
  365. width: 5rpx;
  366. height: 75rpx;
  367. background-color: #E6EAF2;
  368. }
  369. }
  370. &:last-child {
  371. position: relative;
  372. flex: 1;
  373. .link-view {
  374. position: absolute;
  375. top: 0;
  376. right: 0;
  377. >text {
  378. font-size: 17.5rpx;
  379. color: #3377FF;
  380. }
  381. .blue-arr {
  382. margin-left: 10rpx;
  383. width: 8.12rpx;
  384. height: 15.62rpx;
  385. }
  386. }
  387. }
  388. }
  389. }
  390. .btn-group {
  391. display: flex;
  392. justify-content: space-between;
  393. padding: 0 25rpx;
  394. }
  395. .btn-one {
  396. justify-content: center;
  397. }
  398. }
  399. }
  400. }
  401. }
  402. </style>