detail.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. const _Http = getApp().globalData.http,
  2. currency = require("../../utils/currency"),
  3. CNY = sum => currency(sum, {
  4. symbol: "¥",
  5. precision: 2
  6. }).format();
  7. Page({
  8. data: {
  9. sa_tpartreimbursementid: null,
  10. detail: {},
  11. tabsActive: 0,
  12. tabsList: [{
  13. label: "产品明细",
  14. icon: "icon-tabchanpin",
  15. model: "#Product"
  16. }, {
  17. label: "操作记录",
  18. icon: "icon-tabcaozuojilu1",
  19. model: "#record"
  20. }],
  21. productTotal: 0
  22. },
  23. onLoad(options) {
  24. this.setData({
  25. sa_tpartreimbursementid: options.id
  26. })
  27. this.getDetail()
  28. },
  29. getDetail() {
  30. _Http.basic({
  31. "id": 2025081811144603,
  32. "content": {
  33. "sa_tpartreimbursementid": this.data.sa_tpartreimbursementid
  34. }
  35. }).then(res => {
  36. console.log("配件核销详情", res)
  37. if (res.msg != '成功') return wx.showToast({
  38. title: res.msg,
  39. icon: "none"
  40. })
  41. res.data.totalamount = CNY(res.data.totalamount)
  42. res.data.offamount = CNY(res.data.offamount)
  43. this.setData({
  44. detail: res.data,
  45. remarks: res.data.remarks
  46. })
  47. this.partialRenewal()
  48. })
  49. }, //局部数据更新 tabs
  50. partialRenewal(init = false) {
  51. let model = this.data.tabsList[this.data.tabsActive].model;
  52. if (model) {
  53. let Component = this.selectComponent(model),
  54. {
  55. total,
  56. pageNumber,
  57. pageTotal
  58. } = Component.data.content,
  59. id = this.data.sa_tpartreimbursementid;
  60. if (total == null || init) {
  61. Component.getList(id, init);
  62. } else if (pageNumber <= pageTotal) {
  63. Component.getList(id, false);
  64. }
  65. }
  66. }, //tabs 切换
  67. tabsChange({
  68. detail
  69. }) {
  70. this.setData({
  71. tabsActive: detail
  72. });
  73. this.partialRenewal();
  74. },
  75. onReachBottom() {
  76. this.partialRenewal();
  77. },
  78. // 修改单据日期
  79. onEdit(e) {
  80. _Http.basic({
  81. "id": 2025081811143103,
  82. "content": {
  83. "sa_tpartreimbursementid": this.data.detail.sa_tpartreimbursementid,
  84. "remarks": this.data.detail.remarks,
  85. "billdate": e.detail.value,
  86. "id": this.data.detail.sa_tpartreimbursementid
  87. },
  88. }).then(res => {
  89. console.log("修改单据日期", res)
  90. wx.showToast({
  91. title: res.code == 1 ? '修改成功' : res.msg,
  92. icon: "none"
  93. })
  94. if (res.code == 1) this.getDetail()
  95. })
  96. },
  97. onSubmit() {
  98. let that = this;
  99. wx.showModal({
  100. title: '提示',
  101. content: '确定要提交此配件核销申请吗?提交后将无法修改。',
  102. confirmText: "确认提交",
  103. complete: ({
  104. confirm
  105. }) => {
  106. if (confirm) _Http.basic({
  107. "id": 2025081811223203,
  108. "content": {
  109. "sa_tpartreimbursementid": that.data.detail.sa_tpartreimbursementid,
  110. "issubmit": true
  111. }
  112. }).then(res => {
  113. console.log("提交", res)
  114. wx.showToast({
  115. title: res.code == 1 ? '提交成功' : res.msg,
  116. icon: "none"
  117. })
  118. if (res.code == 1) this.getDetail()
  119. })
  120. }
  121. })
  122. },
  123. onDetele() {
  124. let that = this;
  125. wx.showModal({
  126. title: '提示',
  127. content: '确定要删除此配件核销申请吗?删除后将无法恢复',
  128. confirmText: "确认删除",
  129. complete: ({
  130. confirm
  131. }) => {
  132. if (confirm) _Http.basic({
  133. "id": 2025081811150603,
  134. "content": {
  135. "sa_tpartreimbursementids": [that.data.detail.sa_tpartreimbursementid]
  136. }
  137. }).then(res => {
  138. console.log("删除", res)
  139. wx.showToast({
  140. title: res.code == 1 ? '删除成功' : res.msg,
  141. icon: "none",
  142. mask: res.code == 1
  143. })
  144. if (res.code == 1) setTimeout(() => {
  145. wx.navigateBack()
  146. }, 300)
  147. })
  148. }
  149. })
  150. },
  151. onUnload() {
  152. let page = getCurrentPages().find(v => ["packageA/writeOff/index"].includes(v.__route__))
  153. if (page) page.updateList && page.updateList()
  154. },
  155. onBlur(e) {
  156. let remarks = e.detail.value,
  157. that = this;
  158. wx.showModal({
  159. title: '提示',
  160. content: `是否确定修改备注?`,
  161. complete: (res) => {
  162. if (res.cancel) {
  163. that.setData({
  164. remarks: that.data.detail.remarks
  165. })
  166. }
  167. if (res.confirm) _Http.basic({
  168. "id": 2025081811143103,
  169. "content": {
  170. "sa_tpartreimbursementid": that.data.detail.sa_tpartreimbursementid,
  171. "remarks": remarks,
  172. "billdate": that.data.detail.billdate,
  173. },
  174. }).then(res => {
  175. console.log("修改单据日期", res)
  176. wx.showToast({
  177. title: res.code == 1 ? '修改成功' : res.msg,
  178. icon: "none"
  179. })
  180. if (res.code == 1) that.getDetail()
  181. })
  182. }
  183. })
  184. console.log(remarks)
  185. }
  186. })