index.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. const _Http = getApp().globalData.http;
  2. import {
  3. getTypes
  4. } from "./modules/query";
  5. Page({
  6. data: {
  7. loading: true,
  8. navList: [{
  9. label: "我负责的",
  10. icon: "icon-webxialaxuanxiangjiantou",
  11. color: "",
  12. width: "",
  13. id: "1"
  14. }, {
  15. label: "排序",
  16. icon: "icon-jiangxu1",
  17. color: "",
  18. width: "",
  19. id: "sort"
  20. }, {
  21. label: "筛选",
  22. icon: "icon-shaixuan",
  23. color: "",
  24. width: "",
  25. id: "2"
  26. }],
  27. content: {
  28. isend: 0,
  29. nocache: true,
  30. "type": 1,
  31. deleted: 0,
  32. "pageNumber": 1,
  33. "pageSize": 20,
  34. "isExport": 0,
  35. "where": {},
  36. "sort": [{
  37. sortname: "默认",
  38. sorted: 1,
  39. sortid: 67,
  40. reversed: 0
  41. }]
  42. },
  43. list: [],
  44. classShow: false, //type类型
  45. },
  46. /* 去添加 */
  47. toAdd() {
  48. wx.navigateTo({
  49. url: './addAndEditor'
  50. })
  51. },
  52. async onLoad(options) {
  53. getApp().globalData.Language.getLanguagePackage(this, '我的客户');
  54. this.setData({
  55. insert: wx.getStorageSync('auth').wCustomer.options.some(v => v == 'insert'), //查询新增权限
  56. classActions: wx.getStorageSync('templetList').map((v, i) => {
  57. return {
  58. name: v.templetname,
  59. index: v.templetid,
  60. color: i == 0 ? '#3874F6' : '',
  61. i: i,
  62. }
  63. }),
  64. 'navList[0].label': wx.getStorageSync('templetList')[0].templetname,
  65. "content.type": wx.getStorageSync('templetList')[0].templetid,
  66. });
  67. this.getList()
  68. let filtratelist = [{
  69. label: "部门",
  70. index: null,
  71. showName: "depname", //显示字段
  72. valueKey: "departmentid", //返回Key
  73. selectKey: "departmentid", //传参 代表选着字段 不传参返回整个选择对象
  74. value: "", //选中值
  75. type: 'multilevelClass',
  76. list: await _Http.basic({
  77. "id": 20230620102004,
  78. "content": {},
  79. }).then(res => {
  80. console.log("获取部门", res)
  81. return res.data.dep
  82. })
  83. }, {
  84. label: "客户类型",
  85. index: null,
  86. showName: "value", //显示字段
  87. valueKey: "type", //返回Key
  88. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  89. value: "", //选中值
  90. list: await getTypes('customertypemx')
  91. }, {
  92. label: "客户分类",
  93. index: null,
  94. showName: "value", //显示字段
  95. valueKey: "customergrade", //返回Key
  96. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  97. value: "", //选中值
  98. list: await getTypes('customergrade')
  99. }, {
  100. label: "客户等级",
  101. index: null,
  102. showName: "value", //显示字段
  103. valueKey: "grade", //返回Key
  104. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  105. value: "", //选中值
  106. list: await getTypes('agentgrade')
  107. }, {
  108. label: "所属行业",
  109. index: null,
  110. showName: "value", //显示字段
  111. valueKey: "industry", //返回Key
  112. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  113. value: "", //选中值
  114. list: await getTypes('industry')
  115. }, {
  116. label: "合作状态",
  117. index: null,
  118. showName: "value", //显示字段
  119. valueKey: "status", //返回Key
  120. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  121. value: "", //选中值
  122. list: [{
  123. value: "潜在"
  124. }, {
  125. value: "合作中"
  126. }, {
  127. value: "已终止"
  128. }]
  129. }, {
  130. label: "成交状态",
  131. index: null,
  132. showName: "value", //显示字段
  133. valueKey: "tradingstatus", //返回Key
  134. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  135. value: "", //选中值
  136. list: [{
  137. value: "未成交"
  138. }, {
  139. value: "已成交"
  140. }, {
  141. value: "多次成交"
  142. }]
  143. }, {
  144. label: "标签",
  145. index: null,
  146. type: "checkbox",
  147. showName: "tag", //显示字段
  148. valueKey: "tag", //返回Key
  149. selectKey: "tag", //传参 代表选着字段 不传参返回整个选择对象
  150. value: "", //选中值
  151. list: await getTypes('tags')
  152. }]
  153. this.setData({
  154. filtratelist
  155. })
  156. },
  157. /* 处理筛选 */
  158. handleFilter({
  159. detail
  160. }) {
  161. detail.condition = this.data.content.where.condition;
  162. this.data.content.where = detail;
  163. this.getList(true);
  164. },
  165. getList(init = false) {
  166. _Http.init(this.data.content, init).then(content => {
  167. _Http.basic({
  168. "id": 20221012164402,
  169. content
  170. }).then(res => {
  171. console.log("客户列表", res)
  172. this.selectComponent('#ListBox').RefreshToComplete();
  173. if (res.code != '1') return wx.showToast({
  174. title: res.msg,
  175. icon: "none"
  176. })
  177. this.setData({
  178. loading: false,
  179. content: _Http.paging(content, res),
  180. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  181. })
  182. this.getTags();
  183. })
  184. })
  185. },
  186. /* 获取列表标签 */
  187. getTags() {
  188. let list = this.data.list,
  189. ownerids = list.map(v => v.sa_customersid)
  190. _Http.basic({
  191. "id": 20221018102001,
  192. "content": {
  193. "ownertable": "sa_customers",
  194. ownerids
  195. }
  196. }).then(res => {
  197. for (let key in res.data) {
  198. let index = list.findIndex(v => v.sa_customersid == key);
  199. list[index].tags = res.data[key]
  200. };
  201. this.setData({
  202. list
  203. })
  204. })
  205. },
  206. /* 顶部条件导航回调 */
  207. navClick({
  208. detail
  209. }) {
  210. switch (detail.id) {
  211. case '1':
  212. this.setData({
  213. classShow: true
  214. })
  215. break;
  216. case '2':
  217. this.setData({
  218. 'filterShow': true
  219. })
  220. break;
  221. case '3':
  222. this.setData({
  223. 'content.sort[0].reversed': this.data.content.sort[0].reversed == 0 ? 1 : 0
  224. });
  225. this.getList(true)
  226. break;
  227. default:
  228. break;
  229. }
  230. },
  231. /* 处理搜索 */
  232. onSearch({
  233. detail
  234. }) {
  235. this.data.content.where.condition = detail;
  236. this.getList(true);
  237. },
  238. classClose() {
  239. this.setData({
  240. classShow: false
  241. })
  242. },
  243. classSelect({
  244. detail
  245. }) {
  246. if (this.data.content.type == detail.index) return this.classClose();
  247. this.setData({
  248. "content.type": detail.index,
  249. 'navList[0].label': detail.name,
  250. classActions: this.data.classActions.map(v => {
  251. v.color = detail.i == v.i ? '#3874F6' : ''
  252. return v
  253. })
  254. })
  255. this.classClose();
  256. this.getList(true)
  257. }
  258. })