index.js 2.3 KB

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