index.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. lifetimes: {
  17. attached: function () {
  18. getApp().globalData.Language.getLanguagePackage(this)
  19. }
  20. },
  21. options: {
  22. addGlobalClass: true
  23. },
  24. methods: {
  25. toProductDetail(e) {
  26. const {
  27. item
  28. } = e.currentTarget.dataset;
  29. },
  30. onBlur(e) {
  31. let {
  32. data
  33. } = e.currentTarget.dataset;
  34. let i = this.data.list.findIndex(v => v.sa_orderitemsid == data.sa_orderitemsid),
  35. value = e.detail.value;
  36. if (value == 0) {
  37. wx.showToast({
  38. title: 'title',
  39. icon: "none",
  40. mask: true
  41. })
  42. this.setData({
  43. list: this.data.list
  44. })
  45. return;
  46. }
  47. let maxqty = data.uninvoiceamount / data.price;
  48. if (value > maxqty) value = maxqty;
  49. if (e.detail.value != data.invoiceamount) this.triggerEvent("changeProduct", {
  50. "sa_invoiceapply_orderid": data.sa_invoiceapply_orderid,
  51. "saorderid": data.sa_orderid,
  52. "sa_orderitemsid": data.sa_orderitemsid,
  53. "price": data.price,
  54. "invoiceamount": value * data.price,
  55. "invoiceaqty": value
  56. })
  57. if (value > maxqty) setTimeout(() => {
  58. wx.showToast({
  59. title: getApp().globalData.Language.getMapText('超过最大可开票数量'),
  60. icon: "none",
  61. mask: true
  62. })
  63. }, 500)
  64. },
  65. deleteProduct(e) {
  66. let {
  67. item
  68. } = e.currentTarget.dataset;
  69. this.triggerEvent("deleteItem", item)
  70. },
  71. isEdit() {
  72. if (this.data.disabled) getApp().globalData.Language.showToast('当前状态不可编辑')
  73. }
  74. }
  75. })