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

321 line
8.0 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. },
  24. onChange(event) {
  25. this.setData({result:event.detail})
  26. },
  27. onChange2(event) {
  28. this.setData({result2:event.detail})
  29. },
  30. switchTab(e){
  31. var that = this;
  32. this.setData({showGroup:e.currentTarget.dataset.gid})
  33. if(e.currentTarget.dataset.gid){
  34. //收入事项
  35. let data = {
  36. pageNum:'1',
  37. pageSize:'999',
  38. accountType:'',
  39. checkedStatus:this.data.checkedStatus,
  40. incomeExpensesType:'1',
  41. }
  42. UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data ,{
  43. success: (res) => {
  44. if (res.code == API.SUCCESS_CODE) {
  45. let list = res.rows;
  46. for (let i = 0; i < list.length; i++) {
  47. const element = list[i];
  48. element.checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  49. element.incomeTypeText = UTIL.getTransform(element.incomeType,that.data.incomeTypeOptions);
  50. }
  51. this.setData({
  52. flowListSR:list,
  53. flowListSRNum:res.total
  54. });
  55. }
  56. }
  57. })
  58. }else{
  59. let data2 = {
  60. pageNum:'1',
  61. pageSize:'999',
  62. accountType:'',
  63. checkedStatus:this.data.checkedStatus,
  64. incomeExpensesType:'2',
  65. }
  66. UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data2 ,{
  67. success: (res) => {
  68. if (res.code == API.SUCCESS_CODE) {
  69. let list = res.rows;
  70. for (let i = 0; i < list.length; i++) {
  71. const element = list[i];
  72. element.checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  73. }
  74. this.setData({
  75. flowListZC:list,
  76. flowListZCNum:res.total
  77. });
  78. }
  79. }
  80. })
  81. }
  82. },
  83. back:function(){
  84. wx.navigateBack({
  85. delta: 1
  86. })
  87. },
  88. /**
  89. * 生命周期函数--监听页面初次渲染完成
  90. */
  91. onReady() {
  92. },
  93. /**
  94. * 生命周期函数--监听页面显示
  95. */
  96. onShow() {
  97. var that = this;
  98. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'checked_status', {method:'GET'}, {
  99. success: (res) => {
  100. that.setData({
  101. capitalExpenditureTypeOptions:res.data,
  102. })
  103. }
  104. })
  105. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'income_type', {method:'GET'}, {
  106. success: (res) => {
  107. that.setData({
  108. incomeTypeOptions:res.data,
  109. })
  110. }
  111. })
  112. //收入事项
  113. let data = {
  114. pageNum:'1',
  115. pageSize:'999',
  116. accountType:'',
  117. checkedStatus:'1',
  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. element.checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  127. element.incomeTypeText = UTIL.getTransform(element.incomeType,that.data.incomeTypeOptions);
  128. }
  129. this.setData({
  130. flowListSR:list,
  131. flowListSRNum:res.total
  132. });
  133. }
  134. }
  135. })
  136. //支出事项
  137. let data2 = {
  138. pageNum:'1',
  139. pageSize:'999',
  140. accountType:'',
  141. checkedStatus:'1',
  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. element.checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  151. }
  152. this.setData({
  153. flowListZC:list,
  154. flowListZCNum:res.total
  155. });
  156. }
  157. }
  158. })
  159. },
  160. openPopup(even){
  161. this.setData({
  162. showProjectFundType:true
  163. })
  164. },
  165. onConfirmPick(event){
  166. var that = this;
  167. this.setData({
  168. [event.currentTarget.dataset.name]: false,
  169. checkedStatus: event.detail.value.dictValue,
  170. checkedStatusText: event.detail.value.dictLabel,
  171. });
  172. if(that.data.showGroup){
  173. let data = {
  174. pageNum:'1',
  175. pageSize:'999',
  176. accountType:'',
  177. checkedStatus:event.detail.value.dictValue,
  178. incomeExpensesType:'1',
  179. }
  180. UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data ,{
  181. success: (res) => {
  182. if (res.code == API.SUCCESS_CODE) {
  183. let list = res.rows;
  184. for (let i = 0; i < list.length; i++) {
  185. const element = list[i];
  186. element.checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  187. element.incomeTypeText = UTIL.getTransform(element.incomeType,that.data.incomeTypeOptions);
  188. }
  189. this.setData({
  190. flowListSR:list,
  191. flowListSRNum:res.total
  192. });
  193. }
  194. }
  195. })
  196. }else{
  197. let data2 = {
  198. pageNum:'1',
  199. pageSize:'999',
  200. accountType:'',
  201. checkedStatus:event.detail.value.dictValue,
  202. incomeExpensesType:'2',
  203. }
  204. UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data2 ,{
  205. success: (res) => {
  206. if (res.code == API.SUCCESS_CODE) {
  207. let list = res.rows;
  208. for (let i = 0; i < list.length; i++) {
  209. const element = list[i];
  210. element.checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  211. }
  212. this.setData({
  213. flowListZC:list,
  214. flowListZCNum:res.total
  215. });
  216. }
  217. }
  218. })
  219. }
  220. },
  221. closeBox(even){
  222. console.log(even.currentTarget.dataset.name);
  223. this.setData({
  224. [even.currentTarget.dataset.name]:false
  225. })
  226. },
  227. goSubmit(){
  228. var that = this ;
  229. let url = API.URL_GET_GETBOOKKEEP
  230. wx.request({
  231. url,
  232. method:"POST",
  233. timeout: 60000,
  234. data:that.data.result,
  235. header: {
  236. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  237. },
  238. success: function (response) {
  239. wx.showToast({
  240. title: "提交成功!",
  241. duration: 2000,
  242. icon:"success"
  243. })
  244. setTimeout(function(){
  245. wx.reLaunch({
  246. url: '/pages/index/index'
  247. })
  248. },2000)
  249. }
  250. })
  251. },
  252. goUpdate(event){
  253. wx.navigateTo({
  254. url: '/pages/Bookkeeping/update/update?id='+event.currentTarget.dataset.id,
  255. })
  256. },
  257. delete(e){
  258. console.log(e);
  259. var that = this;
  260. UTIL.httpRequest(API.URL_GET_FLOWREMOVE + e.currentTarget.dataset.id, {method:'GET'},{
  261. success: (res) => {
  262. if (res.code == API.SUCCESS_CODE) {
  263. that.data.flowListSR.splice(e.currentTarget.dataset.index, 1);
  264. wx.showToast({
  265. title: '删除成功!',
  266. icon: 'success',
  267. duration: 2000
  268. })
  269. that.setData({
  270. flowListSR : that.data.flowListSR,
  271. flowListSRNum:that.data.flowListSRNum-1
  272. })
  273. }
  274. }
  275. })
  276. },
  277. /**
  278. * 生命周期函数--监听页面隐藏
  279. */
  280. onHide() {
  281. },
  282. /**
  283. * 生命周期函数--监听页面卸载
  284. */
  285. onUnload() {
  286. },
  287. /**
  288. * 页面相关事件处理函数--监听用户下拉动作
  289. */
  290. onPullDownRefresh() {
  291. },
  292. /**
  293. * 页面上拉触底事件的处理函数
  294. */
  295. onReachBottom() {
  296. },
  297. /**
  298. * 用户点击右上角分享
  299. */
  300. onShareAppMessage() {
  301. }
  302. })