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.
 
 
 
 
 
 

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