index.js 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. newOnBlur(e) {
  28. let value = e.detail.value,
  29. data = this.data.data,
  30. that = this;
  31. if (data.oldQty == value) return;
  32. wx.showModal({
  33. title: `提示`,
  34. content: `是否确定修改“${data.itemname}”数量为:${value}`,
  35. complete: (res) => {
  36. if (res.cancel) {
  37. that.setData({
  38. "data.qty": data.oldQty
  39. })
  40. }
  41. if (res.confirm) that.triggerEvent("changeItem", data)
  42. }
  43. })
  44. },
  45. onBlur(e) {
  46. let {
  47. value
  48. } = e.detail,
  49. data = this.data.data,
  50. name = e.currentTarget.dataset.name;
  51. console.log(data)
  52. if (data[name] == value) return;
  53. if (name == 'qty' && value <= 0) {
  54. wx.showToast({
  55. title: '数量不符合规则,已重置为1',
  56. })
  57. data[name] = 1
  58. } else {
  59. data[name] = value
  60. }
  61. _Http.basic({
  62. "id": "20230215201903",
  63. "content": {
  64. "sa_workorderid": data.sa_workorderid,
  65. "iteminfos": [data]
  66. }
  67. }).then(res => {
  68. console.log("产品修改", res)
  69. if (res.msg != '成功') return wx.showToast({
  70. title: res.msg,
  71. icon: "none"
  72. });
  73. this.triggerEvent("changeItem", data)
  74. });
  75. }
  76. }
  77. })