index.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. const _Http = getApp().globalData.http,
  2. file = require("../../../../utils/FormatTheAttachment");
  3. Component({
  4. data: {
  5. sa_invoiceapplyid: 0,
  6. "content": {
  7. nocache: true,
  8. "pageNumber": 1,
  9. pageTotal: 1,
  10. total: null
  11. }
  12. },
  13. methods: {
  14. /* 获取产品列表 */
  15. getList(id, init) {
  16. let content = this.data.content;
  17. content.sa_invoiceapplyid = id;
  18. if (init) content.pageNumber = 1;
  19. _Http.basic({
  20. "id": "20221217091303",
  21. "version": 1,
  22. content
  23. }).then(res => {
  24. console.log("订单行列表", res)
  25. if (res.msg != '成功') return wx.showToast({
  26. title: res.msg,
  27. icon: "none"
  28. })
  29. res.data = res.data.map(value => {
  30. if (value.attinfos.length != 0) {
  31. value.attinfos = file.fileList(value.attinfos)
  32. let image = value.attinfos.find(v => v.fileType == "image");
  33. value.cover = image ? image.cover : "";
  34. }
  35. return value;
  36. })
  37. this.setData({
  38. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  39. "content.pageNumber": res.pageNumber + 1,
  40. "content.pageSize": res.pageSize,
  41. "content.pageTotal": res.pageTotal,
  42. "content.total": res.total,
  43. sa_invoiceapplyid: id
  44. })
  45. })
  46. },
  47. /* 去添加订单行 */
  48. addProduct() {
  49. let detail = getCurrentPages().find(v => v.__route__ == 'packageA/invoice/detail').data.detail;
  50. wx.navigateTo({
  51. url: `/select/orderFormLine/index?params=${JSON.stringify({
  52. "id": "20221217085103",
  53. "version":1,
  54. "content": {
  55. nocache:true,
  56. "sys_enterpriseid":detail.sys_enterpriseid,
  57. "sa_invoiceapplyid":detail.sa_invoiceapplyid,
  58. "where":{
  59. "condition":"",
  60. "sonum":"",
  61. "begindate":"",
  62. "enddate":""
  63. }
  64. }
  65. })}`
  66. });
  67. getApp().globalData.handleSelect = this.handleSelect.bind(this);
  68. },
  69. /* 处理新增订单行 */
  70. handleSelect(detail) {
  71. let that = this;
  72. wx.showModal({
  73. title: '提示',
  74. content: `是否确认添加${detail.result.length}条订单行?`,
  75. complete: (res) => {
  76. if (res.confirm) _Http.basic({
  77. "id": "20221217091203",
  78. "version": 1,
  79. "content": {
  80. "sa_invoiceapplyid": that.data.sa_invoiceapplyid,
  81. "iteminfos": detail.list.map(v => {
  82. return {
  83. "sa_invoiceapply_orderid": 0,
  84. "saorderid": v.sa_orderid,
  85. "sa_orderitemsid": v.sa_orderitemsid,
  86. "price": v.price
  87. }
  88. })
  89. }
  90. }).then(s => {
  91. console.log('新增订单行', s)
  92. wx.showToast({
  93. title: s.msg == '成功' ? '添加成功' : s.msg,
  94. icon: "none"
  95. });
  96. if (s.msg == '成功') setTimeout(() => {
  97. that.getList(that.data.sa_invoiceapplyid, true);
  98. wx.navigateBack();
  99. // that.updateThePrice();
  100. }, 300)
  101. })
  102. }
  103. });
  104. },
  105. /* 修改开票金额数量 */
  106. changeProduct({
  107. detail
  108. }) {
  109. let invoiceaqty = detail.invoiceaqty;
  110. detail.invoiceaqty = 0;
  111. _Http.basic({
  112. "id": "20221217091203",
  113. "version": 1,
  114. "content": {
  115. "sa_invoiceapplyid": this.data.sa_invoiceapplyid,
  116. "iteminfos": [detail]
  117. }
  118. }).then(res => {
  119. console.log("修改订单行", res)
  120. let i = this.data.list.findIndex(v => v.sa_orderitemsid == detail.sa_orderitemsid)
  121. if (res.msg != '成功') {
  122. wx.showToast({
  123. title: res.msg,
  124. icon: "none"
  125. });
  126. if (i != -1) this.setData({
  127. [`list[${i}].invoiceamount`]: this.data.list[i].invoiceamount,
  128. [`list[${i}].invoiceaqty`]: this.data.list[i].invoiceaqty
  129. })
  130. } else {
  131. if (i != -1) this.setData({
  132. [`list[${i}].invoiceamount`]: detail.invoiceamount,
  133. [`list[${i}].invoiceaqty`]: (invoiceaqty - 0).toFixed(2)
  134. })
  135. }
  136. })
  137. },
  138. /* 删除订单行 */
  139. deleteItem({
  140. detail
  141. }) {
  142. console.log(detail)
  143. let that = this;
  144. wx.showModal({
  145. title: '提示',
  146. content: `是否确认删除“${detail.itemname}”`,
  147. complete: ({
  148. confirm
  149. }) => {
  150. if (confirm) _Http.basic({
  151. "id": "20221217091403",
  152. "version": 1,
  153. "content": {
  154. "sa_invoiceapply_orderids": [detail.sa_invoiceapply_orderid]
  155. }
  156. }).then(res => {
  157. console.log('删除订单行', res)
  158. wx.showToast({
  159. title: res.msg == '成功' ? '删除成功' : res.msg,
  160. icon: "none"
  161. });
  162. if (res.msg == '成功') that.setData({
  163. list: that.data.list.filter(v => v.sa_orderitemsid != detail.sa_orderitemsid)
  164. })
  165. })
  166. }
  167. })
  168. },
  169. }
  170. })