微信小程序
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

405 řádky
10 KiB

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