index.js 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263
  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. value: "暂缓"
  130. }]
  131. }, {
  132. label: "成交状态",
  133. index: null,
  134. showName: "value", //显示字段
  135. valueKey: "tradingstatus", //返回Key
  136. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  137. value: "", //选中值
  138. list: [{
  139. value: "未成交"
  140. }, {
  141. value: "已成交"
  142. }, {
  143. value: "多次成交"
  144. }]
  145. }, {
  146. label: "标签",
  147. index: null,
  148. type: "checkbox",
  149. showName: "tag", //显示字段
  150. valueKey: "tag", //返回Key
  151. selectKey: "tag", //传参 代表选着字段 不传参返回整个选择对象
  152. value: "", //选中值
  153. list: await getTypes('tags')
  154. }]
  155. this.setData({
  156. filtratelist
  157. })
  158. },
  159. /* 处理筛选 */
  160. handleFilter({
  161. detail
  162. }) {
  163. detail.condition = this.data.content.where.condition;
  164. this.data.content.where = detail;
  165. this.getList(true);
  166. },
  167. getList(init = false) {
  168. _Http.init(this.data.content, init).then(content => {
  169. _Http.basic({
  170. "id": 20221012164402,
  171. content
  172. }).then(res => {
  173. console.log("客户列表", res)
  174. this.selectComponent('#ListBox').RefreshToComplete();
  175. if (res.code != '1') return wx.showToast({
  176. title: res.msg,
  177. icon: "none"
  178. })
  179. this.setData({
  180. loading: false,
  181. content: _Http.paging(content, res),
  182. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  183. })
  184. this.getTags();
  185. })
  186. })
  187. },
  188. /* 获取列表标签 */
  189. getTags() {
  190. let list = this.data.list,
  191. ownerids = list.map(v => v.sa_customersid)
  192. _Http.basic({
  193. "id": 20221018102001,
  194. "content": {
  195. "ownertable": "sa_customers",
  196. ownerids
  197. }
  198. }).then(res => {
  199. for (let key in res.data) {
  200. let index = list.findIndex(v => v.sa_customersid == key);
  201. list[index].tags = res.data[key]
  202. };
  203. this.setData({
  204. list
  205. })
  206. })
  207. },
  208. /* 顶部条件导航回调 */
  209. navClick({
  210. detail
  211. }) {
  212. switch (detail.id) {
  213. case '1':
  214. this.setData({
  215. classShow: true
  216. })
  217. break;
  218. case '2':
  219. this.setData({
  220. 'filterShow': true
  221. })
  222. break;
  223. case '3':
  224. this.setData({
  225. 'content.sort[0].reversed': this.data.content.sort[0].reversed == 0 ? 1 : 0
  226. });
  227. this.getList(true)
  228. break;
  229. default:
  230. break;
  231. }
  232. },
  233. /* 处理搜索 */
  234. onSearch({
  235. detail
  236. }) {
  237. this.data.content.where.condition = detail;
  238. this.getList(true);
  239. },
  240. classClose() {
  241. this.setData({
  242. classShow: false
  243. })
  244. },
  245. classSelect({
  246. detail
  247. }) {
  248. if (this.data.content.type == detail.index) return this.classClose();
  249. this.setData({
  250. "content.type": detail.index,
  251. 'navList[0].label': detail.name,
  252. classActions: this.data.classActions.map(v => {
  253. v.color = detail.i == v.i ? '#3874F6' : ''
  254. return v
  255. })
  256. })
  257. this.classClose();
  258. this.getList(true)
  259. }
  260. })