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

Bookkeeping.js 8.7 KiB

3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
3 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346
  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. //收入事项
  46. let data = {
  47. pageNum:'1',
  48. pageSize:'999',
  49. accountType:'',
  50. checkedStatus:'1',
  51. incomeExpensesType:'1',
  52. }
  53. UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data ,{
  54. success: (res) => {
  55. if (res.code == API.SUCCESS_CODE) {
  56. let list = res.rows;
  57. for (let i = 0; i < list.length; i++) {
  58. const element = list[i];
  59. list[i].checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  60. list[i].incomeTypeText = UTIL.getTransform(element.incomeType,that.data.incomeTypeOptions);
  61. }
  62. this.setData({
  63. flowListSR:list,
  64. flowListSRNum:res.total
  65. });
  66. }
  67. }
  68. })
  69. //支出事项
  70. let data2 = {
  71. pageNum:'1',
  72. pageSize:'999',
  73. accountType:'',
  74. checkedStatus:'1',
  75. incomeExpensesType:'2',
  76. }
  77. UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data2 ,{
  78. success: (res) => {
  79. if (res.code == API.SUCCESS_CODE) {
  80. let list = res.rows;
  81. this.setData({
  82. flowListZCNum:res.total
  83. });
  84. }
  85. }
  86. })
  87. },
  88. onChange(event) {
  89. this.setData({result:event.detail})
  90. },
  91. onChange2(event) {
  92. this.setData({result2:event.detail})
  93. },
  94. switchTab(e){
  95. var that = this;
  96. this.setData({showGroup:e.currentTarget.dataset.gid})
  97. if(e.currentTarget.dataset.gid){
  98. //收入事项
  99. let data = {
  100. pageNum:'1',
  101. pageSize:'999',
  102. accountType:'',
  103. checkedStatus:this.data.checkedStatus,
  104. incomeExpensesType:'1',
  105. }
  106. UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data ,{
  107. success: (res) => {
  108. if (res.code == API.SUCCESS_CODE) {
  109. let list = res.rows;
  110. for (let i = 0; i < list.length; i++) {
  111. const element = list[i];
  112. list[i].checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  113. list[i].incomeTypeText = UTIL.getTransform(element.incomeType,that.data.incomeTypeOptions);
  114. }
  115. this.setData({
  116. flowListSR:list,
  117. flowListSRNum:res.total
  118. });
  119. }
  120. }
  121. })
  122. }else{
  123. let data2 = {
  124. pageNum:'1',
  125. pageSize:'999',
  126. accountType:'',
  127. checkedStatus:this.data.checkedStatus,
  128. incomeExpensesType:'2',
  129. }
  130. UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data2 ,{
  131. success: (res) => {
  132. if (res.code == API.SUCCESS_CODE) {
  133. let list = res.rows;
  134. for (let i = 0; i < list.length; i++) {
  135. const element = list[i];
  136. list[i].checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  137. list[i].expenditureTypeText = UTIL.getTransform(element.expenditureType,that.data.expenditureTypeOptions);
  138. }
  139. this.setData({
  140. flowListZC:list,
  141. flowListZCNum:res.total
  142. });
  143. }
  144. }
  145. })
  146. }
  147. },
  148. back:function(){
  149. wx.navigateBack({
  150. delta: 1
  151. })
  152. },
  153. /**
  154. * 生命周期函数--监听页面初次渲染完成
  155. */
  156. onReady() {
  157. },
  158. /**
  159. * 生命周期函数--监听页面显示
  160. */
  161. onShow() {
  162. },
  163. openPopup(even){
  164. this.setData({
  165. showProjectFundType:true
  166. })
  167. },
  168. onConfirmPick(event){
  169. var that = this;
  170. this.setData({
  171. [event.currentTarget.dataset.name]: false,
  172. checkedStatus: event.detail.value.dictValue,
  173. checkedStatusText: event.detail.value.dictLabel,
  174. });
  175. let data = {
  176. pageNum:'1',
  177. pageSize:'999',
  178. accountType:'',
  179. checkedStatus:event.detail.value.dictValue,
  180. incomeExpensesType:'1',
  181. }
  182. UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data ,{
  183. success: (res) => {
  184. if (res.code == API.SUCCESS_CODE) {
  185. let list = res.rows;
  186. for (let i = 0; i < list.length; i++) {
  187. const element = list[i];
  188. element.checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  189. element.incomeTypeText = UTIL.getTransform(element.incomeType,that.data.incomeTypeOptions);
  190. }
  191. this.setData({
  192. flowListSR:list,
  193. flowListSRNum:res.total
  194. });
  195. }
  196. }
  197. })
  198. let data2 = {
  199. pageNum:'1',
  200. pageSize:'999',
  201. accountType:'',
  202. checkedStatus:event.detail.value.dictValue,
  203. incomeExpensesType:'2',
  204. }
  205. UTIL.httpRequest(API.URL_GET_GETFLOWLIST,data2 ,{
  206. success: (res) => {
  207. if (res.code == API.SUCCESS_CODE) {
  208. let list = res.rows;
  209. for (let i = 0; i < list.length; i++) {
  210. const element = list[i];
  211. element.checkedStatusText = UTIL.getTransform(element.checkedStatus,that.data.capitalExpenditureTypeOptions);
  212. }
  213. this.setData({
  214. flowListZC:list,
  215. flowListZCNum:res.total
  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. goUpdateZC(event){
  258. wx.navigateTo({
  259. url: '/pages/Bookkeeping/updateZC/update?id='+event.currentTarget.dataset.id,
  260. })
  261. },
  262. delete(e){
  263. console.log(e);
  264. var that = this;
  265. UTIL.httpRequest(API.URL_GET_FLOWREMOVE + e.currentTarget.dataset.id, {method:'GET'},{
  266. success: (res) => {
  267. if (res.code == API.SUCCESS_CODE) {
  268. that.data.flowListSR.splice(e.currentTarget.dataset.index, 1);
  269. wx.showToast({
  270. title: '删除成功!',
  271. icon: 'success',
  272. duration: 2000
  273. })
  274. that.setData({
  275. flowListSR : that.data.flowListSR,
  276. flowListSRNum:that.data.flowListSRNum-1
  277. })
  278. }
  279. }
  280. })
  281. },
  282. delete2(e){
  283. console.log(e);
  284. var that = this;
  285. UTIL.httpRequest(API.URL_GET_FLOWREMOVE + e.currentTarget.dataset.id, {method:'GET'},{
  286. success: (res) => {
  287. if (res.code == API.SUCCESS_CODE) {
  288. that.data.flowListZC.splice(e.currentTarget.dataset.index, 1);
  289. wx.showToast({
  290. title: '删除成功!',
  291. icon: 'success',
  292. duration: 2000
  293. })
  294. that.setData({
  295. flowListZC : that.data.flowListZC,
  296. flowListZCNum:that.data.flowListZCNum-1
  297. })
  298. }
  299. }
  300. })
  301. },
  302. /**
  303. * 生命周期函数--监听页面隐藏
  304. */
  305. onHide() {
  306. },
  307. /**
  308. * 生命周期函数--监听页面卸载
  309. */
  310. onUnload() {
  311. },
  312. /**
  313. * 页面相关事件处理函数--监听用户下拉动作
  314. */
  315. onPullDownRefresh() {
  316. },
  317. /**
  318. * 页面上拉触底事件的处理函数
  319. */
  320. onReachBottom() {
  321. },
  322. /**
  323. * 用户点击右上角分享
  324. */
  325. onShareAppMessage() {
  326. }
  327. })