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

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