TaskFormDetail.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198
  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 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 if(this.formUrl.endsWith('DisposeRubbishForm')){
  87. this.form = DisposeRubbishForm
  88. }else{
  89. uni.showToast({ title: '没有关联流程表单!', icon: "none" });
  90. }
  91. }
  92. } else { // 动态表单
  93. // 读取流程表单
  94. if (this.formUrl === '/404') {
  95. uni.showToast({ title: '没有关联流程表单!', icon: "none" });
  96. } else {
  97. let data = await formService.getMobileForm(this.formUrl);
  98. // 初始化动态表单
  99. data.forEach((item)=>{
  100. item.writable = true //挂载 writable,readable,value 属性,是为了触发对这三个属性的监听
  101. item.readable = true
  102. if(this.isObjectValue(item)){
  103. item.value = null
  104. }else{
  105. item.value = ''
  106. }
  107. let input = JSON.parse(JSON.stringify(item))
  108. this.formData.push(input)
  109. })
  110. // 读取任务表单配置
  111. let res = await formService.getHistoryTaskFormData({ processInstanceId: this.procInsId, procDefId: this.procDefId, taskDefKey: this.taskDefKey })
  112. this.setData(res, 'audit')
  113. }
  114. }
  115. // 读取历史任务列表
  116. taskService.historicTaskList(this.procInsId).then((data) => {
  117. this.historicTaskList = data.reverse()
  118. })
  119. },
  120. components:{
  121. userSelect,
  122. TestActivitiLeaveForm,
  123. DisposeRubbishForm,
  124. PreviewForm
  125. },
  126. data() {
  127. return {
  128. flow: null,
  129. tabIndex: 0,
  130. form: null,
  131. formType: '',
  132. formUrl: '',
  133. taskSelectedTab: 'frist',
  134. historicTaskList: [],
  135. procDefId: '',
  136. procInsId: '',
  137. formReadOnly: false,
  138. procDefKey: '',
  139. taskId: '',
  140. formData: [],
  141. taskDefKey: '',
  142. status: '',
  143. title: '',
  144. businessId: ''
  145. }
  146. },
  147. methods:{
  148. tabSelect (index) {
  149. this.tabIndex = index;
  150. },
  151. // 为任务表单赋值
  152. setData (taskFormData, status) {
  153. this.formData.forEach((input)=>{
  154. let item = taskFormData.filter((item)=>{
  155. if(input.model === item.id){
  156. return true
  157. }else{
  158. return false
  159. }
  160. })[0]
  161. if(item){
  162. if(this.isObjectValue(input)){
  163. if(item.value && typeof item.value=== 'string'){
  164. input.value = JSON.parse(item.value)
  165. }else {
  166. input.value = item.value
  167. }
  168. }else{
  169. input.value = item.value
  170. }
  171. input.readable = item.readable
  172. input.writable = false
  173. }else{
  174. input.readable = false
  175. }
  176. })
  177. },
  178. // 判断数据类型是否是非String类型
  179. isObjectValue (input) {
  180. if(input.type === 'checkbox' ||
  181. input.type === 'slider' ||
  182. input.type === 'switch' ||
  183. input.type === 'rate' ||
  184. input.type === 'imgupload' ||
  185. input.type === 'select' && input.options.multiple ||
  186. input.type === 'fileupload'){
  187. return true
  188. }
  189. return false
  190. }
  191. }
  192. }
  193. </script>