detail.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  1. <template>
  2. <view class="jnpf-wrap personalData">
  3. <view class="u-p-l-20 u-p-r-20 content">
  4. <u-form :model="dataForm" :errorType="['toast']" label-width="180" label-align="left" ref="dataForm">
  5. <u-form-item :label="titleList[config?.current]" prop='toUserId' required>
  6. <view class="txt">
  7. {{dataForm.userName}}
  8. </view>
  9. </u-form-item>
  10. <u-form-item v-if="config.current == 0 || config.current == 2">
  11. <view class="u-flex tag-box">
  12. <view v-for="(item,index) in infoList" :key="index" size="mini">{{item.toUserName}}<u-tag
  13. class="u-m-l-8" size="mini"
  14. :type="item.status=== 0?'info':item.status=== 1?'success':'error'"
  15. :text="item.status === 0 ? '待确认' : item.status === 1 ? '已接受' : '已拒绝'" /></view>
  16. </view>
  17. </u-form-item>
  18. <u-form-item :label="config.current == 2 ? '代理流程' : '委托流程'">
  19. <view class="txt">{{dataForm.flowName}}</view>
  20. </u-form-item>
  21. <u-form-item label="开始时间" prop='startTime' required>
  22. <view class="txt">
  23. {{$u.timeFormat(dataForm.startTime,'yyyy-mm-dd hh:MM:ss')}}
  24. </view>
  25. </u-form-item>
  26. <u-form-item label="结束时间" prop='endTime' required>
  27. <view class="txt">
  28. {{$u.timeFormat(dataForm.endTime,'yyyy-mm-dd hh:MM:ss')}}
  29. </view>
  30. </u-form-item>
  31. <u-form-item label="委托说明">
  32. <u-input input-align='right' v-model="dataForm.description" type="textarea" placeholder="请输入"
  33. disabled />
  34. </u-form-item>
  35. </u-form>
  36. </view>
  37. <view class="flowBefore-actions" v-if="config.confirmStatus != 1 && config.status != 2">
  38. <u-button class="buttom-btn" type="primary" @click.stop="jumpForm"
  39. v-if="isEdit">{{$t('common.editText')}}</u-button>
  40. <template v-if='isAccept'>
  41. <u-button class="buttom-btn" type="primary" @click.stop="getResult('accept')">接受</u-button>
  42. <u-button class="buttom-btn" @click="getResult('refuse')" type="error">拒绝</u-button>
  43. </template>
  44. <u-button class="buttom-btn" type="primary" @click.stop="entrustStop" v-if="isStop">终止</u-button>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. entrustStop,
  51. getPrincipalDetails,
  52. entrustHandle,
  53. FlowDelegateInfo
  54. } from '@/api/workFlow/entrust.js'
  55. export default {
  56. data() {
  57. const data = {
  58. dataForm: {
  59. id: '',
  60. userId: '',
  61. toUserId: [],
  62. flowId: [],
  63. description: '',
  64. startTime: '',
  65. endTime: '',
  66. flowName: '',
  67. toUserName: '',
  68. type: undefined,
  69. },
  70. config: {},
  71. infoList: [],
  72. titleList: ['受委托人', '委托人', '代理人', '被代理人'],
  73. }
  74. return data
  75. },
  76. computed: {
  77. isAccept() {
  78. if (this.config.current == 1 && this.config.confirmStatus == 2) return false
  79. if (this.config.current == 0 || this.config.current == 2) return false
  80. if (this.config.status == 0 || this.config.status == 1) return true
  81. return false
  82. },
  83. isStop() {
  84. return (this.config.current == 0 || this.config.current == 2) && this.config.status == 1
  85. },
  86. isEdit() {
  87. return (this.config.current == 0 || this.config.current == 2) && this.config.status == 0
  88. }
  89. },
  90. onShow() {
  91. uni.$on('refreshDetail', () => {
  92. this.flowDelegateInfo()
  93. })
  94. },
  95. onUnload() {
  96. uni.$emit('refresh')
  97. uni.$off('refreshDetail')
  98. },
  99. onLoad(e) {
  100. this.config = JSON.parse(decodeURIComponent(e.data));
  101. if (this.config) this.init()
  102. },
  103. methods: {
  104. flowDelegateInfo() {
  105. FlowDelegateInfo(this.config.id).then(res => {
  106. this.dataForm = res.data || {}
  107. this.dataForm.flowId = this.dataForm.flowId ? this.dataForm.flowId.split(",") : [];
  108. this.config = {
  109. ...this.config,
  110. ...this.dataForm
  111. }
  112. if (this.dataForm.id) {
  113. if (this.config.current == 0 || this.config.current == 2) this.getPrincipalDetails()
  114. }
  115. })
  116. },
  117. init() {
  118. this.dataForm.id = this.config.id || ''
  119. this.dataForm.userName = this.config.userName
  120. this.dataForm.flowName = this.config.flowName
  121. this.dataForm.description = this.config.description
  122. this.dataForm.startTime = this.config.startTime
  123. this.dataForm.endTime = this.config.endTime
  124. if (this.dataForm.id) {
  125. if (this.config.current == 1) this.dataForm = this.config || {}
  126. if (this.config.current == 0 || this.config.current == 2) this.getPrincipalDetails()
  127. }
  128. },
  129. getPrincipalDetails() {
  130. getPrincipalDetails(this.dataForm.id).then(res => {
  131. this.infoList = res.data || []
  132. this.dataForm.userName = this.infoList.map(o => o.toUserName).join()
  133. })
  134. },
  135. entrustStop() {
  136. let currTime = Math.round(new Date())
  137. uni.showModal({
  138. title: '提示',
  139. content: '结束后,流程不再进行委托!',
  140. success: (res) => {
  141. if (res.confirm) {
  142. entrustStop(this.dataForm.id).then(res => {
  143. this.dataForm.endTime = currTime
  144. uni.$emit('refresh')
  145. uni.navigateBack()
  146. })
  147. }
  148. }
  149. })
  150. },
  151. getResult(entrustType) {
  152. let data = {
  153. 'type': entrustType === 'accept' ? 1 : 2
  154. }
  155. entrustHandle(this.dataForm.id, data).then(res => {
  156. uni.$emit('refresh')
  157. uni.navigateBack()
  158. })
  159. },
  160. jumpForm() {
  161. let isEdit = this.infoList.some(o => o.status == 1)
  162. if (isEdit) return this.$u.toast("已有人接受,不可编辑");
  163. uni.navigateTo({
  164. url: `/pages/my/entrustAgent/form?data=${encodeURIComponent(JSON.stringify(this.config))}`
  165. });
  166. }
  167. }
  168. }
  169. </script>
  170. <style lang="scss">
  171. page {
  172. background-color: #f0f2f6;
  173. }
  174. .content {
  175. background-color: #fff;
  176. :deep(.u-form-item) {
  177. min-height: 112rpx;
  178. }
  179. .u-form {
  180. padding: 0;
  181. }
  182. .tag-box {
  183. flex-wrap: wrap;
  184. justify-content: space-between;
  185. width: 100%;
  186. }
  187. .txt {
  188. text-align: right;
  189. width: 100%;
  190. }
  191. }
  192. </style>