index.js 8.3 KB

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