index.js 2.1 KB

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