index.js 4.9 KB

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