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

461 line
13 KiB

  1. // pages/handle/expenditureAudit/expenditureAudit.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 DISTRIBUTE_ENVIROMENT = 'IMGURL';
  6. let {
  7. URL_PREFIX,
  8. } = EVN_CONFIG[DISTRIBUTE_ENVIROMENT];
  9. const app = getApp();
  10. Page({
  11. /**
  12. * 页面的初始数据
  13. */
  14. data: {
  15. isIPX: app.globalData.isIPX,
  16. active:0,
  17. spsxOptions:[],
  18. paymentPatternOptions:[],
  19. nickName:'',
  20. comment:'',
  21. activeNames: 0,
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad: function (options) {
  27. var that = this;
  28. that.setData({
  29. taskId:options.taskId,
  30. pageType:options.type
  31. })
  32. wx.showLoading({
  33. title: '正在加载模板',
  34. mask:true
  35. })
  36. //所属银行
  37. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bank_type', {method:'GET'}, {
  38. success: (res) => {
  39. this.setData({
  40. bankTypeOptions:res.data
  41. });
  42. }
  43. })
  44. // 资金支出类别字典查询
  45. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'capital_expenditure_type', {method:'GET'}, {
  46. success: (res) => {
  47. that.setData({
  48. capitalExpenditureTypeOptions:res.data,
  49. })
  50. }
  51. })
  52. // 付款方式类型字典查询
  53. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'transfer_type', {method:'GET'}, {
  54. success: (res) => {
  55. that.setData({
  56. transferTypeOptions:res.data,
  57. })
  58. }
  59. })
  60. // 项目工程列表
  61. UTIL.httpRequest(API.URL_GET_GETPROJECTLIST , {method:'GET'}, {
  62. success: (res) => {
  63. that.setData({
  64. projectOptions:res.rows,
  65. })
  66. }
  67. })
  68. // 工程款类型字典查询
  69. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'project_fund_type', {method:'GET'}, {
  70. success: (res) => {
  71. that.setData({
  72. projectFundTypeOptions:res.data,
  73. })
  74. }
  75. })
  76. // 支付方式
  77. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'yn_pay_type', {method:'GET'}, {
  78. success: (res) => {
  79. that.setData({
  80. paymentPatternOptions:res.data,
  81. })
  82. }
  83. })
  84. // 获取合同信息列表
  85. UTIL.httpRequest(API.URL_GET_CONTRACTIONLIST , {method:'GET'}, {
  86. success: (res) => {
  87. that.setData({
  88. contractionOptions:res.rows,
  89. })
  90. }
  91. })
  92. UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
  93. success: (res) => {
  94. if (res.code == API.SUCCESS_CODE) {
  95. that.setData({
  96. nickName:res.user.nickName
  97. })
  98. }
  99. }
  100. })
  101. setTimeout(function(){
  102. UTIL.httpRequest(API.URL_GET_APPROVALITEMS+options.id, {method:'GET'}, {
  103. success: (res) => {
  104. if (res.code == API.SUCCESS_CODE) {
  105. console.log(that.data.capitalExpenditureTypeOptions);
  106. if(res.data.approvalItemTemplate == null){return;}
  107. res.data.approvalItemTemplate.totalAmount = parseFloat(res.data.approvalItemTemplate.totalAmount).toFixed(2)
  108. res.data.transfers = res.data.transfers.filter(function (e) { return e.id == options.ids; });
  109. console.log(options.ids);
  110. console.log(res.data.transfers.filter(function (e) { return e.id == options.ids; }));
  111. res.data.transfers.forEach( (item,index) => {
  112. res.data.transfers[index].capitalExpenditureTypeText = UTIL.getTransform(item.capitalExpenditureType,that.data.capitalExpenditureTypeOptions);
  113. res.data.transfers[index].transferTypeText = UTIL.getTransform(item.transferType,that.data.transferTypeOptions);
  114. res.data.transfers[index].bankTypeText = UTIL.getTransform(item.bankType,that.data.bankTypeOptions);
  115. res.data.transfers[index].paymentPatternText = UTIL.getTransform(item.paymentPattern,that.data.paymentPatternOptions);
  116. res.data.transfers[index].num = UTIL.convertToChinaNum(index+1),
  117. res.data.transfers[index].expenditureAmount = parseFloat(res.data.transfers[index].expenditureAmount).toFixed(2)
  118. res.data.transfers[index].showTitle = false;
  119. res.data.transfers[index].payeeList.forEach( (response,i) => {
  120. res.data.transfers[index].payeeList[i].bankTypeText = UTIL.getTransform(response.bankType,that.data.bankTypeOptions);
  121. })
  122. console.log(res.data.transfers[index].capitalExpenditureType);
  123. if(res.data.transfers[index].capitalExpenditureType == 2){
  124. let prames = {
  125. outId:res.data.transfers[index].id,
  126. ynType: res.data.transfers[index].transferType=='1'||res.data.transfers[index].transferType=='2'||res.data.transfers[index].transferType=='4'?'1':'2'
  127. }
  128. // 工程项目查询
  129. UTIL.httpRequest(API.URL_GET_GETPROJECTTO , prames, {
  130. success: (res) => {
  131. res.data.projectFundTypeText = UTIL.getTransform(res.data.projectFundType,that.data.projectFundTypeOptions);
  132. that.setData({
  133. ["form.transfers["+index+"].projectForm"]:res.data,
  134. })
  135. }
  136. })
  137. }
  138. if(res.data.transfers[index].capitalExpenditureType == 4){
  139. let prames = {
  140. transferId:res.data.transfers[index].id,
  141. }
  142. // 关联合同查询
  143. UTIL.httpRequest(API.URL_GET_GETSELECTINFOBYOUTID , prames, {
  144. success: (res) => {
  145. that.setData({
  146. ["form.transfers["+index+"].contractionForm"]:res.data,
  147. })
  148. }
  149. })
  150. }
  151. if(res.data.transfers[index].transferType == '12'){
  152. var transferTimer = setTimeout(function(){
  153. that.setData({
  154. ["form.transfers["+index+"].moneyOrderForm"]:{
  155. billPayUnit : res.data.transfers[index].payer,
  156. orderNum : res.data.transfers[index].payerAccount,
  157. id : res.data.transfers[index].cashierId,
  158. startTime : res.data.transfers[index].startTime,
  159. endTime : res.data.transfers[index].endTime,
  160. orderType : res.data.transfers[index].orderType,
  161. orderAmount:res.data.transfers[index].expenditureAmount
  162. },
  163. ["form.transfers["+index+"].amountReadonly"]:true
  164. })
  165. },1000)
  166. }
  167. UTIL.httpRequest(
  168. API.URL_GET_FINDLIST,
  169. {
  170. method:'GET',
  171. tableName:'t_yinnong_transfer',
  172. tableId:item.id,
  173. fileType:1
  174. },
  175. {
  176. success: (res) => {
  177. let list = [];
  178. res.data.forEach((item2,index2)=>{
  179. list.push({
  180. tempFilePath:URL_PREFIX+item2.fileUrl
  181. })
  182. that.setData({
  183. ["form.transfers["+index+"].SJimage"]:list,
  184. });
  185. })
  186. }
  187. })
  188. //发票
  189. UTIL.httpRequest(
  190. API.URL_GET_FINDLIST,
  191. {
  192. method:'GET',
  193. tableName:'t_yinnong_transfer',
  194. tableId:item.id,
  195. fileType:2
  196. },
  197. {
  198. success: (res) => {
  199. let list = [];
  200. res.data.forEach((item2,index2)=>{
  201. list.push({
  202. tempFilePath:URL_PREFIX+item2.fileUrl
  203. })
  204. that.setData({
  205. ["form.transfers["+index+"].FPimage"]:list,
  206. });
  207. })
  208. }
  209. })
  210. //其他
  211. UTIL.httpRequest(
  212. API.URL_GET_FINDLIST,
  213. {
  214. method:'GET',
  215. tableName:'t_yinnong_transfer',
  216. tableId:item.id,
  217. fileType:3
  218. },
  219. {
  220. success: (res) => {
  221. let list = [];
  222. res.data.forEach((item2,index2)=>{
  223. list.push({
  224. tempFilePath:URL_PREFIX+item2.fileUrl
  225. })
  226. that.setData({
  227. ["form.transfers["+index+"].QTimage"]:list,
  228. });
  229. })
  230. }
  231. })
  232. })
  233. that.setData({
  234. form:res.data,
  235. activeNames:null
  236. })
  237. wx.hideLoading();
  238. }
  239. }
  240. })
  241. // 查询审批事项流转进度
  242. // UTIL.httpRequest(API.URL_GET_GETPROCESS+options.id , {method:'GET'}, {
  243. // success: (res) => {
  244. // console.log(res);
  245. // if(res.data.processSchedule != null){
  246. // that.setData({spsxOptions:res.data.processSchedule.spsx})
  247. // }
  248. // that.setData({instanceId:res.data.instanceId})
  249. // if(options.business == 'xj'){
  250. // console.log(that.data.instanceId)
  251. // // 查询现金审批事项流转进度
  252. // UTIL.httpRequest(API.URL_GET_REVIEWPROCESS+that.data.instanceId , {method:'GET'}, {
  253. // success: (res) => {
  254. // console.log(res);
  255. // if(res.data.processSchedule.spsx){
  256. // that.setData({spsxOptions:res.data.processSchedule.spsx})
  257. // }
  258. // that.setData({instanceId:res.data.instanceId})
  259. // }
  260. // })
  261. // }
  262. // }
  263. // })
  264. },1000)
  265. },
  266. goPayee(event){
  267. wx.navigateTo({
  268. url: 'payee/payee?options='+JSON.stringify(event.currentTarget.dataset.option)
  269. })
  270. },
  271. goDis(){
  272. var that = this ;
  273. console.log()
  274. let data = {
  275. taskId:that.data.taskId,
  276. instanceId:that.data.instanceId,
  277. variables:JSON.stringify({
  278. comment:that.data.comment == '' ? '驳回':that.data.comment,
  279. pass:false,
  280. }),
  281. method:'POST'
  282. };
  283. UTIL.httpRequest(API.URL_GET_PROCESSCOMPLETE , data, {
  284. success: (res) => {
  285. console.log(res);
  286. if (res.code == API.SUCCESS_CODE) {
  287. wx.showToast({
  288. title: '审批成功',
  289. icon: 'success',
  290. duration: 2000,
  291. complete(){
  292. setTimeout(function(){
  293. that.back();
  294. },2000)
  295. }
  296. })
  297. }else{
  298. wx.showToast({
  299. title: '操作失败',
  300. icon: 'error',
  301. duration: 2000
  302. })
  303. }
  304. }
  305. })
  306. },
  307. goAgree(){
  308. var that = this ;
  309. let data = {
  310. taskId:that.data.taskId,
  311. instanceId:that.data.instanceId,
  312. variables:JSON.stringify({
  313. "comment":that.data.comment == '' ? '同意':that.data.comment,
  314. "pass":true,
  315. }),
  316. method:'POST'
  317. };
  318. UTIL.httpRequest(API.URL_GET_PROCESSCOMPLETE ,data, {
  319. success: (res) => {
  320. console.log(res);
  321. if (res.code == API.SUCCESS_CODE) {
  322. wx.showToast({
  323. title: '审批成功',
  324. icon: 'success',
  325. duration: 2000,
  326. complete(){
  327. setTimeout(function(){
  328. that.back();
  329. },2000)
  330. }
  331. })
  332. }else{
  333. wx.showToast({
  334. title: '操作失败',
  335. icon: 'error',
  336. duration: 2000
  337. })
  338. }
  339. }
  340. })
  341. },
  342. commentInput(e){
  343. console.log(e);
  344. var that = this;
  345. that.setData({
  346. comment:e.detail.value
  347. })
  348. },
  349. onChangeBox(event) {
  350. console.log(event);
  351. this.setData({
  352. activeNames: event.detail,
  353. });
  354. },
  355. onCloseSecond(e){
  356. var that = this ;
  357. console.log(e);
  358. that.setData({
  359. ["form.transfers["+e.detail+"].showTitle"]:false
  360. })
  361. },
  362. onOpen(e){
  363. var that = this ;
  364. console.log(that.data.activeNames);
  365. console.log(e);
  366. for (let i = 0; i < this.data.form.transfers.length; i++) {
  367. const element = this.data.form.transfers[i];
  368. this.setData({
  369. ["form.transfers["+i+"].showTitle"] : false,
  370. })
  371. }
  372. that.setData({
  373. ["form.transfers["+e.detail+"].showTitle"]:true
  374. })
  375. },
  376. openPreview(e){
  377. let array = [];
  378. console.log(e);
  379. e.currentTarget.dataset.option.forEach(item=>{
  380. array.push(item.tempFilePath)
  381. })
  382. console.log(array);
  383. wx.previewImage({
  384. urls: array,
  385. showmenu:true,
  386. current:array[e.currentTarget.dataset.index]
  387. })
  388. },
  389. /**
  390. * 生命周期函数--监听页面初次渲染完成
  391. */
  392. onReady: function () {
  393. },
  394. /**
  395. * 生命周期函数--监听页面显示
  396. */
  397. onShow: function () {
  398. },
  399. back:function(){
  400. wx.navigateBack({
  401. delta: 1
  402. })
  403. },
  404. /**
  405. * 生命周期函数--监听页面隐藏
  406. */
  407. onHide: function () {
  408. },
  409. /**
  410. * 生命周期函数--监听页面卸载
  411. */
  412. onUnload: function () {
  413. },
  414. /**
  415. * 页面相关事件处理函数--监听用户下拉动作
  416. */
  417. onPullDownRefresh: function () {
  418. },
  419. /**
  420. * 页面上拉触底事件的处理函数
  421. */
  422. onReachBottom: function () {
  423. },
  424. /**
  425. * 用户点击右上角分享
  426. */
  427. onShareAppMessage: function () {
  428. }
  429. })