index.js 1.9 KB

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