index.js 6.8 KB

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