details.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  6. data: {
  7. detailsData: {}, //详情数据
  8. butText: "", //底部按钮文本
  9. content: "", //提交内容
  10. loading: false, //按钮加载状态
  11. recordL: {}, //记录
  12. isCommit: false, //是否提交
  13. },
  14. /**
  15. * 生命周期函数--监听页面加载
  16. */
  17. onLoad(options) {
  18. let detailsData = JSON.parse(options.item);
  19. this.setData({
  20. detailsData,
  21. butText: options.type
  22. })
  23. /* 详情计数 */
  24. if (options.type == '开始提报') {
  25. this.select_submitdetailed();
  26. } else if (options.type == '保存') {
  27. _Http.basic({
  28. "classname": "saletool.submitedit.submitedit",
  29. "method": "insertorupdate",
  30. "content": {
  31. "sat_submiteditmodelid": detailsData.sat_submiteditmodelid,
  32. "content": "",
  33. "sat_submiteditid": "0"
  34. }
  35. }).then(res => {
  36. console.log("新增", res)
  37. })
  38. } else if (options.type == 'false') {
  39. /* 查看记录 */
  40. this.setData({
  41. recordL: JSON.parse(options.record)
  42. })
  43. }
  44. console.log("是否一事一报", detailsData.oneToOne)
  45. },
  46. /* 查询详情 */
  47. select_submitdetailed() {
  48. _Http.basic({
  49. "classname": "saletool.submitedit.submitedit",
  50. "method": "select_submitdetailed",
  51. "content": {
  52. "sat_submiteditmodelid": this.data.detailsData.sat_submiteditmodelid
  53. }
  54. }).then(res => {
  55. console.log("提报详情", res)
  56. this.setData({
  57. 'detailsData.submitedit': res.data[0].submitedit
  58. })
  59. });
  60. },
  61. /* 文本域输入 */
  62. textareaInput(e) {
  63. this.setData({
  64. content: e.detail.value.trim()
  65. })
  66. },
  67. /* 去详情 */
  68. toDetails() {
  69. if (this.data.butText == '开始提报') {
  70. wx.navigateTo({
  71. url: './details?type=保存&item=' + JSON.stringify(this.data.detailsData),
  72. })
  73. } else {
  74. if (this.data.isCommit) return wx.showToast({
  75. title: '请勿重新提交',
  76. icon: "none"
  77. })
  78. if (!this.data.content) return wx.showToast({
  79. title: '您还未输入提报内容',
  80. icon: "none"
  81. })
  82. if (this.data.loading) return wx.showToast({
  83. title: '正在提交中,请勿重新提交',
  84. icon: "none"
  85. })
  86. this.setData({
  87. loading: true
  88. })
  89. _Http.basic({
  90. "classname": "saletool.submitedit.submitedit",
  91. "method": "sub_submitdetailed",
  92. "content": {
  93. "sat_submiteditmodelid": this.data.detailsData.sat_submiteditmodelid,
  94. "content": this.data.content,
  95. "sat_submiteditid": 0
  96. }
  97. }).then(res => {
  98. this.setData({
  99. loading: false
  100. })
  101. if (res.msg != '成功') return wx.showToast({
  102. title: res.data,
  103. icon: "none"
  104. });
  105. this.setData({
  106. isCommit: true
  107. })
  108. let pages = getCurrentPages();
  109. let prevPage = pages[pages.length - 2];
  110. if (prevPage.data.butText == '开始提报') prevPage.select_submitdetailed();
  111. wx.showToast({
  112. title: '提交成功',
  113. icon: "success"
  114. });
  115. setTimeout(() => {
  116. wx.navigateBack({
  117. delta: 0,
  118. })
  119. }, 300)
  120. })
  121. }
  122. },
  123. /* 查看提报记录 */
  124. seeHistory(e) {
  125. const {
  126. item
  127. } = e.currentTarget.dataset;
  128. wx.navigateTo({
  129. url: `./details?type=false&item=${JSON.stringify(this.data.detailsData)}&record=${JSON.stringify(item)}`,
  130. })
  131. },
  132. /**
  133. * 生命周期函数--监听页面初次渲染完成
  134. */
  135. onReady() {
  136. },
  137. /**
  138. * 生命周期函数--监听页面显示
  139. */
  140. onShow() {
  141. },
  142. /**
  143. * 生命周期函数--监听页面隐藏
  144. */
  145. onHide() {
  146. },
  147. /**
  148. * 生命周期函数--监听页面卸载
  149. */
  150. onUnload() {
  151. },
  152. /**
  153. * 页面相关事件处理函数--监听用户下拉动作
  154. */
  155. onPullDownRefresh() {
  156. },
  157. /**
  158. * 页面上拉触底事件的处理函数
  159. */
  160. onReachBottom() {
  161. },
  162. /**
  163. * 用户点击右上角分享
  164. */
  165. onShareAppMessage() {
  166. }
  167. })