index.js 5.2 KB

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