mission-details.vue 11 KB

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