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.
 
 
 
 
 
 

636 lines
20 KiB

  1. <template>
  2. <view class="page">
  3. <view v-if="ready">
  4. <l-select @input="setValue('Purchase_Service.DepartmentId', $event)"
  5. :value="getValue('Purchase_Service.DepartmentId')" :disabled="!edit"
  6. :range="dataSource.Purchase_Service.DepartmentId" title="填报部门" required disabled />
  7. <l-organize-picker @input="setValue('Purchase_Service.Creator', $event)"
  8. :value="getValue('Purchase_Service.Creator')" :readonly="!edit" type="user" title="填报人" required readonly />
  9. <l-datetime-picker
  10. @input="setValue('Purchase_Service.Createtime', $event)"
  11. :value="getValue('Purchase_Service.Createtime')"
  12. disabled
  13. title="填报时间"
  14. />
  15. <l-input @input="setValue('Purchase_Service.Payee', $event)" :value="getValue('Purchase_Service.Payee')" title="收款人" required :disabled="!edit"/>
  16. <l-input @input="setValue('Purchase_Service.Attachcount', $event)" :value="getValue('Purchase_Service.Attachcount')" title="附件张数" :disabled="!edit"/>
  17. <l-upload-file @input="setValue('Purchase_Service.FilePath', $event)" :value="getValue('Purchase_Service.FilePath')"
  18. tableName="Purchase_Service" fieldName="FilePath" title="附件" :number="9" :readonly="!edit" />
  19. <l-input @input="setValue('Purchase_Service.Totalamount', $event)" :value="getValue('Purchase_Service.Totalamount')" title="申请报账金额" required :disabled="!edit"/>
  20. <!-- <l-textarea @input="setValue('Purchase_Service.Remark', $event)" :value="getValue('Purchase_Service.Remark')"
  21. :readonly="!edit" title="备注" /> -->
  22. <!-- <l-select
  23. @input="setValue('Purchase_Service.Status', $event)"
  24. :value="getValue('Purchase_Service.Status')"
  25. :disabled="!edit"
  26. :range="dataSource.Purchase_Service.Status"
  27. title="是否提交"
  28. />
  29. <l-datetime-picker
  30. @input="setValue('Purchase_Service.SubmitTime', $event)"
  31. :value="getValue('Purchase_Service.SubmitTime')"
  32. :disabled="!edit"
  33. title="提交时间"
  34. /> -->
  35. <!-- <l-select
  36. @input="setValue('Purchase_Service.CheckStatus', $event)"
  37. :value="getValue('Purchase_Service.CheckStatus')"
  38. :disabled="!edit"
  39. :range="dataSource.Purchase_Service.CheckStatus"
  40. title="审核状态"
  41. />
  42. <l-datetime-picker
  43. @input="setValue('Purchase_Service.CheckTime', $event)"
  44. :value="getValue('Purchase_Service.CheckTime')"
  45. :disabled="!edit"
  46. title="审核时间"
  47. />
  48. <l-organize-picker
  49. @input="setValue('Purchase_Service.CheckUserId', $event)"
  50. :value="getValue('Purchase_Service.CheckUserId')"
  51. :readonly="!edit"
  52. type="user"
  53. title="审核人"
  54. /> -->
  55. <l-input @input="setValue('Purchase_Service.Approvalamount', $event)" :value="getValue('Purchase_Service.Approvalamount')"
  56. :disabled="!edit||!isEdit('Approvalamount')" title="核准金额" />
  57. <view style="background-color: #fff;">
  58. <view style="line-height: 40px;font-size: 14px;padding-left: 12px;">
  59. 报账明细:
  60. </view>
  61. <view v-if="edit" class="customlist-banner-action" style="display: flex;">
  62. <view
  63. @click="detailAdd"
  64. class="customlist-banner-action-btn line-blue text-sm"
  65. style="border: currentColor 1px solid;border-radius: 4px;margin: 8px;padding: 2px 4px;">
  66. <l-icon type="add" />
  67. 新增
  68. </view>
  69. <view
  70. @click="detailDelete"
  71. class="customlist-banner-action-btn line-red text-sm"
  72. style="border: currentColor 1px solid;border-radius: 4px;margin: 8px;padding: 2px 4px;">
  73. <l-icon type="delete" />
  74. 删除
  75. </view>
  76. </view>
  77. <next-table ref="table" :show-header="true" :columns="column" :stripe="true" :fit="false" :border="true" :data="data"
  78. :highlight="true" @currentChange="currentChange">
  79. </next-table>
  80. <l-customform-table
  81. :value="currentRowDetail" :item="Purchase_Service_Details"
  82. :edit="false" />
  83. </view>
  84. </view>
  85. <!-- 指派审核人弹窗 -->
  86. <l-modal v-model="modal" @close="reviewer = ''" title="指派审核人">
  87. <l-checkbox-picker @input="(e)=>{reviewer = e}" :value="reviewer" :readonly="false" :range="reviewerList"
  88. required title="审核人" />
  89. <l-button @click="userAssign" color="blue" class="block" block>确定指派</l-button>
  90. <l-button @click="()=>{modal = false;reviewer = ''}" line="blue" class="block margin-top-sm" block>取消</l-button>
  91. </l-modal>
  92. <view v-if="ready && current.Purchase_Service && current.Purchase_Service.status != '1'" class="bg-white margin-tb padding" style="padding-top: 0; overflow: hidden;">
  93. <l-button v-if="edit" @click="action('save')" size="lg" color="green" class="block margin-top" block>
  94. 保存
  95. </l-button>
  96. <l-button v-if="edit" @click="action('save',true)" size="lg" color="orange" class="block margin-top" block>
  97. 保存并提交
  98. </l-button>
  99. <!-- <l-button v-if="!edit && mode !== 'create'" @click="action('edit')" size="lg" line="orange" class="block margin-top" block>
  100. 编辑本页
  101. </l-button>
  102. <l-button v-if="edit && mode !== 'create'" @click="action('reset')" size="lg" line="red" class="block margin-top" block>
  103. 取消编辑
  104. </l-button>
  105. <l-button v-if="!edit && mode !== 'create'" @click="action('delete')" size="lg" line="red" class="block margin-top" block>
  106. 删除
  107. </l-button> -->
  108. </view>
  109. </view>
  110. </template>
  111. <script>
  112. /*
  113. * 版 本 Learun-ADMS V7.0.3 力软敏捷开发框架(http://www.learun.cn)
  114. * Copyright (c) 2013-2020 上海力软信息技术有限公司
  115. * 创建人:超级管理员
  116. * 日 期:2020-10-20 09:25
  117. * 描 述:活动安排
  118. */
  119. /**
  120. * 本段代码由移动端代码生成器输出,移动端须 2.2.0 版本及以上可以使用
  121. * 请在移动端 /pages.json 中的 pages 字段中添加一条记录:
  122. * { "path": "pages/PersonnelManagement/BookBorrow/single", "style": { "navigationBarTitleText": "表单详情页" } }
  123. *
  124. * (navigationBarTitleText 字段为本页面的标题文本,可以修改)
  125. * (必须自行操作该步骤,力软代码生成器不会自动帮您修改 /pages.json 文件)
  126. */
  127. import get from 'lodash/get'
  128. import set from 'lodash/set'
  129. import moment from 'moment'
  130. import customPageMixins from '@/common/custompage.js'
  131. import workflowFormMixins from '@/pages/nworkflow/workflow.js'
  132. export default {
  133. mixins: [workflowFormMixins,customPageMixins,],
  134. data() {
  135. return {
  136. // 页面相关参数
  137. id: null,
  138. mode: null,
  139. edit: null,
  140. ready: false,
  141. // 表单数据
  142. current: {},
  143. origin: {},
  144. // 表单项数据结构
  145. scheme: {
  146. Purchase_Service: {
  147. DepartmentId: {
  148. type: 'select',
  149. title: '填报部门'
  150. },
  151. Creator: {
  152. type: 'organize',
  153. title: '填报人',
  154. },
  155. Createtime: { type: 'datetime', title: '填报时间', dateformat: '1' },
  156. Payee: {
  157. title: '收款人',
  158. verify:'NotNull'
  159. },
  160. Attachcount: {
  161. title: '附件张数'
  162. },
  163. Totalamount: {
  164. type: 'text',
  165. title: '申请报账金额',
  166. verify:'Price'
  167. },
  168. // Remark: {
  169. // type: 'textarea',
  170. // title: '备注'
  171. // },
  172. FilePath: {
  173. type: 'upload',
  174. title: '附件'
  175. },
  176. Approvalamount:{title:'核准金额',verify:'PriceOrNull'},
  177. // Status: { type: 'select', title: '是否提交' },
  178. // SubmitTime:{ type: 'datetime', title: '提交时间', dateformat: '1' },
  179. // CheckTime:{ type: 'datetime', title: '审核时间', dateformat: '1' },
  180. // CheckUserId:{ type: 'organize', title: '审核人' },
  181. // CheckStatus:{ type: 'select', title: '审核状态', },
  182. },
  183. },
  184. Purchase_Service_Details: {
  185. type: 'girdtable',
  186. title: '劳务维修详情',
  187. __defaultItem__: {},
  188. fieldsData: [
  189. { field:'ServiceContent', type:'input', name:'维修内容' },
  190. { field:'Price', type:'input', name:'价格' },
  191. { field:'Peoplecount', type:'input', name:'人数' },
  192. { field:'Days', type:'input', name:'天数' },
  193. { field:'Standar', type:'input', name:'标准' },
  194. ]
  195. },
  196. // 数据源
  197. dataSource: {
  198. Purchase_Service: {
  199. DepartmentId: [],
  200. Status: [{
  201. text: '已提交',
  202. value: '1'
  203. }, {
  204. text: '未提交',
  205. value: '2'
  206. }],
  207. CheckStatus: [{
  208. text: '审核中',
  209. value: '1'
  210. }, {
  211. text: '审核通过',
  212. value: '2'
  213. }, {
  214. text: '',
  215. value: '草稿'
  216. }]
  217. },
  218. },
  219. // 采购数据
  220. column:[
  221. // { type:'selection', fixed:true,width:60 },
  222. // { name: 'CreatorName', label: '申请人',width:80,emptyString:'--' },
  223. { name: 'TotalAmount', label: '金额',fixed:false,width:86,emptyString:'--' },
  224. // { name: 'DepartmentName', label: '部门',fixed:false,width:200,emptyString:'--' },
  225. { name: 'Remark', label: '备注',fixed:false,width:126,emptyString:'--' },
  226. { name: 'CreateTime', label: '申请时间',width:80,emptyString:'--' },
  227. // { name: 'SubmitTime', label: '提交时间',fixed:false,width:146,emptyString:'--' },
  228. // { name: 'CheckTime', label: '审核时间',fixed:false,width:146,emptyString:'--' },
  229. ],
  230. data:[],
  231. page: 1,
  232. total: 1,
  233. rows:8,
  234. list: [],
  235. currentRow:null,
  236. currentRowDetail:[],
  237. type:null,
  238. code:null,
  239. level: '1',
  240. processId:null,
  241. // 指派审核人数据
  242. modal: false,
  243. userAssignData:{},//收集数据用来判断是否需要审核人
  244. reviewerListId:'',
  245. reviewerList:[],
  246. submitPostData:{},
  247. reviewer: [],
  248. authorize:{},
  249. }
  250. },
  251. async onLoad({
  252. type,
  253. id
  254. }) {
  255. await this.init(type, id)
  256. },
  257. onUnload() {
  258. this.OFF('details-change')
  259. },
  260. methods: {
  261. // 页面初始化
  262. async init(type, id) {
  263. this.LOADING('加载数据中...')
  264. this.ON('details-change',this.dataChange)
  265. this.id = id
  266. this.mode = type
  267. this.edit = ['create', 'edit'].includes(this.mode)
  268. this.type = type
  269. this.code = '1-13'
  270. const currentTask = this.GET_PARAM()
  271. // 新建表单则生成
  272. this.processId = this.GUID('-')
  273. const processInfo = await this.fetchProcessInfo({ code:this.code })
  274. const currentNode = this.getCurrentNode(processInfo)
  275. this.userAssignData.currentTask = currentTask
  276. this.userAssignData.currentNode = currentNode
  277. // wfForms 的数组成员 t,表示表单数据项(TAB页),t.type 表示类别,注意它是字符串型,用 Number(t.type) 转换
  278. // 为 1 则使用工作流表单,依据它的 .formId
  279. // 不为 1 则使用系统表单,依据它的 .appurl
  280. const { wfForms } = currentNode
  281. // 处理没有有效表单的情况,停止加载
  282. if (!wfForms || wfForms.length <= 0) {
  283. this.HIDE_LOADING()
  284. this.TOAST('移动表单数据(wfForms)中无有效表单')
  285. return
  286. }
  287. // 权限
  288. if(currentNode.wfForms && currentNode.wfForms[0].authorize){
  289. let arr = Object.values(currentNode.wfForms[0].authorize)
  290. for (let item of arr) {
  291. this.authorize[item.fieldId] = item
  292. }
  293. }
  294. // 拉取表单数据,同时拉取所有来自数据源的选单数据
  295. await Promise.all([
  296. this.FETCH_DATASOURCE('classdata').then(data => {
  297. this.dataSource.Purchase_Service.DepartmentId = data.data.map(t => ({
  298. text: t.name,
  299. value: t.id
  300. }));
  301. }),
  302. () => {}
  303. ])
  304. await this.fetchForm()
  305. this.ready = true
  306. this.HIDE_LOADING()
  307. },
  308. isEdit(field){
  309. return this.authorize[field] && this.authorize[field].isEdit !== 0
  310. },
  311. // 加载表单数据
  312. async fetchForm() {
  313. if (this.mode === 'create') {
  314. this.origin = await this.getDefaultForm()
  315. let userInfo = this.GET_GLOBAL('loginUser');
  316. this.origin.Purchase_Service.DepartmentId = userInfo.departmentId
  317. this.origin.Purchase_Service.Creator = userInfo.userId
  318. } else {
  319. const result = await this.HTTP_GET('learun/adms/purchaseserviceapply/form', this.id)
  320. this.origin = await this.formatFormData({
  321. Purchase_Service: result.Purchase_Service,
  322. })
  323. this.data = result.Purchase_Service_Details
  324. }
  325. this.current = this.COPY(this.origin)
  326. },
  327. // 计算报账金额
  328. getamount(){
  329. let getamount = 0
  330. this.data.forEach(e=>{
  331. getamount = this.accAdd(e.TotalAmount,getamount)
  332. })
  333. this.setValue('Purchase_Service.Totalamount', getamount)
  334. },
  335. // 点击某一行
  336. async currentChange(row){
  337. this.currentRow = row
  338. this.currentRowDetail = []
  339. const result = await this.HTTP_GET('learun/adms/purchaseservice/formdetail',row.purchaseid)
  340. if(!result)return
  341. this.currentRowDetail = result
  342. },
  343. // 新增明细数据
  344. dataChange(data){
  345. data.forEach(e=>{
  346. if(!this.data.find(e1=>e.Id == e1.purchaseid)){
  347. e.purchaseid = e.Id
  348. this.data.push(e)
  349. }
  350. })
  351. this.getamount()
  352. },
  353. async detailDelete(){
  354. if(!this.currentRow){
  355. this.TOAST('请选中某一项')
  356. return
  357. }
  358. if (!(await this.CONFIRM('删除项目', '确定要删除选中项吗?', true))) {
  359. return
  360. }
  361. let index;
  362. this.data.find((e,i)=>{
  363. if(e.Id == this.currentRow.Id){
  364. index = i
  365. return true
  366. }
  367. })
  368. this.data.splice(index,1)
  369. this.$refs.table.resetHighlight()
  370. this.currentRow = null
  371. this.currentRowDetail = []
  372. this.getamount()
  373. },
  374. // 新增明细
  375. detailAdd(){
  376. // this.NAV_TO('./details',this.data,true)
  377. this.NAV_TO('./details')
  378. },
  379. // 乘法函数
  380. accMul(arg1, arg2) {
  381. let m = 0,
  382. s1 = arg1.toString(),
  383. s2 = arg2.toString()
  384. try {
  385. m += s1.split('.')[1].length
  386. } catch (e) {}
  387. try {
  388. m += s2.split('.')[1].length
  389. } catch (e) {}
  390. return (Number(s1.replace('.', '')) * Number(s2.replace('.', ''))) / Math.pow(10, m)
  391. },
  392. // 加法函数
  393. accAdd(arg1, arg2) {
  394. let r1, r2, m
  395. try {
  396. r1 = arg1.toString().split('.')[1].length
  397. } catch (e) {
  398. r1 = 0
  399. }
  400. try {
  401. r2 = arg2.toString().split('.')[1].length
  402. } catch (e) {
  403. r2 = 0
  404. }
  405. m = Math.pow(10, Math.max(r1, r2))
  406. return (arg1 * m + arg2 * m) / m
  407. },
  408. // 指派审核人
  409. async userAssign() {
  410. this.modal = false
  411. if(!this.reviewer.length){
  412. this.TOAST('请选择审核人')
  413. return
  414. }
  415. this.LOADING('正在提交…')
  416. let postData = {
  417. auditors :JSON.stringify({[this.reviewerListId]:this.reviewer.toString()}),
  418. level : this.level,
  419. code: this.code,
  420. processId: this.processId,
  421. }
  422. const url = 'learun/adms/newwf/createnoform'
  423. const tips = `流程发起失败`
  424. this.HTTP_POST(url, postData, tips).then(success => {
  425. this.HIDE_LOADING()
  426. if (!success) {
  427. return
  428. }
  429. this.submit1()
  430. })
  431. },
  432. // 发起流程
  433. async submit() {
  434. // 判断是否指派审核人
  435. let isNext = this.userAssignData.currentNode.isNext
  436. Object.assign(this.userAssignData,{ code: 'agree' })
  437. if (this.userAssignData.next == '2') {
  438. isNext = '1';
  439. }
  440. if (isNext == '1') {
  441. let params = {
  442. code: this.code,
  443. processId: this.processId,
  444. taskId: '',
  445. nodeId: this.userAssignData.currentNode.id,
  446. operationCode: this.userAssignData.code,
  447. }
  448. this.LOADING('正在获取审核人…')
  449. const userList = await this.HTTP_GET('learun/adms/newwf/auditer', params, `获取审核人时发生错误`)
  450. this.HIDE_LOADING()
  451. if (!userList) {
  452. return
  453. }
  454. let arr = Object.entries(userList)
  455. this.reviewerListId = arr[0][0]
  456. this.reviewerList = arr[0][1].map(item => {
  457. return {
  458. text: item.Name,
  459. value: item.Id
  460. }
  461. })
  462. if(this.reviewerList.length>1){
  463. this.modal = true
  464. return
  465. }
  466. }
  467. this.LOADING('正在提交…')
  468. let postData = {
  469. auditors :JSON.stringify({}),
  470. level : this.level,
  471. code: this.code,
  472. processId: this.processId,
  473. }
  474. const url = 'learun/adms/newwf/createnoform'
  475. const tips = `流程发起失败`
  476. this.HTTP_POST(url, postData, tips).then(success => {
  477. this.HIDE_LOADING()
  478. if (!success) {
  479. return
  480. }
  481. this.submit1()
  482. })
  483. },
  484. // 提交
  485. async submit1(){
  486. // if (!(await this.CONFIRM('提交项目', '是否确认提交该项?', true))) {
  487. // return
  488. // }
  489. this.LOADING('正在提交...')
  490. this.HTTP_POST('learun/adms/purchaseserviceapply/submit', {Id:this.id, ProcessId:this.processId} , '提交失败').then(
  491. success => {
  492. this.HIDE_LOADING()
  493. if (!success) {
  494. return
  495. }
  496. this.TOAST('提交成功', 'success')
  497. this.EMIT('LogisticsapplyManagement-Purchase_Service-list-change')
  498. this.NAV_BACK()
  499. })
  500. return
  501. },
  502. // 点击 「编辑」、「重置」、「保存」、「删除」 按钮
  503. async action(type,isSubmit=false) {
  504. switch (type) {
  505. case 'edit':
  506. this.edit = true
  507. break
  508. case 'reset':
  509. this.current = this.COPY(this.origin)
  510. this.edit = false
  511. break
  512. case 'save':
  513. const verifyResult = this.verifyForm()
  514. if (verifyResult.length > 0) {
  515. this.CONFIRM('表单验证失败', verifyResult.join('\n'))
  516. return
  517. }
  518. if (!(await this.CONFIRM('提交确认', '确定要提交本页表单内容吗?', true))) {
  519. return
  520. }
  521. this.LOADING('正在提交...')
  522. const postData = await this.getPostData(this.id)
  523. // // 处理列表数据
  524. let strEntity = JSON.parse(postData.strEntity)
  525. for (let s of this.data) {
  526. s.TotalAmount = Number(s.TotalAmount);
  527. s.TotalAmount = Number(s.TotalAmount)
  528. }
  529. let DetailList = this.data.map(e=>{
  530. return {
  531. purchaseid:e.purchaseid
  532. }
  533. })
  534. postData.DetailList = JSON.stringify(DetailList)
  535. // 赋值部门和人员数据
  536. let userInfo = this.GET_GLOBAL('loginUser');
  537. let obj = this.dataSource.Purchase_Service.DepartmentId.find(e => e.value == this.origin
  538. .Purchase_Service.DepartmentId)
  539. strEntity.deptname = obj ? obj.text : ''
  540. strEntity.creatorname = userInfo.realName
  541. // 格式化数据
  542. strEntity.Approvalamount = Number(strEntity.Approvalamount)
  543. strEntity.Totalamount = Number(strEntity.Totalamount)
  544. postData.strEntity = JSON.stringify(strEntity)
  545. // console.log(postData,JSON.parse(postData.strEntity))
  546. this.HTTP_POST('learun/adms/purchaseserviceapply/save', postData, '表单提交保存失败').then(success => {
  547. this.HIDE_LOADING()
  548. if (!success) {
  549. return
  550. }
  551. this.id = success.Id
  552. if(isSubmit){
  553. this.submit()
  554. return
  555. }
  556. this.EMIT('LogisticsapplyManagement-Purchase_Service-list-change')
  557. setTimeout(()=>this.NAV_BACK(),500)
  558. this.TOAST('提交保存成功')
  559. })
  560. break
  561. case 'delete':
  562. if (!(await this.CONFIRM('删除项目', '确定要删除本项吗?', true))) {
  563. return
  564. }
  565. this.LOADING('提交删除中...')
  566. this.HTTP_POST('learun/adms/purchaseserviceapply/delete', this.id, '删除失败').then(success => {
  567. this.HIDE_LOADING()
  568. if (!success) {
  569. return
  570. }
  571. this.EMIT('LogisticsapplyManagement-Purchase_Service-list-change')
  572. this.NAV_BACK()
  573. this.this.TOAST('删除成功', 'success')
  574. })
  575. break
  576. default:
  577. break
  578. }
  579. },
  580. // 获取表单值
  581. getValue(path) {
  582. return get(this.current, path)
  583. },
  584. // 设置表单值
  585. setValue(path, val) {
  586. set(this.current, path, val)
  587. },
  588. }
  589. }
  590. </script>