index.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. content: {
  5. loading: false,
  6. "ownertable": "sa_project",
  7. sa_projectid: "",
  8. nocache: true,
  9. pageNumber: 1,
  10. pageSize: 20,
  11. pageTotal: 1,
  12. total: 0,
  13. where: {
  14. "condition": "",
  15. }
  16. },
  17. list: [],
  18. },
  19. getList(init = false) {
  20. _Http.init(this.data.content, init).then(content => {
  21. _Http.basic({
  22. "id": 20240531152004,
  23. content
  24. }).then(res => {
  25. this.selectComponent('#ListBox').RefreshToComplete();
  26. console.log("通讯录列表", res)
  27. if (res.code != '1') return wx.showToast({
  28. title: res.data,
  29. icon: "none"
  30. });
  31. this.setData({
  32. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  33. content: _Http.paging(content, res),
  34. })
  35. })
  36. })
  37. },
  38. onLoad(options) {
  39. if (options.sa_projectid) this.setData({
  40. 'content.ownertable': "sa_project",
  41. 'content.ownerid': options.sa_projectid,
  42. 'content.sa_projectid': options.sa_projectid
  43. });
  44. this.getList();
  45. getApp().globalData.Language.getLanguagePackage(this, '选择联系人');
  46. },
  47. /* 默认添加 */
  48. created() {
  49. wx.redirectTo({
  50. url: '/packageA/project/modules/contacts/add/index?sa_projectid=' + this.data.content.sa_projectid,
  51. })
  52. },
  53. onClick(e) {
  54. if (this.data.loading) return;
  55. const {
  56. item
  57. } = e.currentTarget.dataset;
  58. delete(item.tag1)
  59. return wx.redirectTo({
  60. url: `/packageA/project/modules/contacts/add/index?sa_projectid=${this.data.content.sa_projectid}&data=${JSON.stringify(item)}&sys_phonebookid=${item.sys_phonebookid}`,
  61. })
  62. item.sa_project_contactsid = 0;
  63. item.sa_projectid = this.data.content.sa_projectid;
  64. item.ownertable = "sa_project";
  65. item.ownerid = item.sa_projectid;
  66. this.data.loading = true;
  67. _Http.basic({
  68. "id": "20221219135502",
  69. "content": item
  70. }).then(res => {
  71. console.log("添加项目联系人", res)
  72. this.data.loading = false;
  73. wx.showToast({
  74. title: res.code != '1' ? res.msg : getApp().globalData.Language.getMapText('添加成功'),
  75. icon: "none",
  76. mask: true
  77. })
  78. if (res.code == '1') setTimeout(() => {
  79. wx.navigateBack()
  80. getCurrentPages().forEach(v => {
  81. if (v.__route__ == 'packageA/project/detail') {
  82. let page = v.selectComponent("#Contacts");
  83. page.getList(item.sa_projectid, true)
  84. }
  85. });
  86. }, 500)
  87. })
  88. },
  89. onSearch({
  90. detail
  91. }) {
  92. this.setData({
  93. 'content.where.condition': detail ? detail : ""
  94. });
  95. this.getList(true);
  96. },
  97. onClear() {
  98. this.setData({
  99. 'content.where.condition': ""
  100. });
  101. this.getList(true);
  102. },
  103. onReachBottom() {
  104. this.getList();
  105. },
  106. })