mission-details.vue 11 KB

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