TaskFormDetail.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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. <component :formReadOnly="formReadOnly" :class="formReadOnly?'readonly':''" ref="form" :businessId="businessId" :is="form"></component>
  13. <PreviewForm :formData="formData" v-if="formType !== '2'" :processDefinitionId="procDefId" :edit="false" ref="form"></PreviewForm>
  14. <u-gap height="40" bgColor="#fff"></u-gap>
  15. </scroll-view>
  16. </view>
  17. <view v-show="1 === tabIndex">
  18. <view class="padding">
  19. <view class="cu-timeline" :key="index" v-for="(act, index) in historicTaskList">
  20. <view class="cu-time">{{act.histIns.startTime |formatDate('MM-DD')}}</view>
  21. <view class="cu-item text-blue">
  22. <view class="content">
  23. <view class="cu-capsule radius">
  24. <view class="cu-tag bg-cyan">{{act.histIns.activityName}}</view>
  25. <!-- <view class="cu-tag line-cyan">{{act.histIns.activityName}}</view> -->
  26. </view>
  27. <view class="margin-top">
  28. 审批人 : {{act.assigneeName}}
  29. </view>
  30. <view class="margin-top">
  31. 办理状态 :<view class="cu-tag bg-blue">{{act.comment.status}}</view>
  32. </view>
  33. <view class="margin-top">
  34. 审批意见 : {{act.comment.message}}
  35. </view>
  36. <view class="margin-top">
  37. 开始时间 : {{act.histIns.startTime |formatDate}}
  38. </view>
  39. <view class="margin-top">
  40. 结束时间 : {{act.histIns.endTime |formatDate}}
  41. </view>
  42. <view class="margin-top">
  43. 用时 : {{act.durationTime || '0秒'}}
  44. </view>
  45. </view>
  46. </view>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </template>
  52. <script>
  53. import userSelect from '@/components/user-select/user-select.vue'
  54. import PreviewForm from '../form/GenerateFlowableForm'
  55. import TestActivitiLeaveForm from '@/pages/test/activiti/TestActivitiLeaveForm.vue'
  56. import DisposeRubbishForm from '@/pages/edt/DisposeRubbishFormDetail.vue'
  57. import PatrolWorkOrderForm from '@/pages/edt/PatrolWorkOrderForm.vue'
  58. import PatrolWorkOrderAuditForm from '@/pages/edt/PatrolWorkOrderAuditForm.vue'
  59. import taskService from "@/api/flowable/taskService"
  60. import formService from "@/api/flowable/formService"
  61. export default {
  62. onLoad: function (option) {
  63. this.flow = JSON.parse(decodeURIComponent(option.flow));
  64. this.procDefId = this.flow.procDefId
  65. this.procDefKey = this.flow.procDefKey
  66. this.formType = this.flow.formType
  67. this.formUrl = this.flow.formUrl
  68. this.taskId = this.flow.taskId
  69. this.taskDefKey = this.flow.taskDefKey
  70. this.status = this.flow.status
  71. this.title = this.flow.formTitle
  72. this.businessId = this.flow.businessId
  73. this.procInsId = this.flow.procInsId
  74. this.formReadOnly = true
  75. uni.setNavigationBarTitle({
  76. title: this.title
  77. });
  78. },
  79. async mounted () {
  80. if (this.formType === '2') { //外置表单
  81. if (this.formUrl === '/404') {
  82. this.form = null
  83. uni.showToast({ title: '没有关联流程表单!', icon: "none" });
  84. } else {
  85. // uniapp 不支持动态组件,所以通过名称匹配决定调用的表单组件
  86. if(this.formUrl.endsWith('TestActivitiLeaveForm')) {
  87. this.form = TestActivitiLeaveForm
  88. }else if(this.formUrl.endsWith('DisposeRubbishForm')){
  89. this.form = DisposeRubbishForm
  90. }else if(this.formUrl.endsWith('PatrolWorkOrderForm')){
  91. this.form = PatrolWorkOrderForm
  92. }else if(this.formUrl.endsWith('PatrolWorkOrderAuditForm')){
  93. this.form = PatrolWorkOrderAuditForm
  94. }else{
  95. uni.showToast({ title: '没有关联流程表单!', icon: "none" });
  96. }
  97. }
  98. } else { // 动态表单
  99. // 读取流程表单
  100. if (this.formUrl === '/404') {
  101. uni.showToast({ title: '没有关联流程表单!', icon: "none" });
  102. } else {
  103. let data = await formService.getMobileForm(this.formUrl);
  104. // 初始化动态表单
  105. data.forEach((item)=>{
  106. item.writable = true //挂载 writable,readable,value 属性,是为了触发对这三个属性的监听
  107. item.readable = true
  108. if(this.isObjectValue(item)){
  109. item.value = null
  110. }else{
  111. item.value = ''
  112. }
  113. let input = JSON.parse(JSON.stringify(item))
  114. this.formData.push(input)
  115. })
  116. // 读取任务表单配置
  117. let res = await formService.getHistoryTaskFormData({ processInstanceId: this.procInsId, procDefId: this.procDefId, taskDefKey: this.taskDefKey })
  118. this.setData(res, 'audit')
  119. }
  120. }
  121. // 读取历史任务列表
  122. taskService.historicTaskList(this.procInsId).then((data) => {
  123. this.historicTaskList = data.reverse()
  124. })
  125. },
  126. components:{
  127. userSelect,
  128. TestActivitiLeaveForm,
  129. DisposeRubbishForm,
  130. PatrolWorkOrderForm,
  131. PatrolWorkOrderAuditForm,
  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 (index) {
  157. this.tabIndex = index;
  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>