index.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. loading: true,
  5. navList: [{
  6. label: "我负责的",
  7. icon: "icon-webxialaxuanxiangjiantou",
  8. color: "",
  9. width: "",
  10. id: "1"
  11. }, {
  12. label: "排序",
  13. icon: "icon-jiangxu1",
  14. color: "",
  15. width: "",
  16. id: "sort"
  17. }, {
  18. label: "筛选",
  19. icon: "icon-shaixuan",
  20. color: "",
  21. width: "",
  22. id: "2"
  23. }],
  24. classShow: false,
  25. "content": {
  26. "nocache": true,
  27. "isExport": 0,
  28. "pageNumber": 1,
  29. "pageTotal": 1,
  30. "pageSize": 20,
  31. "where": {
  32. "condition": "",
  33. "tablefilter": {},
  34. // "cluetype": "业务员",
  35. "allocationstatus": "", //分配状态
  36. "status": "", //跟进状态
  37. "tradefield": "", //领域
  38. "tag": [], //标签
  39. },
  40. },
  41. filtrate: false
  42. },
  43. onLoad(options) {
  44. getApp().globalData.Language.getLanguagePackage(this, '线索管理');
  45. this.setData({
  46. insert: wx.getStorageSync('auth').worderclue_admin.options.some(v => v == 'insert'), //查询新增权限
  47. classActions: wx.getStorageSync('templetList').map((v, i) => {
  48. return {
  49. name: v.templetname,
  50. index: v.templetid,
  51. color: i == 0 ? '#3874F6' : '',
  52. i: i,
  53. }
  54. }),
  55. 'navList[0].label': wx.getStorageSync('templetList')[0].templetname,
  56. "content.type": wx.getStorageSync('templetList')[0].templetid,
  57. });
  58. this.getList()
  59. this.getClueArea()
  60. _Http.basic({
  61. "classname": "sysmanage.develop.optiontype.optiontype",
  62. "method": "optiontypeselect",
  63. "content": {
  64. "typename": "cluesourcesift"
  65. }
  66. }).then(res => {
  67. console.log("获取来源", res)
  68. if (res.code == '1') {
  69. this.data.filtratelist.push({
  70. label: "来源",
  71. index: null,
  72. showName: "value", //显示字段
  73. valueKey: "cluesource", //返回Key
  74. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  75. value: "", //选中值
  76. list: res.data
  77. })
  78. this.setData({
  79. filtratelist: this.data.filtratelist
  80. })
  81. }
  82. })
  83. },
  84. /* 获取列表 */
  85. getList(init = false) {
  86. if (init.detail != undefined) init = init.detail;
  87. let content = this.data.content;
  88. if (init) content.pageNumber = 1;
  89. if (content.pageNumber > content.pageTotal) return;
  90. _Http.basic({
  91. "id": 20221101094302,
  92. content
  93. }).then(res => {
  94. console.log("线索管理", res)
  95. this.selectComponent('#ListBox').RefreshToComplete();
  96. if (res.code != '1') return wx.showToast({
  97. title: res.msg,
  98. icon: "none"
  99. })
  100. this.setData({
  101. loading: false,
  102. 'content.pageNumber': res.pageNumber + 1,
  103. 'content.pageTotal': res.pageTotal,
  104. 'content.total': res.total,
  105. 'content.sort': res.sort,
  106. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  107. });
  108. this.setListHeight();
  109. this.getTags();
  110. })
  111. },
  112. /* 获取线索状态 */
  113. getClueArea() {
  114. let filtratelist = [{
  115. label: "分配状态",
  116. index: null,
  117. showName: "value", //显示字段
  118. valueKey: "allocationstatus", //返回Key
  119. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  120. value: "", //选中值
  121. list: [{
  122. value: "待分配"
  123. }, {
  124. value: "已分配"
  125. }]
  126. }];
  127. _Http.basic({
  128. "classname": "sysmanage.develop.optiontype.optiontype",
  129. "method": "optiontypeselect",
  130. "content": {
  131. "typename": 'clueprivate'
  132. }
  133. }).then(res => {
  134. console.log("线索范围", res)
  135. if (res.code != '1') return wx.showToast({
  136. title: res.data,
  137. icon: "none"
  138. })
  139. filtratelist.push({
  140. label: "线索状态",
  141. index: null,
  142. showName: "value", //显示字段
  143. valueKey: "status", //返回Key
  144. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  145. value: "", //选中值
  146. list: res.data
  147. })
  148. this.setData({
  149. filtratelist
  150. })
  151. this.setListHeight();
  152. })
  153. _Http.basic({
  154. "id": 20221223141802,
  155. "content": {
  156. "pageNumber": 1,
  157. "pageSize": 9999,
  158. "where": {
  159. "condition": ""
  160. }
  161. }
  162. }, false).then(res => {
  163. console.log("获取领域", res)
  164. if (res.code == '1') {
  165. filtratelist.push({
  166. label: "领域",
  167. index: null,
  168. showName: "tradefield", //显示字段
  169. valueKey: "tradefield", //返回Key
  170. selectKey: "tradefield", //传参 代表选着字段 不传参返回整个选择对象
  171. value: "", //选中值
  172. list: res.data
  173. })
  174. this.setData({
  175. filtratelist
  176. })
  177. }
  178. })
  179. _Http.basic({
  180. "id": 20221013104401,
  181. "content": {
  182. "nochace": true,
  183. "isExport": 1,
  184. "pageNumber": 1,
  185. sys_systemtagid: 14,
  186. "pageSize": 1000,
  187. "where": {
  188. "condition": ""
  189. }
  190. }
  191. }, false).then(res => {
  192. console.log("获取标签", res)
  193. if (res.code == '1') {
  194. filtratelist.push({
  195. label: "标签",
  196. index: null,
  197. type: "checkbox",
  198. showName: "tag", //显示字段
  199. valueKey: "tag", //返回Key
  200. selectKey: "tag", //传参 代表选着字段 不传参返回整个选择对象
  201. value: "", //选中值
  202. list: res.data
  203. })
  204. this.setData({
  205. filtratelist
  206. })
  207. }
  208. })
  209. },
  210. /* 处理搜索 */
  211. onSearch({
  212. detail
  213. }) {
  214. this.setData({
  215. "content.where.condition": detail
  216. });
  217. this.getList(true);
  218. },
  219. /* 获取列表标签 */
  220. getTags() {
  221. let list = this.data.list,
  222. ownerids = list.map(v => v.sat_orderclueid);
  223. _Http.basic({
  224. "id": 20221018102001,
  225. "content": {
  226. nocache: true,
  227. "ownertable": "sat_orderclue",
  228. ownerids
  229. }
  230. }).then(res => {
  231. console.log("标签", res)
  232. for (let key in res.data) {
  233. let index = list.findIndex(v => v.sat_orderclueid == key);
  234. list[index].tags = res.data[key]
  235. };
  236. this.setData({
  237. list
  238. })
  239. })
  240. },
  241. /* 去添加 */
  242. openType() {
  243. wx.navigateTo({
  244. url: '/packageA/saleAdmin/insert',
  245. })
  246. },
  247. onReady() {
  248. this.setListHeight();
  249. },
  250. setListHeight() {
  251. this.selectComponent("#ListBox").setHeight(".total", this);
  252. },
  253. /* 顶部条件导航回调 */
  254. navClick({
  255. detail
  256. }) {
  257. switch (detail.id) {
  258. case '1':
  259. this.setData({
  260. classShow: true
  261. })
  262. break;
  263. case '2':
  264. this.setData({
  265. filtrate: true
  266. })
  267. break;
  268. }
  269. },
  270. classClose() {
  271. this.setData({
  272. classShow: false
  273. })
  274. },
  275. classSelect({
  276. detail
  277. }) {
  278. if (this.data.content.type == detail.index) return this.classClose();
  279. this.setData({
  280. "content.type": detail.index,
  281. 'navList[0].label': detail.name,
  282. classActions: this.data.classActions.map(v => {
  283. v.color = detail.i == v.i ? '#3874F6' : ''
  284. return v
  285. })
  286. })
  287. this.classClose();
  288. this.getList(true)
  289. },
  290. /* 处理筛选 */
  291. handleFilter({
  292. detail
  293. }) {
  294. console.log(detail)
  295. detail.condition = this.data.content.where.condition;
  296. this.data.content.where = detail;
  297. this.getList(true)
  298. }
  299. })