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

322 lines
7.8 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:'1',
  14. flowList:[],
  15. showProjectFundType:false,
  16. checkedStatusText:'全部',
  17. checkedStatus:'1',
  18. incomeExpensesType:'1',
  19. listNy:[],
  20. farmingTypeOptions:[{
  21. dictLabel:'全部',
  22. dictValue:''
  23. }],
  24. buildTypeOptions:[{
  25. dictLabel:'全部',
  26. dictValue:''
  27. }],
  28. unusedTypeOptions:[{
  29. dictLabel:'全部',
  30. dictValue:''
  31. }],
  32. resourceType:1,//资源分类 字典 1:农用地 2:建设用地 3:未利用地、林木
  33. resourceSort:'',//资源类型
  34. searchName:'',//搜索资源名称
  35. },
  36. /**
  37. * 生命周期函数--监听页面加载
  38. */
  39. onLoad(options) {
  40. var that = this;
  41. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'resource_farming_type', {method:'GET'}, {
  42. success: (res) => {
  43. let options = that.data.farmingTypeOptions;
  44. res.data.map(rr=>{
  45. options.push(rr)
  46. })
  47. that.setData({
  48. farmingTypeOptions:options,
  49. })
  50. }
  51. })
  52. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'resources_build_type', {method:'GET'}, {
  53. success: (res) => {
  54. let options = that.data.buildTypeOptions;
  55. res.data.map(rr=>{
  56. options.push(rr)
  57. })
  58. that.setData({
  59. buildTypeOptions:options,
  60. })
  61. }
  62. })
  63. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'resources_unused_type', {method:'GET'}, {
  64. success: (res) => {
  65. let options = that.data.unusedTypeOptions;
  66. res.data.map(rr=>{
  67. options.push(rr)
  68. })
  69. that.setData({
  70. unusedTypeOptions:options,
  71. })
  72. }
  73. })
  74. setTimeout(function(){
  75. that.SRSelect();
  76. },1000)
  77. },
  78. SRSelect(){
  79. var that = this;
  80. //收入事项
  81. let data = {
  82. pageNum:'1',
  83. pageSize:'999',
  84. resourceType:that.data.resourceType,
  85. resourceSort:that.data.resourceSort,
  86. name:that.data.searchName,
  87. }
  88. UTIL.httpRequest(API.URL_GET_GETRESOURCELIST,data ,{
  89. success: (res) => {
  90. if (res.code == API.SUCCESS_CODE) {
  91. let list = res.rows;
  92. for (let i = 0; i < list.length; i++) {
  93. const element = list[i];
  94. list[i].resourceSortText = UTIL.getTransform(element.resourceSort,that.data.resourceType == 1 ? that.data.farmingTypeOptions : that.data.resourceType == 2 ? that.data.buildTypeOptions : that.data.resourceType == 3 ? that.data.unusedTypeOptions : '');
  95. // list[i].jieAmount = Number(element.jieAmount).toFixed(2).replace(/(\d)(?=(\d{3})+\.)/g, ($0, $1) => {
  96. // return $1 + ","; }).replace(/\.$/, "");
  97. }
  98. this.setData({
  99. listNy:list,
  100. });
  101. }
  102. }
  103. })
  104. },
  105. onChange(event) {
  106. this.setData({result:event.detail})
  107. },
  108. onChange2(event) {
  109. this.setData({result2:event.detail})
  110. },
  111. switchTab(e){
  112. var that = this;
  113. this.setData({
  114. showGroup:e.currentTarget.dataset.gid,
  115. resourceType:e.currentTarget.dataset.gid,
  116. resourceSort:'',
  117. checkedStatusText:'全部',
  118. searchName:''
  119. })
  120. that.SRSelect();
  121. },
  122. back:function(){
  123. wx.navigateBack({
  124. delta: 1
  125. })
  126. },
  127. goSearch(e){
  128. console.log(e);
  129. var that = this;
  130. that.setData({
  131. searchName:e.detail
  132. })
  133. that.SRSelect();
  134. },
  135. /**
  136. * 生命周期函数--监听页面初次渲染完成
  137. */
  138. onReady() {
  139. },
  140. /**
  141. * 生命周期函数--监听页面显示
  142. */
  143. onShow() {
  144. var that = this ;
  145. },
  146. openPopup(even){
  147. this.setData({
  148. showProjectFundType:true
  149. })
  150. },
  151. onConfirmPick(event){
  152. var that = this;
  153. this.setData({
  154. [event.currentTarget.dataset.name]: false,
  155. checkedStatus: event.detail.value.dictValue,
  156. checkedStatusText: event.detail.value.dictLabel,
  157. resourceSort: event.detail.value.dictValue,
  158. });
  159. that.SRSelect()
  160. },
  161. closeBox(even){
  162. console.log(even.currentTarget.dataset.name);
  163. this.setData({
  164. [even.currentTarget.dataset.name]:false
  165. })
  166. },
  167. goSubmit(){
  168. var that = this ;
  169. console.log(that.data.showGroup);
  170. if(that.data.showGroup){
  171. if(that.data.result.length==0){
  172. UTIL.showToastNoneIcon('至少选择一个收入事项!');
  173. return;
  174. }
  175. let url = wx.getStorageSync('dressCode')+ API.URL_GET_GETBOOKKEEP
  176. wx.request({
  177. url,
  178. method:"POST",
  179. timeout: 60000,
  180. data:that.data.result,
  181. header: {
  182. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  183. },
  184. success: function (response) {
  185. wx.showToast({
  186. title: "提交成功!",
  187. duration: 2000,
  188. icon:"success"
  189. })
  190. that.setData({
  191. result:[]
  192. })
  193. that.SRSelect();
  194. }
  195. })
  196. }else{
  197. if(that.data.result2.length==0){
  198. UTIL.showToastNoneIcon('至少选择一个支出事项!');
  199. return;
  200. }
  201. let url =wx.getStorageSync('dressCode')+ API.URL_GET_GETBOOKKEEP
  202. wx.request({
  203. url,
  204. method:"POST",
  205. timeout: 60000,
  206. data:that.data.result2,
  207. header: {
  208. 'Authorization':'Bearer '+getApp().globalData.userInfo.token
  209. },
  210. success: function (response) {
  211. wx.showToast({
  212. title: "提交成功!",
  213. duration: 2000,
  214. icon:"success"
  215. })
  216. that.setData({
  217. result2:[]
  218. })
  219. }
  220. })
  221. }
  222. },
  223. goSee(event){
  224. wx.navigateTo({
  225. url: 'detail/detail?id='+event.currentTarget.dataset.id+'&typeid='+this.data.showGroup,
  226. })
  227. },
  228. goSeeZC(event){
  229. wx.navigateTo({
  230. url: '/pages/Bookkeeping/seeBookZC/seeBookZC?id='+event.currentTarget.dataset.id,
  231. })
  232. },
  233. goUpdate(event){
  234. wx.navigateTo({
  235. url: 'edit/edit?id='+event.currentTarget.dataset.id+'&typeid='+this.data.showGroup+'&listindex='+event.currentTarget.dataset.index,
  236. })
  237. },
  238. goUpdateZC(event){
  239. wx.navigateTo({
  240. url: '/pages/Bookkeeping/updateZC/update?id='+event.currentTarget.dataset.id,
  241. })
  242. },
  243. delete(e){
  244. console.log(e);
  245. var that = this;
  246. UTIL.httpRequest(API.URL_GET_FLOWREMOVE + e.currentTarget.dataset.id, {method:'GET'},{
  247. success: (res) => {
  248. if (res.code == API.SUCCESS_CODE) {
  249. that.data.flowListSR.splice(e.currentTarget.dataset.index, 1);
  250. wx.showToast({
  251. title: '删除成功!',
  252. icon: 'success',
  253. duration: 2000
  254. })
  255. that.setData({
  256. flowListSR : that.data.flowListSR,
  257. flowListSRNum:that.data.flowListSRNum-1
  258. })
  259. }
  260. }
  261. })
  262. },
  263. delete2(e){
  264. console.log(e);
  265. var that = this;
  266. UTIL.httpRequest(API.URL_GET_FLOWREMOVE + e.currentTarget.dataset.id, {method:'GET'},{
  267. success: (res) => {
  268. if (res.code == API.SUCCESS_CODE) {
  269. that.data.flowListZC.splice(e.currentTarget.dataset.index, 1);
  270. wx.showToast({
  271. title: '删除成功!',
  272. icon: 'success',
  273. duration: 2000
  274. })
  275. that.setData({
  276. flowListZC : that.data.flowListZC,
  277. flowListZCNum:that.data.flowListZCNum-1
  278. })
  279. }
  280. }
  281. })
  282. },
  283. /**
  284. * 生命周期函数--监听页面隐藏
  285. */
  286. onHide() {
  287. },
  288. /**
  289. * 生命周期函数--监听页面卸载
  290. */
  291. onUnload() {
  292. },
  293. /**
  294. * 页面相关事件处理函数--监听用户下拉动作
  295. */
  296. onPullDownRefresh() {
  297. },
  298. /**
  299. * 页面上拉触底事件的处理函数
  300. */
  301. onReachBottom() {
  302. },
  303. /**
  304. * 用户点击右上角分享
  305. */
  306. onShareAppMessage() {
  307. }
  308. })