index.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  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: ''
  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. label: "关联",
  57. index: null,
  58. showName: "value", //显示字段
  59. valueKey: "contactstype",
  60. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  61. value: "", //选中值
  62. list: [{
  63. value: "关联客户"
  64. }, {
  65. value: "关联项目"
  66. }]
  67. }],
  68. total: 0
  69. },
  70. methods: {
  71. getList(init = false) {
  72. if (init.detail != undefined) init = init.detail;
  73. let content = this.data.content;
  74. if (init) {
  75. content.pageNumber = 1;
  76. content.pageTotal = 1;
  77. }
  78. if (content.pageNumber > content.pageTotal) return;
  79. content.groupname = this.data.groupname;
  80. content.sys_phonebookgroupid = this.data.sys_phonebookgroupid;
  81. if (this.data.classActions.length == 0) {
  82. let templetList = wx.getStorageSync('templetList');
  83. if (wx.getStorageSync('userMsg').usertype != 0) templetList = templetList.filter(v => v.templetname != '站点全部')
  84. this.setData({
  85. classActions: templetList.map(v => {
  86. return {
  87. name: v.templetname,
  88. index: v.templetid
  89. }
  90. }),
  91. 'navList[0].label': templetList[0].templetname
  92. });
  93. content.type = templetList[0].templetid;
  94. console.log(" templetList[0].templetname", templetList)
  95. this.selectComponent("#ListBox").setHeight(".head", this);
  96. }
  97. return new Promise((resolve) => {
  98. _Http.basic({
  99. "id": 20231220085804,
  100. content
  101. }).then(res => {
  102. console.log("联系人列表", res)
  103. this.selectComponent('#ListBox').RefreshToComplete();
  104. resolve()
  105. if (res.msg != '成功') return wx.showToast({
  106. title: res.msg,
  107. icon: "none"
  108. })
  109. content.pageTotal = res.pageTotal;
  110. content.pageNumber = res.pageNumber + 1;
  111. this.setData({
  112. content,
  113. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data),
  114. total: res.total
  115. })
  116. })
  117. })
  118. },
  119. insertRows() {
  120. wx.navigateTo({
  121. url: `/packageA/contacts/insert?id=${this.data.sys_phonebookgroupid||0}&name=${this.data.groupname||'默认群组'}`,
  122. });
  123. this.updateList()
  124. },
  125. toDetail(e) {
  126. let {
  127. sys_phonebookid,
  128. groupname
  129. } = e.currentTarget.dataset.item;
  130. console.log("groupname", groupname)
  131. wx.navigateTo({
  132. url: `/packageA/contacts/detail?id=${sys_phonebookid||0}&groupname=${groupname||'默认分组'}`,
  133. });
  134. this.updateList()
  135. },
  136. updateList() {
  137. _Http.updateList = () => {
  138. let content = JSON.parse(JSON.stringify(this.data.content));
  139. content.pageSize = (content.pageNumber - 1) * (content.pageSize || 20);
  140. console.log(content.pageSize)
  141. content.pageNumber = 1;
  142. _Http.basic({
  143. "id": 20231220085804,
  144. content
  145. }).then(res => {
  146. console.log("更新联系人列表", res)
  147. this.setData({
  148. list: res.data,
  149. total: res.total
  150. })
  151. })
  152. }
  153. },
  154. classSelect({
  155. detail
  156. }) {
  157. if (this.data.content.type == detail.index) return this.classClose();
  158. this.setData({
  159. "content.type": detail.index,
  160. 'navList[0].label': detail.name
  161. })
  162. this.classClose();
  163. this.getList(true)
  164. },
  165. classClose() {
  166. this.setData({
  167. classShow: false
  168. })
  169. },
  170. /* 顶部条件导航回调 */
  171. navClick({
  172. detail
  173. }) {
  174. switch (detail.id) {
  175. case '1':
  176. this.setData({
  177. classShow: true
  178. })
  179. break;
  180. case '2':
  181. this.setData({
  182. 'filterShow': true
  183. })
  184. break;
  185. }
  186. },
  187. onSearch({
  188. detail
  189. }) {
  190. this.data.content.where.condition = detail;
  191. this.getList(true)
  192. },
  193. handleFilter({
  194. detail
  195. }) {
  196. console.log("筛选项", detail)
  197. detail.condition = this.data.content.where.condition;
  198. if (getCurrentPages()[getCurrentPages().length - 1].__route__ == 'packageA/contacts/index') {
  199. if (detail.group) {
  200. this.data.groupname = detail.group.groupname;
  201. this.data.sys_phonebookgroupid = detail.group.sys_phonebookgroupid;
  202. } else {
  203. this.data.groupname = "";
  204. this.data.sys_phonebookgroupid = '';
  205. }
  206. delete(detail.group)
  207. }
  208. this.data.content.where = detail;
  209. this.getList(true);
  210. }
  211. }
  212. })