You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

257 lines
7.8 KiB

  1. <template>
  2. <view id="notice" class="page">
  3. <!-- 顶部页签 -->
  4. <l-nav v-model="tab" :items="['表单信息', '流程信息']" type="flex" class="solid-bottom" />
  5. <view v-if="ready && tab == 0">
  6. <l-organize-picker
  7. :value="formData.Purchase_Travel.CreatorId"
  8. type="user"
  9. title="申请人"
  10. readonly
  11. />
  12. <l-input :value="formData.Purchase_Travel.TravelAddress" title="出差地址" disabled/>
  13. <l-input :value="formData.Purchase_Travel.Traveler" title="出差人员" disabled/>
  14. <l-textarea
  15. :value="formData.Purchase_Travel.Follows"
  16. readonly
  17. title="随行人员"
  18. />
  19. <l-datetime-picker
  20. :value="formData.Purchase_Travel.Starttime"
  21. disabled
  22. title="开始时间"
  23. />
  24. <l-datetime-picker
  25. :value="formData.Purchase_Travel.Endtime"
  26. disabled
  27. title="结束时间"
  28. />
  29. <l-textarea
  30. :value="formData.Purchase_Travel.Reason"
  31. readonly
  32. title="出差原因"
  33. />
  34. <l-upload-file
  35. :value="fileList"
  36. readonly
  37. title="附件"
  38. />
  39. <l-workflow-action
  40. @audit="audit"
  41. @action="action"
  42. :type="type"
  43. :currentNode="currentNode"
  44. :currentTask="currentTask"
  45. />
  46. </view>
  47. <view v-if="ready && tab == 1" class="progress"><l-workflow-timeline :processList="processList" /></view>
  48. <!-- <view class="padding-sm text-grey notice-info">
  49. <view class="text-right">本页内容发布于 {{ time }}</view>
  50. <view class="text-right">{{ date }}</view>
  51. </view> -->
  52. </view>
  53. </template>
  54. <script>
  55. import moment from 'moment'
  56. import workflowFormMixins from '@/pages/nworkflow/workflow.js'
  57. export default {
  58. mixins: [workflowFormMixins],
  59. data() {
  60. return {
  61. tab:0,
  62. type:'view',
  63. currentNode:null,
  64. currentTask:null,
  65. taskId:'',
  66. processId:'',
  67. processInfo:null,
  68. processList:[],
  69. formData:{},
  70. ready: false,
  71. content: '',
  72. time: '',
  73. date: '',
  74. fileList:[],
  75. // 数据源
  76. dataSource: {
  77. Purchase_Travel: {
  78. DepartmentId:[],
  79. Status: [{text:'已提交',value:'1'},{text:'未提交',value:'2'}],
  80. CheckStatus:[{text:'审核中',value:'1'},{text:'审核通过',value:'2'},{text:'',value:'草稿'}]
  81. },
  82. }
  83. }
  84. },
  85. async onLoad({type}) {
  86. await this.init(type)
  87. },
  88. methods: {
  89. async init(type) {
  90. if(type){this.type = type}
  91. this.LOADING('加载中…')
  92. const noticeItem = this.GET_PARAM()
  93. this.processList = noticeItem.logList
  94. this.currentNode = noticeItem.currentNode
  95. this.currentTask = noticeItem.currentTask
  96. this.processInfo = noticeItem.processInfo
  97. this.taskId = this.currentTask.F_TaskId
  98. this.processId = this.currentTask.F_Id
  99. this.formValue = noticeItem.formValue
  100. this.scheme = noticeItem.scheme
  101. // 拉取表单数据,同时拉取所有来自数据源的选单数据
  102. await Promise.all([
  103. this.FETCH_DATASOURCE('classdata').then(data => {
  104. this.dataSource.Purchase_Travel.DepartmentId = data.data.map(t => ({
  105. text: t.name,
  106. value: t.id
  107. }));
  108. }),
  109. () => {}
  110. ])
  111. await this.getFormData(this.processList[0].F_ProcessId)
  112. this.HIDE_LOADING();
  113. // this.content = this.CONVERT_HTML(noticeItem.f_content)
  114. // this.time = moment(noticeItem.f_time).format('HH : mm')
  115. // this.date = moment(noticeItem.f_time).format('YYYY年 M月 D日')
  116. // this.SET_TITLE(noticeItem.f_title)
  117. // this.HIDE_LOADING()
  118. },
  119. // 获取表单数据
  120. getFormData(ProcessId){
  121. return this.HTTP_GET("learun/adms/purchasetravel/shList",{ProcessId},"加载数据时出错").then(async res=>{
  122. if(res){
  123. // res.F_SourceName = res.F_SourceName&&this.GET_GLOBAL('department')[res.F_SourceName]? this.GET_GLOBAL('department')[res.F_SourceName].name : res.F_SourceName
  124. this.formData = res
  125. let fileList = await this.getFileListById(res.Purchase_Travel.FilePath)
  126. if(fileList&&fileList.length){
  127. this.fileList = fileList
  128. }
  129. // this.content = res.F_NewsContent
  130. this.ready = true
  131. }
  132. })
  133. },
  134. // 点击审批相关按钮
  135. async audit(action) {
  136. this.LOADING('加载中…')
  137. const currentTask = this.processInfo.task.find(t => t.F_NodeId === this.currentNode.id)
  138. const postData = await this.getPostData(this.formValue, this.scheme)
  139. const pageParam = {
  140. type: 'sign',
  141. processId: currentTask.F_ProcessId,
  142. taskId: currentTask.F_Id,
  143. formreq: postData.formreq,
  144. taskName: this.currentTask.F_Title,
  145. currentNode:this.currentNode,
  146. code:this.code||''
  147. }
  148. // 不是加签
  149. if (action.code !== '__sign__') {
  150. Object.assign(pageParam, action)
  151. pageParam.type = 'verify'
  152. pageParam.auditors = JSON.stringify({})
  153. pageParam.isFromSignAudit = Number(this.currentTask.F_TaskType) === 3
  154. }
  155. this.HIDE_LOADING()
  156. this.NAV_TO('/pages/nworkflow/myflow/sign', pageParam, true)
  157. },
  158. // 点击操作按钮(非审批类按钮)
  159. async action(taskType) {
  160. switch (taskType) {
  161. // 点击「催办」/「撤销流程」/「标记已阅」按钮
  162. case 'urge':
  163. case 'revoke':
  164. case 'refer':
  165. const actionText = { urge: '催办', revoke: '撤销', refer: '已阅' }[taskType]
  166. const actionUrl = { urge: '/urge', revoke: '/revoke', refer: '/refer' }[taskType]
  167. let actionData = this.processId
  168. if (taskType === 'refer') {
  169. actionData = { processId: this.processId, taskId: this.taskId }
  170. }
  171. if (!(await this.CONFIRM(`${actionText}确认`, `确定要提交${actionText}吗?`, true))) {
  172. return
  173. }
  174. this.LOADING(`提交${actionText}中…`)
  175. this.HTTP_POST(`/newwf${actionUrl}`, actionData, `提交${actionText}失败`).then(success => {
  176. this.HIDE_LOADING()
  177. if (success) {
  178. this.EMIT('task-list-change')
  179. this.TOAST(`成功提交${actionText}`, 'success')
  180. if (taskType === 'revoke') {
  181. this.NAV_BACK()
  182. }
  183. }
  184. })
  185. break
  186. // 点击「提交草稿」按钮
  187. case 'draft':
  188. this.CONFIRM('不支持此操作')
  189. return
  190. if (!(await this.CONFIRM('提交确认', '确定要提交草稿吗?', true))) {
  191. return
  192. }
  193. this.LOADING('正在提交…')
  194. const draftFormValue = this.$refs.form.getFormValue()
  195. const draftPostData = await this.getPostData(draftFormValue, this.scheme)
  196. this.HTTP_POST('/newwf​/draft', draftPostData, '提交草稿失败').then(success => {
  197. this.HIDE_LOADING()
  198. if (success) {
  199. this.EMIT('task-list-change')
  200. this.NAV_BACK()
  201. this.TOAST('草稿已保存', 'success')
  202. }
  203. })
  204. break
  205. // 点击「发起流程」按钮
  206. case 'submit':
  207. this.CONFIRM('不支持此操作')
  208. return
  209. const verifyResult = this.$refs.form.verifyValue()
  210. if (verifyResult.length > 0) {
  211. this.CONFIRM('表单验证失败', verifyResult.join('\n'))
  212. return
  213. }
  214. if (!(await this.CONFIRM('提交确认', '确定要发起流程吗?', true))) {
  215. return
  216. }
  217. this.LOADING('正在提交…')
  218. const formValue = this.$refs.form.getFormValue()
  219. const postData = await this.getPostData(formValue, this.scheme)
  220. postData.auditors = JSON.stringify({})
  221. if (this.type === 'child') {
  222. postData.parentProcessId = this.processId
  223. postData.parentTaskId = this.taskId
  224. }
  225. const errorTips = '流程发起失败'
  226. this.HTTP_POST('/newwf/createchildflow', postData, errorTips).then(success => {
  227. this.HIDE_LOADING()
  228. if (success) {
  229. this.EMIT('task-list-change')
  230. this.NAV_BACK()
  231. this.TOAST('流程发起成功', 'success')
  232. }
  233. })
  234. break
  235. default:
  236. break
  237. }
  238. },
  239. }
  240. }
  241. </script>