index.js 1.8 KB

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