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

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