index.js 3.8 KB

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