index.js 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. options: {
  4. addGlobalClass: true
  5. },
  6. properties: {
  7. list: Array,
  8. changeTotal: Function,
  9. disabled:Boolean
  10. },
  11. data: {
  12. range: ['高层', '中层', '项目负责人']
  13. },
  14. methods: {
  15. handleItem(e) {
  16. const {
  17. name,
  18. item
  19. } = e.target.dataset,
  20. that = this;
  21. switch (name) {
  22. case "call":
  23. if (!item.phonenumber) return wx.showToast({
  24. title: '该用户手机号为空',
  25. icon: "none"
  26. })
  27. wx.makePhoneCall({
  28. phoneNumber: item.phonenumber,
  29. })
  30. break;
  31. case "delete":
  32. wx.showModal({
  33. title: '提示',
  34. content: `是否确认删除"${item.name}"`,
  35. complete: (res) => {
  36. if (res.confirm) _Http.basic({
  37. "id": "20221111130904",
  38. "content": {
  39. sa_project_contactsids: [item.sa_project_contactsid],
  40. }
  41. }).then(res => {
  42. console.log("删除联系人", res)
  43. if (res.msg != '成功') return wx.showToast({
  44. title: res.data,
  45. icon: "none"
  46. });
  47. wx.showToast({
  48. title: `删除成功!`,
  49. icon: "none"
  50. })
  51. getCurrentPages().forEach(v => {
  52. if (v.selectComponent("#Contacts")) {
  53. const page = v.selectComponent("#Contacts");
  54. page.setData({
  55. list: page.data.list.filter(v => v.contactsid != item.contactsid)
  56. });
  57. page.changeTotal();
  58. } else if (v.__route__ == "packageA/project/modules/contacts/search/index") {
  59. v.setData({
  60. list: v.data.list.filter(v => v.contactsid != item.contactsid),
  61. 'content.total': v.data.content.total - 1
  62. });
  63. } else if (v.__route__ == "packageA/setclient/modules/contacts/detail/index") {
  64. wx.navigateBack()
  65. }
  66. })
  67. })
  68. }
  69. })
  70. break;
  71. case "edit":
  72. wx.navigateTo({
  73. url: `/packageA/setclient/modules/contacts/add/index?data=${JSON.stringify(item)}`
  74. })
  75. break;
  76. }
  77. },
  78. bindPickerChange(e) {
  79. let item = e.currentTarget.dataset.item,
  80. tag = this.data.range[e.detail.value];
  81. if (item.tag == tag) return;
  82. _Http.basic({
  83. "id": 20221119103902,
  84. "content": {
  85. "sa_project_contactsid": item.sa_project_contactsid,
  86. tag,
  87. },
  88. }).then(res => {
  89. console.log("修改关联客户类型", res)
  90. if (res.msg != '成功') return wx.showToast({
  91. title: res.data,
  92. icon: "none"
  93. });
  94. this.setData({
  95. [`list[${this.data.list.findIndex(v=>v.sa_project_contactsid==item.sa_project_contactsid)}].tag[0]`]: tag
  96. });
  97. wx.showToast({
  98. title: `已更改“${item.name}”联系人类型为“${tag}”`,
  99. icon: "none"
  100. })
  101. })
  102. },
  103. }
  104. })