index.js 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. const _Http = getApp().globalData.http;
  2. Component({
  3. properties: {
  4. groupname: {
  5. type: String,
  6. value: ""
  7. },
  8. sys_phonebookgroupid: {
  9. type: [String, Number],
  10. value: 0
  11. }
  12. },
  13. data: {
  14. list: [],
  15. "content": {
  16. nocache: true,
  17. "type": 1,
  18. "pageNumber": 1,
  19. "pageTotal": 1,
  20. "pageSize": 20,
  21. "where": {
  22. "condition": ""
  23. }
  24. },
  25. navList: [{
  26. label: "我负责的",
  27. icon: "icon-webxialaxuanxiangjiantou",
  28. color: "",
  29. width: "",
  30. id: "1"
  31. }, {
  32. label: "筛选",
  33. icon: "icon-shaixuan",
  34. color: "",
  35. width: "",
  36. id: "2"
  37. }],
  38. classShow: false,
  39. classActions: [],
  40. filtratelist: [{
  41. label: "标签",
  42. index: null,
  43. type: "checkbox",
  44. showName: "tag", //显示字段
  45. valueKey: "tag", //返回Key
  46. selectKey: "tag", //传参 代表选着字段 不传参返回整个选择对象
  47. value: "", //选中值
  48. list: [{
  49. tag: "关键决策人"
  50. }, {
  51. tag: "反对者"
  52. }, {
  53. tag: "支持者"
  54. }]
  55. }],
  56. total: 0
  57. },
  58. methods: {
  59. getList(init = false) {
  60. if (init.detail != undefined) init = init.detail;
  61. let content = this.data.content;
  62. if (init) {
  63. content.pageNumber = 1;
  64. content.pageTotal = 1;
  65. }
  66. if (content.pageNumber > content.pageTotal) return;
  67. content.groupname = this.data.groupname;
  68. content.sys_phonebookgroupid = this.data.sys_phonebookgroupid;
  69. if (this.data.classActions.length == 0) {
  70. this.setData({
  71. classActions: wx.getStorageSync('templetList').map(v => {
  72. return {
  73. name: v.templetname,
  74. index: v.templetid
  75. }
  76. }),
  77. 'navList[0].label': wx.getStorageSync('templetList')[0].templetname
  78. });
  79. content.type = wx.getStorageSync('templetList')[0].templetid;
  80. this.selectComponent("#ListBox").setHeight(".head", this);
  81. }
  82. return new Promise((resolve) => {
  83. _Http.basic({
  84. "id": 20231220085804,
  85. content
  86. }).then(res => {
  87. console.log("联系人列表", res)
  88. this.selectComponent('#ListBox').RefreshToComplete();
  89. resolve()
  90. if (res.msg != '成功') return wx.showToast({
  91. title: res.msg,
  92. icon: "none"
  93. })
  94. content.pageTotal = res.pageTotal;
  95. content.pageNumber = res.pageNumber + 1;
  96. this.setData({
  97. content,
  98. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  99. total: res.total
  100. })
  101. })
  102. })
  103. },
  104. insertRows() {
  105. wx.navigateTo({
  106. url: `/packageA/contacts/insert?id=${this.data.sys_phonebookgroupid||0}&name=${this.data.groupname||'默认群组'}`,
  107. });
  108. this.updateList()
  109. },
  110. toDetail(e) {
  111. let {
  112. sys_phonebookid,
  113. sa_project_contactsid,
  114. contactsid,
  115. } = e.currentTarget.dataset.item;
  116. wx.navigateTo({
  117. url: `/packageA/contacts/detail?id=${sys_phonebookid||0}&sa_project_contactsid=${sa_project_contactsid||0}&contactsid=${contactsid||0}`,
  118. });
  119. this.updateList()
  120. },
  121. updateList() {
  122. _Http.updateList = () => {
  123. let content = JSON.parse(JSON.stringify(this.data.content));
  124. content.pageSize = (content.pageNumber - 1) * (content.pageSize || 20);
  125. console.log(content.pageSize)
  126. content.pageNumber = 1;
  127. _Http.basic({
  128. "id": 20231220085804,
  129. content
  130. }).then(res => {
  131. console.log("更新联系人列表", res)
  132. this.setData({
  133. list: res.data
  134. })
  135. })
  136. }
  137. },
  138. classSelect({
  139. detail
  140. }) {
  141. if (this.data.content.type == detail.index) return this.classClose();
  142. this.setData({
  143. "content.type": detail.index,
  144. 'navList[0].label': detail.name
  145. })
  146. this.classClose();
  147. this.getList(true)
  148. },
  149. classClose() {
  150. this.setData({
  151. classShow: false
  152. })
  153. },
  154. /* 顶部条件导航回调 */
  155. navClick({
  156. detail
  157. }) {
  158. switch (detail.id) {
  159. case '1':
  160. this.setData({
  161. classShow: true
  162. })
  163. break;
  164. case '2':
  165. this.setData({
  166. 'filterShow': true
  167. })
  168. break;
  169. }
  170. },
  171. onSearch({
  172. detail
  173. }) {
  174. this.data.content.where.condition = detail;
  175. this.getList(true)
  176. },
  177. handleFilter({
  178. detail
  179. }) {
  180. console.log("筛选项", detail)
  181. detail.condition = this.data.content.where.condition;
  182. if (getCurrentPages()[getCurrentPages().length - 1].__route__ == 'packageA/contacts/index') {
  183. if (detail.group) {
  184. this.data.groupname = detail.group.groupname;
  185. this.data.sys_phonebookgroupid = detail.group.sys_phonebookgroupid;
  186. } else {
  187. this.data.groupname = "";
  188. this.data.sys_phonebookgroupid = 0;
  189. }
  190. delete(detail.group)
  191. }
  192. this.data.content.where = detail;
  193. this.getList(true);
  194. }
  195. }
  196. })