delete.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. deletereason: "",
  5. id: 20221010164402,
  6. },
  7. onLoad(options) {
  8. if (options.item) this.setData({
  9. ...JSON.parse(options.item)
  10. })
  11. if (options.id) this.setData({
  12. id: options.id
  13. })
  14. },
  15. onInput(e) {
  16. this.setData({
  17. deletereason: e.detail.value
  18. })
  19. },
  20. handleDetele() {
  21. _Http.basic({
  22. "id": this.data.id,
  23. "content": {
  24. ...this.data
  25. }
  26. }).then(res => {
  27. console.log("作废", res);
  28. if (res.msg != '成功') return wx.showToast({
  29. title: res.data,
  30. icon: "none"
  31. });
  32. wx.showToast({
  33. title: '作废成功',
  34. icon: "none"
  35. })
  36. setTimeout(() => {
  37. getCurrentPages().forEach(v => {
  38. if (['packageA/setclient/detail', 'packageA/publicCustomer/detail'].includes(v.__route__)) {
  39. wx.navigateBack();
  40. } else if (['packageA/setclient/index', 'packageA/setclient/search', 'packageA/publicCustomer/index'].includes(v.__route__)) {
  41. v.setData({
  42. list: v.data.list.filter(s => s.sa_customersid != this.data.sa_customersids[0]),
  43. 'content.total': v.data.content.total - 1
  44. })
  45. } else if (['packageA/opponent/index'].includes(v.__route__)) {
  46. wx.navigateBack();
  47. v.getList(true);
  48. }
  49. });
  50. wx.navigateBack();
  51. }, 300)
  52. })
  53. }
  54. })