index.js 8.0 KB

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