index.js 6.5 KB

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