detail.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  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. try {
  29. let privacyFieldC = wx.getStorageSync('auth').writeOff.forms.list.formcols.map(v => v.title);
  30. this.setData({
  31. privacyFieldC
  32. })
  33. console.log("privacyFieldC", privacyFieldC)
  34. } catch (error) {
  35. console.error(error)
  36. }
  37. },
  38. getDetail() {
  39. _Http.basic({
  40. "id": 2025081811144603,
  41. "content": {
  42. "sa_tpartreimbursementid": this.data.sa_tpartreimbursementid
  43. }
  44. }).then(res => {
  45. console.log("配件核销详情", res)
  46. if (res.msg != '成功') return wx.showToast({
  47. title: res.msg,
  48. icon: "none"
  49. })
  50. res.data.totalamount = CNY(res.data.totalamount)
  51. res.data.offamount = CNY(res.data.offamount)
  52. this.setData({
  53. detail: res.data,
  54. remarks: res.data.remarks
  55. })
  56. this.partialRenewal()
  57. })
  58. }, //局部数据更新 tabs
  59. partialRenewal(init = false) {
  60. let model = this.data.tabsList[this.data.tabsActive].model;
  61. if (model) {
  62. let Component = this.selectComponent(model),
  63. {
  64. total,
  65. pageNumber,
  66. pageTotal
  67. } = Component.data.content,
  68. id = this.data.sa_tpartreimbursementid;
  69. if (total == null || init) {
  70. Component.getList(id, init);
  71. } else if (pageNumber <= pageTotal) {
  72. Component.getList(id, false);
  73. }
  74. }
  75. }, //tabs 切换
  76. tabsChange({
  77. detail
  78. }) {
  79. this.setData({
  80. tabsActive: detail
  81. });
  82. this.partialRenewal();
  83. },
  84. onReachBottom() {
  85. this.partialRenewal();
  86. },
  87. // 修改单据日期
  88. onEdit(e) {
  89. _Http.basic({
  90. "id": 2025081811143103,
  91. "content": {
  92. "sa_tpartreimbursementid": this.data.detail.sa_tpartreimbursementid,
  93. "remarks": this.data.detail.remarks,
  94. "billdate": e.detail.value,
  95. "id": this.data.detail.sa_tpartreimbursementid
  96. },
  97. }).then(res => {
  98. console.log("修改单据日期", res)
  99. wx.showToast({
  100. title: res.code == 1 ? '修改成功' : res.msg,
  101. icon: "none"
  102. })
  103. if (res.code == 1) this.getDetail()
  104. })
  105. },
  106. onSubmit() {
  107. let that = this;
  108. wx.showModal({
  109. title: '提示',
  110. content: '确定要提交此配件核销申请吗?提交后将无法修改。',
  111. confirmText: "确认提交",
  112. complete: ({
  113. confirm
  114. }) => {
  115. if (confirm) _Http.basic({
  116. "id": 2025081811223203,
  117. "content": {
  118. "sa_tpartreimbursementid": that.data.detail.sa_tpartreimbursementid,
  119. "issubmit": true
  120. }
  121. }).then(res => {
  122. console.log("提交", res)
  123. wx.showToast({
  124. title: res.code == 1 ? '提交成功' : res.msg,
  125. icon: "none"
  126. })
  127. if (res.code == 1) this.getDetail()
  128. })
  129. }
  130. })
  131. },
  132. onDetele() {
  133. let that = this;
  134. wx.showModal({
  135. title: '提示',
  136. content: '确定要删除此配件核销申请吗?删除后将无法恢复',
  137. confirmText: "确认删除",
  138. complete: ({
  139. confirm
  140. }) => {
  141. if (confirm) _Http.basic({
  142. "id": 2025081811150603,
  143. "content": {
  144. "sa_tpartreimbursementids": [that.data.detail.sa_tpartreimbursementid]
  145. }
  146. }).then(res => {
  147. console.log("删除", res)
  148. wx.showToast({
  149. title: res.code == 1 ? '删除成功' : res.msg,
  150. icon: "none",
  151. mask: res.code == 1
  152. })
  153. if (res.code == 1) setTimeout(() => {
  154. wx.navigateBack()
  155. }, 300)
  156. })
  157. }
  158. })
  159. },
  160. onUnload() {
  161. let page = getCurrentPages().find(v => ["packageA/writeOff/index"].includes(v.__route__))
  162. if (page) page.updateList && page.updateList()
  163. },
  164. onBlur(e) {
  165. let remarks = e.detail.value,
  166. that = this;
  167. wx.showModal({
  168. title: '提示',
  169. content: `是否确定修改备注?`,
  170. complete: (res) => {
  171. if (res.cancel) {
  172. that.setData({
  173. remarks: that.data.detail.remarks
  174. })
  175. }
  176. if (res.confirm) _Http.basic({
  177. "id": 2025081811143103,
  178. "content": {
  179. "sa_tpartreimbursementid": that.data.detail.sa_tpartreimbursementid,
  180. "remarks": remarks,
  181. "billdate": that.data.detail.billdate,
  182. },
  183. }).then(res => {
  184. console.log("修改单据日期", res)
  185. wx.showToast({
  186. title: res.code == 1 ? '修改成功' : res.msg,
  187. icon: "none"
  188. })
  189. if (res.code == 1) that.getDetail()
  190. })
  191. }
  192. })
  193. console.log(remarks)
  194. }
  195. })