TaskFormDetail.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <template>
  2. <view>
  3. <cu-custom bgColor="bg-blue" :isBack="true">
  4. <block slot="backText">返回</block>
  5. <block slot="content">{{title}}</block>
  6. </cu-custom>
  7. <!-- 菜单 -->
  8. <view class="bg-white nav fixed flex text-center" :style="[{top:CustomBar + 'px'}]">
  9. <view class="cu-item flex-sub" :class="0==tabIndex?'text-blue cur':''" @tap="tabSelect" data-id="0">
  10. 表单信息
  11. </view>
  12. <view class="cu-item flex-sub" v-if="procInsId" :class="2==tabIndex?'text-blue cur':''" @tap="tabSelect" data-id="2">
  13. 流转记录
  14. </view>
  15. <!-- <view class="cu-item flex-sub" :class="1==tabIndex?'text-blue cur':''" @tap="tabSelect" data-id="1">
  16. 流程图
  17. </view> -->
  18. </view>
  19. <view v-show="0 === tabIndex">
  20. <scroll-view scroll-y class="page">
  21. <view class=" bg-white margin-top">
  22. <component :formReadOnly="formReadOnly" :class="formReadOnly?'readonly':''" ref="form" :businessId="businessId" :is="form"></component>
  23. <PreviewForm :formData="formData" v-if="formType !== '2'" :processDefinitionId="procDefId" :edit="false" ref="form"></PreviewForm>
  24. </view>
  25. <view class="cu-tabbar-height"></view>
  26. </scroll-view>
  27. </view>
  28. <view v-show="1 === tabIndex">
  29. <view class="padding bg-white margin-top">
  30. </view>
  31. </view>
  32. <view v-show="2 === tabIndex">
  33. <view class="padding bg-white margin-top">
  34. <view class="cu-timeline" :key="index" v-for="(act, index) in historicTaskList">
  35. <view class="cu-time">{{act.histIns.startTime |formatDate('MM-DD')}}</view>
  36. <view class="cu-item text-blue">
  37. <view class="content">
  38. <view class="cu-capsule radius">
  39. <view class="cu-tag bg-cyan">{{act.histIns.activityName}}</view>
  40. <!-- <view class="cu-tag line-cyan">{{act.histIns.activityName}}</view> -->
  41. </view>
  42. <view class="margin-top">
  43. 审批人 : {{act.assigneeName}}
  44. </view>
  45. <view class="margin-top">
  46. 办理状态 :<view class="cu-tag bg-blue">{{act.comment.status}}</view>
  47. </view>
  48. <view class="margin-top">
  49. 审批意见 : {{act.comment.message}}
  50. </view>
  51. <view class="margin-top">
  52. 开始时间 : {{act.histIns.startTime |formatDate}}
  53. </view>
  54. <view class="margin-top">
  55. 结束时间 : {{act.histIns.endTime |formatDate}}
  56. </view>
  57. <view class="margin-top">
  58. 用时 : {{act.durationTime || '0秒'}}
  59. </view>
  60. </view>
  61. </view>
  62. </view>
  63. </view>
  64. </view>
  65. </view>
  66. </template>
  67. <script>
  68. import userSelect from '@/components/user-select/user-select.vue'
  69. import PreviewForm from '../form/GenerateFlowableForm'
  70. import TestActivitiLeaveForm from '@/pages/test/activiti/TestActivitiLeaveForm.vue'
  71. import taskService from "@/api/flowable/taskService"
  72. import formService from "@/api/flowable/formService"
  73. export default {
  74. onLoad: function (option) {
  75. this.flow = JSON.parse(decodeURIComponent(option.flow));
  76. this.procDefId = this.flow.procDefId
  77. this.procDefKey = this.flow.procDefKey
  78. this.formType = this.flow.formType
  79. this.formUrl = this.flow.formUrl
  80. this.taskId = this.flow.taskId
  81. this.taskDefKey = this.flow.taskDefKey
  82. this.status = this.flow.status
  83. this.title = this.flow.formTitle
  84. this.businessId = this.flow.businessId
  85. this.procInsId = this.flow.procInsId
  86. this.formReadOnly = true
  87. },
  88. async mounted () {
  89. if (this.formType === '2') { //外置表单
  90. if (this.formUrl === '/404') {
  91. this.form = null
  92. uni.showToast({ title: '没有关联流程表单!', icon: "none" });
  93. } else {
  94. // uniapp 不支持动态组件,所以通过名称匹配决定调用的表单组件
  95. if(this.formUrl.endsWith('TestActivitiLeaveForm')){
  96. this.form = TestActivitiLeaveForm
  97. }else{
  98. uni.showToast({ title: '没有关联流程表单!', icon: "none" });
  99. }
  100. }
  101. } else { // 动态表单
  102. // 读取流程表单
  103. if (this.formUrl === '/404') {
  104. uni.showToast({ title: '没有关联流程表单!', icon: "none" });
  105. } else {
  106. let {data} = await formService.getMobileForm(this.formUrl);
  107. // 初始化动态表单
  108. data.forEach((item)=>{
  109. item.writable = true //挂载 writable,readable,value 属性,是为了触发对这三个属性的监听
  110. item.readable = true
  111. if(this.isObjectValue(item)){
  112. item.value = null
  113. }else{
  114. item.value = ''
  115. }
  116. let input = JSON.parse(JSON.stringify(item))
  117. this.formData.push(input)
  118. })
  119. // 读取任务表单配置
  120. let res = await formService.getHistoryTaskFormData({ processInstanceId: this.procInsId, procDefId: this.procDefId, taskDefKey: this.taskDefKey })
  121. this.setData(res.data, 'audit')
  122. }
  123. }
  124. // 读取历史任务列表
  125. taskService.historicTaskList(this.procInsId).then(({data}) => {
  126. this.historicTaskList = data.reverse()
  127. })
  128. },
  129. components:{
  130. userSelect,
  131. TestActivitiLeaveForm,
  132. PreviewForm
  133. },
  134. data() {
  135. return {
  136. flow: null,
  137. tabIndex: 0,
  138. form: null,
  139. formType: '',
  140. formUrl: '',
  141. taskSelectedTab: 'frist',
  142. historicTaskList: [],
  143. procDefId: '',
  144. procInsId: '',
  145. formReadOnly: false,
  146. procDefKey: '',
  147. taskId: '',
  148. formData: [],
  149. taskDefKey: '',
  150. status: '',
  151. title: '',
  152. businessId: ''
  153. }
  154. },
  155. methods:{
  156. tabSelect (e) {
  157. this.tabIndex = parseInt(e.currentTarget.dataset.id);
  158. },
  159. // 为任务表单赋值
  160. setData (taskFormData, status) {
  161. this.formData.forEach((input)=>{
  162. let item = taskFormData.filter((item)=>{
  163. if(input.model === item.id){
  164. return true
  165. }else{
  166. return false
  167. }
  168. })[0]
  169. if(item){
  170. if(this.isObjectValue(input)){
  171. if(item.value && typeof item.value=== 'string'){
  172. input.value = JSON.parse(item.value)
  173. }else {
  174. input.value = item.value
  175. }
  176. }else{
  177. input.value = item.value
  178. }
  179. input.readable = item.readable
  180. input.writable = false
  181. }else{
  182. input.readable = false
  183. }
  184. })
  185. },
  186. // 判断数据类型是否是非String类型
  187. isObjectValue (input) {
  188. if(input.type === 'checkbox' ||
  189. input.type === 'slider' ||
  190. input.type === 'switch' ||
  191. input.type === 'rate' ||
  192. input.type === 'imgupload' ||
  193. input.type === 'select' && input.options.multiple ||
  194. input.type === 'fileupload'){
  195. return true
  196. }
  197. return false
  198. }
  199. }
  200. }
  201. </script>
  202. <style>
  203. page {
  204. padding-top: 45px;
  205. }
  206. .cu-form-group .title {
  207. min-width: calc(4em + 40px);
  208. }
  209. </style>