index.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. properties: {
  4. disabled: Boolean
  5. },
  6. data: {
  7. "sa_projectid": null,
  8. content: {
  9. nocache: true,
  10. pageNumber: 1,
  11. pageTotal: 1,
  12. pageSize: 10,
  13. total: null,
  14. where: {
  15. condition: "",
  16. }
  17. },
  18. },
  19. methods: {
  20. /* 获取地址列表 */
  21. getList(id, init) {
  22. let content = this.data.content;
  23. content.sa_projectid = id;
  24. if (init) {
  25. content.pageNumber = 1
  26. content.pageTotal = 1
  27. }
  28. _Http.basic({
  29. "id": "20221027143702",
  30. content
  31. }).then(res => {
  32. console.log("关联客户列表", res)
  33. if (res.msg != '成功') return wx.showToast({
  34. title: res.data,
  35. icon: "none"
  36. })
  37. this.setData({
  38. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  39. "content.pageNumber": res.pageNumber + 1,
  40. "content.pageSize": res.pageSize,
  41. "content.pageTotal": res.pageTotal,
  42. "content.total": res.total,
  43. sa_projectid: id
  44. })
  45. this.getTags();
  46. })
  47. },
  48. /* 获取列表标签 */
  49. getTags() {
  50. let list = this.data.list,
  51. ownerids = list.map(v => v.sa_customersid);
  52. _Http.basic({
  53. "id": 20221018102001,
  54. "content": {
  55. "ownertable": "sa_customers",
  56. ownerids
  57. }
  58. }).then(res => {
  59. console.log("标签", res)
  60. for (let key in res.data) {
  61. let index = list.findIndex(v => v.sa_customersid == key);
  62. if (index != -1) list[index].tags = res.data[key]
  63. };
  64. this.setData({
  65. list
  66. })
  67. })
  68. },
  69. fastCallBack({
  70. detail
  71. }) {
  72. const that = this;
  73. switch (detail.name) {
  74. case 'delete':
  75. wx.showModal({
  76. title: '提示',
  77. content: `是否确认删除"${detail.item.enterprisename}"?`,
  78. complete: ({
  79. confirm
  80. }) => {
  81. if (confirm) _Http.basic({
  82. "id": 20221027143802,
  83. "content": {
  84. "sa_project_partiesids": [detail.item.sa_project_partiesid],
  85. sa_projectid: detail.item.sa_projectid
  86. },
  87. }).then(res => {
  88. if (res.msg != '成功') return wx.showToast({
  89. title: res.data,
  90. icon: "none"
  91. });
  92. that.setData({
  93. list: that.data.list.filter(v => v.sa_project_partiesid != detail.item.sa_project_partiesid),
  94. 'content.total': that.data.content.total - 1
  95. });
  96. wx.showToast({
  97. title: `已删除"${detail.item.enterprisename}"`,
  98. icon: "none"
  99. })
  100. })
  101. }
  102. })
  103. break;
  104. case 'change':
  105. break;
  106. default:
  107. console.log(detail.name)
  108. break;
  109. }
  110. },
  111. /* 添加关联 */
  112. submit(content = false) {
  113. if (!content) return;
  114. _Http.basic({
  115. "id": 20221111102902,
  116. content
  117. }).then(res => {
  118. console.log("批量添加客户", res)
  119. if (res.msg != '成功') return wx.showToast({
  120. title: res.data,
  121. icon: "none"
  122. });
  123. wx.showToast({
  124. title: '添加成功',
  125. icon: "none"
  126. })
  127. setTimeout(() => {
  128. this.getList(content.sa_projectid, true);
  129. wx.navigateBack();
  130. }, 300)
  131. })
  132. }
  133. }
  134. })