index.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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. },
  17. data: {
  18. range: ['高层', '中层', '项目负责人']
  19. },
  20. methods: {
  21. handleItem(e) {
  22. const {
  23. name,
  24. item
  25. } = e.target.dataset,
  26. that = this;
  27. switch (name) {
  28. case "call":
  29. if (!item.phonenumber) return wx.showToast({
  30. title: '该用户联系方式为空',
  31. icon: "none"
  32. })
  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": "20221111130904",
  44. "content": {
  45. sa_project_contactsids: [item.sa_project_contactsid],
  46. }
  47. }).then(res => {
  48. console.log("删除联系人", res)
  49. if (res.msg != '成功') return wx.showToast({
  50. title: res.data,
  51. icon: "none"
  52. });
  53. wx.showToast({
  54. title: `删除成功!`,
  55. icon: "none"
  56. })
  57. getCurrentPages().forEach(v => {
  58. if (v.selectComponent("#Contacts")) {
  59. const page = v.selectComponent("#Contacts");
  60. page.setData({
  61. list: page.data.list.filter(v => v.contactsid != item.contactsid)
  62. });
  63. page.changeTotal();
  64. } else if (v.__route__ == "packageA/project/modules/contacts/search/index") {
  65. v.setData({
  66. list: v.data.list.filter(v => v.contactsid != item.contactsid),
  67. 'content.total': v.data.content.total - 1
  68. });
  69. } else if (v.__route__ == "packageA/setclient/modules/contacts/detail/index") {
  70. wx.navigateBack()
  71. }
  72. })
  73. })
  74. }
  75. })
  76. break;
  77. case "edit":
  78. console.log(item)
  79. wx.navigateTo({
  80. url: `/packageA/project/modules/contacts/add/index?data=${JSON.stringify(item)}`
  81. })
  82. break;
  83. }
  84. },
  85. bindPickerChange(e) {
  86. let item = e.currentTarget.dataset.item,
  87. tag = this.data.range[e.detail.value];
  88. if (item.tag == tag) return;
  89. _Http.basic({
  90. "id": 20221119103902,
  91. "content": {
  92. "sa_project_contactsid": item.sa_project_contactsid,
  93. tag,
  94. },
  95. }).then(res => {
  96. console.log("修改关联客户类型", res)
  97. if (res.msg != '成功') return wx.showToast({
  98. title: res.data,
  99. icon: "none"
  100. });
  101. this.setData({
  102. [`list[${this.data.list.findIndex(v=>v.sa_project_contactsid==item.sa_project_contactsid)}].tag[0]`]: tag
  103. });
  104. wx.showToast({
  105. title: `已更改“${item.name}”联系人类型为“${tag}”`,
  106. icon: "none"
  107. })
  108. })
  109. },
  110. }
  111. })