index.js 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  1. const _Http = getApp().globalData.http,
  2. getHeight = require("../../utils/getRheRemainingHeight");
  3. Page({
  4. /* , {
  5. label: "筛选",
  6. icon: "icon-shaixuan",
  7. color: "",
  8. width: "",
  9. id: "2"
  10. } */
  11. /**
  12. * 页面的初始数据
  13. */
  14. data: {
  15. typeList: [{
  16. name: '客户报价',
  17. index: 0
  18. }, {
  19. name: '项目报价',
  20. index: 1
  21. }],
  22. typeShow: false,
  23. navList: [{
  24. label: "全部",
  25. icon: "icon-webxialaxuanxiangjiantou",
  26. color: "",
  27. width: "",
  28. id: "1"
  29. }, {
  30. label: "排序",
  31. icon: "icon-shengxu",
  32. color: "",
  33. width: "",
  34. id: "sort"
  35. }],
  36. classShow: false,
  37. classActions: [{
  38. name: '全部',
  39. index: 0
  40. }, {
  41. name: '我负责的',
  42. index: 1
  43. },
  44. {
  45. name: '我参与的',
  46. index: 2
  47. },
  48. {
  49. name: "我下属负责的",
  50. index: 3
  51. }, {
  52. name: "我下属参与的",
  53. index: 4
  54. }
  55. ],
  56. content: {
  57. "nocache": true,
  58. "type": 0,
  59. "version": 1,
  60. "pageNumber": 1,
  61. "pageSize": 20,
  62. "where": {
  63. "condition": "",
  64. "startdate": "",
  65. "enddate": "",
  66. "status": "",
  67. },
  68. "sort": []
  69. },
  70. filter: {
  71. show: false,
  72. type: ['客户报价', '项目报价'], //状态项
  73. typeActive: "",
  74. status: ['新建', '提交', '审核'], //状态项
  75. statusActive: "",
  76. startdate: "",
  77. enddate: ""
  78. }
  79. },
  80. onLoad(options) {
  81. this.getList();
  82. },
  83. /* 获取列表 */
  84. getList(init = false, data) {
  85. if (init.detail != undefined) init = init.detail;
  86. let content = this.data.content;
  87. if (init) content.pageNumber = 1;
  88. if (content.pageNumber > content.pageTotal) return;
  89. if (data) {
  90. content.where.status = data.statusActive;
  91. content.where.startdate = data.startdate;
  92. content.where.enddate = data.enddate;
  93. }
  94. _Http.basic({
  95. "id": 20220908134403,
  96. content
  97. }).then(res => {
  98. console.log("预测列表", res)
  99. this.selectComponent('#ListBox').RefreshToComplete();
  100. if (res.msg != '成功') return wx.showToast({
  101. title: res.data,
  102. icon: "none"
  103. })
  104. this.setData({
  105. 'content.pageNumber': res.pageNumber + 1,
  106. 'content.pageTotal': res.pageTotal,
  107. 'content.total': res.total,
  108. 'content.sort': res.sort,
  109. list: res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  110. });
  111. this.setListHeight();
  112. this.getTags();
  113. })
  114. },
  115. /* 处理搜索 */
  116. onSearch({
  117. detail
  118. }) {
  119. this.setData({
  120. "content.where.condition": detail
  121. });
  122. this.getList(true);
  123. },
  124. /* 获取列表标签 */
  125. getTags() {
  126. let list = this.data.list,
  127. ownerids = list.map(v => v.sa_salesforecastbillid);
  128. _Http.basic({
  129. "id": 20221018102001,
  130. "content": {
  131. nocache: true,
  132. "ownertable": "sa_salesforecastbill",
  133. ownerids
  134. }
  135. }).then(res => {
  136. console.log("标签", res)
  137. for (let key in res.data) {
  138. let index = list.findIndex(v => v.sa_salesforecastbillid == key);
  139. list[index].tags = res.data[key]
  140. };
  141. this.setData({
  142. list
  143. })
  144. })
  145. },
  146. typeCancel() {
  147. this.setData({
  148. typeShow: false
  149. })
  150. },
  151. /* 选择添加报价形式 */
  152. typeSelect({
  153. detail
  154. }) {
  155. wx.navigateTo({
  156. url: detail.name == '项目报价' ? '/packageA/offers/addProjectOffer' : '/packageA/offers/addSetclientOffer',
  157. });
  158. this.typeCancel();
  159. },
  160. onReady() {
  161. this.setListHeight();
  162. },
  163. setListHeight() {
  164. getHeight.getHeight('.total', this).then(res => {
  165. if (this.data.listHeight != res)
  166. this.setData({
  167. listHeight: res
  168. })
  169. });
  170. },
  171. /* 顶部条件导航回调 */
  172. navClick({
  173. detail
  174. }) {
  175. switch (detail.id) {
  176. case '1':
  177. this.setData({
  178. classShow: true
  179. })
  180. break;
  181. case '2':
  182. this.setData({
  183. 'filter.show': true
  184. })
  185. break;
  186. }
  187. },
  188. classClose() {
  189. this.setData({
  190. classShow: false
  191. })
  192. },
  193. classSelect({
  194. detail
  195. }) {
  196. if (this.data.content.type == detail.index) return this.classClose();
  197. this.setData({
  198. "content.type": detail.index,
  199. 'navList[0].label': detail.name
  200. })
  201. this.classClose();
  202. this.getList(true)
  203. },
  204. /* 筛选状态选择 */
  205. selectStatus(e) {
  206. const {
  207. item
  208. } = e.currentTarget.dataset;
  209. this.setData({
  210. "filter.statusActive": this.data.filter.statusActive == item ? "" : item
  211. })
  212. },
  213. /* 筛选状态选择 */
  214. typeStatus(e) {
  215. const {
  216. item
  217. } = e.currentTarget.dataset;
  218. this.setData({
  219. "filter.typeActive": this.data.filter.typeActive == item ? "" : item
  220. })
  221. },
  222. /* 处理筛选 */
  223. handleFilter({
  224. detail
  225. }) {
  226. const data = this.data.filter;
  227. if (data.typeActive) data.typeActive = data.typeActive == '客户报价' ? 0 : 1;
  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. })