index.js 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. Component({
  2. properties: {
  3. list: Array,
  4. deleteItem: Function,
  5. changeQueue: Function, //修改队列
  6. disabled: Boolean
  7. },
  8. options: {
  9. addGlobalClass: true
  10. },
  11. methods: {
  12. /* 修改产品数量/单价 */
  13. onBlur(e) {
  14. let {
  15. name,
  16. index
  17. } = e.currentTarget.dataset;
  18. let item = this.data.list[index];
  19. if (e.detail.value <= 0) {
  20. wx.showToast({
  21. title: '非法数值',
  22. icon: "none"
  23. });
  24. } else {
  25. if (item[name] == e.detail.value) return;
  26. item[name] = e.detail.value - 0;
  27. item.outamount = item.outqty * item.price;
  28. if (name == "price" && item[name] > item.marketprice) item[name] = item.marketprice;
  29. let obj = {};
  30. ["sa_salesforecastid", "itemid", "orderqty", "orderamount", "invoiceqty", "price", "invoiceamount", "outqty"].forEach(v => obj[v] = item[v]);
  31. this.triggerEvent("changeQueue", obj)
  32. }
  33. this.setData({
  34. list: this.data.list
  35. })
  36. },
  37. deleteProduct(e) {
  38. const {
  39. sa_salesforecastbillid,
  40. sa_salesforecastid,
  41. itemname
  42. } = e.currentTarget.dataset.item,
  43. that = this;
  44. wx.showModal({
  45. title: '提示',
  46. content: `是否确认删除“${itemname}”?`,
  47. complete: ({
  48. confirm
  49. }) => {
  50. if (confirm) that.triggerEvent("deleteItem", {
  51. sa_salesforecastbillid,
  52. sa_salesforecastid,
  53. sa_projectid: 0
  54. });
  55. }
  56. })
  57. },
  58. }
  59. })