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

561 line
14 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. UTIL.showToastNoneIcon(res.msg)
  128. }
  129. }
  130. })
  131. },
  132. bankReceipt(){
  133. console.log(this.data.form)
  134. var that = this ;
  135. const form = that.data.form;
  136. if(form.selectType == ''){
  137. UTIL.showToastNoneIcon('请选择查询类型!');
  138. return;
  139. }else if(form.direction == ''){
  140. UTIL.showToastNoneIcon('请选择来往账标识!');
  141. return;
  142. }else if(form.datescopeFrom == ''){
  143. UTIL.showToastNoneIcon('请选择开始日期!');
  144. return;
  145. }else if(form.datescopeTo == ''){
  146. UTIL.showToastNoneIcon('请选择截止日期!');
  147. return;
  148. }
  149. that.data.form.method = "GET"
  150. UTIL.showLoadingHaveMask('正在查询');
  151. UTIL.httpRequest(API.URL_GET_SELECTBANKRECEIPT, that.data.form, {
  152. success: (res) => {
  153. if (res.code == API.SUCCESS_CODE) {
  154. UTIL.hideLoadingHaveMask();
  155. wx.showToast({
  156. title: '查询成功',
  157. icon: 'success',
  158. duration: 2000,
  159. })
  160. }else{
  161. UTIL.hideLoadingHaveMask();
  162. UTIL.showToastNoneIcon(res.msg)
  163. }
  164. }
  165. })
  166. },
  167. showTransactionDialog(e){
  168. var that = this;
  169. that.setData({
  170. form:{
  171. selectTypeText:'',
  172. selectType:'',
  173. directionText:'',
  174. direction:'',
  175. datescopeFrom:'',
  176. datescopeTo:'',
  177. }
  178. })
  179. that.setData({
  180. showTransactionDialog:true,
  181. ["form.accountId"]:e.currentTarget.dataset.id
  182. })
  183. },
  184. showReceiptDialog(e){
  185. var that = this;
  186. that.setData({
  187. form:{
  188. selectTypeText:'',
  189. selectType:'',
  190. directionText:'',
  191. direction:'',
  192. datescopeFrom:'',
  193. datescopeTo:'',
  194. }
  195. })
  196. that.setData({
  197. showReceiptDialog:true,
  198. ["form.accountId"]:e.currentTarget.dataset.id
  199. })
  200. },
  201. goRegular(e){
  202. wx.navigateTo({
  203. url: '/pages/regular/regular?id='+e.currentTarget.dataset.id,
  204. })
  205. },
  206. //跳转支出申请
  207. swichPaymentApply:function(e){
  208. console.log(e.currentTarget.dataset.current);
  209. // let cur = e.currentTarget.dataset.current;
  210. // if (this.data.currentTaB == cur) {
  211. // return false;
  212. // }else{
  213. // wx.navigateTo({
  214. // url: '../inCome/index?id=' + id,
  215. // })
  216. // }
  217. wx.navigateTo({
  218. url: '/pages/apply/paymentTemplate/add/add',
  219. })
  220. },
  221. openBox(even){
  222. console.log(even.currentTarget.dataset.name);
  223. this.setData({
  224. [even.currentTarget.dataset.name]:true
  225. })
  226. },
  227. closeBox:function(){
  228. var that = this ;
  229. that.setData({
  230. show: false,
  231. })
  232. },
  233. goTemplate:function(e){
  234. wx.navigateTo({
  235. url: 'paymentTemplate/add/add?id='+e.currentTarget.dataset.id+'&type=template'
  236. })
  237. },
  238. updateMoney:function(e){
  239. UTIL.showLoadingHaveMask('正在查询');
  240. UTIL.httpRequest(API.URL_GET_GETBALANCEENQUIRY+e.currentTarget.dataset.id, {method:'GET'}, {
  241. success: (res) => {
  242. if (res.code == API.SUCCESS_CODE) {
  243. this.setData({
  244. ["accountList["+e.currentTarget.dataset.index+"].balance"]:res.msg
  245. })
  246. UTIL.hideLoadingHaveMask();
  247. wx.showToast({
  248. title: '查询成功',
  249. icon: 'success',
  250. duration: 2000,
  251. })
  252. }else{
  253. UTIL.hideLoadingHaveMask();
  254. UTIL.showToastNoneIcon(res.msg)
  255. }
  256. }
  257. })
  258. },
  259. back:function(){
  260. wx.navigateBack({
  261. delta: 1
  262. })
  263. },
  264. /**
  265. * 生命周期函数--监听页面初次渲染完成
  266. */
  267. onReady: function () {
  268. },
  269. /**
  270. * 生命周期函数--监听页面显示
  271. */
  272. onShow: function () {
  273. var that = this;
  274. wx.showLoading({
  275. title: '正在加载账户',
  276. mask:true
  277. })
  278. var sendData = {
  279. pageNum:'1',
  280. pageSize:'100',
  281. accountName:'',
  282. bankAccountNumber:'',
  283. status:'N',
  284. method:'GET',
  285. accountType:102
  286. }
  287. var sendData2 = {
  288. pageNum:'1',
  289. pageSize:'100',
  290. accountName:'',
  291. bankAccountNumber:'',
  292. status:'N',
  293. method:'GET',
  294. accountType:101
  295. }
  296. var sendData3 = {
  297. pageNum:'1',
  298. pageSize:'100',
  299. payeeType:'4',
  300. status:'0',
  301. method:'GET',
  302. }
  303. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'bank_type', {method:'GET'}, {
  304. success: (res) => {
  305. this.setData({
  306. bankTypeOptions:res.data
  307. });
  308. }
  309. })
  310. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'select_type', {method:'GET'}, {
  311. success: (res) => {
  312. this.setData({
  313. selectTypeOptions:res.data
  314. });
  315. }
  316. })
  317. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'direction', {method:'GET'}, {
  318. success: (res) => {
  319. this.setData({
  320. directionOptions:res.data
  321. });
  322. }
  323. })
  324. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'receipt_trans_type', {method:'GET'}, {
  325. success: (res) => {
  326. this.setData({
  327. receiptOptions:res.data
  328. });
  329. }
  330. })
  331. UTIL.httpRequest(API.URL_GET_GETINFO, {method:'GET'}, {
  332. success: (res) => {
  333. if (res.code == API.SUCCESS_CODE) {
  334. this.setData({bookName:res.user.bookName})
  335. }
  336. }
  337. })
  338. UTIL.httpRequest(API.URL_GET_APPROVALITEMSLIST, {method:'GET',dataType:'1'}, {
  339. success: (res) => {
  340. if (res.code == API.SUCCESS_CODE) {
  341. that.setData({
  342. approvalItemsOptions : res.rows
  343. })
  344. }
  345. }
  346. })
  347. setTimeout(function(){
  348. UTIL.httpRequest(API.URL_GET_ACCOUNTLIST, sendData,{
  349. success: (res) => {
  350. if(res.rows){
  351. for (let i = 0; i < res.rows.length; i++) {
  352. if(res.rows[i].bankAccountNumber==null){continue;}
  353. res.rows[i].bankAccountNumber = res.rows[i].bankAccountNumber.replace(/(\d{4})(?=\d)/g, "$1 ");
  354. res.rows[i].balance = Number(res.rows[i].balance).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  355. return $1 + ","; }).replace(/\.$/, "");
  356. res.rows[i].bankTypeText = UTIL.getTransform(res.rows[i].bankType,that.data.bankTypeOptions);
  357. }
  358. console.log(res.rows)
  359. that.setData({
  360. accountList:res.rows
  361. })
  362. wx.hideLoading();
  363. }else{
  364. wx.hideLoading();
  365. }
  366. }
  367. })
  368. UTIL.httpRequest(API.URL_GET_ACCOUNTLIST, sendData2,{
  369. success: (res) => {
  370. if(res.rows){
  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. })
  382. UTIL.httpRequest(API.URL_GET_SELECTLIST, sendData3,{
  383. success: (res) => {
  384. for (let i = 0; i < res.rows.length; i++) {
  385. res.rows[i].payeeAccount = res.rows[i].payeeAccount.replace(/(\d{4})(?=\d)/g, "$1 ");
  386. res.rows[i].payeePaymentLines = Number(res.rows[i].payeePaymentLines).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  387. return $1 + ","; }).replace(/\.$/, "");
  388. }
  389. that.setData({
  390. accountListGWK:res.rows
  391. })
  392. }
  393. })
  394. },1000)
  395. },
  396. delete(e){
  397. console.log(e);
  398. var that = this;
  399. UTIL.httpRequest(API.URL_GET_REMOVEAPPROVAL + e.currentTarget.dataset.id, {method:'GET'},{
  400. success: (res) => {
  401. if (res.code == API.SUCCESS_CODE) {
  402. that.data.approvalItemsOptions.splice(e.currentTarget.dataset.index, 1);
  403. wx.showToast({
  404. title: '删除成功!',
  405. icon: 'success',
  406. duration: 2000
  407. })
  408. that.setData({
  409. approvalItemsOptions : that.data.approvalItemsOptions
  410. })
  411. }
  412. }
  413. })
  414. },
  415. getMr(e){
  416. var that = this;
  417. UTIL.httpRequest(API.URL_GET_GETSETDEFAULTVALUES + e.currentTarget.dataset.id, {method:'GET'},{
  418. success: (res) => {
  419. if (res.code == API.SUCCESS_CODE) {
  420. UTIL.httpRequest(API.URL_GET_APPROVALITEMSLIST, {method:'GET',dataType:'1'}, {
  421. success: (res) => {
  422. if (res.code == API.SUCCESS_CODE) {
  423. wx.showToast({
  424. title: '设置成功!',
  425. icon: 'success',
  426. duration: 2000
  427. })
  428. that.setData({
  429. approvalItemsOptions : res.rows
  430. })
  431. }
  432. }
  433. })
  434. }
  435. }
  436. })
  437. },
  438. showDialog(e){
  439. var that = this ;
  440. that.setData({
  441. showDialog:true,
  442. projectId:e.currentTarget.dataset.id,
  443. bankName:e.currentTarget.dataset.name,
  444. id: '' ,
  445. password: '',})
  446. },
  447. //支付口令修改
  448. edit(e){
  449. var that = this ;
  450. var zz = /^(?=.*\d)(?=.*[a-zA-Z])(?=.*[~!@#$%^&*])[\da-zA-Z~!@#$%^&*]{6,}$/;
  451. console.log(zz.test(that.data.password));
  452. if(!(zz.test(that.data.password))){
  453. wx.showToast({
  454. title: '请根据提示修改',
  455. icon: 'error',
  456. duration: 2000,
  457. })
  458. return;
  459. }
  460. let data = {
  461. id: that.data.projectId ,
  462. accountPassword: that.data.password,
  463. method:'POST'
  464. }
  465. UTIL.httpRequest(API.URL_GET_PASSWORDEDIT, data,{
  466. success: (res) => {
  467. if (res.code == API.SUCCESS_CODE) {
  468. wx.showToast({
  469. title: '设置成功!',
  470. icon: 'success',
  471. duration: 2000
  472. })
  473. that.setData({
  474. showDialog : false,
  475. })
  476. }else if(res.code == "403"){
  477. wx.showToast({
  478. title: "无修改权限",
  479. icon: 'error',
  480. duration: 2000
  481. })
  482. that.setData({
  483. showDialog : false,
  484. })
  485. }else{
  486. wx.showToast({
  487. title: "系统错误",
  488. icon: 'error',
  489. duration: 2000
  490. })
  491. }
  492. }
  493. })
  494. },
  495. bindNameInput(e){
  496. var that = this ;
  497. console.log(e);
  498. that.setData({password:e.detail.value});
  499. },
  500. onClose(e){
  501. this.setData({
  502. [e.currentTarget.dataset.name]:false
  503. })
  504. },
  505. /**
  506. * 生命周期函数--监听页面隐藏
  507. */
  508. onHide: function () {
  509. },
  510. /**
  511. * 生命周期函数--监听页面卸载
  512. */
  513. onUnload: function () {
  514. },
  515. /**
  516. * 页面相关事件处理函数--监听用户下拉动作
  517. */
  518. onPullDownRefresh: function () {
  519. },
  520. /**
  521. * 页面上拉触底事件的处理函数
  522. */
  523. onReachBottom: function () {
  524. },
  525. navigate(even){
  526. wx.navigateTo({
  527. url: even.currentTarget.dataset.url,
  528. })
  529. },
  530. /**
  531. * 用户点击右上角分享
  532. */
  533. onShareAppMessage: function () {
  534. }
  535. })