Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.
 
 
 
 
 
 

366 строки
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_Other.DepartmentId" disabled
  8. :range="dataSource.Purchase_Other.DepartmentId" title="填报部门" disabled />
  9. <l-organize-picker
  10. :value="formData.Purchase_Other.Creator" :readonly="!edit" type="user" title="填报人" readonly />
  11. <l-datetime-picker
  12. :value="formData.Purchase_Other.Createtime"
  13. disabled
  14. title="填报时间"
  15. />
  16. <l-input :value="formData.Purchase_Other.Payee" title="收款人" disabled/>
  17. <l-input :value="formData.Purchase_Other.Attachcount" title="附件张数" disabled/>
  18. <l-upload-file :value="fileList" title="附件" readonly />
  19. <l-input :value="formData.Purchase_Other.Totalamount" title="申请报账金额" disabled/>
  20. <l-input :value="formData.Purchase_Other.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_Other_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_Other_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_Other: {
  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_Other.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/purchaseotherapply/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_Other_Details
  193. let fileList = await this.getFileListById(res.Purchase_Other.FilePath)
  194. if(fileList&&fileList.length){
  195. this.fileList = [fileList[0]]
  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/purchaseother/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_Other.Id,
  222. }
  223. let res = await this.HTTP_POST('learun/adms/purchaseotherapply/save', postData, '表单提交保存失败')
  224. if(!res){
  225. this.TOAST('表单提交保存失败')
  226. return false
  227. }
  228. return true
  229. },
  230. // 点击审批相关按钮
  231. async audit(action) {
  232. this.LOADING('加载中…')
  233. let res = await this.saveForm()
  234. if(!res){
  235. this.HIDE_LOADING()
  236. return
  237. }
  238. const currentTask = this.processInfo.task.find(t => t.F_NodeId === this.currentNode.id)
  239. const postData = await this.getPostData(this.formValue, this.scheme)
  240. const pageParam = {
  241. type: 'sign',
  242. processId: currentTask.F_ProcessId,
  243. taskId: currentTask.F_Id,
  244. formreq: postData.formreq,
  245. taskName: this.currentTask.F_Title,
  246. currentNode:this.currentNode,
  247. code:this.code||''
  248. }
  249. // 不是加签
  250. if (action.code !== '__sign__') {
  251. Object.assign(pageParam, action)
  252. pageParam.type = 'verify'
  253. pageParam.auditors = JSON.stringify({})
  254. pageParam.isFromSignAudit = Number(this.currentTask.F_TaskType) === 3
  255. }
  256. this.HIDE_LOADING()
  257. this.NAV_TO('/pages/nworkflow/myflow/sign', pageParam, true)
  258. },
  259. // 点击操作按钮(非审批类按钮)
  260. async action(taskType) {
  261. switch (taskType) {
  262. // 点击「催办」/「撤销流程」/「标记已阅」按钮
  263. case 'urge':
  264. case 'revoke':
  265. case 'refer':
  266. const actionText = { urge: '催办', revoke: '撤销', refer: '已阅' }[taskType]
  267. const actionUrl = { urge: '/urge', revoke: '/revoke', refer: '/refer' }[taskType]
  268. let actionData = this.processId
  269. if (taskType === 'refer') {
  270. actionData = { processId: this.processId, taskId: this.taskId }
  271. }
  272. if (!(await this.CONFIRM(`${actionText}确认`, `确定要提交${actionText}吗?`, true))) {
  273. return
  274. }
  275. this.LOADING(`提交${actionText}中…`)
  276. this.HTTP_POST(`/newwf${actionUrl}`, actionData, `提交${actionText}失败`).then(success => {
  277. this.HIDE_LOADING()
  278. if (success) {
  279. this.EMIT('task-list-change')
  280. this.TOAST(`成功提交${actionText}`, 'success')
  281. if (taskType === 'revoke') {
  282. this.NAV_BACK()
  283. }
  284. }
  285. })
  286. break
  287. // 点击「提交草稿」按钮
  288. case 'draft':
  289. this.CONFIRM('不支持此操作')
  290. return
  291. if (!(await this.CONFIRM('提交确认', '确定要提交草稿吗?', true))) {
  292. return
  293. }
  294. this.LOADING('正在提交…')
  295. const draftFormValue = this.$refs.form.getFormValue()
  296. const draftPostData = await this.getPostData(draftFormValue, this.scheme)
  297. this.HTTP_POST('/newwf​/draft', draftPostData, '提交草稿失败').then(success => {
  298. this.HIDE_LOADING()
  299. if (success) {
  300. this.EMIT('task-list-change')
  301. this.NAV_BACK()
  302. this.TOAST('草稿已保存', 'success')
  303. }
  304. })
  305. break
  306. // 点击「发起流程」按钮
  307. case 'submit':
  308. this.CONFIRM('不支持此操作')
  309. return
  310. const verifyResult = this.$refs.form.verifyValue()
  311. if (verifyResult.length > 0) {
  312. this.CONFIRM('表单验证失败', verifyResult.join('\n'))
  313. return
  314. }
  315. if (!(await this.CONFIRM('提交确认', '确定要发起流程吗?', true))) {
  316. return
  317. }
  318. this.LOADING('正在提交…')
  319. const formValue = this.$refs.form.getFormValue()
  320. const postData = await this.getPostData(formValue, this.scheme)
  321. postData.auditors = JSON.stringify({})
  322. if (this.type === 'child') {
  323. postData.parentProcessId = this.processId
  324. postData.parentTaskId = this.taskId
  325. }
  326. const errorTips = '流程发起失败'
  327. this.HTTP_POST('/newwf/createchildflow', postData, errorTips).then(success => {
  328. this.HIDE_LOADING()
  329. if (success) {
  330. this.EMIT('task-list-change')
  331. this.NAV_BACK()
  332. this.TOAST('流程发起成功', 'success')
  333. }
  334. })
  335. break
  336. default:
  337. break
  338. }
  339. },
  340. }
  341. }
  342. </script>