details.js 4.4 KB

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