index.js 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. properties: {
  4. data: {
  5. value: '',
  6. type: {}
  7. },
  8. changeQty: {
  9. value: false,
  10. type: Boolean
  11. },
  12. model: {
  13. type: String,
  14. value: 1
  15. },
  16. changeItem: Function,
  17. delete: Function
  18. },
  19. methods: {
  20. onIconTap() {
  21. this.triggerEvent("delete", this.data.data);
  22. },
  23. inputChange(e) {
  24. this.data.data.qty = e.detail.value
  25. this.triggerEvent("input", this.data.data);
  26. },
  27. onBlur(e) {
  28. let {
  29. value
  30. } = e.detail,
  31. data = this.data.data,
  32. name = e.currentTarget.dataset.name;
  33. if (data[name] == value) return;
  34. if (name == 'qty' && value <= 0) {
  35. wx.showToast({
  36. title: '数量不符合规则,已重置为1',
  37. })
  38. data[name] = 1
  39. } else {
  40. data[name] = value
  41. }
  42. _Http.basic({
  43. "id": "20230215201903",
  44. "content": {
  45. "sa_workorderid": data.sa_workorderid,
  46. "iteminfos": [data]
  47. }
  48. }).then(res => {
  49. console.log("产品修改", res)
  50. if (res.msg != '成功') return wx.showToast({
  51. title: res.msg,
  52. icon: "none"
  53. });
  54. this.triggerEvent("changeItem", data)
  55. });
  56. }
  57. }
  58. })