index.js 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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. value = e.detail.value;
  24. if (value == 0) {
  25. wx.showToast({
  26. title: 'title',
  27. icon: "none",
  28. mask: true
  29. })
  30. this.setData({
  31. list: this.data.list
  32. })
  33. return;
  34. }
  35. let maxqty = data.uninvoiceamount / data.price;
  36. if (value > maxqty) value = maxqty;
  37. if (e.detail.value != data.invoiceamount) this.triggerEvent("changeProduct", {
  38. "sa_invoiceapply_orderid": data.sa_invoiceapply_orderid,
  39. "saorderid": data.sa_orderid,
  40. "sa_orderitemsid": data.sa_orderitemsid,
  41. "price": data.price,
  42. "invoiceamount": value * data.price,
  43. "invoiceaqty": value
  44. })
  45. if (value > maxqty) setTimeout(() => {
  46. wx.showToast({
  47. title: `超过最大可开票数量`,
  48. icon: "none",
  49. mask: true
  50. })
  51. }, 500)
  52. },
  53. deleteProduct(e) {
  54. let {
  55. item
  56. } = e.currentTarget.dataset;
  57. this.triggerEvent("deleteItem", item)
  58. },
  59. isEdit() {
  60. if (this.data.disabled) wx.showToast({
  61. title: '当前状态不可编辑!',
  62. icon: "none"
  63. })
  64. }
  65. }
  66. })