微信小程序
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

198 行
4.9 KiB

  1. // pages/handle/expenditureAudit/expenditureAudit.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. form:[]
  12. },
  13. /**
  14. * 生命周期函数--监听页面加载
  15. */
  16. onLoad: function (options) {
  17. var that = this;
  18. that.setData({
  19. id:options.id,
  20. typeid:options.typeid,
  21. listindex:options.listindex
  22. })
  23. wx.showLoading({
  24. title: '正在加载模板',
  25. mask:true
  26. })
  27. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'resource_farming_type', {method:'GET'}, {
  28. success: (res) => {
  29. that.setData({
  30. farmingTypeOptions:res.data,
  31. })
  32. }
  33. })
  34. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'resources_build_type', {method:'GET'}, {
  35. success: (res) => {
  36. that.setData({
  37. buildTypeOptions:res.data,
  38. })
  39. }
  40. })
  41. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'resources_unused_type', {method:'GET'}, {
  42. success: (res) => {
  43. that.setData({
  44. unusedTypeOptions:res.data,
  45. })
  46. }
  47. })
  48. /**使用情况 字典 1:自用 2:闲置 3:出租或外借 4:其他*/
  49. UTIL.httpRequest(API.URL_GET_GETDICTTYPE + 'use_type', {method:'GET'}, {
  50. success: (res) => {
  51. that.setData({
  52. useTypeOptions:res.data,
  53. })
  54. }
  55. })
  56. setTimeout(function(){
  57. //详情
  58. UTIL.httpRequest(API.URL_GET_GETRESOURCEGET + options.id, {method:'GET'}, {
  59. success: (res) => {
  60. res.data.resourceSortText = UTIL.getTransform(res.data.resourceSort,that.data.typeid == 1 ? that.data.farmingTypeOptions : that.data.typeid == 2 ? that.data.buildTypeOptions : that.data.typeid == 3 ? that.data.unusedTypeOptions : '');
  61. res.data.useTypeText = UTIL.getTransform(res.data.useType,that.data.useTypeOptions);
  62. that.setData({
  63. form:res.data
  64. })
  65. }
  66. })
  67. },1000)
  68. wx.hideLoading()
  69. },
  70. onChangeInput(e){
  71. var that = this;
  72. that.setData({
  73. ['form.'+e.currentTarget.dataset.formname]:e.detail
  74. })
  75. },
  76. goSubmit(){
  77. console.log(this.data.form);
  78. var that = this;
  79. let data = that.data.form;
  80. if (data.name == '') {
  81. UTIL.showToastNoneIcon('请填写资源名称!');return;
  82. }else if(data.resourceSortText == '' || data.resourceSort == null){
  83. UTIL.showToastNoneIcon('请选择资源类型!');return;
  84. }
  85. data.method = 'POST'
  86. UTIL.httpRequest(API.URL_GET_GETRESOURCEEDIT, data, {
  87. success: (res) => {
  88. if (res.code == API.SUCCESS_CODE) {
  89. let pages = getCurrentPages();
  90. let currentPage = null; //当前页面
  91. let prevPage = null; //上一个页面
  92. currentPage = pages[pages.length - 1]; //获取当前页面,将其赋值
  93. prevPage = pages[pages.length - 2]; //获取上一个页面,将其赋值
  94. if (prevPage) {
  95. prevPage.setData({
  96. ["listNy["+that.data.listindex+"]"]: that.data.form,//将想要传的信息赋值给上一个页面data中的值
  97. })
  98. }
  99. wx.showToast({
  100. title: '保存成功',
  101. icon: 'success',
  102. duration: 2000,
  103. complete(){
  104. setTimeout(function(){
  105. that.back();
  106. },2000)
  107. }
  108. })
  109. }
  110. }
  111. })
  112. },
  113. closeBox(even){
  114. console.log(even.currentTarget.dataset.name);
  115. this.setData({
  116. [even.currentTarget.dataset.name]:false
  117. })
  118. },
  119. onConfirma(even){
  120. console.log(even.currentTarget.dataset.name);
  121. this.setData({
  122. [even.currentTarget.dataset.name]:false,
  123. [even.currentTarget.dataset.value]: even.detail.value.dictValue,
  124. [even.currentTarget.dataset.value+'Text']: even.detail.value.dictLabel,
  125. })
  126. },
  127. openBox(even){
  128. console.log(even.currentTarget.dataset.name);
  129. this.setData({
  130. [even.currentTarget.dataset.name]:true,
  131. })
  132. },
  133. bindDateChange: function(e) {
  134. console.log('picker发送选择改变,携带值为', e.detail.value)
  135. this.setData({
  136. [e.currentTarget.dataset.value]: e.detail.value
  137. })
  138. },
  139. /**
  140. * 生命周期函数--监听页面初次渲染完成
  141. */
  142. onReady: function () {
  143. },
  144. /**
  145. * 生命周期函数--监听页面显示
  146. */
  147. onShow: function () {
  148. },
  149. back:function(){
  150. wx.navigateBack({
  151. delta: 1
  152. })
  153. },
  154. /**
  155. * 生命周期函数--监听页面隐藏
  156. */
  157. onHide: function () {
  158. },
  159. /**
  160. * 生命周期函数--监听页面卸载
  161. */
  162. onUnload: function () {
  163. },
  164. /**
  165. * 页面相关事件处理函数--监听用户下拉动作
  166. */
  167. onPullDownRefresh: function () {
  168. },
  169. /**
  170. * 页面上拉触底事件的处理函数
  171. */
  172. onReachBottom: function () {
  173. },
  174. /**
  175. * 用户点击右上角分享
  176. */
  177. onShareAppMessage: function () {
  178. }
  179. })