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.
 
 
 
 
 
 

380 lines
11 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_Student.DepartmentId" disabled
  8. :range="dataSource.Purchase_Student.DepartmentId" title="填报部门" disabled />
  9. <l-organize-picker
  10. :value="formData.Purchase_Student.Creator" :readonly="!edit" type="user" title="填报人" readonly />
  11. <l-datetime-picker
  12. :value="formData.Purchase_Student.Createtime"
  13. disabled
  14. title="填报时间"
  15. />
  16. <l-input :value="formData.Purchase_Student.Payee" title="收款人" disabled/>
  17. <l-input :value="formData.Purchase_Student.Attachcount" title="附件张数" disabled/>
  18. <l-upload-file :value="fileList" title="附件" readonly />
  19. <l-input :value="formData.Purchase_Student.Totalamount" title="申请报账金额" disabled/>
  20. <l-input :value="formData.Purchase_Student.Approvalamount"
  21. :disabled="!isEdit('Approvalamount')" title="核准金额" @input="setValue('Approvalamount',$event)" />
  22. <view style="background-color: #fff;">
  23. <view style="line-height: 40px;font-size: 14px;padding-left: 12px;">
  24. 报账明细:
  25. </view>
  26. <next-table ref="table" :show-header="true" :columns="column" :stripe="true" :fit="false" :border="true" :data="data"
  27. :highlight="true" @currentChange="currentChange">
  28. </next-table>
  29. <l-customform-table
  30. :value="currentRowDetail" :item="Purchase_Student_Details"
  31. :edit="false" />
  32. </view>
  33. <l-workflow-action
  34. @audit="audit"
  35. @action="action"
  36. :type="type"
  37. :currentNode="currentNode"
  38. :currentTask="currentTask"
  39. />
  40. </view>
  41. <view v-if="ready && tab == 1" class="progress"><l-workflow-timeline :processList="processList" /></view>
  42. <!-- <view class="padding-sm text-grey notice-info">
  43. <view class="text-right">本页内容发布于 {{ time }}</view>
  44. <view class="text-right">{{ date }}</view>
  45. </view> -->
  46. </view>
  47. </template>
  48. <script>
  49. import moment from 'moment'
  50. import workflowFormMixins from '@/pages/nworkflow/workflow.js'
  51. export default {
  52. mixins: [workflowFormMixins],
  53. data() {
  54. return {
  55. tab:0,
  56. type:'view',
  57. currentNode:null,
  58. currentTask:null,
  59. taskId:'',
  60. processId:'',
  61. processInfo:null,
  62. processList:[],
  63. formData:{},
  64. ready: false,
  65. content: '',
  66. time: '',
  67. date: '',
  68. fileList:[],
  69. Purchase_Student_Details: {
  70. type: 'girdtable',
  71. title: '采购列表',
  72. __defaultItem__: {},
  73. fieldsData: [{
  74. field: 'Name',
  75. type: 'input',
  76. name: '采购物品名称'
  77. },
  78. {
  79. field: 'Price',
  80. type: 'input',
  81. name: '价格'
  82. },
  83. {
  84. field: 'Quantity',
  85. type: 'input',
  86. name: '采购数量'
  87. },
  88. {
  89. field: 'Unit',
  90. type: 'input',
  91. name: '单位'
  92. },
  93. {
  94. field: 'UseTo',
  95. type: 'input',
  96. name: '用途'
  97. },
  98. { field:'Spec', type:'input', name:'规格' },
  99. ]
  100. },
  101. // 数据源
  102. dataSource: {
  103. Purchase_Student: {
  104. DepartmentId: [],
  105. Status: [{
  106. text: '已提交',
  107. value: '1'
  108. }, {
  109. text: '未提交',
  110. value: '2'
  111. }],
  112. CheckStatus: [{
  113. text: '审核中',
  114. value: '1'
  115. }, {
  116. text: '审核通过',
  117. value: '2'
  118. }, {
  119. text: '',
  120. value: '草稿'
  121. }]
  122. },
  123. },
  124. // 采购数据
  125. column:[
  126. // { type:'selection', fixed:true,width:60 },
  127. // { name: 'CreatorName', label: '申请人',width:80,emptyString:'--' },
  128. { name: 'TotalAmount', label: '金额',fixed:false,width:86,emptyString:'--' },
  129. // { name: 'DepartmentName', label: '部门',fixed:false,width:200,emptyString:'--' },
  130. { name: 'Remark', label: '备注',fixed:false,width:126,emptyString:'--' },
  131. { name: 'CreateTime', label: '申请时间',width:80,emptyString:'--' },
  132. // { name: 'SubmitTime', label: '提交时间',fixed:false,width:146,emptyString:'--' },
  133. // { name: 'CheckTime', label: '审核时间',fixed:false,width:146,emptyString:'--' },
  134. ],
  135. data:[],
  136. list: [],
  137. currentRow:null,
  138. currentRowDetail:[],
  139. changeData:{},
  140. // 权限
  141. authorize:{},
  142. }
  143. },
  144. async onLoad({type}) {
  145. await this.init(type)
  146. },
  147. methods: {
  148. async init(type) {
  149. if(type){this.type = type}
  150. this.LOADING('加载中…')
  151. const noticeItem = this.GET_PARAM()
  152. this.processList = noticeItem.logList
  153. this.currentNode = noticeItem.currentNode
  154. this.currentTask = noticeItem.currentTask
  155. this.processInfo = noticeItem.processInfo
  156. this.taskId = this.currentTask.F_TaskId
  157. this.processId = this.currentTask.F_Id
  158. this.formValue = noticeItem.formValue
  159. this.scheme = noticeItem.scheme
  160. // console.log(this.currentNode.wfForms[0].authorize)
  161. // 权限
  162. if(this.currentNode.wfForms && this.currentNode.wfForms[0].authorize){
  163. let arr = Object.values(this.currentNode.wfForms[0].authorize)
  164. for (let item of arr) {
  165. this.authorize[item.fieldId] = item
  166. }
  167. }
  168. // 拉取表单数据,同时拉取所有来自数据源的选单数据
  169. await Promise.all([
  170. this.FETCH_DATASOURCE('classdata').then(data => {
  171. this.dataSource.Purchase_Student.DepartmentId = data.data.map(t => ({
  172. text: t.name,
  173. value: t.id
  174. }));
  175. }),
  176. () => {}
  177. ])
  178. await this.getFormData(this.processList[0].F_ProcessId)
  179. this.HIDE_LOADING();
  180. // this.content = this.CONVERT_HTML(noticeItem.f_content)
  181. // this.time = moment(noticeItem.f_time).format('HH : mm')
  182. // this.date = moment(noticeItem.f_time).format('YYYY年 M月 D日')
  183. // this.SET_TITLE(noticeItem.f_title)
  184. // this.HIDE_LOADING()
  185. },
  186. // 获取表单数据
  187. getFormData(ProcessId){
  188. return this.HTTP_GET("learun/adms/purchasestudentapply/shList",{ProcessId},"加载数据时出错").then(async res=>{
  189. if(res){
  190. // res.F_SourceName = res.F_SourceName&&this.GET_GLOBAL('department')[res.F_SourceName]? this.GET_GLOBAL('department')[res.F_SourceName].name : res.F_SourceName
  191. this.formData = res
  192. this.data = res.Purchase_Student_Details
  193. let fileList = await this.getFileListById(res.Purchase_Student.FilePath)
  194. if(fileList&&fileList.length){
  195. this.fileList = fileList
  196. }
  197. // this.content = res.F_NewsContent
  198. this.ready = true
  199. }
  200. })
  201. },
  202. isEdit(field){
  203. return this.authorize[field] && this.authorize[field].isEdit !== 0
  204. },
  205. // 点击某一行
  206. async currentChange(row){
  207. this.currentRow = row
  208. this.currentRowDetail = []
  209. const result = await this.HTTP_GET('learun/adms/purchasestudent/formdetail',row.purchaseid)
  210. if(!result)return
  211. this.currentRowDetail = result
  212. },
  213. // 保存表单
  214. async saveForm(){
  215. if(this.changeData.Approvalamount&&!this.checkAmt(this.changeData.Approvalamount)){
  216. this.TOAST('请输入正确的核准金额')
  217. return false
  218. }
  219. let postData = {
  220. strEntity:JSON.stringify(this.changeData),
  221. keyValue:this.formData.Purchase_Student.Id,
  222. }
  223. let res = await this.HTTP_POST('learun/adms/purchasestudentapply/save', postData, '表单提交保存失败')
  224. if(!res){
  225. this.TOAST('表单提交保存失败')
  226. return false
  227. }
  228. return true
  229. },
  230. setValue(field,value){
  231. this.$set(this.changeData,field,value)
  232. },
  233. // 校验金额
  234. checkAmt(dPrice){
  235. if(!dPrice&&dPrice!==0){
  236. return false
  237. }
  238. let num = Number(dPrice)
  239. if(!/^(\-|\+)?\d+(\.\d+)?$/.test(num)){
  240. return false
  241. }
  242. return true;
  243. },
  244. // 点击审批相关按钮
  245. async audit(action) {
  246. this.LOADING('加载中…')
  247. let res = await this.saveForm()
  248. if(!res){
  249. this.HIDE_LOADING()
  250. return
  251. }
  252. const currentTask = this.processInfo.task.find(t => t.F_NodeId === this.currentNode.id)
  253. const postData = await this.getPostData(this.formValue, this.scheme)
  254. const pageParam = {
  255. type: 'sign',
  256. processId: currentTask.F_ProcessId,
  257. taskId: currentTask.F_Id,
  258. formreq: postData.formreq,
  259. taskName: this.currentTask.F_Title,
  260. currentNode:this.currentNode,
  261. code:this.code||''
  262. }
  263. // 不是加签
  264. if (action.code !== '__sign__') {
  265. Object.assign(pageParam, action)
  266. pageParam.type = 'verify'
  267. pageParam.auditors = JSON.stringify({})
  268. pageParam.isFromSignAudit = Number(this.currentTask.F_TaskType) === 3
  269. }
  270. this.HIDE_LOADING()
  271. this.NAV_TO('/pages/nworkflow/myflow/sign', pageParam, true)
  272. },
  273. // 点击操作按钮(非审批类按钮)
  274. async action(taskType) {
  275. switch (taskType) {
  276. // 点击「催办」/「撤销流程」/「标记已阅」按钮
  277. case 'urge':
  278. case 'revoke':
  279. case 'refer':
  280. const actionText = { urge: '催办', revoke: '撤销', refer: '已阅' }[taskType]
  281. const actionUrl = { urge: '/urge', revoke: '/revoke', refer: '/refer' }[taskType]
  282. let actionData = this.processId
  283. if (taskType === 'refer') {
  284. actionData = { processId: this.processId, taskId: this.taskId }
  285. }
  286. if (!(await this.CONFIRM(`${actionText}确认`, `确定要提交${actionText}吗?`, true))) {
  287. return
  288. }
  289. this.LOADING(`提交${actionText}中…`)
  290. this.HTTP_POST(`/newwf${actionUrl}`, actionData, `提交${actionText}失败`).then(success => {
  291. this.HIDE_LOADING()
  292. if (success) {
  293. this.EMIT('task-list-change')
  294. this.TOAST(`成功提交${actionText}`, 'success')
  295. if (taskType === 'revoke') {
  296. this.NAV_BACK()
  297. }
  298. }
  299. })
  300. break
  301. // 点击「提交草稿」按钮
  302. case 'draft':
  303. this.CONFIRM('不支持此操作')
  304. return
  305. if (!(await this.CONFIRM('提交确认', '确定要提交草稿吗?', true))) {
  306. return
  307. }
  308. this.LOADING('正在提交…')
  309. const draftFormValue = this.$refs.form.getFormValue()
  310. const draftPostData = await this.getPostData(draftFormValue, this.scheme)
  311. this.HTTP_POST('/newwf​/draft', draftPostData, '提交草稿失败').then(success => {
  312. this.HIDE_LOADING()
  313. if (success) {
  314. this.EMIT('task-list-change')
  315. this.NAV_BACK()
  316. this.TOAST('草稿已保存', 'success')
  317. }
  318. })
  319. break
  320. // 点击「发起流程」按钮
  321. case 'submit':
  322. this.CONFIRM('不支持此操作')
  323. return
  324. const verifyResult = this.$refs.form.verifyValue()
  325. if (verifyResult.length > 0) {
  326. this.CONFIRM('表单验证失败', verifyResult.join('\n'))
  327. return
  328. }
  329. if (!(await this.CONFIRM('提交确认', '确定要发起流程吗?', true))) {
  330. return
  331. }
  332. this.LOADING('正在提交…')
  333. const formValue = this.$refs.form.getFormValue()
  334. const postData = await this.getPostData(formValue, this.scheme)
  335. postData.auditors = JSON.stringify({})
  336. if (this.type === 'child') {
  337. postData.parentProcessId = this.processId
  338. postData.parentTaskId = this.taskId
  339. }
  340. const errorTips = '流程发起失败'
  341. this.HTTP_POST('/newwf/createchildflow', postData, errorTips).then(success => {
  342. this.HIDE_LOADING()
  343. if (success) {
  344. this.EMIT('task-list-change')
  345. this.NAV_BACK()
  346. this.TOAST('流程发起成功', 'success')
  347. }
  348. })
  349. break
  350. default:
  351. break
  352. }
  353. },
  354. }
  355. }
  356. </script>