微信小程序
Não pode escolher mais do que 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

451 linhas
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.forEach( (item,index) => {
  109. res.data.transfers[index].capitalExpenditureTypeText = UTIL.getTransform(item.capitalExpenditureType,that.data.capitalExpenditureTypeOptions);
  110. res.data.transfers[index].transferTypeText = UTIL.getTransform(item.transferType,that.data.transferTypeOptions);
  111. res.data.transfers[index].bankTypeText = UTIL.getTransform(item.bankType,that.data.bankTypeOptions);
  112. res.data.transfers[index].paymentPatternText = UTIL.getTransform(item.paymentPattern,that.data.paymentPatternOptions);
  113. res.data.transfers[index].num = UTIL.convertToChinaNum(index+1),
  114. res.data.transfers[index].expenditureAmount = parseFloat(res.data.transfers[index].expenditureAmount).toFixed(2)
  115. res.data.transfers[index].showTitle = false;
  116. res.data.transfers[index].payeeList.forEach( (response,i) => {
  117. res.data.transfers[index].payeeList[i].bankTypeText = UTIL.getTransform(response.bankType,that.data.bankTypeOptions);
  118. })
  119. console.log(res.data.transfers[index].capitalExpenditureType);
  120. if(res.data.transfers[index].capitalExpenditureType == 2){
  121. let prames = {
  122. outId:res.data.transfers[index].id,
  123. ynType: res.data.transfers[index].transferType=='1'||res.data.transfers[index].transferType=='2'||res.data.transfers[index].transferType=='4'?'1':'2'
  124. }
  125. // 工程项目查询
  126. UTIL.httpRequest(API.URL_GET_GETPROJECTTO , prames, {
  127. success: (res) => {
  128. res.data.projectFundTypeText = UTIL.getTransform(res.data.projectFundType,that.data.projectFundTypeOptions);
  129. that.setData({
  130. ["form.transfers["+index+"].projectForm"]:res.data,
  131. })
  132. }
  133. })
  134. }
  135. if(res.data.transfers[index].capitalExpenditureType == 4){
  136. let prames = {
  137. transferId:res.data.transfers[index].id,
  138. }
  139. // 关联合同查询
  140. UTIL.httpRequest(API.URL_GET_GETSELECTINFOBYOUTID , prames, {
  141. success: (res) => {
  142. that.setData({
  143. ["form.transfers["+index+"].contractionForm"]:res.data,
  144. })
  145. }
  146. })
  147. }
  148. if(res.data.transfers[index].transferType == '12'){
  149. var transferTimer = setTimeout(function(){
  150. that.setData({
  151. ["form.transfers["+index+"].moneyOrderForm"]:{
  152. billPayUnit : res.data.transfers[index].payer,
  153. orderNum : res.data.transfers[index].payerAccount,
  154. id : res.data.transfers[index].cashierId,
  155. startTime : res.data.transfers[index].startTime,
  156. endTime : res.data.transfers[index].endTime,
  157. orderType : res.data.transfers[index].orderType,
  158. orderAmount:res.data.transfers[index].expenditureAmount
  159. },
  160. ["form.transfers["+index+"].amountReadonly"]:true
  161. })
  162. },1000)
  163. }
  164. UTIL.httpRequest(
  165. API.URL_GET_FINDLIST,
  166. {
  167. method:'GET',
  168. tableName:'t_yinnong_transfer',
  169. tableId:item.id,
  170. fileType:1
  171. },
  172. {
  173. success: (res) => {
  174. let list = [];
  175. res.data.forEach((item2,index2)=>{
  176. list.push({
  177. tempFilePath:URL_PREFIX+item2.fileUrl
  178. })
  179. that.setData({
  180. ["form.transfers["+index+"].SJimage"]:list,
  181. });
  182. })
  183. }
  184. })
  185. //发票
  186. UTIL.httpRequest(
  187. API.URL_GET_FINDLIST,
  188. {
  189. method:'GET',
  190. tableName:'t_yinnong_transfer',
  191. tableId:item.id,
  192. fileType:2
  193. },
  194. {
  195. success: (res) => {
  196. let list = [];
  197. res.data.forEach((item2,index2)=>{
  198. list.push({
  199. tempFilePath:URL_PREFIX+item2.fileUrl
  200. })
  201. that.setData({
  202. ["form.transfers["+index+"].FPimage"]:list,
  203. });
  204. })
  205. }
  206. })
  207. //其他
  208. UTIL.httpRequest(
  209. API.URL_GET_FINDLIST,
  210. {
  211. method:'GET',
  212. tableName:'t_yinnong_transfer',
  213. tableId:item.id,
  214. fileType:3
  215. },
  216. {
  217. success: (res) => {
  218. let list = [];
  219. res.data.forEach((item2,index2)=>{
  220. list.push({
  221. tempFilePath:URL_PREFIX+item2.fileUrl
  222. })
  223. that.setData({
  224. ["form.transfers["+index+"].QTimage"]:list,
  225. });
  226. })
  227. }
  228. })
  229. })
  230. that.setData({
  231. form:res.data,
  232. activeNames:null
  233. })
  234. wx.hideLoading();
  235. }
  236. }
  237. })
  238. // 查询审批事项流转进度
  239. UTIL.httpRequest(API.URL_GET_GETPROCESS+options.id , {method:'GET'}, {
  240. success: (res) => {
  241. console.log(res);
  242. if(res.data.processSchedule != null){
  243. that.setData({spsxOptions:res.data.processSchedule.spsx})
  244. }
  245. that.setData({instanceId:res.data.instanceId})
  246. if(options.business == 'xj'){
  247. console.log(that.data.instanceId)
  248. // 查询现金审批事项流转进度
  249. UTIL.httpRequest(API.URL_GET_REVIEWPROCESS+that.data.instanceId , {method:'GET'}, {
  250. success: (res) => {
  251. console.log(res);
  252. if(res.data.processSchedule.spsx){
  253. that.setData({spsxOptions:res.data.processSchedule.spsx})
  254. }
  255. that.setData({instanceId:res.data.instanceId})
  256. }
  257. })
  258. }
  259. }
  260. })
  261. },1000)
  262. },
  263. goDis(){
  264. var that = this ;
  265. console.log()
  266. let data = {
  267. taskId:that.data.taskId,
  268. instanceId:that.data.instanceId,
  269. variables:JSON.stringify({
  270. comment:that.data.comment == '' ? '驳回':that.data.comment,
  271. pass:false,
  272. }),
  273. method:'POST'
  274. };
  275. UTIL.httpRequest(API.URL_GET_PROCESSCOMPLETE , data, {
  276. success: (res) => {
  277. console.log(res);
  278. if (res.code == API.SUCCESS_CODE) {
  279. wx.showToast({
  280. title: '审批成功',
  281. icon: 'success',
  282. duration: 2000,
  283. complete(){
  284. setTimeout(function(){
  285. that.back();
  286. },2000)
  287. }
  288. })
  289. }else{
  290. wx.showToast({
  291. title: '操作失败',
  292. icon: 'error',
  293. duration: 2000
  294. })
  295. }
  296. }
  297. })
  298. },
  299. goAgree(){
  300. var that = this ;
  301. let data = {
  302. taskId:that.data.taskId,
  303. instanceId:that.data.instanceId,
  304. variables:JSON.stringify({
  305. "comment":that.data.comment == '' ? '同意':that.data.comment,
  306. "pass":true,
  307. }),
  308. method:'POST'
  309. };
  310. UTIL.httpRequest(API.URL_GET_PROCESSCOMPLETE ,data, {
  311. success: (res) => {
  312. console.log(res);
  313. if (res.code == API.SUCCESS_CODE) {
  314. wx.showToast({
  315. title: '审批成功',
  316. icon: 'success',
  317. duration: 2000,
  318. complete(){
  319. setTimeout(function(){
  320. that.back();
  321. },2000)
  322. }
  323. })
  324. }else{
  325. wx.showToast({
  326. title: '操作失败',
  327. icon: 'error',
  328. duration: 2000
  329. })
  330. }
  331. }
  332. })
  333. },
  334. commentInput(e){
  335. console.log(e);
  336. var that = this;
  337. that.setData({
  338. comment:e.detail.value
  339. })
  340. },
  341. onChangeBox(event) {
  342. console.log(event);
  343. this.setData({
  344. activeNames: event.detail,
  345. });
  346. },
  347. onCloseSecond(e){
  348. var that = this ;
  349. console.log(e);
  350. that.setData({
  351. ["form.transfers["+e.detail+"].showTitle"]:false
  352. })
  353. },
  354. onOpen(e){
  355. var that = this ;
  356. console.log(that.data.activeNames);
  357. console.log(e);
  358. for (let i = 0; i < this.data.form.transfers.length; i++) {
  359. const element = this.data.form.transfers[i];
  360. this.setData({
  361. ["form.transfers["+i+"].showTitle"] : false,
  362. })
  363. }
  364. that.setData({
  365. ["form.transfers["+e.detail+"].showTitle"]:true
  366. })
  367. },
  368. openPreview(e){
  369. let array = [];
  370. console.log(e);
  371. e.currentTarget.dataset.option.forEach(item=>{
  372. array.push(item.tempFilePath)
  373. })
  374. console.log(array);
  375. wx.previewImage({
  376. urls: array,
  377. showmenu:true,
  378. current:array[e.currentTarget.dataset.index]
  379. })
  380. },
  381. /**
  382. * 生命周期函数--监听页面初次渲染完成
  383. */
  384. onReady: function () {
  385. },
  386. /**
  387. * 生命周期函数--监听页面显示
  388. */
  389. onShow: function () {
  390. },
  391. back:function(){
  392. wx.navigateBack({
  393. delta: 1
  394. })
  395. },
  396. /**
  397. * 生命周期函数--监听页面隐藏
  398. */
  399. onHide: function () {
  400. },
  401. /**
  402. * 生命周期函数--监听页面卸载
  403. */
  404. onUnload: function () {
  405. },
  406. /**
  407. * 页面相关事件处理函数--监听用户下拉动作
  408. */
  409. onPullDownRefresh: function () {
  410. },
  411. /**
  412. * 页面上拉触底事件的处理函数
  413. */
  414. onReachBottom: function () {
  415. },
  416. /**
  417. * 用户点击右上角分享
  418. */
  419. onShareAppMessage: function () {
  420. }
  421. })