index.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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. lifetimes: {
  31. attached: function () {
  32. getApp().globalData.Language.getLanguagePackage(this)
  33. }
  34. },
  35. methods: {
  36. handleItem(e) {
  37. const {
  38. name,
  39. item
  40. } = e.target.dataset,
  41. that = this;
  42. switch (name) {
  43. case "call":
  44. wx.makePhoneCall({
  45. phoneNumber: item.phonenumber,
  46. })
  47. break;
  48. case "delete":
  49. wx.showModal({
  50. title: getApp().globalData.Language.getMapText('提示'),
  51. content: getApp().globalData.Language.getMapText('是否确认删除') + `"${item.name}"`,
  52. cancelText: getApp().globalData.Language.getMapText('取消'),
  53. confirmText: getApp().globalData.Language.getMapText('确定'),
  54. complete: (res) => {
  55. if (res.confirm) _Http.basic({
  56. "id": "20221018145502",
  57. "content": {
  58. "contactsid": item.contactsid,
  59. "sys_enterpriseid": item.sys_enterpriseid
  60. }
  61. }).then(res => {
  62. console.log("删除联系人", res)
  63. if (res.code != '1') return wx.showToast({
  64. title: res.data,
  65. icon: "none"
  66. });
  67. that.triggerEvent("changeTotal")
  68. wx.showToast({
  69. title: getApp().globalData.Language.getMapText('删除成功') + '!',
  70. icon: "none"
  71. })
  72. getCurrentPages().forEach(v => {
  73. if (v.__route__ == "packageA/setclient/detail" || v.__route__ == "packageA/opponent/detail" || v.__route__ == "packageA/publicCustomer/detail") {
  74. let model = v.selectComponent("#Contacts");
  75. model.setData({
  76. list: model.data.list.filter(value => value.contactsid != item.contactsid)
  77. });
  78. // model.changeTotal();
  79. } else if (v.__route__ == "packageA/setclient/modules/contacts/search/index") {
  80. v.setData({
  81. list: v.data.list.filter(value => value.contactsid != item.contactsid)
  82. });
  83. } else if (v.__route__ == "packageA/setclient/modules/contacts/detail/index") {
  84. wx.navigateBack()
  85. } else if (v.__route__ == "packageA/publicCustomer/detail" || v.__route__ == "packageA/setclient/detail") {
  86. v.getDetail()
  87. }
  88. })
  89. })
  90. }
  91. })
  92. break;
  93. case "edit":
  94. wx.navigateTo({
  95. 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}`
  96. })
  97. break;
  98. }
  99. },
  100. }
  101. })