index.js 3.9 KB

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