微信小程序
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.

2540 lines
85 KiB

  1. // pages/apply/paymentTemplate/add/add.js
  2. import * as UTIL from '../../../../utils/util.js';
  3. import * as API from '../../../../utils/API.js';
  4. let EVN_CONFIG = require('../../../../env/env');
  5. const app = getApp();
  6. Page({
  7. /**
  8. * 页面的初始数据
  9. */
  10. data: {
  11. isIPX: app.globalData.isIPX,
  12. radio:'1',
  13. active:0,
  14. projectText:'',
  15. balance:0,
  16. capitalExpenditureTypeOptions:[],
  17. transferTypeOptions:[],
  18. projectOptions:[],
  19. projectFundTypeOptions:[],
  20. contractionOptions:[],
  21. accountOptions:[],
  22. moneyorderOptions:[],
  23. topInputTirme:false,
  24. // form:{
  25. // approvalMode:'1',
  26. // payeeList:[{}],
  27. // approvalItemTemplate:{
  28. // approvalItems:'',//审批事项
  29. // submitCompany:'',//提交单位
  30. // submitDate:'',//提交日期
  31. // submitter:'',//提交人
  32. // telephone:'',//联系方式
  33. // totalAmount:"0.00",//合计金额
  34. // templateName:'',//模板名称 选择保存模板的时候添加
  35. // dataType:'',//数据类型
  36. // },
  37. // transfers:[{//事项信息集合以下是List对象信息
  38. // num:"一",
  39. // amountReadonly:false,
  40. // expenditureAmountTirme:false,
  41. // remarkTirme:false,
  42. // showCapitalExpenditureType:false,
  43. // showApplyDate:false,
  44. // showTransferType:false,
  45. // showProject:false,
  46. // showProjectFundType:false,
  47. // showAccount:false,
  48. // showDialog:false,
  49. // showContraction:false,
  50. // showMoneyOrder:false,
  51. // cashForm:{
  52. // payee:'',
  53. // phone:'',
  54. // unit:'',
  55. // leader:'',
  56. // remark:'',
  57. // },
  58. // SJimage:[],
  59. // FPimage:[],
  60. // QTimage:[],
  61. // activeName:0,
  62. // showTitle:true,
  63. // collapseDis:false,
  64. // capitalExpenditureType:'1',//资金支出类别
  65. // capitalExpenditureTypeText:'结算类',//资金支出类别(展示用)
  66. // succeedAmount:'',//成功支付金额
  67. // payer:'',//付款方
  68. // paymentPattern:'1',
  69. // payerAccount:'',//付款方账户
  70. // bankType:'',//所属银行
  71. // bankTypeText:'',//所属银行(展示用)
  72. // isPeers:'N',//是否同行
  73. // operatorCode:'',//操作员代码
  74. // enterpriseCode:'',//企业编码
  75. // expenditureAmount:'',//支出总金额
  76. // applyDate:'',//申请时间
  77. // transferStatus:'',//转账状态
  78. // auditStatus:'0',//审批状态
  79. // paymentState:'',//支付状态
  80. // approvalMode:'1',//审批模式
  81. // paymentTime:'',//支付时间
  82. // bankPriority:'',//银行处理优先级
  83. // clientPriority:'',//客户处理优先级
  84. // transferType:'1',//付款方式
  85. // transferTypeText:'垫付报销:电子支付',//付款方式(展示用)
  86. // requiredTransferTime:'',//要求转账时间
  87. // remark:'',//付款事由
  88. // startTime:'',//开票日期
  89. // endTime:'',//到期日期
  90. // orderType:'',//汇票类型
  91. // bankAccountType:'2',//账户类别1 公户2私户
  92. // villageAccountType:'',//账户分类
  93. // payeeList:[{//收款方账户集合
  94. // payeeId:'0',//收款方id
  95. // payee:'',//收款方
  96. // bankDeposit:'',//开户行
  97. // incomeAmount:'',//收入金额
  98. // bankType:'',//所属银行0其他银行1中国银行2农商行(山东省)3农业银行4建设银行5工商银行
  99. // payeeAccount:'',//收款账户
  100. // }],
  101. // projectForm:{
  102. // projectId:'',
  103. // projectName:'',
  104. // projectContractor:'',
  105. // projectAmount:'',
  106. // projectBillNum:'',
  107. // projectFundType:'',
  108. // outId:'',
  109. // ynType:'1',
  110. // },
  111. // contractionForm:{
  112. // contractionId:'',
  113. // name:'',
  114. // code:'',
  115. // totalAmount:'',
  116. // },
  117. // moneyOrderForm:{
  118. // orderNum:'',
  119. // orderType:'',
  120. // orderAmount:'',
  121. // billPayUnit:'',
  122. // billReceiveUnit:'',
  123. // startTime:'',
  124. // endTime:'',
  125. // orderStatus:'',
  126. // remark:'',
  127. // }
  128. // }],
  129. // },
  130. form:{
  131. approvalItemTemplate:{
  132. approvalItems:'',//审批事项
  133. submitCompany:'',//提交单位
  134. submitDate:'',//提交日期
  135. submitter:'',//提交人
  136. telephone:'',//联系方式
  137. totalAmount:"0.00",//合计金额
  138. templateName:'',//模板名称 选择保存模板的时候添加
  139. dataType:'',//数据类型
  140. },
  141. num:"一",
  142. amountReadonly:false,
  143. expenditureAmountTirme:false,
  144. remarkTirme:false,
  145. showCapitalExpenditureType:false,
  146. showApplyDate:false,
  147. showTransferType:false,
  148. showProject:false,
  149. showProjectFundType:false,
  150. showAccount:false,
  151. showDialog:false,
  152. showContraction:false,
  153. showMoneyOrder:false,
  154. cashForm:{
  155. payee:'',
  156. phone:'',
  157. unit:'',
  158. leader:'',
  159. remark:'',
  160. },
  161. SJimage:[],
  162. FPimage:[],
  163. QTimage:[],
  164. SYLGKimage:[],
  165. activeName:0,
  166. showTitle:true,
  167. collapseDis:false,
  168. capitalExpenditureType:'1',//资金支出类别
  169. capitalExpenditureTypeText:'结算类',//资金支出类别(展示用)
  170. approvalTemplateId:'1',//资金支出类别
  171. approvalTemplateName:'',//资金支出类别(展示用)
  172. succeedAmount:'',//成功支付金额
  173. payer:'',//付款方
  174. paymentPattern:'1',
  175. payerAccount:'',//付款方账户
  176. bankType:'',//所属银行
  177. bankTypeText:'',//所属银行(展示用)
  178. isPeers:'',//是否同行
  179. operatorCode:'',//操作员代码
  180. enterpriseCode:'',//企业编码
  181. expenditureAmount:'',//支出总金额
  182. applyDate:'',//申请时间
  183. transferStatus:'',//转账状态
  184. auditStatus:'0',//审批状态
  185. paymentState:'1',//支付状态
  186. approvalMode:'1',//审批模式
  187. paymentTime:'',//支付时间
  188. bankPriority:'',//银行处理优先级
  189. clientPriority:'',//客户处理优先级
  190. transferType:'1',//付款方式
  191. transferTypeText:'银行转账',//付款方式(展示用)
  192. requiredTransferTime:'',//要求转账时间
  193. remark:'',//付款事由
  194. startTime:'',//开票日期
  195. endTime:'',//到期日期
  196. orderType:'',//汇票类型
  197. bankAccountType:'2',//账户类别1 公户2私户
  198. accountType:'1',//账户类别1 公户2私户
  199. villageAccountType:'',//账户分类
  200. payeeList:[{//收款方账户集合
  201. payeeId:'0',//收款方id
  202. payee:'',//收款方
  203. bankDeposit:'',//开户行
  204. incomeAmount:'',//收入金额
  205. bankType:'',//所属银行0其他银行1中国银行2农商行(山东省)3农业银行4建设银行5工商银行
  206. payeeAccount:'',//收款账户
  207. }],
  208. projectForm:{
  209. projectId:'',
  210. projectName:'',
  211. projectContractor:'',
  212. projectAmount:'',
  213. projectBillNum:'',
  214. projectFundType:'',
  215. outId:'',
  216. ynType:'1',
  217. },
  218. contractionForm:{
  219. contractionId:'',
  220. name:'',
  221. code:'',
  222. totalAmount:'',
  223. },
  224. moneyOrderForm:{
  225. orderNum:'',
  226. orderType:'',
  227. orderAmount:'',
  228. billPayUnit:'',
  229. billReceiveUnit:'',
  230. startTime:'',
  231. endTime:'',
  232. orderStatus:'',
  233. remark:'',
  234. }
  235. },
  236. transferTypeOption:[
  237. {
  238. dictLabel:'银行转账',
  239. dictValue:'1'
  240. },
  241. {
  242. dictLabel:'信用卡转账',
  243. dictValue:'2'
  244. }
  245. ],
  246. accountForm:{},
  247. fileForm:[],
  248. isUpdate:false,
  249. SJimage: [],
  250. FPimage: [],
  251. QTimage: [],
  252. SYLGKimage: [],
  253. imgcount:0,
  254. activeNames: 0,
  255. applyDate:'',
  256. autosize: { maxHeight: 500, minHeight: 50 },
  257. showFile:false,
  258. showCapitalExpenditureType:false,
  259. showSteps:false,
  260. showAccountType:false,
  261. activeStepsNames: 0,
  262. },
  263. showS(){
  264. this.setData({
  265. showSteps:!this.data.showSteps,
  266. })
  267. },
  268. /**
  269. * 生命周期函数--监听页面加载
  270. */
  271. onLoad(options) {
  272. var that = this;
  273. //所属银行
  274. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bank_type', {method:'GET'}, {
  275. success: (res) => {
  276. this.setData({
  277. bankTypeOptions:res.data
  278. });
  279. }
  280. })
  281. // 资金支出类别字典查询
  282. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'capital_expenditure_type', {method:'GET'}, {
  283. success: (res) => {
  284. that.setData({
  285. capitalExpenditureTypeOptions:res.data,
  286. })
  287. }
  288. })
  289. // 汇票列表查询
  290. UTIL.httpRequest(API.URL_GET_GETMONEYORDERLIST, {method:'GET'}, {
  291. success: (res) => {
  292. that.setData({
  293. moneyOrderOptions:res.rows,
  294. })
  295. }
  296. })
  297. // 付款方式类型字典查询 (2.0)
  298. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'yn_pay_type', {method:'GET'}, {
  299. success: (res) => {
  300. that.setData({
  301. transferTypeOptions:res.data,
  302. })
  303. }
  304. })
  305. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bank_account_type', {method:'GET'}, {
  306. success: (res) => {
  307. that.setData({
  308. bankAccountTypeOptions:res.data,
  309. })
  310. }
  311. })
  312. // 项目工程列表
  313. UTIL.httpRequest(API.URL_GET_GETPROJECTLIST , {method:'GET'}, {
  314. success: (res) => {
  315. that.setData({
  316. projectOptions:res.rows,
  317. })
  318. }
  319. })
  320. // 工程款类型字典查询
  321. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'project_fund_type', {method:'GET'}, {
  322. success: (res) => {
  323. that.setData({
  324. projectFundTypeOptions:res.data,
  325. })
  326. }
  327. })
  328. // 获取合同信息列表
  329. UTIL.httpRequest(API.URL_GET_CONTRACTIONLIST , {method:'GET',contractionStatus:1}, {
  330. success: (res) => {
  331. that.setData({
  332. contractionOptions:res.rows,
  333. })
  334. }
  335. })
  336. let templateQueryParams = {
  337. // 分页
  338. method:'GET',
  339. pageNum: 1,
  340. pageSize: 999,
  341. orderByColumn:'defaultValue',
  342. isAsc: "desc",
  343. type:'1'
  344. };
  345. // 审批流程列表
  346. UTIL.httpRequest(API.URL_GET_TEMPLATELIST , templateQueryParams, {
  347. success: (res) => {
  348. that.setData({
  349. approvalTemplateNameOptions:res.rows,
  350. ["form.approvalTemplateId"]:res.rows[0].id,
  351. ["form.approvalTemplateName"]:res.rows[0].name,
  352. })
  353. // 审批模板
  354. UTIL.httpRequest(API.URL_GET_selectApprovalByTemplateId+res.rows[0].id , {method:'GET'}, {
  355. success: (rres) => {
  356. that.setData({
  357. steps:rres.approvalDetails
  358. })
  359. }
  360. })
  361. }
  362. })
  363. if(options.id && options.type != 'template'){
  364. UTIL.showLoadingHaveMask();
  365. var perames = {
  366. pageNum:1,
  367. pageSize:999,
  368. accountType:'102',
  369. method:'POST'
  370. }
  371. // 付款方列表
  372. UTIL.httpRequest(API.URL_GET_SELECTACCOUNTLIST , perames, {
  373. success: (res) => {
  374. console.log(res);
  375. that.setData({
  376. accountOptions:res.rows,
  377. })
  378. }
  379. })
  380. setTimeout(function(){
  381. UTIL.httpRequest(API.URL_GET_APPROVALITEMS+options.id, {method:'GET'}, {
  382. success: (res) => {
  383. if (res.code == API.SUCCESS_CODE) {
  384. // 审批模板
  385. UTIL.httpRequest(API.URL_GET_selectApprovalByTemplateId+res.data.approvalTemplateId, {method:'GET'}, {
  386. success: (rres) => {
  387. that.setData({
  388. steps:rres.approvalDetails
  389. })
  390. }
  391. })
  392. res.data.capitalExpenditureTypeText = UTIL.getTransform(res.data.capitalExpenditureType,that.data.capitalExpenditureTypeOptions);
  393. res.data.transferTypeText = UTIL.getTransform(res.data.transferType,that.data.transferTypeOption);
  394. if(res.data.capitalExpenditureType == 2){
  395. let prames = {
  396. outId:res.data.id,
  397. ynType: res.data.transferType=='1'||res.data.transferType=='2'||res.data.transferType=='4'?'1':'2'
  398. }
  399. // 工程项目查询
  400. UTIL.httpRequest(API.URL_GET_GETPROJECTTO , prames, {
  401. success: (res) => {
  402. res.data.projectFundTypeText = UTIL.getTransform(res.data.projectFundType,that.data.projectFundTypeOptions);
  403. that.setData({
  404. ["form.projectForm"]:res.data,
  405. })
  406. }
  407. })
  408. }
  409. if(res.data.capitalExpenditureType == 4){
  410. let prames = {
  411. transferId:res.data.id,
  412. }
  413. // 关联合同查询
  414. UTIL.httpRequest(API.URL_GET_GETSELECTINFOBYOUTID , prames, {
  415. success: (res) => {
  416. that.setData({
  417. ["form.contractionForm"]:res.data,
  418. })
  419. }
  420. })
  421. }
  422. that.setData({
  423. ["form.fileNum"]:0,
  424. })
  425. UTIL.httpRequest(
  426. API.URL_GET_FINDLIST,
  427. {
  428. method:'GET',
  429. tableName:'t_yinnong_transfer',
  430. tableId:res.data.id,
  431. fileType:1
  432. },
  433. {
  434. success: (res) => {
  435. let list = [];
  436. res.data.forEach((item2,index2)=>{
  437. let fileForm = res.data.fileForm?res.data.fileForm:[];
  438. fileForm.push({
  439. file: wx.getStorageSync('dressCode')+item2.fileUrl,
  440. fileType:'1',
  441. bizPath:'transfer',
  442. tableName:'t_yinnong_transfer',
  443. tableId:''
  444. })
  445. list.push({
  446. tempFilePath:wx.getStorageSync('dressCode')+item2.fileUrl,
  447. id:item2.id
  448. })
  449. that.setData({
  450. ["form.fileNum"]:that.data.form.fileNum+1,
  451. ["form.SJimage"]:list,
  452. ["form.fileForm"]:fileForm,
  453. });
  454. })
  455. }
  456. })
  457. //发票
  458. UTIL.httpRequest(
  459. API.URL_GET_FINDLIST,
  460. {
  461. method:'GET',
  462. tableName:'t_yinnong_transfer',
  463. tableId:res.data.id,
  464. fileType:2
  465. },
  466. {
  467. success: (res) => {
  468. let list = [];
  469. res.data.forEach((item2,index2)=>{
  470. let fileForm = res.data.fileForm?res.data.fileForm:[];
  471. fileForm.push({
  472. file: wx.getStorageSync('dressCode')+item2.fileUrl,
  473. fileType:'2',
  474. bizPath:'transfer',
  475. tableName:'t_yinnong_transfer',
  476. tableId:res.data.id
  477. })
  478. list.push({
  479. tempFilePath:wx.getStorageSync('dressCode')+item2.fileUrl,
  480. id:item2.id
  481. })
  482. that.setData({
  483. ["form.fileNum"]:that.data.form.fileNum+1,
  484. ["form.FPimage"]:list,
  485. ["form.fileForm"]:fileForm
  486. });
  487. })
  488. }
  489. })
  490. //其他
  491. UTIL.httpRequest(
  492. API.URL_GET_FINDLIST,
  493. {
  494. method:'GET',
  495. tableName:'t_yinnong_transfer',
  496. tableId:res.data.id,
  497. fileType:3
  498. },
  499. {
  500. success: (res) => {
  501. let list = [];
  502. res.data.forEach((item2,index2)=>{
  503. let fileForm = res.data.fileForm?res.data.fileForm:[];
  504. fileForm.push({
  505. file: wx.getStorageSync('dressCode')+item2.fileUrl,
  506. fileType:'3',
  507. bizPath:'transfer',
  508. tableName:'t_yinnong_transfer',
  509. tableId:res.data.id
  510. })
  511. list.push({
  512. tempFilePath:wx.getStorageSync('dressCode')+item2.fileUrl,
  513. id:item2.id
  514. })
  515. that.setData({
  516. ["form.fileNum"]:that.data.form.fileNum+1,
  517. ["form.QTimage"]:list,
  518. ["form.fileForm"]:fileForm
  519. });
  520. })
  521. }
  522. })
  523. //四议两公开
  524. UTIL.httpRequest(
  525. API.URL_GET_FINDLIST,
  526. {
  527. method:'GET',
  528. tableName:'t_yinnong_transfer',
  529. tableId:res.data.id,
  530. fileType:4
  531. },
  532. {
  533. success: (res) => {
  534. let list = [];
  535. res.data.forEach((item2,index2)=>{
  536. let fileForm = res.data.fileForm?res.data.fileForm:[];
  537. fileForm.push({
  538. file: wx.getStorageSync('dressCode')+item2.fileUrl,
  539. fileType:'4',
  540. bizPath:'transfer',
  541. tableName:'t_yinnong_transfer',
  542. tableId:res.data.id
  543. })
  544. list.push({
  545. tempFilePath:wx.getStorageSync('dressCode')+item2.fileUrl,
  546. id:item2.id
  547. })
  548. that.setData({
  549. ["form.fileNum"]:that.data.form.fileNum+1,
  550. ["form.SYLGKimage"]:list,
  551. ["form.fileForm"]:fileForm
  552. });
  553. })
  554. }
  555. })
  556. let query = {
  557. method:'GET',
  558. // accountType:res.data.accountType,
  559. // status:"0",
  560. // orderByColumn: "id",
  561. // isAsc: "desc",
  562. }
  563. UTIL.httpRequest(API.URL_GET_TRANSFERINFOS+options.id, query, {
  564. success: (response) => {
  565. if (res.code == API.SUCCESS_CODE) {
  566. for(let i = 0 ; i < response.rows.length ; i++){
  567. response.rows[i].bankTypeText = UTIL.getTransform(response.rows[i].bankType,that.data.bankTypeOptions);
  568. }
  569. that.setData({
  570. ["form.payeeList"]:response.rows
  571. })
  572. }
  573. }
  574. })
  575. that.setData({
  576. form:res.data,
  577. isUpdate:true,
  578. showFile:true,
  579. activeNames:null,
  580. })
  581. UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
  582. success: (res) => {
  583. if (res.code == API.SUCCESS_CODE) {
  584. that.setData({
  585. ["form.approvalItemTemplate.submitCompany"]:res.user.bookName,
  586. ["form.approvalItemTemplate.submitDate"]:UTIL.js_date_time(new Date()),
  587. ["form.approvalItemTemplate.submitter"]:res.user.nickName,
  588. ["form.approvalItemTemplate.telephone"]:res.user.phonenumber,
  589. })
  590. }
  591. }
  592. })
  593. UTIL.hideLoadingHaveMask();
  594. }
  595. }
  596. })
  597. },1000)
  598. }else{
  599. //村账户查询参数
  600. var perames = {
  601. pageNum:1,
  602. pageSize:999,
  603. accountType:'102',
  604. method:'post',
  605. }
  606. // 付款方列表
  607. UTIL.httpRequest(API.URL_GET_SELECTACCOUNTLIST , perames, {
  608. success: (res) => {
  609. console.log(res);
  610. that.setData({
  611. accountOptions:res.rows,
  612. ["form.applyDate"]: UTIL.formatDate(new Date()),
  613. applyDate: UTIL.formatDate(new Date()),
  614. })
  615. }
  616. })
  617. UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
  618. success: (res) => {
  619. if (res.code == API.SUCCESS_CODE) {
  620. that.setData({
  621. ["form.approvalItemTemplate.submitCompany"]:res.user.bookName,
  622. ["form.approvalItemTemplate.submitDate"]:UTIL.js_date_time(new Date()),
  623. ["form.approvalItemTemplate.submitter"]:res.user.nickName,
  624. ["form.approvalItemTemplate.telephone"]:res.user.phonenumber,
  625. })
  626. }
  627. }
  628. })
  629. }
  630. },
  631. onChangeBox(event) {
  632. console.log(event);
  633. this.setData({
  634. activeNames: event.detail,
  635. });
  636. },
  637. onChangePayee(event) {
  638. console.log(event);
  639. this.setData({
  640. ["form.activeName"]:event.detail
  641. });
  642. },
  643. onClosePayee(event){
  644. console.log("aaa");
  645. this.setData({
  646. ["form.activeName"]:''
  647. });
  648. },
  649. onChangeSteps(event) {
  650. console.log(event);
  651. this.setData({
  652. activeStepsNames:event.detail
  653. });
  654. },
  655. onCloseSteps(event){
  656. console.log("aaa");
  657. this.setData({
  658. activeStepsNames:''
  659. });
  660. },
  661. /**
  662. * 生命周期函数--监听页面初次渲染完成
  663. */
  664. onReady() {
  665. },
  666. /**
  667. * 生命周期函数--监听页面显示
  668. */
  669. onShow() {
  670. },
  671. openBox(even){
  672. console.log(even.currentTarget.dataset.name);
  673. this.setData({
  674. [even.currentTarget.dataset.name]:true
  675. })
  676. },
  677. closeBox(even){
  678. console.log(even);
  679. this.setData({
  680. [even.currentTarget.dataset.name]:false
  681. })
  682. },
  683. onConfirm(event) {
  684. this.setData({
  685. [event.currentTarget.dataset.name]: false,
  686. [event.currentTarget.dataset.value]: UTIL.formatDate(event.detail),
  687. });
  688. },
  689. onConfirmPick(event) {
  690. console.log(event);
  691. this.setData({
  692. [event.currentTarget.dataset.name]: false,
  693. [event.currentTarget.dataset.value]: event.detail.value.dictValue,
  694. [event.currentTarget.dataset.value+'Text']: event.detail.value.dictLabel,
  695. });
  696. },
  697. onConfirmPickApproval(event) {
  698. console.log(event);
  699. var that = this;
  700. this.setData({
  701. showApprovalTemplateName: false,
  702. ["form.approvalTemplateName"]: event.detail.value.name,
  703. ["form.approvalTemplateId"]: event.detail.value.id,
  704. });
  705. // 审批模板
  706. UTIL.httpRequest(API.URL_GET_selectApprovalByTemplateId+event.detail.value.id , {method:'GET'}, {
  707. success: (rres) => {
  708. that.setData({
  709. steps:rres.approvalDetails
  710. })
  711. }
  712. })
  713. },
  714. onConfirmAccount(event) {
  715. console.log(event);
  716. var that = this;
  717. // 所属银行字典查询
  718. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bank_type', {method:'GET'}, {
  719. success: (res) => {
  720. if(event.detail.value.bankType != 10){
  721. this.setData({
  722. ['form.accountType']: ''
  723. })
  724. }
  725. this.setData({
  726. [event.currentTarget.dataset.name]: false,
  727. [event.currentTarget.dataset.value+'.payer']: event.detail.value.accountName,
  728. [event.currentTarget.dataset.value+'.cashierId']: event.detail.value.id,
  729. [event.currentTarget.dataset.value+'.bankAccountNumber']: event.detail.value.bankAccountNumber,
  730. [event.currentTarget.dataset.value+'.bankTypeText']: UTIL.getTransform(event.detail.value.bankType,that.data.bankTypeOptions),
  731. [event.currentTarget.dataset.value+'.bankType']: event.detail.value.bankType,
  732. [event.currentTarget.dataset.value+'.payerAccount']:event.detail.value.bankAccountNumber,
  733. [event.currentTarget.dataset.value+'.balance']:event.detail.value.balance,
  734. [event.currentTarget.dataset.value+'.isPeers']:"",
  735. [event.currentTarget.dataset.value+'.payeeList'] : [{//收款方账户集合
  736. payeeId:'0',//收款方id
  737. payee:'',//收款方
  738. bankDeposit:'',//开户行
  739. incomeAmount:'',//收入金额
  740. bankType:'',//所属银行0其他银行1中国银行2农商行(山东省)3农业银行4建设银行5工商银行
  741. payeeAccount:'',//收款账户
  742. }]
  743. });
  744. }
  745. })
  746. },
  747. onConfirmaTransfer(event) {
  748. console.log(event);
  749. var that = this;
  750. let perames = {};
  751. this.setData({
  752. [event.currentTarget.dataset.value+'.payer']: '',
  753. [event.currentTarget.dataset.value+'.payerAccount']: '',
  754. [event.currentTarget.dataset.value+'.bankTypeText']: '',
  755. [event.currentTarget.dataset.value+'.bankType']: '',
  756. [event.currentTarget.dataset.value+'.bankAccountType']: '2',
  757. [event.currentTarget.dataset.value+'.isPeers']: '',
  758. [event.currentTarget.dataset.value+'.paymentPattern']: event.detail.value.dictValue,
  759. [event.currentTarget.dataset.value+'.amountReadonly']:false,
  760. [event.currentTarget.dataset.value+'.payeeList']:[{//收款方账户集合
  761. payeeId:'0',//收款方id
  762. payee:'',//收款方
  763. bankDeposit:'',//开户行
  764. incomeAmount:'',//收入金额
  765. bankType:'',//所属银行0其他银行1中国银行2农商行(山东省)3农业银行4建设银行5工商银行
  766. payeeAccount:'',//收款账户
  767. }],
  768. balance:0,
  769. });
  770. console.log(event.detail.value.dictValue);
  771. if(event.detail.value.dictValue == 1 || event.detail.value.dictValue == 2 || event.detail.value.dictValue == 4 || event.detail.value.dictValue == 6 || event.detail.value.dictValue == 7 ){event.detail.value.dictValue = 1 ;}
  772. else if(event.detail.value.dictValue == 3){event.detail.value.dictValue = 2 ;}
  773. else if(event.detail.value.dictValue == 5){event.detail.value.dictValue = 12 ;}
  774. else if(event.detail.value.dictValue == 8){event.detail.value.dictValue = 11 ;}
  775. if(event.detail.value.dictValue == 1){//村账户查询参数
  776. perames = {
  777. pageNum:1,
  778. pageSize:999,
  779. accountType:'102',
  780. method:'post',
  781.   params: {
  782.          "townAccountType":"0"
  783.     }
  784. }
  785. // 付款方列表
  786. UTIL.httpRequest(API.URL_GET_SELECTACCOUNTLIST , perames, {
  787. success: (res) => {
  788. that.setData({
  789. accountOptions:res.rows,
  790. })
  791. }
  792. })
  793. }
  794. if(event.detail.value.dictValue == 2 || event.detail.value.dictValue == 10){//公务卡和现金提现查询参数
  795. perames = {
  796. pageNum:1,
  797. pageSize:999,
  798. accountType:'102',
  799. method:'GET',
  800. villageAccountType:''
  801. }
  802. // 付款方列表
  803. UTIL.httpRequest(API.URL_GET_ACCOUNTLIST , perames, {
  804. success: (res) => {
  805. that.setData({
  806. accountOptions:res.rows,
  807. })
  808. }
  809. })
  810. }
  811. if(event.detail.value.dictValue == 11){//现金使用查询参数
  812. perames = {
  813. pageNum:1,
  814. pageSize:999,
  815. accountType:'101',
  816. method:'GET'
  817. }
  818. // 付款方列表
  819. UTIL.httpRequest(API.URL_GET_ACCOUNTLIST , perames, {
  820. success: (res) => {
  821. that.setData({
  822. accountOptions:res.rows
  823. })
  824. }
  825. })
  826. }
  827. if(event.detail.value.dictValue == 4){//代管账户查询参数
  828. perames = {
  829. pageNum:1,
  830. pageSize:999,
  831. accountType:'102',
  832. method:'GET',
  833. villageAccountType:'1'
  834. }
  835. // 付款方列表
  836. UTIL.httpRequest(API.URL_GET_ACCOUNTLIST , perames, {
  837. success: (res) => {
  838. that.setData({
  839. accountOptions:res.rows,
  840. })
  841. }
  842. })
  843. }
  844. if(event.detail.value.dictValue == 12){//汇票支出查询参数
  845. perames = {
  846. pageNum:1,
  847. pageSize:999,
  848. }
  849. // 付款方列表
  850. UTIL.httpRequest(API.URL_GET_MONEYORDERLIST , perames, {
  851. success: (res) => {
  852. that.setData({
  853. moneyorderOptions:res.rows,
  854. [event.currentTarget.dataset.value+'.amountReadonly']:true
  855. })
  856. }
  857. })
  858. }
  859. this.setData({
  860. [event.currentTarget.dataset.name]: false,
  861. [event.currentTarget.dataset.value+'.transferType']: event.detail.value.dictValue,
  862. [event.currentTarget.dataset.value+'.transferTypeText']: event.detail.value.dictLabel,
  863. });
  864. },
  865. onConfirmProject(event) {
  866. console.log(event);
  867. this.setData({
  868. [event.currentTarget.dataset.name]: false,
  869. [event.currentTarget.dataset.value+'.projectName']: event.detail.value.projectName,
  870. [event.currentTarget.dataset.value+'.projectId']: event.detail.value.id,
  871. [event.currentTarget.dataset.value+'.projectContractor']: event.detail.value.projectContractor,
  872. [event.currentTarget.dataset.value+'.projectAmount']: event.detail.value.projectAmount,
  873. });
  874. },
  875. onConfirmContraction(event) {
  876. console.log(event);
  877. this.setData({
  878. [event.currentTarget.dataset.name]: false,
  879. [event.currentTarget.dataset.value+".name"]: event.detail.value.name,
  880. [event.currentTarget.dataset.value+'.code']: event.detail.value.code,
  881. [event.currentTarget.dataset.value+'.totalAmount']: event.detail.value.totalAmount,
  882. [event.currentTarget.dataset.value+'.contractionId']: event.detail.value.id,
  883. });
  884. },
  885. onConfirmMoneyOrder(event) {
  886. console.log(event);
  887. var that = this ;
  888. this.setData({
  889. [event.currentTarget.dataset.name]: false,
  890. [event.currentTarget.dataset.value+'.moneyOrderForm']: event.detail.value,
  891. [event.currentTarget.dataset.value+'.expenditureAmount']: event.detail.value.orderAmount,
  892. [event.currentTarget.dataset.value+".payeeList[0].incomeAmount"]: event.detail.value.orderAmount,
  893. [event.currentTarget.dataset.value+'.payer']:event.detail.value.billPayUnit,
  894. [event.currentTarget.dataset.value+'.payerAccount'] : event.detail.value.orderNum,
  895. [event.currentTarget.dataset.value+'.cashierId'] : event.detail.value.id,
  896. [event.currentTarget.dataset.value+'.startTime'] : event.detail.value.startTime,
  897. [event.currentTarget.dataset.value+'.endTime'] : event.detail.value.endTime,
  898. [event.currentTarget.dataset.value+'.orderType'] : event.detail.value.orderType
  899. });
  900. var moneyCount = 0 ;
  901. for (let i = 0; i < that.data.form.transfers.length; i++) {
  902. const element = that.data.form.transfers[i];
  903. for (let j = 0; j < element.payeeList.length; j++) {
  904. const element2 = element.payeeList[j];
  905. var allCount = 0 ;
  906. moneyCount = parseFloat(moneyCount)+parseFloat(element2.incomeAmount);
  907. // allCount = parseFloat(allCount)+parseFloat(element2.incomeAmount);
  908. // this.setData({
  909. // ["form.transfers["+i+"].expenditureAmount"]:allCount,
  910. // })
  911. }
  912. }
  913. console.log(moneyCount.toFixed(2));
  914. this.setData({
  915. ["form.approvalItemTemplate.totalAmount"]:moneyCount.toFixed(2),
  916. })
  917. },
  918. goPayeeList(event){
  919. console.log(event)
  920. if(event.currentTarget.dataset.payer == null || event.currentTarget.dataset.payer == ''){
  921. UTIL.showToastNoneIcon('请先选择付款方!');
  922. return;
  923. }
  924. if(event.currentTarget.dataset.banktype == 10){
  925. if(event.currentTarget.dataset.childaccounttype == null || event.currentTarget.dataset.childaccounttype == ''){
  926. UTIL.showToastNoneIcon('请先选择账户类型!');
  927. return;
  928. }
  929. }else{
  930. event.currentTarget.dataset.accounttype = '';
  931. this.setData({
  932. ['form.accountType']: ''
  933. })
  934. }
  935. if(this.data.form.payeeList.length>10){
  936. return;
  937. }
  938. // if(event.currentTarget.dataset.accounttype == null ){
  939. // event.currentTarget.dataset.accounttype = ''
  940. // }
  941. // '/pages/payee/index?isPeers='+event.currentTarget.dataset.ispeers+'&bankType='+event.currentTarget.dataset.banktype+'&accountType='+event.currentTarget.dataset.accounttype+'&transferType='+event.currentTarget.dataset.transfertype + '&index='+event.currentTarget.dataset.index+'&money='+this.data.form.transfers
  942. console.log(this.data.form.isPeers);
  943. console.log(event.currentTarget.dataset.isPeers);
  944. wx.navigateTo({
  945. url: '/pages/payee/index?transferType='+event.currentTarget.dataset.transfertype+'&money='+this.data.form.expenditureAmount + '&index='+event.currentTarget.dataset.index + '&isPeers='+event.currentTarget.dataset.ispeers+'&bankType='+event.currentTarget.dataset.banktype+'&accountType='+event.currentTarget.dataset.accounttype,
  946. })
  947. },
  948. goPayee(event){
  949. wx.navigateTo({
  950. url: '/pages/pay/payee/payee?options='+JSON.stringify(event.currentTarget.dataset.option)
  951. })
  952. },
  953. onChange(event){
  954. console.log(event);
  955. this.setData({
  956. [event.currentTarget.dataset.value]: event.detail,
  957. })
  958. },
  959. onChangeZZFY(event){
  960. console.log(event);
  961. this.setData({
  962. [event.currentTarget.dataset.value]: event.detail,
  963. })
  964. },
  965. onChangeHnzz(event){
  966. console.log(event);
  967. this.setData({
  968. [event.currentTarget.dataset.value]: event.detail,
  969. ["form.payeeList"]: [{//收款方账户集合
  970. payeeId:'0',//收款方id
  971. payee:'',//收款方
  972. bankDeposit:'',//开户行
  973. incomeAmount:'',//收入金额
  974. bankType:'',//所属银行0其他银行1中国银行2农商行(山东省)3农业银行4建设银行5工商银行
  975. payeeAccount:'',//收款账户
  976. }],
  977. })
  978. },
  979. onChangeTime(event){
  980. console.log(event);
  981. this.setData({
  982. applyDate: event.detail,
  983. })
  984. },
  985. onConfirmTime(event){
  986. this.setData({
  987. [event.currentTarget.dataset.name]: false,
  988. applyDate: UTIL.formatDate(event.detail),
  989. });
  990. this.setData({
  991. ["form.applyDate"]:UTIL.formatDate(event.detail),
  992. })
  993. },
  994. onChangeMoneyOut(event){
  995. console.log(event);
  996. var that = this;
  997. if( !(event.detail.value > -1)){
  998. this.setData({
  999. ["form.transfers["+event.currentTarget.dataset.index+"].expenditureAmount"]:'',
  1000. })
  1001. return;
  1002. }
  1003. if( event.detail.value.indexOf('.')>0 && event.detail.value.toString().split(".")[1].length>2){
  1004. this.setData({
  1005. ["form.transfers["+event.currentTarget.dataset.index+"].expenditureAmount"]:event.detail.value.toString().split(".")[0] + '.' + event.detail.value.toString().split(".")[1].substr(0,2),
  1006. })
  1007. return;
  1008. }
  1009. this.setData({
  1010. // ["form.transfers["+event.currentTarget.dataset.index+"].payeeList["+event.currentTarget.dataset.childrenindex+"].incomeAmount"]: event.detail,
  1011. ["form.transfers["+event.currentTarget.dataset.index+"].payeeList[0].incomeAmount"]: event.detail.value,
  1012. ["form.transfers["+event.currentTarget.dataset.index+"].expenditureAmount"]:event.detail.value,
  1013. // ["form.transfers["+event.currentTarget.dataset.index+"].expenditureAmount"]:event.detail,
  1014. })
  1015. if(event.detail.value == ''){
  1016. that.data.form.transfers[event.currentTarget.dataset.index].payeeList[0].incomeAmount = parseFloat(0).toFixed(2);
  1017. that.data.form.transfers[event.currentTarget.dataset.index].expenditureAmount = parseFloat(0).toFixed(2);
  1018. }
  1019. var moneyCount = 0 ;
  1020. for (let i = 0; i < that.data.form.transfers.length; i++) {
  1021. const element = that.data.form.transfers[i];
  1022. for (let j = 0; j < element.payeeList.length; j++) {
  1023. const element2 = element.payeeList[j];
  1024. console.log(element2.incomeAmount);
  1025. var allCount = 0 ;
  1026. moneyCount = parseFloat(moneyCount) + parseFloat(element2.incomeAmount);
  1027. // allCount = parseFloat(allCount)+parseFloat(element2.incomeAmount);
  1028. // this.setData({
  1029. // ["form.transfers["+i+"].expenditureAmount"]:allCount,
  1030. // })
  1031. }
  1032. }
  1033. this.setData({
  1034. ["form.approvalItemTemplate.totalAmount"]:moneyCount.toFixed(2),
  1035. })
  1036. },
  1037. onChangeMoney(event){
  1038. console.log(event);
  1039. var that = this;
  1040. if( !(event.detail > -1)){
  1041. this.setData({
  1042. ["form.transfers["+event.currentTarget.dataset.index+"].expenditureAmount"]:'',
  1043. })
  1044. return;
  1045. }
  1046. if( event.detail.indexOf('.')>0 && event.detail.toString().split(".")[1].length>2){
  1047. this.setData({
  1048. ["form.transfers["+event.currentTarget.dataset.index+"].expenditureAmount"]:event.detail.toString().split(".")[0] + '.' + event.detail.toString().split(".")[1].substr(0,2),
  1049. })
  1050. return;
  1051. }
  1052. this.setData({
  1053. // ["form.transfers["+event.currentTarget.dataset.index+"].payeeList["+event.currentTarget.dataset.childrenindex+"].incomeAmount"]: event.detail,
  1054. ["form.transfers["+event.currentTarget.dataset.index+"].payeeList[0].incomeAmount"]: event.detail,
  1055. ["form.transfers["+event.currentTarget.dataset.index+"].expenditureAmount"]:event.detail,
  1056. // ["form.transfers["+event.currentTarget.dataset.index+"].expenditureAmount"]:event.detail,
  1057. })
  1058. if(event.detail == ''){
  1059. that.data.form.transfers[event.currentTarget.dataset.index].payeeList[0].incomeAmount = parseFloat(0).toFixed(2);
  1060. that.data.form.transfers[event.currentTarget.dataset.index].expenditureAmount = parseFloat(0).toFixed(2);
  1061. }
  1062. console.log(that.data.form);
  1063. var moneyCount = 0 ;
  1064. for (let i = 0; i < that.data.form.transfers.length; i++) {
  1065. const element = that.data.form.transfers[i];
  1066. for (let j = 0; j < element.payeeList.length; j++) {
  1067. const element2 = element.payeeList[j];
  1068. var allCount = 0 ;
  1069. moneyCount = parseFloat(moneyCount)+parseFloat(element2.incomeAmount);
  1070. // allCount = parseFloat(allCount)+parseFloat(element2.incomeAmount);
  1071. // this.setData({
  1072. // ["form.transfers["+i+"].expenditureAmount"]:allCount,
  1073. // })
  1074. }
  1075. }
  1076. this.setData({
  1077. ["form.approvalItemTemplate.totalAmount"]:moneyCount.toFixed(2),
  1078. })
  1079. },
  1080. back:function(){
  1081. wx.navigateBack({
  1082. delta: 1
  1083. })
  1084. },
  1085. goSubmitMB(){
  1086. this.setData({
  1087. showDialog:true
  1088. })
  1089. },
  1090. onClose(){
  1091. this.setData({
  1092. showDialog:false
  1093. })
  1094. },
  1095. bindNameInput(even){
  1096. this.setData({
  1097. ["form.approvalItemTemplate.templateName"]:even.detail.value
  1098. })
  1099. },
  1100. goSubmit(e){
  1101. var that = this;
  1102. console.log(that.data.form);
  1103. var list = that.data.form;
  1104. // approvalItems = list.approvalItemTemplate.approvalItems;
  1105. // if(approvalItems == ''){
  1106. // UTIL.showToastNoneIcon('请填写审批事项名称!');
  1107. // that.setData({
  1108. // topInputTirme:true
  1109. // })
  1110. // return;
  1111. // }
  1112. if(list.applyDate == ''){
  1113. UTIL.showToastNoneIcon('请选择申请时间!');
  1114. return;
  1115. }
  1116. if(list.remark == ''){
  1117. UTIL.showToastNoneIcon('请填写转账附言!');
  1118. return;
  1119. }
  1120. if(list.explainSituation == ''){
  1121. UTIL.showToastNoneIcon('请填写说明情况!');
  1122. return;
  1123. }
  1124. if(list.expenditureAmount == ''){
  1125. UTIL.showToastNoneIcon('请检查收款方收款金额!');
  1126. return;
  1127. }
  1128. console.log(parseFloat(list.expenditureAmount).toFixed(2))
  1129. console.log(parseFloat(list.payerAccount).toFixed(2))
  1130. console.log(list.transferType);
  1131. if((parseFloat(list.expenditureAmount).toFixed(2) - parseFloat(list.payerAccount).toFixed(2) >0) && list.transferType == 11){
  1132. UTIL.showToastNoneIcon('支出金额不能超过付款账户余额!');
  1133. return;
  1134. }
  1135. if(list.payer == ''&&list.transferType != 12){
  1136. UTIL.showToastNoneIcon('请选择付款方!');
  1137. return;
  1138. }
  1139. if(list.payeeList[0].payee == ''&&list.transferType!=12){
  1140. UTIL.showToastNoneIcon('请选择收款方!');
  1141. return;
  1142. }
  1143. if((list.payeeList[0].incomeAmount == '' || list.payeeList[0].incomeAmount == undefined)&&list.transferType!=12){
  1144. UTIL.showToastNoneIcon('请填写收款方的收入金额!');
  1145. return;
  1146. }
  1147. if(list.transferType == '12'){
  1148. list.transfers[i].payer = list.transfers[i].moneyOrderForm.billPayUnit;
  1149. list.transfers[i].payerAccount = list.transfers[i].moneyOrderForm.orderNum;
  1150. list.transfers[i].cashierId = list.transfers[i].moneyOrderForm.id;
  1151. list.transfers[i].startTime = list.transfers[i].moneyOrderForm.startTime;
  1152. list.transfers[i].endTime = list.transfers[i].moneyOrderForm.endTime;
  1153. list.transfers[i].orderType = list.transfers[i].moneyOrderForm.orderType;
  1154. }
  1155. if(e.currentTarget.dataset.type == 1){
  1156. if(that.data.form.approvalItemTemplate.templateName == ''){
  1157. UTIL.showToastNoneIcon('请输入模板名称!');
  1158. return;
  1159. }
  1160. }
  1161. if(e.currentTarget.dataset.type == 3){
  1162. for (let i = 0; i < that.data.form.transfers.length; i++) {
  1163. that.data.form.transfers[i].approvalMode = '2';
  1164. }
  1165. that.data.form.approvalItemTemplate.dataType = e.currentTarget.dataset.type
  1166. }
  1167. that.data.form.method = 'POST';
  1168. that.data.form.approvalItemTemplate.dataType = e.currentTarget.dataset.type;
  1169. console.log(that.data.form);
  1170. UTIL.httpRequest(API.URL_GET_SAVE, that.data.form, {
  1171. success: (res) => {
  1172. if (res.code == API.SUCCESS_CODE) {
  1173. console.log(res.data.transfers.length);
  1174. for (let j = 0; j < res.data.transfers.length; j++) {
  1175. if(that.data.form.transfers[j].capitalExpenditureType == 2){
  1176. that.data.form.transfers[j].projectForm.ynType = res.data.transfers[j].transferType=='1'||res.data.transfers[j].transferType=='2'||res.data.transfers[j].transferType=='4'?'1':'2';
  1177. that.data.form.transfers[j].projectForm.outId = res.data.transfers[j].id;
  1178. that.data.form.transfers[j].projectForm.method = 'POST';
  1179. // 工程项目提交
  1180. UTIL.httpRequest(API.URL_GET_ADDPROJECTTO , that.data.form.transfers[j].projectForm, {
  1181. success: (res) => {
  1182. }
  1183. })
  1184. }
  1185. if(that.data.form.transfers[j].capitalExpenditureType == 4){
  1186. that.data.form.transfers[j].contractionForm.transferId = res.data.transfers[j].id;
  1187. that.data.form.transfers[j].contractionForm.id = '';
  1188. that.data.form.transfers[j].contractionForm.method = 'POST';
  1189. // 关联合同提交
  1190. UTIL.httpRequest(API.URL_GET_GETRELATIONADD , that.data.form.transfers[j].contractionForm, {
  1191. success: (res) => {
  1192. }
  1193. })
  1194. }
  1195. // if(that.data.form.transfers[j].fileForm == undefined){continue;}
  1196. that.data.form.transfers[j].id = res.data.transfers[j].id
  1197. console.log(that.data.form.transfers[j])
  1198. that.upDownFile(that.data.form.transfers[j]).then(response=>{
  1199. wx.hideLoading();
  1200. console.log(e.currentTarget.dataset.type);
  1201. if(e.currentTarget.dataset.type == 0){
  1202. wx.navigateTo({
  1203. url: '/pages/apply/approval/approval?id='+res.data.approvalItemTemplate.id+'&deptId='+res.data.approvalItemTemplate.deptId+'&form='+JSON.stringify(res.data)+'&type='+that.data.formType+'&applyOptions='+JSON.stringify(that.data.templateModel),
  1204. })
  1205. }
  1206. if(e.currentTarget.dataset.type == 2){
  1207. wx.showToast({
  1208. title: '保存成功',
  1209. icon: 'success',
  1210. duration: 2000,
  1211. })
  1212. }
  1213. if(e.currentTarget.dataset.type == 1){
  1214. console.log("aaa");
  1215. wx.showToast({
  1216. title: '保存成功',
  1217. icon: 'success',
  1218. duration: 2000,
  1219. complete(){
  1220. setTimeout(function(){
  1221. that.back();
  1222. },2000)
  1223. }
  1224. })
  1225. }
  1226. if(e.currentTarget.dataset.type == 3){
  1227. UTIL.httpRequest(API.URL_GET_TOREVIEWSUBMIT+res.data.approvalItemTemplate.id , {method:'POST'}, {
  1228. success: (res2) => {
  1229. if (res2.code == API.SUCCESS_CODE) {
  1230. wx.showToast({
  1231. title: '操作成功',
  1232. icon: 'success',
  1233. duration: 2000,
  1234. complete(){
  1235. setTimeout(function(){
  1236. that.back();
  1237. },2000)
  1238. }
  1239. })
  1240. }else{
  1241. wx.showToast({
  1242. title: '操作失败',
  1243. icon: 'error',
  1244. duration: 2000
  1245. })
  1246. }
  1247. }
  1248. })
  1249. }
  1250. }).catch((err) => {
  1251. console.log(err);
  1252. wx.hideLoading();
  1253. if(e.currentTarget.dataset.type == 0){
  1254. wx.navigateTo({
  1255. url: '/pages/apply/approval/approval?id='+res.data.approvalItemTemplate.id+'&deptId='+res.data.approvalItemTemplate.deptId+'&form='+JSON.stringify(res.data)+'&type='+that.data.formType+'&applyOptions='+JSON.stringify(that.data.templateModel),
  1256. })
  1257. }
  1258. if(e.currentTarget.dataset.type == 2){
  1259. wx.showToast({
  1260. title: '保存成功',
  1261. icon: 'success',
  1262. duration: 2000,
  1263. })
  1264. }
  1265. if(e.currentTarget.dataset.type == 1){
  1266. console.log("aaa");
  1267. wx.showToast({
  1268. title: '保存成功',
  1269. icon: 'success',
  1270. duration: 2000,
  1271. complete(){
  1272. setTimeout(function(){
  1273. that.back();
  1274. },2000)
  1275. }
  1276. })
  1277. }
  1278. if(e.currentTarget.dataset.type == 3){
  1279. UTIL.httpRequest(API.URL_GET_TOREVIEWSUBMIT+res.data.approvalItemTemplate.id , {method:'POST'}, {
  1280. success: (res2) => {
  1281. if (res2.code == API.SUCCESS_CODE) {
  1282. wx.showToast({
  1283. title: '操作成功',
  1284. icon: 'success',
  1285. duration: 2000,
  1286. complete(){
  1287. setTimeout(function(){
  1288. that.back();
  1289. },2000)
  1290. }
  1291. })
  1292. }else{
  1293. wx.showToast({
  1294. title: '操作失败',
  1295. icon: 'error',
  1296. duration: 2000
  1297. })
  1298. }
  1299. }
  1300. })
  1301. }
  1302. })
  1303. }
  1304. }
  1305. }
  1306. })
  1307. },
  1308. goSubmitNew(e){
  1309. var that = this;
  1310. console.log(that.data.form);
  1311. var list = that.data.form;
  1312. if(list.applyDate == ''){
  1313. UTIL.showToastNoneIcon('请选择申请时间!');
  1314. return;
  1315. }
  1316. if(list.remark == ''){
  1317. UTIL.showToastNoneIcon('请填写转账附言!');
  1318. return;
  1319. }
  1320. var p = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  1321. if (p.test(list.remark)) {
  1322. UTIL.showToastNoneIcon('‘转账附言’存在非法字符,请尽量简洁并减少标点符号的使用,详情可在‘说明情况’中描述。');
  1323. return;
  1324. }
  1325. // if(list.explainSituation == ''){
  1326. // UTIL.showToastNoneIcon('请填写说明情况!');
  1327. // return;
  1328. // }
  1329. if(list.expenditureAmount == ''){
  1330. UTIL.showToastNoneIcon('请检查收款方收款金额!');
  1331. return;
  1332. }
  1333. if((parseFloat(list.expenditureAmount).toFixed(2) - parseFloat(list.payerAccount).toFixed(2) >0) && list.transferType == 11){
  1334. UTIL.showToastNoneIcon('支出金额不能超过付款账户余额!');
  1335. return;
  1336. }
  1337. if(list.payer == ''&&list.transferType != 12){
  1338. UTIL.showToastNoneIcon('请选择付款方!');
  1339. return;
  1340. }
  1341. if(list.payeeList[0].payee == ''&&list.transferType!=12){
  1342. UTIL.showToastNoneIcon('请选择收款方!');
  1343. return;
  1344. }
  1345. for(let i = 0 ; i < list.payeeList.length ; i++){
  1346. if(list.payeeList[i].payee == ''){
  1347. UTIL.showToastNoneIcon('请选择收款方!');
  1348. return;
  1349. }
  1350. console.log(list.transferType);
  1351. if((list.payeeList[i].incomeAmount == '' || list.payeeList[i].incomeAmount == undefined)){
  1352. UTIL.showToastNoneIcon('请填写收款方的收入金额!');
  1353. return;
  1354. }
  1355. console.log(isNaN(parseFloat(list.payeeList[i].incomeAmount)));
  1356. console.log(!isFinite(list.payeeList[i].incomeAmount));
  1357. if(isNaN(parseFloat(list.payeeList[i].incomeAmount)) || !isFinite(list.payeeList[i].incomeAmount)){
  1358. UTIL.showToastNoneIcon('请填写正确的收款方收入金额!');
  1359. return;
  1360. }
  1361. }
  1362. if(list.capitalExpenditureType == 2){
  1363. if(list.projectForm.projectName==""||list.projectForm.projectName==null){
  1364. UTIL.showToastNoneIcon('请选择项目名称!');
  1365. return;
  1366. }
  1367. if(list.projectForm.projectBillNum==""||list.projectForm.projectBillNum==null){
  1368. UTIL.showToastNoneIcon('请输入工程发票号!');
  1369. return;
  1370. }
  1371. }
  1372. if(list.capitalExpenditureType==4){
  1373. if(list.contractionForm.name==""||list.contractionForm.name==null){
  1374. UTIL.showToastNoneIcon('请选择合同名称!');
  1375. return;
  1376. }
  1377. if(list.contractionForm.code==""||list.contractionForm.code==null){
  1378. UTIL.showToastNoneIcon('请输入合同编码!');
  1379. return;
  1380. }
  1381. if(list.contractionForm.totalAmount==""||list.contractionForm.totalAmount==null){
  1382. UTIL.showToastNoneIcon('请输入合同价款!');
  1383. return;
  1384. }
  1385. }
  1386. if(list.transferType == '12'){
  1387. list.transfers[i].payer = list.transfers[i].moneyOrderForm.billPayUnit;
  1388. list.transfers[i].payerAccount = list.transfers[i].moneyOrderForm.orderNum;
  1389. list.transfers[i].cashierId = list.transfers[i].moneyOrderForm.id;
  1390. list.transfers[i].startTime = list.transfers[i].moneyOrderForm.startTime;
  1391. list.transfers[i].endTime = list.transfers[i].moneyOrderForm.endTime;
  1392. list.transfers[i].orderType = list.transfers[i].moneyOrderForm.orderType;
  1393. }
  1394. that.data.form.method = 'POST';
  1395. console.log(that.data.form);
  1396. UTIL.httpRequest(API.URL_GET_TRANSFERADD, that.data.form, {
  1397. success: (res) => {
  1398. if (res.code == API.SUCCESS_CODE) {
  1399. if(that.data.form.capitalExpenditureType == 2){
  1400. that.data.form.projectForm.ynType = res.data.transferType=='1'||res.data.transferType=='2'||res.data.transferType=='4'?'1':'2';
  1401. that.data.form.projectForm.outId = res.data.id;
  1402. that.data.form.projectForm.method = 'POST';
  1403. // 工程项目提交
  1404. UTIL.httpRequest(API.URL_GET_ADDPROJECTTO , that.data.form.projectForm, {
  1405. success: (res) => {
  1406. }
  1407. })
  1408. }
  1409. if(that.data.form.capitalExpenditureType == 4){
  1410. that.data.form.contractionForm.transferId = res.data.id;
  1411. that.data.form.contractionForm.id = '';
  1412. that.data.form.contractionForm.method = 'POST';
  1413. // 关联合同提交
  1414. UTIL.httpRequest(API.URL_GET_GETRELATIONADD , that.data.form.contractionForm, {
  1415. success: (res) => {
  1416. }
  1417. })
  1418. }
  1419. // if(that.data.form.fileForm == undefined){continue;}
  1420. that.data.form.id = res.data.id
  1421. that.setData({
  1422. showFile:true
  1423. })
  1424. // console.log(that.data.form)
  1425. }else{
  1426. wx.showToast({
  1427. title: res.msg,
  1428. icon: 'error',
  1429. duration: 2000
  1430. })
  1431. }
  1432. }
  1433. })
  1434. },
  1435. upLoadNew(){
  1436. var that = this;
  1437. that.upDownFile(that.data.form).then(response=>{
  1438. wx.hideLoading();
  1439. console.log(e.currentTarget.dataset.type);
  1440. if(e.currentTarget.dataset.type == 0){
  1441. wx.navigateTo({
  1442. url: '/pages/apply/approval/approval?id='+res.data.approvalItemTemplate.id+'&deptId='+res.data.approvalItemTemplate.deptId+'&form='+JSON.stringify(res.data)+'&type='+that.data.formType+'&applyOptions='+JSON.stringify(that.data.templateModel),
  1443. })
  1444. }
  1445. if(e.currentTarget.dataset.type == 2){
  1446. wx.showToast({
  1447. title: '保存成功',
  1448. icon: 'success',
  1449. duration: 2000,
  1450. })
  1451. }
  1452. if(e.currentTarget.dataset.type == 1){
  1453. console.log("aaa");
  1454. wx.showToast({
  1455. title: '保存成功',
  1456. icon: 'success',
  1457. duration: 2000,
  1458. complete(){
  1459. setTimeout(function(){
  1460. that.back();
  1461. },2000)
  1462. }
  1463. })
  1464. }
  1465. if(e.currentTarget.dataset.type == 3){
  1466. UTIL.httpRequest(API.URL_GET_TOREVIEWSUBMIT+res.data.approvalItemTemplate.id , {method:'POST'}, {
  1467. success: (res2) => {
  1468. if (res2.code == API.SUCCESS_CODE) {
  1469. wx.showToast({
  1470. title: '操作成功',
  1471. icon: 'success',
  1472. duration: 2000,
  1473. complete(){
  1474. setTimeout(function(){
  1475. that.back();
  1476. },2000)
  1477. }
  1478. })
  1479. }else{
  1480. wx.showToast({
  1481. title: '操作失败',
  1482. icon: 'error',
  1483. duration: 2000
  1484. })
  1485. }
  1486. }
  1487. })
  1488. }
  1489. }).catch((err) => {
  1490. console.log(err);
  1491. wx.hideLoading();
  1492. if(e.currentTarget.dataset.type == 0){
  1493. wx.navigateTo({
  1494. url: '/pages/apply/approval/approval?id='+res.data.approvalItemTemplate.id+'&deptId='+res.data.approvalItemTemplate.deptId+'&form='+JSON.stringify(res.data)+'&type='+that.data.formType+'&applyOptions='+JSON.stringify(that.data.templateModel),
  1495. })
  1496. }
  1497. if(e.currentTarget.dataset.type == 2){
  1498. wx.showToast({
  1499. title: '保存成功',
  1500. icon: 'success',
  1501. duration: 2000,
  1502. })
  1503. }
  1504. if(e.currentTarget.dataset.type == 1){
  1505. console.log("aaa");
  1506. wx.showToast({
  1507. title: '保存成功',
  1508. icon: 'success',
  1509. duration: 2000,
  1510. complete(){
  1511. setTimeout(function(){
  1512. that.back();
  1513. },2000)
  1514. }
  1515. })
  1516. }
  1517. if(e.currentTarget.dataset.type == 3){
  1518. UTIL.httpRequest(API.URL_GET_TOREVIEWSUBMIT+res.data.approvalItemTemplate.id , {method:'POST'}, {
  1519. success: (res2) => {
  1520. if (res2.code == API.SUCCESS_CODE) {
  1521. wx.showToast({
  1522. title: '操作成功',
  1523. icon: 'success',
  1524. duration: 2000,
  1525. complete(){
  1526. setTimeout(function(){
  1527. that.back();
  1528. },2000)
  1529. }
  1530. })
  1531. }else{
  1532. wx.showToast({
  1533. title: '操作失败',
  1534. icon: 'error',
  1535. duration: 2000
  1536. })
  1537. }
  1538. }
  1539. })
  1540. }
  1541. })
  1542. },
  1543. upDownFile(op){
  1544. var that = this;
  1545. console.log(op)
  1546. wx.showLoading({
  1547. title: '正在上传附件',
  1548. mask:true
  1549. })
  1550. return new Promise((resolve, reject) => {
  1551. if(op.fileForm.length > 0){
  1552. for (let i = 0; i < op.fileForm.length; i++) {
  1553. op.fileForm[i].tableId = op.id
  1554. const element = op.fileForm[i];
  1555. console.log(element);
  1556. wx.uploadFile({
  1557. url: wx.getStorageSync('dressCode')+API.URL_GET_UPLOAD,
  1558. filePath: element.file,
  1559. name: 'file',
  1560. header: {
  1561. "Content-Type": "multipart/form-data",//记得设置
  1562. "chartset":"utf-8",
  1563. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  1564. },
  1565. formData:element,
  1566. success (response){
  1567. if(op.fileForm.length == (i+1)){
  1568. resolve();
  1569. }
  1570. },
  1571. fail(res){
  1572. console.log(res)
  1573. reject();
  1574. }
  1575. })
  1576. }
  1577. }else{
  1578. reject();
  1579. }
  1580. });
  1581. },
  1582. goCustomSubmit(){
  1583. var that = this;
  1584. UTIL.httpRequest(API.URL_GET_TRANSFERCUSTOMSUBMIT2+this.data.form.id, {method : 'POST'}, {
  1585. success: (res) => {
  1586. if (res.code == API.SUCCESS_CODE) {
  1587. wx.showToast({
  1588. title: '提交成功',
  1589. icon: 'success',
  1590. duration: 2000,
  1591. complete(){
  1592. setTimeout(function(){
  1593. that.back();
  1594. },2000)
  1595. }
  1596. })
  1597. }else{
  1598. wx.showToast({
  1599. title: res.msg,
  1600. icon: 'error',
  1601. duration: 2000
  1602. })
  1603. }
  1604. }
  1605. })
  1606. },
  1607. goCustomSubmit2(){
  1608. var that = this;
  1609. wx.showLoading({
  1610. title: '正在提交',
  1611. mask:true
  1612. })
  1613. that.goKeepNew();
  1614. setTimeout(() => {
  1615. UTIL.httpRequest(API.URL_GET_TRANSFERCUSTOMSUBMIT2+this.data.form.id, {method : 'POST'}, {
  1616. success: (res) => {
  1617. if (res.code == API.SUCCESS_CODE) {
  1618. wx.hideLoading();
  1619. wx.showToast({
  1620. title: '提交成功',
  1621. icon: 'success',
  1622. duration: 2000,
  1623. complete(){
  1624. setTimeout(function(){
  1625. that.back();
  1626. },2000)
  1627. }
  1628. })
  1629. }else{
  1630. wx.showToast({
  1631. title: res.msg,
  1632. icon: 'error',
  1633. duration: 2000
  1634. })
  1635. }
  1636. }
  1637. })
  1638. }, 1000);
  1639. },
  1640. bindKeyInput(even){
  1641. console.log(even);
  1642. this.setData({
  1643. ["form.approvalItemTemplate.approvalItems"]: even.detail,
  1644. })
  1645. },
  1646. errorPd(e){
  1647. console.log(e);
  1648. this.setData({
  1649. [e.currentTarget.dataset.formname+"Tirme"]:e.detail.value == '' ? true:false
  1650. })
  1651. },
  1652. errorJE(e){
  1653. console.log(e);
  1654. this.setData({
  1655. [e.currentTarget.dataset.formname+"Tirme"]:e.detail.value == '' ? true:false
  1656. })
  1657. },
  1658. errorYY(e){
  1659. console.log(e);
  1660. this.setData({
  1661. [e.currentTarget.dataset.formname+"Tirme"]:e.detail.value == '' ? true:false
  1662. })
  1663. },
  1664. SJtakephoto(e){
  1665. var that = this;
  1666. let fileForm = [];
  1667. wx.chooseMedia({
  1668. mediaType: ['image'],
  1669. sourceType: ['album', 'camera'],
  1670. camera: 'back',
  1671. count: 9,
  1672. success(res) {
  1673. console.log(res);
  1674. res.tempFiles.forEach(item => {
  1675. fileForm.push({
  1676. file: item.tempFilePath,
  1677. fileType:'1',
  1678. bizPath:'transfer',
  1679. tableName:'t_yinnong_transfer',
  1680. tableId:that.data.form.id
  1681. })
  1682. })
  1683. console.log(fileForm);
  1684. const element = fileForm[0];
  1685. let tem = that.data.form.SJimage?that.data.form.SJimage:[];
  1686. fileForm.forEach( (rr,index) => {
  1687. wx.uploadFile({
  1688. url: wx.getStorageSync('dressCode')+API.URL_GET_UPLOAD,
  1689. filePath: rr.file,
  1690. name: 'file',
  1691. header: {
  1692. "Content-Type": "multipart/form-data",//记得设置
  1693. "chartset":"utf-8",
  1694. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  1695. },
  1696. formData:rr,
  1697. success (response){
  1698. let data = JSON.parse(response.data);
  1699. console.log(data);
  1700. tem.push({
  1701. tempFilePath:wx.getStorageSync('dressCode')+data.fileUrl,
  1702. id:data.id
  1703. })
  1704. console.log(tem);
  1705. that.setData({
  1706. ["form.SJimage"]:tem,
  1707. ["form.fileForm"]:fileForm,
  1708. })
  1709. let SJlength = that.data.form.SJimage == undefined ? 0:that.data.form.SJimage.length;
  1710. let FPlength = that.data.form.FPimage == undefined ? 0:that.data.form.FPimage.length;
  1711. let QTlength = that.data.form.QTimage == undefined ? 0:that.data.form.QTimage.length;
  1712. let SYLGKlength = that.data.form.SYLGKimage == undefined ? 0:that.data.form.SYLGKimage.length;
  1713. let fileNum = parseInt( SJlength ) + parseInt( FPlength ) + parseInt( QTlength ) + parseInt( SYLGKlength ) ;
  1714. that.setData({
  1715. ["form.fileNum"]:fileNum,
  1716. })
  1717. wx.showToast({
  1718. title: '上传成功',
  1719. icon: 'success',
  1720. duration: 2000,
  1721. })
  1722. },
  1723. fail(res){
  1724. console.log(res)
  1725. }
  1726. })
  1727. })
  1728. },fail(err){
  1729. console.log(err);
  1730. }
  1731. })
  1732. },
  1733. FPtakephoto(e){
  1734. var that = this;
  1735. let fileForm = [];
  1736. console.log(fileForm);
  1737. wx.chooseMedia({
  1738. mediaType: ['image'],
  1739. sourceType: ['album', 'camera'],
  1740. camera: 'back',
  1741. count: 9,
  1742. success(res) {
  1743. console.log(res);
  1744. res.tempFiles.forEach(item => {
  1745. fileForm.push({
  1746. file: item.tempFilePath,
  1747. fileType:'2',
  1748. bizPath:'transfer',
  1749. tableName:'t_yinnong_transfer',
  1750. tableId:that.data.form.id
  1751. })
  1752. })
  1753. let tem = that.data.form.FPimage?that.data.form.FPimage:[];
  1754. fileForm.forEach( rr => {
  1755. wx.uploadFile({
  1756. url: wx.getStorageSync('dressCode')+API.URL_GET_UPLOAD,
  1757. filePath: rr.file,
  1758. name: 'file',
  1759. header: {
  1760. "Content-Type": "multipart/form-data",//记得设置
  1761. "chartset":"utf-8",
  1762. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  1763. },
  1764. formData:rr,
  1765. success (response){
  1766. let data = JSON.parse(response.data);
  1767. console.log(data);
  1768. tem.push({
  1769. tempFilePath:wx.getStorageSync('dressCode')+data.fileUrl,
  1770. id:data.id
  1771. })
  1772. console.log(tem);
  1773. that.setData({
  1774. ["form.FPimage"]:tem,
  1775. ["form.fileForm"]:fileForm
  1776. })
  1777. let SJlength = that.data.form.SJimage == undefined ? 0:that.data.form.SJimage.length;
  1778. let FPlength = that.data.form.FPimage == undefined ? 0:that.data.form.FPimage.length;
  1779. let QTlength = that.data.form.QTimage == undefined ? 0:that.data.form.QTimage.length;
  1780. let SYLGKlength = that.data.form.SYLGKimage == undefined ? 0:that.data.form.SYLGKimage.length;
  1781. let fileNum = parseInt( SJlength ) + parseInt( FPlength ) + parseInt( QTlength ) + parseInt( SYLGKlength ) ;
  1782. that.setData({
  1783. ["form.fileNum"]:fileNum,
  1784. })
  1785. wx.showToast({
  1786. title: '上传成功',
  1787. icon: 'success',
  1788. duration: 2000,
  1789. })
  1790. },
  1791. fail(res){
  1792. console.log(res)
  1793. }
  1794. })
  1795. })
  1796. },fail(err){
  1797. console.log(err);
  1798. }
  1799. })
  1800. },
  1801. QTtakephoto(e){
  1802. var that = this;
  1803. let fileForm = [];
  1804. wx.chooseMedia({
  1805. mediaType: ['image'],
  1806. sourceType: ['album', 'camera'],
  1807. camera: 'back',
  1808. count: 9,
  1809. success(res) {
  1810. console.log(res);
  1811. res.tempFiles.forEach(item => {
  1812. fileForm.push({
  1813. file: item.tempFilePath,
  1814. fileType:'3',
  1815. bizPath:'transfer',
  1816. tableName:'t_yinnong_transfer',
  1817. tableId:that.data.form.id
  1818. })
  1819. })
  1820. console.log(fileForm);
  1821. let tem = that.data.form.QTimage?that.data.form.QTimage:[];
  1822. fileForm.forEach( rr => {
  1823. wx.uploadFile({
  1824. url: wx.getStorageSync('dressCode')+API.URL_GET_UPLOAD,
  1825. filePath: rr.file,
  1826. name: 'file',
  1827. header: {
  1828. "Content-Type": "multipart/form-data",//记得设置
  1829. "chartset":"utf-8",
  1830. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  1831. },
  1832. formData:rr,
  1833. success (response){
  1834. let data = JSON.parse(response.data);
  1835. console.log(data);
  1836. tem.push({
  1837. tempFilePath:wx.getStorageSync('dressCode')+data.fileUrl,
  1838. id:data.id
  1839. })
  1840. that.setData({
  1841. ["form.QTimage"]:tem,
  1842. ["form.fileForm"]:fileForm
  1843. })
  1844. let SJlength = that.data.form.SJimage == undefined ? 0:that.data.form.SJimage.length;
  1845. let FPlength = that.data.form.FPimage == undefined ? 0:that.data.form.FPimage.length;
  1846. let QTlength = that.data.form.QTimage == undefined ? 0:that.data.form.QTimage.length;
  1847. let SYLGKlength = that.data.form.SYLGKimage == undefined ? 0:that.data.form.SYLGKimage.length;
  1848. let fileNum = parseInt( SJlength ) + parseInt( FPlength ) + parseInt( QTlength ) + parseInt( SYLGKlength ) ;
  1849. that.setData({
  1850. ["form.fileNum"]:fileNum,
  1851. })
  1852. wx.showToast({
  1853. title: '上传成功',
  1854. icon: 'success',
  1855. duration: 2000,
  1856. })
  1857. },
  1858. fail(res){
  1859. console.log(res)
  1860. }
  1861. })
  1862. })
  1863. },fail(err){
  1864. console.log(err);
  1865. }
  1866. })
  1867. },
  1868. SYLGKtakephoto(e){
  1869. var that = this;
  1870. let fileForm = [];
  1871. wx.chooseMedia({
  1872. mediaType: ['image'],
  1873. sourceType: ['album', 'camera'],
  1874. camera: 'back',
  1875. count: 9,
  1876. success(res) {
  1877. console.log(res);
  1878. res.tempFiles.forEach(item => {
  1879. fileForm.push({
  1880. file: item.tempFilePath,
  1881. fileType:'4',
  1882. bizPath:'transfer',
  1883. tableName:'t_yinnong_transfer',
  1884. tableId:that.data.form.id
  1885. })
  1886. })
  1887. console.log(fileForm);
  1888. let tem = that.data.form.SYLGKimage?that.data.form.SYLGKimage:[];
  1889. fileForm.forEach( rr => {
  1890. wx.uploadFile({
  1891. url: wx.getStorageSync('dressCode')+API.URL_GET_UPLOAD,
  1892. filePath: rr.file,
  1893. name: 'file',
  1894. header: {
  1895. "Content-Type": "multipart/form-data",//记得设置
  1896. "chartset":"utf-8",
  1897. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  1898. },
  1899. formData:rr,
  1900. success (response){
  1901. let data = JSON.parse(response.data);
  1902. console.log(data);
  1903. tem.push({
  1904. tempFilePath:wx.getStorageSync('dressCode')+data.fileUrl,
  1905. id:data.id
  1906. })
  1907. that.setData({
  1908. ["form.SYLGKimage"]:tem,
  1909. ["form.fileForm"]:fileForm
  1910. })
  1911. let SJlength = that.data.form.SJimage == undefined ? 0:that.data.form.SJimage.length;
  1912. let FPlength = that.data.form.FPimage == undefined ? 0:that.data.form.FPimage.length;
  1913. let QTlength = that.data.form.QTimage == undefined ? 0:that.data.form.QTimage.length;
  1914. let SYLGKlength = that.data.form.SYLGKimage == undefined ? 0:that.data.form.SYLGKimage.length;
  1915. let fileNum = parseInt( SJlength ) + parseInt( FPlength ) + parseInt( QTlength ) + parseInt( SYLGKlength ) ;
  1916. that.setData({
  1917. ["form.fileNum"]:fileNum,
  1918. })
  1919. wx.showToast({
  1920. title: '上传成功',
  1921. icon: 'success',
  1922. duration: 2000,
  1923. })
  1924. },
  1925. fail(res){
  1926. console.log(res)
  1927. }
  1928. })
  1929. })
  1930. },fail(err){
  1931. console.log(err);
  1932. }
  1933. })
  1934. },
  1935. addList(){
  1936. var that = this;
  1937. let transList = this.data.form.transfers;
  1938. console.log(this.data.form);
  1939. for (let i = 0; i < transList.length; i++) {
  1940. const element = transList[i];
  1941. if(element.applyDate == '' || element.remark == '' || element.expenditureAmount == '' || element.payer == '' || element.payeeList[0].payee == '' || element.payeeList[0].incomeAmount == '' || element.payeeList[0].incomeAmount == undefined){
  1942. UTIL.showToastNoneIcon('事项'+UTIL.convertToChinaNum(i+1)+'的信息填写不完整,检查后重试!');
  1943. return;
  1944. }
  1945. }
  1946. transList.push({
  1947. num:UTIL.convertToChinaNum(transList.length+1),
  1948. expenditureAmountTirme:false,
  1949. remarkTirme:false,
  1950. showCapitalExpenditureType:false,
  1951. showApplyDate:false,
  1952. showTransferType:false,
  1953. showProject:false,
  1954. showProjectFundType:false,
  1955. showAccount:false,
  1956. showDialog:false,
  1957. showContraction:false,
  1958. SJimage:[],
  1959. FPimage:[],
  1960. QTimage:[],
  1961. activeName:0,
  1962. cashForm:{
  1963. payee:'',
  1964. phone:'',
  1965. unit:'',
  1966. leader:'',
  1967. remark:'',
  1968. },
  1969. showTitle:true,
  1970. capitalExpenditureType:'1',//资金支出类别
  1971. capitalExpenditureTypeText:'结算类',//资金支出类别(展示用)
  1972. succeedAmount:'',//成功支付金额
  1973. payer:'',//付款方
  1974. payerAccount:'',//付款方账户
  1975. bankType:'',//所属银行
  1976. bankTypeText:'',//所属银行(展示用)
  1977. isPeers:'N',//是否同行
  1978. operatorCode:'',//操作员代码
  1979. enterpriseCode:'',//企业编码
  1980. expenditureAmount:'',//支出总金额
  1981. applyDate:that.data.applyDate,//申请时间
  1982. transferStatus:'',//转账状态
  1983. auditStatus:'0',//审批状态
  1984. paymentState:'',//支付状态
  1985. approvalMode:'1',//审批模式
  1986. paymentTime:'',//支付时间
  1987. bankPriority:'',//银行处理优先级
  1988. clientPriority:'',//客户处理优先级
  1989. paymentPattern:'1',
  1990. transferType:'1',//付款方式
  1991. transferTypeText:'垫付报销:电子支付',//付款方式(展示用)
  1992. requiredTransferTime:'',//要求转账时间
  1993. remark:'',//付款事由
  1994. startTime:'',//开票日期
  1995. endTime:'',//到期日期
  1996. orderType:'',//汇票类型
  1997. bankAccountType:'2',//账户类别1 公户2私户
  1998. villageAccountType:'',//账户分类
  1999. payeeList:[{//收款方账户集合
  2000. payeeId:'0',//收款方id
  2001. payee:'',//收款方
  2002. bankDeposit:'',//开户行
  2003. incomeAmount:'0.00',//收入金额
  2004. bankType:'',//所属银行0其他银行1中国银行2农商行(山东省)3农业银行4建设银行5工商银行
  2005. payeeAccount:'',//收款账户
  2006. }],
  2007. projectForm:{
  2008. projectId:'',
  2009. projectName:'',
  2010. projectContractor:'',
  2011. projectAmount:'',
  2012. projectBillNum:'',
  2013. projectFundType:'',
  2014. outId:'',
  2015. ynType:'1',
  2016. },
  2017. contractionForm:{
  2018. contractionId:'',
  2019. name:'',
  2020. code:'',
  2021. totalAmount:'',
  2022. },
  2023. });
  2024. //村账户查询参数
  2025. var perames = {
  2026. pageNum:1,
  2027. pageSize:999,
  2028. accountType:'102',
  2029. method:'post',
  2030.   params: {
  2031.          "townAccountType":"0"
  2032.     }
  2033. }
  2034. // 付款方列表
  2035. UTIL.httpRequest(API.URL_GET_SELECTACCOUNTLIST , perames, {
  2036. success: (res) => {
  2037. that.setData({
  2038. accountOptions:res.rows,
  2039. ["form.transfers[0].applyDate"]: UTIL.formatDate(new Date()),
  2040. applyDate: UTIL.formatDate(new Date()),
  2041. })
  2042. }
  2043. })
  2044. this.setData({
  2045. ["form.transfers"] : transList,
  2046. activeNames:transList.length-1
  2047. })
  2048. for (let i = 0; i < this.data.form.transfers.length; i++) {
  2049. const element = this.data.form.transfers[i];
  2050. this.setData({
  2051. ["form.transfers["+i+"].showTitle"] : false,
  2052. })
  2053. }
  2054. this.setData({
  2055. ["form.transfers["+(transList.length-1)+"].showTitle"] : true,
  2056. })
  2057. console.log(this.data.form);
  2058. },
  2059. openPreview(e){
  2060. let array = [];
  2061. console.log(e);
  2062. e.currentTarget.dataset.option.forEach(item=>{
  2063. array.push(item.tempFilePath)
  2064. })
  2065. console.log(array);
  2066. wx.previewImage({
  2067. urls: array,
  2068. showmenu:true,
  2069. current:array[e.currentTarget.dataset.index]
  2070. })
  2071. },
  2072. goKeep(){
  2073. var that = this;
  2074. let pages = getCurrentPages();
  2075. let currentPage = null; //当前页面
  2076. let prevPage = null; //上一个页面
  2077. currentPage = pages[pages.length - 1]; //获取当前页面,将其赋值
  2078. prevPage = pages[pages.length - 2]; //获取上一个页面,将其赋值
  2079. console.log(that.data.form);
  2080. if (prevPage) {
  2081. prevPage.setData({
  2082. form : that.data.form,//将想要传的信息赋值给上一个页面data中的值
  2083. })
  2084. that.back()
  2085. }
  2086. },
  2087. goKeepNew(e){
  2088. var that = this;
  2089. console.log(that.data.form);
  2090. var list = that.data.form;
  2091. if(list.applyDate == ''){
  2092. UTIL.showToastNoneIcon('请选择申请时间!');
  2093. return;
  2094. }
  2095. if(list.remark == ''){
  2096. UTIL.showToastNoneIcon('请填写转账附言!');
  2097. return;
  2098. }
  2099. var p = new RegExp("[`~!@#$^&*()=|{}':;',\\[\\].<>/?~!@#¥……&*()——|{}【】‘;:”“'。,、?]")
  2100. if (p.test(list.remark)) {
  2101. UTIL.showToastNoneIcon('‘转账附言’存在非法字符,请尽量简洁并减少标点符号的使用,详情可在‘说明情况’中描述。');
  2102. return;
  2103. }
  2104. // if(list.explainSituation == ''){
  2105. // UTIL.showToastNoneIcon('请填写说明情况!');
  2106. // return;
  2107. // }
  2108. if(list.expenditureAmount == ''){
  2109. UTIL.showToastNoneIcon('请检查收款方收款金额!');
  2110. return;
  2111. }
  2112. if((parseFloat(list.expenditureAmount).toFixed(2) - parseFloat(list.payerAccount).toFixed(2) >0) && list.transferType == 11){
  2113. UTIL.showToastNoneIcon('支出金额不能超过付款账户余额!');
  2114. return;
  2115. }
  2116. if(list.payer == ''&&list.transferType != 12){
  2117. UTIL.showToastNoneIcon('请选择付款方!');
  2118. return;
  2119. }
  2120. for(let i = 0 ; i < list.payeeList.length ; i++){
  2121. if(list.payeeList[i].payee == ''){
  2122. UTIL.showToastNoneIcon('请选择收款方!');
  2123. return;
  2124. }
  2125. console.log(list.transferType);
  2126. if((list.payeeList[i].incomeAmount == '' || list.payeeList[i].incomeAmount == undefined)){
  2127. UTIL.showToastNoneIcon('请填写收款方的收入金额!');
  2128. return;
  2129. }
  2130. console.log(isNaN(parseFloat(list.payeeList[i].incomeAmount)));
  2131. console.log(!isFinite(list.payeeList[i].incomeAmount));
  2132. if(isNaN(parseFloat(list.payeeList[i].incomeAmount)) || !isFinite(list.payeeList[i].incomeAmount)){
  2133. UTIL.showToastNoneIcon('请填写正确的收款方收入金额!');
  2134. return;
  2135. }
  2136. }
  2137. if(list.capitalExpenditureType == 2){
  2138. if(list.projectForm.projectName==""||list.projectForm.projectName==null){
  2139. UTIL.showToastNoneIcon('请选择项目名称!');
  2140. return;
  2141. }
  2142. if(list.projectForm.projectBillNum==""||list.projectForm.projectBillNum==null){
  2143. UTIL.showToastNoneIcon('请输入工程发票号!');
  2144. return;
  2145. }
  2146. }
  2147. if(list.capitalExpenditureType==4){
  2148. if(list.contractionForm.name==""||list.contractionForm.name==null){
  2149. UTIL.showToastNoneIcon('请选择合同名称!');
  2150. return;
  2151. }
  2152. if(list.contractionForm.code==""||list.contractionForm.code==null){
  2153. UTIL.showToastNoneIcon('请输入合同编码!');
  2154. return;
  2155. }
  2156. if(list.contractionForm.totalAmount==""||list.contractionForm.totalAmount==null){
  2157. UTIL.showToastNoneIcon('请输入合同价款!');
  2158. return;
  2159. }
  2160. }
  2161. if(list.transferType == '12'){
  2162. list.transfers[i].payer = list.transfers[i].moneyOrderForm.billPayUnit;
  2163. list.transfers[i].payerAccount = list.transfers[i].moneyOrderForm.orderNum;
  2164. list.transfers[i].cashierId = list.transfers[i].moneyOrderForm.id;
  2165. list.transfers[i].startTime = list.transfers[i].moneyOrderForm.startTime;
  2166. list.transfers[i].endTime = list.transfers[i].moneyOrderForm.endTime;
  2167. list.transfers[i].orderType = list.transfers[i].moneyOrderForm.orderType;
  2168. }
  2169. that.data.form.method = 'POST';
  2170. console.log(that.data.form);
  2171. UTIL.httpRequest(API.URL_GET_TRANSFEREDIT, that.data.form, {
  2172. success: (res) => {
  2173. if (res.code == API.SUCCESS_CODE) {
  2174. if(that.data.form.capitalExpenditureType == 2){
  2175. that.data.form.projectForm.ynType = that.data.form.transferType=='1'||that.data.form.transferType=='2'||that.data.form.transferType=='4'?'1':'2';
  2176. that.data.form.projectForm.outId = that.data.form.id;
  2177. that.data.form.projectForm.method = 'POST';
  2178. // 工程项目提交
  2179. UTIL.httpRequest(API.URL_GET_ADDPROJECTTO , that.data.form.projectForm, {
  2180. success: (res) => {
  2181. }
  2182. })
  2183. }
  2184. if(that.data.form.capitalExpenditureType == 4){
  2185. that.data.form.contractionForm.transferId = that.data.form.id;
  2186. that.data.form.contractionForm.id = '';
  2187. that.data.form.contractionForm.method = 'POST';
  2188. // 关联合同提交
  2189. UTIL.httpRequest(API.URL_GET_GETRELATIONADD , that.data.form.contractionForm, {
  2190. success: (res) => {
  2191. }
  2192. })
  2193. }
  2194. wx.showToast({
  2195. title: '保存成功',
  2196. icon: 'success',
  2197. duration: 2000,
  2198. complete(){
  2199. setTimeout(function(){
  2200. that.back();
  2201. },2000)
  2202. }
  2203. })
  2204. }else{
  2205. wx.showToast({
  2206. title: res.msg,
  2207. icon: 'error',
  2208. duration: 2000
  2209. })
  2210. }
  2211. }
  2212. })
  2213. },
  2214. deleteTransfers(e){
  2215. var that = this ;
  2216. console.log(e.currentTarget.dataset.index);
  2217. // that.data.form.collapseDis = true;
  2218. that.setData({
  2219. ["form.collapseDis"]:true
  2220. })
  2221. if(that.data.form.transfers.length<2){
  2222. UTIL.showToastNoneIcon('最少保留一条事项');
  2223. return;
  2224. }
  2225. that.data.form.transfers[e.currentTarget.dataset.index].expenditureAmount = that.data.form.transfers[e.currentTarget.dataset.index].expenditureAmount == '' ? '0' : that.data.form.transfers[e.currentTarget.dataset.index].expenditureAmount;
  2226. that.data.form.approvalItemTemplate.totalAmount = parseFloat(parseFloat(that.data.form.approvalItemTemplate.totalAmount)- parseFloat(that.data.form.transfers[e.currentTarget.dataset.index].expenditureAmount)).toFixed(2);
  2227. that.data.form.transfers.splice(e.currentTarget.dataset.index,1);
  2228. for (let i = 0; i < that.data.form.transfers.length; i++) {
  2229. that.data.form.transfers[i].num = UTIL.convertToChinaNum(i+1)
  2230. }
  2231. console.log(that.data.form);
  2232. that.setData({
  2233. form:that.data.form,
  2234. })
  2235. UTIL.httpRequest(API.URL_GET_TRANSFERREMOVE+e.currentTarget.dataset.id , {method:'GET'}, {
  2236. success: (res) => {
  2237. }
  2238. })
  2239. },
  2240. disabledNone(e){
  2241. console.log("b");
  2242. var that = this ;
  2243. that.setData({
  2244. ["form.transfers["+e.currentTarget.dataset.index+"].collapseDis"]:true
  2245. })
  2246. },
  2247. disabledBlock(e){
  2248. console.log("a");
  2249. var that = this ;
  2250. that.setData({
  2251. ["form.transfers["+e.currentTarget.dataset.index+"].collapseDis"]:false
  2252. })
  2253. },
  2254. onOpen(e){
  2255. var that = this ;
  2256. console.log(that.data.activeNames);
  2257. console.log(e);
  2258. for (let i = 0; i < this.data.form.transfers.length; i++) {
  2259. const element = this.data.form.transfers[i];
  2260. this.setData({
  2261. ["form.transfers["+i+"].showTitle"] : false,
  2262. })
  2263. }
  2264. that.setData({
  2265. ["form.transfers["+e.detail+"].showTitle"]:true
  2266. })
  2267. },
  2268. onCloseSecond(e){
  2269. var that = this ;
  2270. console.log(e);
  2271. that.setData({
  2272. ["form.transfers["+e.detail+"].showTitle"]:false
  2273. })
  2274. },
  2275. deleteimg(e){
  2276. let options = e.currentTarget.dataset.options;
  2277. console.log(options);
  2278. let file = this.data.form.fileForm;
  2279. for (let i = 0; i < file.length; i++) {
  2280. const element = file[i];
  2281. if(element.file == options[e.currentTarget.dataset.index].tempFilePath){
  2282. file.splice(i,1);
  2283. }
  2284. }
  2285. options.splice(e.currentTarget.dataset.index,1);
  2286. let length = this.data.form.fileNum - 1;
  2287. UTIL.httpRequest(API.URL_GET_GETFILEREMOVE+e.currentTarget.dataset.id , {method:'GET'}, {
  2288. success: (res) => {
  2289. this.setData({
  2290. [e.currentTarget.dataset.name]:options,
  2291. ["form.fileNum"]:length,
  2292. ["form.fileForm"]:file,
  2293. })
  2294. wx.showToast({
  2295. title: '删除成功!',
  2296. icon: 'success',
  2297. duration: 2000,
  2298. })
  2299. }
  2300. })
  2301. },
  2302. uploadFile(e){
  2303. var that = this;
  2304. if(e.currentTarget.dataset.payer == null || e.currentTarget.dataset.payer == ''){
  2305. UTIL.showToastNoneIcon('请先选择付款方!');
  2306. return;
  2307. }
  2308. console.log(e);
  2309. let moneyParents = e.currentTarget.dataset.totalamount == ''?'0.00':e.currentTarget.dataset.totalamount;
  2310. let moneyChildren = e.currentTarget.dataset.expenditureamount == ''?'0.00':e.currentTarget.dataset.expenditureamount
  2311. let totalAmount = parseFloat(moneyParents) - parseFloat(moneyChildren);
  2312. console.log(moneyParents);
  2313. console.log(moneyChildren);
  2314. wx.navigateTo({
  2315. url: '../add/upLoad/upLoad?bankType='+e.currentTarget.dataset.banktype+'&index='+e.currentTarget.dataset.index+'&totalAmount='+totalAmount+'&isPeers='+e.currentTarget.dataset.ispeers
  2316. })
  2317. return;
  2318. wx.chooseMessageFile({
  2319. count: 1,
  2320. type: 'file',
  2321. success (res) {
  2322. console.log(res);
  2323. // tempFilePath可以作为 img 标签的 src 属性显示图片
  2324. const tempFilePaths = res.tempFiles
  2325. wx.uploadFile({
  2326. url: API.URL_GET_UPLOADFILE,
  2327. filePath: tempFilePaths[0].path,
  2328. name: 'file',
  2329. header: {
  2330. "Content-Type": "multipart/form-data",//记得设置
  2331. "chartset":"utf-8",
  2332. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  2333. },
  2334. formData:{
  2335. bankType:'2',
  2336. accountType:'1',
  2337. isPeers:'Y'
  2338. },
  2339. success (response){
  2340. console.log(response);
  2341. let list = JSON.parse(response.data);
  2342. console.log(list);
  2343. that.setData({
  2344. ['form.transfers[0].payeeList']:list.rows
  2345. })
  2346. },
  2347. fail(res){
  2348. }
  2349. })
  2350. }
  2351. })
  2352. },
  2353. downLoad(){
  2354. wx.downloadFile({
  2355. url: API.URL_GET_DOWNFILE, //仅为示例,并非真实的资源
  2356. success (res) {
  2357. console.log(res);
  2358. // 只要服务器有响应数据,就会把响应内容写入文件并进入 success 回调,业务需要自行判断是否下载到了想要的内容
  2359. if (res.statusCode === 200) {
  2360. var fs = wx.getFileSystemManager();
  2361. fs.saveFile({
  2362. tempFilePath:res.tempFilePath,
  2363. success:function(response){
  2364. console.log(response);
  2365. }
  2366. })
  2367. // wx.saveFile({
  2368. // tempFilePath: res.tempFilePath,
  2369. // success:function(response){
  2370. // console.log(response);
  2371. // }
  2372. // })
  2373. // wx.playVoice({
  2374. // filePath: res.tempFilePath
  2375. // })
  2376. }
  2377. }
  2378. })
  2379. },
  2380. addPayee(){
  2381. console.log(this.data.form.payeeList);
  2382. if(this.data.form.payeeList.length > 10){
  2383. UTIL.showToastNoneIcon('收款方过多,请使用批量上传功能');
  2384. return;
  2385. }
  2386. for(let i = 0 ; i < this.data.form.payeeList.length ; i++ ){
  2387. if(!this.data.form.payeeList[i].payee && !this.data.form.payeeList[i].payeeAccount && !this.data.form.payeeList[i].bankDeposit && !this.data.form.payeeList[i].bankTypeText){
  2388. UTIL.showToastNoneIcon('请勿添加多个空付款人');
  2389. return;
  2390. }
  2391. if(!this.data.form.payeeList[i].incomeAmount || this.data.form.payeeList[i].incomeAmount == "" || this.data.form.payeeList[i].incomeAmount == undefined || this.data.form.payeeList[i].incomeAmount == null){
  2392. UTIL.showToastNoneIcon('请完善收入金额');
  2393. return;
  2394. }
  2395. }
  2396. this.data.form.payeeList.push({});
  2397. this.setData({
  2398. ["form.payeeList"]:this.data.form.payeeList,
  2399. })
  2400. },
  2401. removePayer(e){
  2402. console.log(e);
  2403. let i = e.currentTarget.dataset.index;
  2404. let list = this.data.form.payeeList;
  2405. list.splice(i,1);
  2406. this.setData({
  2407. ["form.payeeList"]:list,
  2408. })
  2409. },
  2410. onChangePayeeMoney(event){
  2411. console.log(event);
  2412. this.setData({
  2413. [event.currentTarget.dataset.value]: event.detail,
  2414. })
  2415. let moneyCount = parseFloat(0);
  2416. for(let i = 0 ; i < this.data.form.payeeList.length ; i++){
  2417. moneyCount += parseFloat(this.data.form.payeeList[i].incomeAmount==""?0:this.data.form.payeeList[i].incomeAmount)
  2418. }
  2419. this.setData({
  2420. ["form.expenditureAmount"]: moneyCount.toFixed(2),
  2421. })
  2422. },
  2423. /**
  2424. * 生命周期函数--监听页面隐藏
  2425. */
  2426. onHide() {
  2427. },
  2428. /**
  2429. * 生命周期函数--监听页面卸载
  2430. */
  2431. onUnload() {
  2432. },
  2433. /**
  2434. * 页面相关事件处理函数--监听用户下拉动作
  2435. */
  2436. onPullDownRefresh() {
  2437. },
  2438. /**
  2439. * 页面上拉触底事件的处理函数
  2440. */
  2441. onReachBottom() {
  2442. },
  2443. /**
  2444. * 用户点击右上角分享
  2445. */
  2446. onShareAppMessage() {
  2447. }
  2448. })