mission-details.vue 10 KB

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