index.js 7.3 KB

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