index.js 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. /**
  4. * 页面的初始数据
  5. */
  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. classShow: false,
  27. content: {
  28. "isAll": 0,
  29. "nocache": true,
  30. deleted: 0,
  31. "version": 1,
  32. "pageNumber": 1,
  33. "pageSize": 20,
  34. type: 1,
  35. "where": {
  36. "condition": "",
  37. },
  38. "sort": []
  39. },
  40. filter: {
  41. show: false,
  42. status: ['新建', '发布', '结束'], //状态项
  43. statusActive: "",
  44. startdate: "",
  45. enddate: ""
  46. }
  47. },
  48. onLoad(options) {
  49. this.setData({
  50. insert: wx.getStorageSync('auth').worderclue.options.some(v => v == 'insert'), //查询新增权限
  51. classActions: wx.getStorageSync('templetList').map(v => {
  52. return {
  53. name: v.templetname,
  54. index: v.templetid
  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, data) {
  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. if (data) {
  70. content.where.status = data.statusActive;
  71. }
  72. _Http.basic({
  73. "id": 20221101094502,
  74. content
  75. }).then(res => {
  76. console.log("线索", res)
  77. this.selectComponent('#ListBox').RefreshToComplete();
  78. if (res.msg != '成功') return wx.showToast({
  79. title: res.msg,
  80. icon: "none"
  81. })
  82. res.data = res.data.map(v => {
  83. v.progress = v.stage / v.totalstage * 100;
  84. return v
  85. })
  86. this.setData({
  87. 'content.pageNumber': res.pageNumber + 1,
  88. 'content.pageTotal': res.pageTotal,
  89. 'content.total': res.total,
  90. 'content.sort': res.sort,
  91. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  92. });
  93. this.setListHeight();
  94. this.getTags();
  95. })
  96. },
  97. /* 获取线索状态 */
  98. getClueArea() {
  99. _Http.basic({
  100. "classname": "sysmanage.develop.optiontype.optiontype",
  101. "method": "optiontypeselect",
  102. "content": {
  103. "typename": 'clueprivate'
  104. }
  105. }).then(res => {
  106. console.log("线索范围", res)
  107. if (res.msg != '成功') return wx.showToast({
  108. title: res.data,
  109. icon: "none"
  110. })
  111. let status = res.data.map(item => {
  112. return item.value
  113. })
  114. this.setData({
  115. 'filter.status': status
  116. });
  117. this.setListHeight();
  118. })
  119. },
  120. /* 处理搜索 */
  121. onSearch({
  122. detail
  123. }) {
  124. this.setData({
  125. "content.where.condition": detail
  126. });
  127. this.getList(true);
  128. },
  129. /* 获取列表标签 */
  130. getTags() {
  131. let list = this.data.list,
  132. ownerids = list.map(v => v.sat_orderclueid);
  133. _Http.basic({
  134. "id": 20221018102001,
  135. "content": {
  136. nocache: true,
  137. "ownertable": "sat_orderclue",
  138. ownerids
  139. }
  140. }).then(res => {
  141. console.log("标签", res)
  142. for (let key in res.data) {
  143. let index = list.findIndex(v => v.sat_orderclueid == key);
  144. list[index].tags = res.data[key]
  145. };
  146. this.setData({
  147. list
  148. })
  149. })
  150. },
  151. /* 去添加 */
  152. openType() {
  153. wx.navigateTo({
  154. url: '/packageA/saleClue/addClue',
  155. })
  156. },
  157. /* 选择添加报价形式 */
  158. typeSelect({
  159. detail
  160. }) {
  161. wx.navigateTo({
  162. url: detail.name == '项目报价' ? '/packageA/offers/addProjectOffer' : '/packageA/offers/addSetclientOffer',
  163. });
  164. this.typeCancel();
  165. },
  166. onReady() {
  167. this.setListHeight();
  168. },
  169. setListHeight() {
  170. this.selectComponent("#ListBox").setHeight(".total", this);
  171. },
  172. /* 顶部条件导航回调 */
  173. navClick({
  174. detail
  175. }) {
  176. switch (detail.id) {
  177. case '1':
  178. this.setData({
  179. classShow: true
  180. })
  181. break;
  182. case '2':
  183. this.setData({
  184. 'filter.show': true
  185. })
  186. break;
  187. }
  188. },
  189. classClose() {
  190. this.setData({
  191. classShow: false
  192. })
  193. },
  194. classSelect({
  195. detail
  196. }) {
  197. if (this.data.content.type == detail.index) return this.classClose();
  198. this.setData({
  199. "content.type": detail.index,
  200. 'navList[0].label': detail.name
  201. })
  202. this.classClose();
  203. this.getList(true)
  204. },
  205. /* 筛选状态选择 */
  206. selectStatus(e) {
  207. const {
  208. item
  209. } = e.currentTarget.dataset;
  210. this.setData({
  211. "filter.statusActive": this.data.filter.statusActive == item ? "" : item
  212. })
  213. },
  214. /* 筛选状态选择 */
  215. typeStatus(e) {
  216. const {
  217. item
  218. } = e.currentTarget.dataset;
  219. this.setData({
  220. "filter.typeActive": this.data.filter.typeActive == item ? "" : item
  221. })
  222. },
  223. /* 处理筛选 */
  224. handleFilter({
  225. detail
  226. }) {
  227. const data = this.data.filter;
  228. switch (detail) {
  229. case 'confirm':
  230. this.setData({
  231. 'filter.show': false
  232. });
  233. this.getList(true, data);
  234. break;
  235. case 'reset':
  236. this.setData({
  237. 'filter.statusActive': "",
  238. 'filter.typeActive': "",
  239. 'filter.startdate': "",
  240. 'filter.enddate': "",
  241. });
  242. this.getList(true, this.data.filter)
  243. break;
  244. case 'close':
  245. this.setData({
  246. 'filter.show': false
  247. });
  248. break;
  249. }
  250. },
  251. onShareAppMessage() {
  252. }
  253. })