index.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. Component({
  2. properties: {
  3. list: Array,
  4. deleteItem: Function,
  5. changeProduct: Function, //修改队列
  6. disabled: Boolean
  7. },
  8. options: {
  9. addGlobalClass: true
  10. },
  11. methods: {
  12. toProductDetail(e) {
  13. const {
  14. item
  15. } = e.currentTarget.dataset;
  16. console.log(item)
  17. },
  18. onBlur(e) {
  19. let {
  20. data
  21. } = e.currentTarget.dataset;
  22. let i = this.data.list.findIndex(v => v.sa_orderitemsid == data.sa_orderitemsid)
  23. if (e.detail.value > data.uninvoiceamount) {
  24. e.detail.value = data.uninvoiceamount;
  25. wx.showToast({
  26. title: `最大开票金额${data.uninvoiceamount}元`,
  27. icon: "none"
  28. });
  29. if (i != -1) this.setData({
  30. [`list[${i}].invoiceamount`]: data.uninvoiceamount,
  31. [`list[${i}].invoiceaqty`]: data.uninvoiceamount / data.price,
  32. })
  33. } else if (e.detail.value == 0) {
  34. wx.showToast({
  35. title: `开票金额不可为0`,
  36. icon: "none"
  37. });
  38. if (i != -1) return this.setData({
  39. [`list[${i}].invoiceamount`]: this.data.list[i].invoiceamount,
  40. [`list[${i}].invoiceaqty`]: this.data.list[i].invoiceaqty,
  41. })
  42. }
  43. if (e.detail.value != data.invoiceamount) this.triggerEvent("changeProduct", {
  44. "sa_invoiceapply_orderid": data.sa_invoiceapply_orderid,
  45. "saorderid": data.sa_orderid,
  46. "sa_orderitemsid": data.sa_orderitemsid,
  47. "price": data.price,
  48. "invoiceamount": e.detail.value - 0,
  49. "invoiceaqty": (e.detail.value - 0) / data.price
  50. })
  51. },
  52. deleteProduct(e) {
  53. let {
  54. item
  55. } = e.currentTarget.dataset;
  56. this.triggerEvent("deleteItem", item)
  57. },
  58. isEdit() {
  59. if (this.data.disabled) wx.showToast({
  60. title: '当前状态不可编辑!',
  61. icon: "none"
  62. })
  63. }
  64. }
  65. })