微信小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

536 行
13 KiB

  1. import * as UTIL from '../../utils/util.js';
  2. import * as API from '../../utils/API.js';
  3. const app = getApp();
  4. Page({
  5. /**
  6. * 页面的初始数据
  7. */
  8. data: {
  9. isIPX: app.globalData.isIPX,
  10. show:false,
  11. accountList:[],
  12. approvalItemsOptions:[],
  13. receiptOptions:[],
  14. bookName:'',
  15. accountListXJ:[],
  16. showDialog:false,
  17. projectId:'',
  18. bankName:'',
  19. beforeClose(action) {
  20. return new Promise((resolve) => {
  21. setTimeout(() => {
  22. if (action === 'confirm') {
  23. // 拦截确认操作
  24. resolve(false);
  25. } else {
  26. resolve(true);
  27. }
  28. }, 0);
  29. });
  30. },
  31. index: 0,
  32. showTransactionDialog:false,
  33. showReceiptDialog:false,
  34. showSelectType:false,
  35. form:{
  36. selectTypeText:'',
  37. selectType:'',
  38. directionText:'',
  39. direction:'',
  40. datescopeFrom:'',
  41. datescopeTo:'',
  42. }
  43. },
  44. /**
  45. * 生命周期函数--监听页面加载
  46. */
  47. onLoad: function (options) {
  48. },
  49. bindSelectTypePickerChange: function(e) {
  50. var that = this;
  51. var dictValue = that.data.selectTypeOptions[e.detail.value].dictValue;
  52. var text = UTIL.getTransform(dictValue,that.data.selectTypeOptions);
  53. this.setData({
  54. ["form.selectTypeText"]: text,
  55. ["form.selectType"]:dictValue
  56. })
  57. },
  58. bindDirectionPickerChange: function(e) {
  59. var that = this;
  60. var dictValue = that.data.directionOptions[e.detail.value].dictValue;
  61. var text = UTIL.getTransform(dictValue,that.data.directionOptions);
  62. this.setData({
  63. ["form.directionText"]: text,
  64. ["form.direction"]:dictValue
  65. })
  66. },
  67. bindReceiptPickerChange: function(e) {
  68. var that = this;
  69. var dictValue = that.data.receiptOptions[e.detail.value].dictValue;
  70. var text = UTIL.getTransform(dictValue,that.data.receiptOptions);
  71. this.setData({
  72. ["form.directionText"]: text,
  73. ["form.direction"]:dictValue
  74. })
  75. },
  76. bindDatescopeFromPickerChange: function(e) {
  77. console.log(e);
  78. var that = this;
  79. that.setData({
  80. ["form.datescopeFrom"]: e.detail.value,
  81. })
  82. },
  83. bindDatescopeToPickerChange: function(e) {
  84. console.log(e);
  85. var that = this;
  86. that.setData({
  87. ["form.datescopeTo"]: e.detail.value,
  88. })
  89. },
  90. onChange(e){
  91. var that = this;
  92. console.log(e);
  93. that.setData({
  94. [e.currentTarget.dataset.name]: e.detail,
  95. })
  96. },
  97. selectAccount(){
  98. console.log(this.data.form)
  99. var that = this ;
  100. const form = that.data.form;
  101. if(form.selectType == ''){
  102. UTIL.showToastNoneIcon('请选择查询类型!');
  103. return;
  104. }else if(form.direction == ''){
  105. UTIL.showToastNoneIcon('请选择来往账标识!');
  106. return;
  107. }else if(form.datescopeFrom == ''){
  108. UTIL.showToastNoneIcon('请选择开始日期!');
  109. return;
  110. }else if(form.datescopeTo == ''){
  111. UTIL.showToastNoneIcon('请选择截止日期!');
  112. return;
  113. }
  114. that.data.form.method = "POST"
  115. UTIL.showLoadingHaveMask('正在查询');
  116. UTIL.httpRequest(API.URL_GET_SELECTRECORD, that.data.form, {
  117. success: (res) => {
  118. if (res.code == API.SUCCESS_CODE) {
  119. UTIL.hideLoadingHaveMask();
  120. wx.showToast({
  121. title: '查询成功',
  122. icon: 'success',
  123. duration: 2000,
  124. })
  125. }else{
  126. UTIL.hideLoadingHaveMask();
  127. wx.showToast({
  128. title: '查询失败',
  129. icon: 'error',
  130. duration: 2000,
  131. })
  132. }
  133. }
  134. })
  135. },
  136. bankReceipt(){
  137. console.log(this.data.form)
  138. var that = this ;
  139. const form = that.data.form;
  140. if(form.selectType == ''){
  141. UTIL.showToastNoneIcon('请选择查询类型!');
  142. return;
  143. }else if(form.direction == ''){
  144. UTIL.showToastNoneIcon('请选择来往账标识!');
  145. return;
  146. }else if(form.datescopeFrom == ''){
  147. UTIL.showToastNoneIcon('请选择开始日期!');
  148. return;
  149. }else if(form.datescopeTo == ''){
  150. UTIL.showToastNoneIcon('请选择截止日期!');
  151. return;
  152. }
  153. that.data.form.method = "GET"
  154. UTIL.showLoadingHaveMask('正在查询');
  155. UTIL.httpRequest(API.URL_GET_SELECTBANKRECEIPT, that.data.form, {
  156. success: (res) => {
  157. if (res.code == API.SUCCESS_CODE) {
  158. UTIL.hideLoadingHaveMask();
  159. wx.showToast({
  160. title: '查询成功',
  161. icon: 'success',
  162. duration: 2000,
  163. })
  164. }else{
  165. UTIL.hideLoadingHaveMask();
  166. wx.showToast({
  167. title: '查询失败',
  168. icon: 'error',
  169. duration: 2000,
  170. })
  171. }
  172. }
  173. })
  174. },
  175. showTransactionDialog(e){
  176. var that = this;
  177. that.setData({
  178. form:{
  179. selectTypeText:'',
  180. selectType:'',
  181. directionText:'',
  182. direction:'',
  183. datescopeFrom:'',
  184. datescopeTo:'',
  185. }
  186. })
  187. that.setData({
  188. showTransactionDialog:true,
  189. ["form.accountId"]:e.currentTarget.dataset.id
  190. })
  191. },
  192. showReceiptDialog(e){
  193. var that = this;
  194. that.setData({
  195. form:{
  196. selectTypeText:'',
  197. selectType:'',
  198. directionText:'',
  199. direction:'',
  200. datescopeFrom:'',
  201. datescopeTo:'',
  202. }
  203. })
  204. that.setData({
  205. showReceiptDialog:true,
  206. ["form.accountId"]:e.currentTarget.dataset.id
  207. })
  208. },
  209. goRegular(e){
  210. wx.navigateTo({
  211. url: '/pages/regular/regular?id='+e.currentTarget.dataset.id,
  212. })
  213. },
  214. //跳转支出申请
  215. swichPaymentApply:function(e){
  216. console.log(e.currentTarget.dataset.current);
  217. // let cur = e.currentTarget.dataset.current;
  218. // if (this.data.currentTaB == cur) {
  219. // return false;
  220. // }else{
  221. // wx.navigateTo({
  222. // url: '../inCome/index?id=' + id,
  223. // })
  224. // }
  225. wx.navigateTo({
  226. url: '/pages/apply/paymentTemplate/add/add',
  227. })
  228. },
  229. openBox(even){
  230. console.log(even.currentTarget.dataset.name);
  231. this.setData({
  232. [even.currentTarget.dataset.name]:true
  233. })
  234. },
  235. closeBox:function(){
  236. var that = this ;
  237. that.setData({
  238. show: false,
  239. })
  240. },
  241. goTemplate:function(e){
  242. wx.navigateTo({
  243. url: 'paymentTemplate/add/add?id='+e.currentTarget.dataset.id+'&type=template'
  244. })
  245. },
  246. updateMoney:function(e){
  247. UTIL.showLoadingHaveMask('正在查询');
  248. UTIL.httpRequest(API.URL_GET_GETBALANCEENQUIRY+e.currentTarget.dataset.id, {method:'GET'}, {
  249. success: (res) => {
  250. if (res.code == API.SUCCESS_CODE) {
  251. this.setData({
  252. ["accountList["+e.currentTarget.dataset.index+"].balance"]:res.msg
  253. })
  254. UTIL.hideLoadingHaveMask();
  255. wx.showToast({
  256. title: '查询成功',
  257. icon: 'success',
  258. duration: 2000,
  259. })
  260. }else{
  261. UTIL.hideLoadingHaveMask();
  262. wx.showToast({
  263. title: '查询失败',
  264. icon: 'error',
  265. duration: 2000,
  266. })
  267. }
  268. }
  269. })
  270. },
  271. back:function(){
  272. wx.navigateBack({
  273. delta: 1
  274. })
  275. },
  276. /**
  277. * 生命周期函数--监听页面初次渲染完成
  278. */
  279. onReady: function () {
  280. },
  281. /**
  282. * 生命周期函数--监听页面显示
  283. */
  284. onShow: function () {
  285. var that = this;
  286. wx.showLoading({
  287. title: '正在加载账户',
  288. mask:true
  289. })
  290. var sendData = {
  291. pageNum:'1',
  292. pageSize:'100',
  293. accountName:'',
  294. bankAccountNumber:'',
  295. status:'N',
  296. method:'GET',
  297. accountType:102
  298. }
  299. var sendData2 = {
  300. pageNum:'1',
  301. pageSize:'100',
  302. accountName:'',
  303. bankAccountNumber:'',
  304. status:'N',
  305. method:'GET',
  306. accountType:101
  307. }
  308. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bank_type', {method:'GET'}, {
  309. success: (res) => {
  310. this.setData({
  311. bankTypeOptions:res.data
  312. });
  313. }
  314. })
  315. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'select_type', {method:'GET'}, {
  316. success: (res) => {
  317. this.setData({
  318. selectTypeOptions:res.data
  319. });
  320. }
  321. })
  322. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'direction', {method:'GET'}, {
  323. success: (res) => {
  324. this.setData({
  325. directionOptions:res.data
  326. });
  327. }
  328. })
  329. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'receipt_trans_type', {method:'GET'}, {
  330. success: (res) => {
  331. this.setData({
  332. receiptOptions:res.data
  333. });
  334. }
  335. })
  336. UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
  337. success: (res) => {
  338. if (res.code == API.SUCCESS_CODE) {
  339. this.setData({bookName:res.user.bookName})
  340. }
  341. }
  342. })
  343. UTIL.httpRequest(API.URL_GET_APPROVALITEMSLIST, {method:'GET',dataType:'1'}, {
  344. success: (res) => {
  345. if (res.code == API.SUCCESS_CODE) {
  346. that.setData({
  347. approvalItemsOptions : res.rows
  348. })
  349. }
  350. }
  351. })
  352. setTimeout(function(){
  353. UTIL.httpRequest(API.URL_GET_ACCOUNTLIST, sendData,{
  354. success: (res) => {
  355. for (let i = 0; i < res.rows.length; i++) {
  356. if(res.rows[i].bankAccountNumber==null){continue;}
  357. res.rows[i].bankAccountNumber = res.rows[i].bankAccountNumber.replace(/(\d{4})(?=\d)/g, "$1 ");
  358. res.rows[i].balance = Number(res.rows[i].balance).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  359. return $1 + ","; }).replace(/\.$/, "");
  360. res.rows[i].bankTypeText = UTIL.getTransform(res.rows[i].bankType,that.data.bankTypeOptions);
  361. }
  362. console.log(res.rows)
  363. that.setData({
  364. accountList:res.rows
  365. })
  366. wx.hideLoading();
  367. }
  368. })
  369. UTIL.httpRequest(API.URL_GET_ACCOUNTLIST, sendData2,{
  370. success: (res) => {
  371. for (let i = 0; i < res.rows.length; i++) {
  372. res.rows[i].balance = Number(res.rows[i].balance).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  373. return $1 + ","; }).replace(/\.$/, "");
  374. }
  375. console.log(res.rows)
  376. that.setData({
  377. accountListXJ:res.rows
  378. })
  379. }
  380. })
  381. },1000)
  382. },
  383. delete(e){
  384. console.log(e);
  385. var that = this;
  386. UTIL.httpRequest(API.URL_GET_REMOVEAPPROVAL + e.currentTarget.dataset.id, {method:'GET'},{
  387. success: (res) => {
  388. if (res.code == API.SUCCESS_CODE) {
  389. that.data.approvalItemsOptions.splice(e.currentTarget.dataset.index, 1);
  390. wx.showToast({
  391. title: '删除成功!',
  392. icon: 'success',
  393. duration: 2000
  394. })
  395. that.setData({
  396. approvalItemsOptions : that.data.approvalItemsOptions
  397. })
  398. }
  399. }
  400. })
  401. },
  402. getMr(e){
  403. var that = this;
  404. UTIL.httpRequest(API.URL_GET_GETSETDEFAULTVALUES + e.currentTarget.dataset.id, {method:'GET'},{
  405. success: (res) => {
  406. if (res.code == API.SUCCESS_CODE) {
  407. UTIL.httpRequest(API.URL_GET_APPROVALITEMSLIST, {method:'GET',dataType:'1'}, {
  408. success: (res) => {
  409. if (res.code == API.SUCCESS_CODE) {
  410. wx.showToast({
  411. title: '设置成功!',
  412. icon: 'success',
  413. duration: 2000
  414. })
  415. that.setData({
  416. approvalItemsOptions : res.rows
  417. })
  418. }
  419. }
  420. })
  421. }
  422. }
  423. })
  424. },
  425. showDialog(e){
  426. var that = this ;
  427. that.setData({
  428. showDialog:true,
  429. projectId:e.currentTarget.dataset.id,
  430. bankName:e.currentTarget.dataset.name,
  431. id: '' ,
  432. password: '',})
  433. },
  434. //支付口令修改
  435. edit(e){
  436. var that = this ;
  437. var zz = /^(?=.*\d)(?=.*[a-zA-Z])(?=.*[~!@#$%^&*])[\da-zA-Z~!@#$%^&*]{6,}$/;
  438. if(!(zz.test(that.data.password))){
  439. wx.showToast({
  440. title: '请根据提示修改',
  441. icon: 'error',
  442. duration: 2000,
  443. })
  444. return;
  445. }
  446. let data = {
  447. id: that.data.projectId ,
  448. accountPassword: that.data.password,
  449. method:'POST'
  450. }
  451. UTIL.httpRequest(API.URL_GET_PASSWORDEDIT, data,{
  452. success: (res) => {
  453. if (res.code == API.SUCCESS_CODE) {
  454. wx.showToast({
  455. title: '设置成功!',
  456. icon: 'success',
  457. duration: 2000
  458. })
  459. that.setData({
  460. showDialog : false,
  461. })
  462. }else if(res.code == "403"){
  463. wx.showToast({
  464. title: "无修改权限",
  465. icon: 'error',
  466. duration: 2000
  467. })
  468. that.setData({
  469. showDialog : false,
  470. })
  471. }else{
  472. wx.showToast({
  473. title: "系统错误",
  474. icon: 'error',
  475. duration: 2000
  476. })
  477. }
  478. }
  479. })
  480. },
  481. bindNameInput(e){
  482. var that = this ;
  483. console.log(e);
  484. that.setData({password:e.detail.value});
  485. },
  486. /**
  487. * 生命周期函数--监听页面隐藏
  488. */
  489. onHide: function () {
  490. },
  491. /**
  492. * 生命周期函数--监听页面卸载
  493. */
  494. onUnload: function () {
  495. },
  496. /**
  497. * 页面相关事件处理函数--监听用户下拉动作
  498. */
  499. onPullDownRefresh: function () {
  500. },
  501. /**
  502. * 页面上拉触底事件的处理函数
  503. */
  504. onReachBottom: function () {
  505. },
  506. navigate(even){
  507. wx.navigateTo({
  508. url: even.currentTarget.dataset.url,
  509. })
  510. },
  511. /**
  512. * 用户点击右上角分享
  513. */
  514. onShareAppMessage: function () {
  515. }
  516. })