index.js 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. showReason: {
  22. type: Boolean,
  23. value: true
  24. }
  25. },
  26. lifetimes: {
  27. attached: function () {
  28. getApp().globalData.Language.getLanguagePackage(this)
  29. this.setData({
  30. siteid: wx.getStorageSync('userMsg').siteid
  31. })
  32. }
  33. },
  34. methods: {
  35. onIconTap() {
  36. this.triggerEvent("delete", this.data.data);
  37. },
  38. inputChange(e) {
  39. this.data.data.qty = e.detail.value
  40. this.setData({
  41. "data.qty": e.detail.value
  42. })
  43. this.triggerEvent("input", this.data.data);
  44. },
  45. newOnBlur(e) {
  46. let value = parseInt(e.detail.value) || 1
  47. if (value <= 0) {
  48. value = 1
  49. }
  50. let data = this.data.data,
  51. that = this;
  52. if (data.oldQty == value) return;
  53. data.qty = value
  54. that.setData({
  55. "data.qty": value
  56. })
  57. that.triggerEvent("changeItem", data)
  58. },
  59. onBlur(e) {
  60. let {
  61. value
  62. } = e.detail,
  63. data = this.data.data,
  64. name = e.currentTarget.dataset.name;
  65. console.log(data)
  66. if (data[name] == value) return;
  67. if (name == 'qty' && value <= 0) {
  68. getApp().globalData.Language.modeBoxPrompts(getApp().globalData.Language.getMapText('数量不符合规则,已重置为1') || '数量不符合规则,已重置为1')
  69. data[name] = 1
  70. } else {
  71. data[name] = value
  72. }
  73. _Http.basic({
  74. "id": "20230215201903",
  75. "content": {
  76. "sa_workorderid": data.sa_workorderid,
  77. "iteminfos": [data]
  78. }
  79. }).then(res => {
  80. console.log("产品修改", res)
  81. if (res.code != '1') return wx.showToast({
  82. title: res.msg,
  83. icon: "none"
  84. });
  85. this.triggerEvent("changeItem", data)
  86. });
  87. }
  88. }
  89. })