TaskFormDetail.vue 6.0 KB

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