delete.js 1.9 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. getApp().globalData.Language.getLanguagePackage(this, '作废原因');
  15. },
  16. onInput(e) {
  17. this.setData({
  18. deletereason: e.detail.value
  19. })
  20. },
  21. handleDetele() {
  22. _Http.basic({
  23. "id": this.data.id,
  24. "content": {
  25. ...this.data
  26. }
  27. }).then(res => {
  28. console.log("作废", res);
  29. if (res.code != '1') return wx.showToast({
  30. title: res.data,
  31. icon: "none"
  32. });
  33. wx.showToast({
  34. title: getApp().globalData.Language.getMapText('作废成功'),
  35. icon: "none"
  36. })
  37. setTimeout(() => {
  38. getCurrentPages().forEach(v => {
  39. if (['packageA/setclient/detail', 'packageA/publicCustomer/detail'].includes(v.__route__)) {
  40. wx.navigateBack();
  41. } else if (['packageA/setclient/index', 'packageA/setclient/search', 'packageA/publicCustomer/index'].includes(v.__route__)) {
  42. v.setData({
  43. list: v.data.list.filter(s => s.sa_customersid != this.data.sa_customersids[0]),
  44. 'content.total': v.data.content.total - 1
  45. })
  46. } else if (['packageA/opponent/index'].includes(v.__route__)) {
  47. wx.navigateBack();
  48. v.getList(true);
  49. }
  50. });
  51. wx.navigateBack();
  52. }, 300)
  53. })
  54. }
  55. })