微信小程序
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

552 рядки
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. for (let i = 0; i < res.rows.length; i++) {
  351. if(res.rows[i].bankAccountNumber==null){continue;}
  352. res.rows[i].bankAccountNumber = res.rows[i].bankAccountNumber.replace(/(\d{4})(?=\d)/g, "$1 ");
  353. res.rows[i].balance = Number(res.rows[i].balance).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  354. return $1 + ","; }).replace(/\.$/, "");
  355. res.rows[i].bankTypeText = UTIL.getTransform(res.rows[i].bankType,that.data.bankTypeOptions);
  356. }
  357. console.log(res.rows)
  358. that.setData({
  359. accountList:res.rows
  360. })
  361. wx.hideLoading();
  362. }
  363. })
  364. UTIL.httpRequest(API.URL_GET_ACCOUNTLIST, sendData2,{
  365. success: (res) => {
  366. for (let i = 0; i < res.rows.length; i++) {
  367. res.rows[i].balance = Number(res.rows[i].balance).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  368. return $1 + ","; }).replace(/\.$/, "");
  369. }
  370. console.log(res.rows)
  371. that.setData({
  372. accountListXJ:res.rows
  373. })
  374. }
  375. })
  376. UTIL.httpRequest(API.URL_GET_SELECTLIST, sendData3,{
  377. success: (res) => {
  378. for (let i = 0; i < res.rows.length; i++) {
  379. res.rows[i].payeeAccount = res.rows[i].payeeAccount.replace(/(\d{4})(?=\d)/g, "$1 ");
  380. res.rows[i].payeePaymentLines = Number(res.rows[i].payeePaymentLines).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  381. return $1 + ","; }).replace(/\.$/, "");
  382. }
  383. that.setData({
  384. accountListGWK:res.rows
  385. })
  386. }
  387. })
  388. },1000)
  389. },
  390. delete(e){
  391. console.log(e);
  392. var that = this;
  393. UTIL.httpRequest(API.URL_GET_REMOVEAPPROVAL + e.currentTarget.dataset.id, {method:'GET'},{
  394. success: (res) => {
  395. if (res.code == API.SUCCESS_CODE) {
  396. that.data.approvalItemsOptions.splice(e.currentTarget.dataset.index, 1);
  397. wx.showToast({
  398. title: '删除成功!',
  399. icon: 'success',
  400. duration: 2000
  401. })
  402. that.setData({
  403. approvalItemsOptions : that.data.approvalItemsOptions
  404. })
  405. }
  406. }
  407. })
  408. },
  409. getMr(e){
  410. var that = this;
  411. UTIL.httpRequest(API.URL_GET_GETSETDEFAULTVALUES + e.currentTarget.dataset.id, {method:'GET'},{
  412. success: (res) => {
  413. if (res.code == API.SUCCESS_CODE) {
  414. UTIL.httpRequest(API.URL_GET_APPROVALITEMSLIST, {method:'GET',dataType:'1'}, {
  415. success: (res) => {
  416. if (res.code == API.SUCCESS_CODE) {
  417. wx.showToast({
  418. title: '设置成功!',
  419. icon: 'success',
  420. duration: 2000
  421. })
  422. that.setData({
  423. approvalItemsOptions : res.rows
  424. })
  425. }
  426. }
  427. })
  428. }
  429. }
  430. })
  431. },
  432. showDialog(e){
  433. var that = this ;
  434. that.setData({
  435. showDialog:true,
  436. projectId:e.currentTarget.dataset.id,
  437. bankName:e.currentTarget.dataset.name,
  438. id: '' ,
  439. password: '',})
  440. },
  441. //支付口令修改
  442. edit(e){
  443. var that = this ;
  444. var zz = /^(?=.*\d)(?=.*[a-zA-Z])(?=.*[~!@#$%^&*])[\da-zA-Z~!@#$%^&*]{6,}$/;
  445. console.log(zz.test(that.data.password));
  446. if(!(zz.test(that.data.password))){
  447. wx.showToast({
  448. title: '请根据提示修改',
  449. icon: 'error',
  450. duration: 2000,
  451. })
  452. return;
  453. }
  454. let data = {
  455. id: that.data.projectId ,
  456. accountPassword: that.data.password,
  457. method:'POST'
  458. }
  459. UTIL.httpRequest(API.URL_GET_PASSWORDEDIT, data,{
  460. success: (res) => {
  461. if (res.code == API.SUCCESS_CODE) {
  462. wx.showToast({
  463. title: '设置成功!',
  464. icon: 'success',
  465. duration: 2000
  466. })
  467. that.setData({
  468. showDialog : false,
  469. })
  470. }else if(res.code == "403"){
  471. wx.showToast({
  472. title: "无修改权限",
  473. icon: 'error',
  474. duration: 2000
  475. })
  476. that.setData({
  477. showDialog : false,
  478. })
  479. }else{
  480. wx.showToast({
  481. title: "系统错误",
  482. icon: 'error',
  483. duration: 2000
  484. })
  485. }
  486. }
  487. })
  488. },
  489. bindNameInput(e){
  490. var that = this ;
  491. console.log(e);
  492. that.setData({password:e.detail.value});
  493. },
  494. onClose(e){
  495. this.setData({
  496. [e.currentTarget.dataset.name]:false
  497. })
  498. },
  499. /**
  500. * 生命周期函数--监听页面隐藏
  501. */
  502. onHide: function () {
  503. },
  504. /**
  505. * 生命周期函数--监听页面卸载
  506. */
  507. onUnload: function () {
  508. },
  509. /**
  510. * 页面相关事件处理函数--监听用户下拉动作
  511. */
  512. onPullDownRefresh: function () {
  513. },
  514. /**
  515. * 页面上拉触底事件的处理函数
  516. */
  517. onReachBottom: function () {
  518. },
  519. navigate(even){
  520. wx.navigateTo({
  521. url: even.currentTarget.dataset.url,
  522. })
  523. },
  524. /**
  525. * 用户点击右上角分享
  526. */
  527. onShareAppMessage: function () {
  528. }
  529. })