index.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. options: {
  4. addGlobalClass: true
  5. },
  6. properties: {
  7. list: {
  8. type: Array
  9. },
  10. changeTotal: {
  11. type: Function
  12. },
  13. disabled: {
  14. type: Boolean
  15. },
  16. enterprisename: {
  17. type: String
  18. },
  19. sys_enterpriseid: {
  20. type: String
  21. },
  22. sa_customersid: {
  23. type: String
  24. },
  25. groupname: {
  26. type: String,
  27. value: "客户联系人"
  28. },
  29. },
  30. data: {},
  31. methods: {
  32. handleItem(e) {
  33. const {
  34. name,
  35. item
  36. } = e.target.dataset,
  37. that = this;
  38. switch (name) {
  39. case "call":
  40. wx.makePhoneCall({
  41. phoneNumber: item.phonenumber,
  42. })
  43. break;
  44. case "delete":
  45. wx.showModal({
  46. title: '提示',
  47. content: `是否确认删除"${item.name}"`,
  48. complete: (res) => {
  49. if (res.confirm) _Http.basic({
  50. "id": "20221018145502",
  51. "content": {
  52. "contactsid": item.contactsid,
  53. "sys_enterpriseid": item.sys_enterpriseid
  54. }
  55. }).then(res => {
  56. console.log("删除联系人", res)
  57. if (res.msg != '成功') return wx.showToast({
  58. title: res.data,
  59. icon: "none"
  60. });
  61. that.triggerEvent("changeTotal")
  62. wx.showToast({
  63. title: `删除成功!`,
  64. icon: "none"
  65. })
  66. getCurrentPages().forEach(v => {
  67. if (v.__route__ == "packageA/setclient/detail" || v.__route__ == "packageA/opponent/detail" || v.__route__ == "packageA/publicCustomer/detail") {
  68. let model = v.selectComponent("#Contacts");
  69. model.setData({
  70. list: model.data.list.filter(value => value.contactsid != item.contactsid)
  71. });
  72. // model.changeTotal();
  73. } else if (v.__route__ == "packageA/setclient/modules/contacts/search/index") {
  74. v.setData({
  75. list: v.data.list.filter(value => value.contactsid != item.contactsid)
  76. });
  77. } else if (v.__route__ == "packageA/setclient/modules/contacts/detail/index") {
  78. wx.navigateBack()
  79. }
  80. })
  81. })
  82. }
  83. })
  84. break;
  85. case "edit":
  86. wx.navigateTo({
  87. url: `/packageA/setclient/modules/contacts/add/index?data=${JSON.stringify(item)}&enterprisename=${this.data.enterprisename}&sa_customersid=${this.data.sa_customersid}&sys_enterpriseid=${this.data.sys_enterpriseid}&contactsid=${item.contactsid}`
  88. })
  89. break;
  90. }
  91. },
  92. }
  93. })