index.js 7.3 KB

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