index.js 7.3 KB

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