index.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  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. show: getApp().globalData.Language.getMapText('高层'),
  20. value: '高层',
  21. }, {
  22. show: getApp().globalData.Language.getMapText('中层'),
  23. value: '中层',
  24. }, {
  25. show: getApp().globalData.Language.getMapText('项目负责人'),
  26. value: '项目负责人',
  27. }],
  28. range1: ['高层', '中层', '项目负责人'],
  29. },
  30. methods: {
  31. handleItem(e) {
  32. const {
  33. name,
  34. item
  35. } = e.target.dataset,
  36. that = this;
  37. switch (name) {
  38. case "call":
  39. if (!item.phonenumber) return getApp().globalData.Language.modeBoxPrompts('该用户联系方式为空')
  40. wx.makePhoneCall({
  41. phoneNumber: item.phonenumber,
  42. })
  43. break;
  44. case "delete":
  45. wx.showModal({
  46. title: getApp().globalData.Language.getMapText('提示'),
  47. content: getApp().globalData.Language.getMapText('是否确认删除') + `"${item.name}"`,
  48. cancelText: getApp().globalData.Language.getMapText('取消'),
  49. confirmText: getApp().globalData.Language.getMapText('确定'),
  50. complete: (res) => {
  51. if (res.confirm) _Http.basic({
  52. "id": "20221111130904",
  53. "content": {
  54. sa_project_contactsids: [item.sa_project_contactsid],
  55. }
  56. }).then(res => {
  57. console.log("删除联系人", res)
  58. if (res.code != '1') return wx.showToast({
  59. title: res.data,
  60. icon: "none"
  61. });
  62. wx.showToast({
  63. title: getApp().globalData.Language.getMapText('删除成功') + `!`,
  64. icon: "none"
  65. })
  66. getCurrentPages().forEach(v => {
  67. if (v.selectComponent("#Contacts")) {
  68. const page = v.selectComponent("#Contacts");
  69. page.setData({
  70. list: page.data.list.filter(v => v.contactsid != item.contactsid)
  71. });
  72. page.changeTotal();
  73. } else if (v.__route__ == "packageA/project/modules/contacts/search/index") {
  74. v.setData({
  75. list: v.data.list.filter(v => v.contactsid != item.contactsid),
  76. 'content.total': v.data.content.total - 1
  77. });
  78. } else if (v.__route__ == "packageA/setclient/modules/contacts/detail/index") {
  79. wx.navigateBack()
  80. }
  81. })
  82. })
  83. }
  84. })
  85. break;
  86. case "edit":
  87. wx.navigateTo({
  88. url: `/packageA/project/modules/contacts/add/index?data=${JSON.stringify(item)}`
  89. })
  90. break;
  91. }
  92. },
  93. bindPickerChange(e) {
  94. let item = e.currentTarget.dataset.item,
  95. tag = this.data.range1[e.detail.value];
  96. if (item.tag == tag) return;
  97. _Http.basic({
  98. "id": 20221119103902,
  99. "content": {
  100. "sa_project_contactsid": item.sa_project_contactsid,
  101. tag,
  102. },
  103. }).then(res => {
  104. console.log("修改关联客户类型", res)
  105. if (res.code != '1') return wx.showToast({
  106. title: res.data,
  107. icon: "none"
  108. });
  109. this.setData({
  110. [`list[${this.data.list.findIndex(v=>v.sa_project_contactsid==item.sa_project_contactsid)}].tag[0]`]: tag
  111. });
  112. getApp().globalData.Language.modeBoxPrompts([{
  113. t: 1,
  114. v: '已更改',
  115. r: " "
  116. }, {
  117. v: item.name,
  118. r: " "
  119. }, {
  120. t: 1,
  121. v: '联系人类型为',
  122. r: " "
  123. }, {
  124. t: 1,
  125. v: tag
  126. }])
  127. })
  128. },
  129. }
  130. })