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

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