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.

singleFlow.vue 8.3 KiB

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