微信小程序
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458
  1. // pages/Bookkeeping/Bookkeeping.js
  2. import * as UTIL from '../../utils/util.js';
  3. import * as API from '../../utils/API.js';
  4. const app = getApp();
  5. Page({
  6. /**
  7. * 页面的初始数据
  8. */
  9. data: {
  10. isIPX: app.globalData.isIPX,
  11. result:[],
  12. result2:[],
  13. showGroup:true,
  14. flowList:[],
  15. showProjectFundType:false,
  16. checkedStatusText:'未提交',
  17. checkedStatus:'1',
  18. incomeExpensesType:'1'
  19. },
  20. /**
  21. * 生命周期函数--监听页面加载
  22. */
  23. onLoad(options) {
  24. var that = this;
  25. wx.showLoading({
  26. title: '正在加载',
  27. mask:true
  28. })
  29. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'checked_status', {method:'GET'}, {
  30. success: (res) => {
  31. that.setData({
  32. capitalExpenditureTypeOptions:res.data,
  33. })
  34. }
  35. })
  36. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'income_type', {method:'GET'}, {
  37. success: (res) => {
  38. that.setData({
  39. incomeTypeOptions:res.data,
  40. })
  41. }
  42. })
  43. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'capital_expenditure_type', {method:'GET'}, {
  44. success: (res) => {
  45. that.setData({
  46. expenditureTypeOptions:res.data,
  47. })
  48. }
  49. })
  50. },
  51. SRSelect(){
  52. var that = this;
  53. //收入事项
  54. let data = {
  55. pageNum:'1',
  56. pageSize:'999',
  57. accountType:'',
  58. checkedStatus:that.data.checkedStatus,
  59. incomeExpensesType:'1',
  60. }
  61. UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data ,{
  62. success: (res) => {
  63. if (res.code == API.SUCCESS_CODE) {
  64. let list = res.rows;
  65. for (let i = 0; i < list.length; i++) {
  66. const element = list[i];
  67. list[i].checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  68. list[i].incomeTypeText = UTIL.getTransform(element.incomeType,that.data.incomeTypeOptions);
  69. list[i].jieAmount = Number(element.jieAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  70. return $1 + ","; }).replace(/\.$/, "");
  71. }
  72. this.setData({
  73. flowListSR:list,
  74. flowListSRNum:res.total
  75. });
  76. wx.hideLoading();
  77. }
  78. }
  79. })
  80. },
  81. ZCSelect(){
  82. var that = this;
  83. //支出事项
  84. let data2 = {
  85. pageNum:'1',
  86. pageSize:'999',
  87. accountType:'',
  88. checkedStatus:that.data.checkedStatus,
  89. incomeExpensesType:'2',
  90. }
  91. UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data2 ,{
  92. success: (res) => {
  93. if (res.code == API.SUCCESS_CODE) {
  94. let list = res.rows;
  95. for (let i = 0; i < list.length; i++) {
  96. const element = list[i];
  97. list[i].checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  98. list[i].expenditureTypeText = UTIL.getTransform(element.expenditureType,that.data.expenditureTypeOptions);
  99. list[i].daiAmount = Number(element.daiAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  100. return $1 + ","; }).replace(/\.$/, "");
  101. }
  102. this.setData({
  103. flowListZC:list,
  104. flowListZCNum:res.total
  105. });
  106. wx.hideLoading();
  107. }
  108. }
  109. })
  110. },
  111. onChange(event) {
  112. this.setData({result:event.detail})
  113. },
  114. onChange2(event) {
  115. this.setData({result2:event.detail})
  116. },
  117. switchTab(e){
  118. var that = this;
  119. this.setData({
  120. showGroup:e.currentTarget.dataset.gid,
  121. result:[],
  122. result2:[],
  123. })
  124. if(e.currentTarget.dataset.gid){
  125. //收入事项
  126. let data = {
  127. pageNum:'1',
  128. pageSize:'999',
  129. accountType:'',
  130. checkedStatus:this.data.checkedStatus,
  131. incomeExpensesType:'1',
  132. }
  133. UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data ,{
  134. success: (res) => {
  135. if (res.code == API.SUCCESS_CODE) {
  136. let list = res.rows;
  137. for (let i = 0; i < list.length; i++) {
  138. const element = list[i];
  139. list[i].checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  140. list[i].incomeTypeText = UTIL.getTransform(element.incomeType,that.data.incomeTypeOptions);
  141. list[i].jieAmount = Number(element.jieAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  142. return $1 + ","; }).replace(/\.$/, "");
  143. }
  144. this.setData({
  145. flowListSR:list,
  146. flowListSRNum:res.total
  147. });
  148. }
  149. }
  150. })
  151. }else{
  152. let data2 = {
  153. pageNum:'1',
  154. pageSize:'999',
  155. accountType:'',
  156. checkedStatus:this.data.checkedStatus,
  157. incomeExpensesType:'2',
  158. }
  159. UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data2 ,{
  160. success: (res) => {
  161. if (res.code == API.SUCCESS_CODE) {
  162. let list = res.rows;
  163. for (let i = 0; i < list.length; i++) {
  164. const element = list[i];
  165. list[i].checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  166. list[i].expenditureTypeText = UTIL.getTransform(element.expenditureType,that.data.expenditureTypeOptions);
  167. list[i].daiAmount = Number(element.daiAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  168. return $1 + ","; }).replace(/\.$/, "");
  169. }
  170. this.setData({
  171. flowListZC:list,
  172. flowListZCNum:res.total
  173. });
  174. }
  175. }
  176. })
  177. }
  178. },
  179. goAdd(){
  180. wx.navigateTo({
  181. url: 'inCome',
  182. })
  183. },
  184. back:function(){
  185. wx.navigateBack({
  186. delta: 1
  187. })
  188. },
  189. /**
  190. * 生命周期函数--监听页面初次渲染完成
  191. */
  192. onReady() {
  193. },
  194. /**
  195. * 生命周期函数--监听页面显示
  196. */
  197. onShow() {
  198. var that = this ;
  199. setTimeout(function(){
  200. that.SRSelect();
  201. that.ZCSelect();
  202. },1500)
  203. },
  204. openPopup(even){
  205. this.setData({
  206. showProjectFundType:true
  207. })
  208. },
  209. onConfirmPick(event){
  210. var that = this;
  211. this.setData({
  212. [event.currentTarget.dataset.name]: false,
  213. checkedStatus: event.detail.value.dictValue,
  214. checkedStatusText: event.detail.value.dictLabel,
  215. result:[],
  216. result2:[]
  217. });
  218. let data = {
  219. pageNum:'1',
  220. pageSize:'999',
  221. accountType:'',
  222. checkedStatus:event.detail.value.dictValue,
  223. incomeExpensesType:'1',
  224. }
  225. UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data ,{
  226. success: (res) => {
  227. if (res.code == API.SUCCESS_CODE) {
  228. let list = res.rows;
  229. for (let i = 0; i < list.length; i++) {
  230. const element = list[i];
  231. element.checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  232. element.incomeTypeText = UTIL.getTransform(element.incomeType,that.data.incomeTypeOptions);
  233. element.jieAmount = Number(element.jieAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  234. return $1 + ","; }).replace(/\.$/, "");
  235. }
  236. this.setData({
  237. flowListSR:list,
  238. flowListSRNum:res.total
  239. });
  240. }
  241. }
  242. })
  243. let data2 = {
  244. pageNum:'1',
  245. pageSize:'999',
  246. accountType:'',
  247. checkedStatus:event.detail.value.dictValue,
  248. incomeExpensesType:'2',
  249. }
  250. UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data2 ,{
  251. success: (res) => {
  252. if (res.code == API.SUCCESS_CODE) {
  253. let list = res.rows;
  254. for (let i = 0; i < list.length; i++) {
  255. const element = list[i];
  256. list[i].checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  257. list[i].expenditureTypeText = UTIL.getTransform(element.expenditureType,that.data.expenditureTypeOptions);
  258. list[i].daiAmount = Number(element.daiAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  259. return $1 + ","; }).replace(/\.$/, "");
  260. }
  261. this.setData({
  262. flowListZC:list,
  263. flowListZCNum:res.total
  264. });
  265. }
  266. }
  267. })
  268. },
  269. closeBox(even){
  270. console.log(even.currentTarget.dataset.name);
  271. this.setData({
  272. [even.currentTarget.dataset.name]:false
  273. })
  274. },
  275. goSubmit(){
  276. var that = this ;
  277. console.log(that.data.showGroup);
  278. if(that.data.showGroup){
  279. if(that.data.result.length==0){
  280. UTIL.showToastNoneIcon('至少选择一个收入事项!');
  281. return;
  282. }
  283. let url = wx.getStorageSync('dressCode')+ API.URL_GET_GETBOOKKEEP
  284. wx.request({
  285. url,
  286. method:"POST",
  287. timeout: 60000,
  288. data:that.data.result,
  289. header: {
  290. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  291. },
  292. success: function (response) {
  293. wx.showToast({
  294. title: "提交成功!",
  295. duration: 2000,
  296. icon:"success"
  297. })
  298. that.setData({
  299. result:[]
  300. })
  301. that.SRSelect();
  302. }
  303. })
  304. }else{
  305. if(that.data.result2.length==0){
  306. UTIL.showToastNoneIcon('至少选择一个支出事项!');
  307. return;
  308. }
  309. let url =wx.getStorageSync('dressCode')+ API.URL_GET_GETBOOKKEEP
  310. wx.request({
  311. url,
  312. method:"POST",
  313. timeout: 60000,
  314. data:that.data.result2,
  315. header: {
  316. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  317. },
  318. success: function (response) {
  319. wx.showToast({
  320. title: "提交成功!",
  321. duration: 2000,
  322. icon:"success"
  323. })
  324. that.setData({
  325. result2:[]
  326. })
  327. that.ZCSelect();
  328. }
  329. })
  330. }
  331. },
  332. goSee(event){
  333. wx.navigateTo({
  334. url: '/pages/Bookkeeping/seeBook/seeBook?id='+event.currentTarget.dataset.id,
  335. })
  336. },
  337. goSeeZC(event){
  338. wx.navigateTo({
  339. url: '/pages/Bookkeeping/seeBookZC/seeBookZC?id='+event.currentTarget.dataset.id,
  340. })
  341. },
  342. goUpdate(event){
  343. wx.navigateTo({
  344. url: '/pages/Bookkeeping/update/update?id='+event.currentTarget.dataset.id,
  345. })
  346. },
  347. goUpdateZC(event){
  348. wx.navigateTo({
  349. url: '/pages/Bookkeeping/updateZC/update?id='+event.currentTarget.dataset.id,
  350. })
  351. },
  352. delete(e){
  353. console.log(e);
  354. var that = this;
  355. wx.showModal({
  356. title: '提示',
  357. content: '是否删除?',
  358. success (res) {
  359. if (res.confirm) {
  360. UTIL.httpRequest(API.URL_GET_FLOWREMOVE + e.currentTarget.dataset.id, {method:'GET'},{
  361. success: (res) => {
  362. if (res.code == API.SUCCESS_CODE) {
  363. that.data.flowListSR.splice(e.currentTarget.dataset.index, 1);
  364. wx.showToast({
  365. title: '删除成功!',
  366. icon: 'success',
  367. duration: 2000
  368. })
  369. that.setData({
  370. flowListSR : that.data.flowListSR,
  371. flowListSRNum:that.data.flowListSRNum-1
  372. })
  373. }
  374. }
  375. })
  376. } else if (res.cancel) {
  377. console.log('用户点击取消')
  378. }
  379. }
  380. })
  381. },
  382. delete2(e){
  383. console.log(e);
  384. var that = this;
  385. wx.showModal({
  386. title: '提示',
  387. content: '是否删除?',
  388. success (res) {
  389. if (res.confirm) {
  390. UTIL.httpRequest(API.URL_GET_FLOWREMOVE + e.currentTarget.dataset.id, {method:'GET'},{
  391. success: (res) => {
  392. if (res.code == API.SUCCESS_CODE) {
  393. that.data.flowListZC.splice(e.currentTarget.dataset.index, 1);
  394. wx.showToast({
  395. title: '删除成功!',
  396. icon: 'success',
  397. duration: 2000
  398. })
  399. that.setData({
  400. flowListZC : that.data.flowListZC,
  401. flowListZCNum:that.data.flowListZCNum-1
  402. })
  403. }
  404. }
  405. })
  406. } else if (res.cancel) {
  407. console.log('用户点击取消')
  408. }
  409. }
  410. })
  411. },
  412. /**
  413. * 生命周期函数--监听页面隐藏
  414. */
  415. onHide() {
  416. },
  417. /**
  418. * 生命周期函数--监听页面卸载
  419. */
  420. onUnload() {
  421. },
  422. /**
  423. * 页面相关事件处理函数--监听用户下拉动作
  424. */
  425. onPullDownRefresh() {
  426. },
  427. /**
  428. * 页面上拉触底事件的处理函数
  429. */
  430. onReachBottom() {
  431. },
  432. /**
  433. * 用户点击右上角分享
  434. */
  435. onShareAppMessage() {
  436. }
  437. })