index.js 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. properties: {
  4. },
  5. data: {
  6. "sa_projectid": null,
  7. content: {
  8. nocache: true,
  9. pageNumber: 1,
  10. pageTotal: 1,
  11. pageSize: 10,
  12. total: null,
  13. where: {
  14. condition: "",
  15. }
  16. },
  17. },
  18. methods: {
  19. /* 获取地址列表 */
  20. getList(id, init) {
  21. let content = this.data.content;
  22. content.sa_projectid = id;
  23. if (init) {
  24. content.pageNumber = 1
  25. content.pageTotal = 1
  26. }
  27. _Http.basic({
  28. "id": "20221027143702",
  29. content
  30. }).then(res => {
  31. console.log("关联客户列表", res)
  32. if (res.msg != '成功') return wx.showToast({
  33. title: res.data,
  34. icon: "none"
  35. })
  36. this.getTags(res.data.map(v => v.sa_customersid));
  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. })
  46. },
  47. /* 获取列表标签 */
  48. getTags(ownerids = []) {
  49. _Http.basic({
  50. "id": 20221018102001,
  51. "content": {
  52. "ownertable": "sa_customers",
  53. ownerids
  54. }
  55. }).then(res => {
  56. console.log("标签", res)
  57. let list = this.data.list;
  58. for (let key in res.data) {
  59. let index = list.findIndex(v => v.sa_customersid == key);
  60. if (index != -1) list[index].tags = res.data[key]
  61. };
  62. this.setData({
  63. list
  64. })
  65. })
  66. },
  67. /* 去搜索 */
  68. toSearch() {
  69. wx.navigateTo({
  70. url: '/packageA/project/modules/treaty/search?data=' + JSON.stringify(this.data.content),
  71. })
  72. },
  73. fastCallBack({
  74. detail
  75. }) {
  76. console.log(detail.name, detail.item)
  77. const that = this;
  78. switch (detail.name) {
  79. case 'delete':
  80. wx.showModal({
  81. title: '提示',
  82. content: `是否确认取消关联"${detail.item.enterprisename}"?`,
  83. complete: ({
  84. confirm
  85. }) => {
  86. if (confirm) _Http.basic({
  87. "id": 20221027143802,
  88. "content": {
  89. "sa_project_partiesids": [detail.item.sa_project_partiesid]
  90. },
  91. }).then(res => {
  92. if (res.msg != '成功') return wx.showToast({
  93. title: res.data,
  94. icon: "none"
  95. });
  96. that.setData({
  97. list: that.data.list.filter(v => v.sa_project_partiesid != detail.item.sa_project_partiesid),
  98. 'content.total': that.data.content.total - 1
  99. });
  100. wx.showToast({
  101. title: `已取消关联"${detail.item.enterprisename}"`,
  102. icon: "none"
  103. })
  104. })
  105. }
  106. })
  107. break;
  108. default:
  109. break;
  110. }
  111. }
  112. }
  113. })