index.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. const _Http = getApp().globalData.http;
  2. import {
  3. getTypes
  4. } from "./modules/query";
  5. Page({
  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. nocache: true,
  29. deleted: 0,
  30. "type": 1,
  31. "pageNumber": 1,
  32. "pageSize": 20,
  33. "where": {
  34. "condition": "", //模糊搜索
  35. "startdate": "",
  36. "enddate": "",
  37. "status": "", //项目状态
  38. "projecttype": "", //项目类型
  39. "stagename": "", //项目阶段
  40. "tag": "" //标签
  41. },
  42. "sort": []
  43. },
  44. filter: {
  45. show: false,
  46. status: ['跟进中', '已成交', '已失败'], //状态项
  47. statusActive: "",
  48. projectTypeList: [], //项目类型项
  49. typeActive: "",
  50. tagList: [], //标签
  51. tagActive: "",
  52. stageList: [], //项目阶段项目
  53. stageActive: "",
  54. startdate: "",
  55. enddate: ""
  56. }
  57. },
  58. async onLoad(options) {
  59. this.setData({
  60. classActions: wx.getStorageSync('templetList').map(v => {
  61. return {
  62. name: v.templetname,
  63. index: v.templetid
  64. }
  65. }),
  66. 'navList[0].label': wx.getStorageSync('templetList')[0].templetname,
  67. "content.type": wx.getStorageSync('templetList')[0].templetid,
  68. insert: wx.getStorageSync('auth').wproject.options.some(v => v == 'insert'), //查询新增权限
  69. });
  70. this.getList();
  71. let filtratelist = [{
  72. label: "项目类型",
  73. index: null,
  74. showName: "value", //显示字段
  75. valueKey: "projecttype", //返回Key
  76. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  77. value: "", //选中值
  78. list: await getTypes('projecttype')
  79. }, {
  80. label: "项目等级",
  81. index: null,
  82. showName: "value", //显示字段
  83. valueKey: "grade", //返回Key
  84. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  85. value: "", //选中值
  86. list: await getTypes('projectgrade')
  87. }, {
  88. label: "当前项目阶段",
  89. index: null,
  90. showName: "stagename", //显示字段
  91. valueKey: "stagename", //返回Key
  92. selectKey: "stagename", //传参 代表选着字段 不传参返回整个选择对象
  93. value: "", //选中值
  94. list: await getTypes('stagename')
  95. }, {
  96. label: "领域",
  97. index: null,
  98. showName: "value", //显示字段
  99. valueKey: "tradefield", //返回Key
  100. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  101. value: "", //选中值
  102. list: await getTypes('tradefield')
  103. },
  104. {
  105. label: "品牌",
  106. index: null,
  107. showName: "brandname", //显示字段
  108. valueKey: "brandname", //返回Key
  109. selectKey: "brandname", //传参 代表选着字段 不传参返回整个选择对象
  110. value: "", //选中值
  111. list: await getTypes('brandname')
  112. },
  113. {
  114. label: "项目状态",
  115. index: null,
  116. showName: "value", //显示字段
  117. valueKey: "status", //返回Key
  118. selectKey: "value", //传参 代表选着字段 不传参返回整个选择对象
  119. value: "", //选中值
  120. list: [{
  121. value: "跟进中"
  122. }, {
  123. value: "已成交"
  124. }, {
  125. value: "已失败"
  126. }]
  127. }, {
  128. label: "标签",
  129. index: null,
  130. showName: "tag", //显示字段
  131. valueKey: "tag", //返回Key
  132. selectKey: "tag", //传参 代表选着字段 不传参返回整个选择对象
  133. value: "", //选中值
  134. list: await getTypes('tags')
  135. }
  136. ]
  137. console.log(filtratelist)
  138. this.setData({
  139. filtratelist
  140. })
  141. },
  142. /* 处理搜索 */
  143. onSearch({
  144. detail
  145. }) {
  146. this.data.content.where.condition = detail;
  147. this.getList(true);
  148. },
  149. /* 获取列表 */
  150. getList(init = false, data) {
  151. if (init.detail != undefined) init = init.detail;
  152. let content = this.data.content;
  153. if (init) content.pageNumber = 1;
  154. if (content.pageNumber > content.pageTotal) return;
  155. if (data) {
  156. content.where.status = data.statusActive;
  157. content.where.projecttype = data.typeActive;
  158. content.where.stagename = data.stageActive;
  159. content.where.tag = data.tagActive;
  160. content.where.startdate = data.startdate;
  161. content.where.enddate = data.enddate;
  162. }
  163. _Http.basic({
  164. "id": 20221020143502,
  165. content
  166. }).then(res => {
  167. console.log("客户商机列表", res)
  168. this.selectComponent('#ListBox').RefreshToComplete();
  169. if (res.msg != '成功') return wx.showToast({
  170. title: res.msg,
  171. icon: "none"
  172. })
  173. content.pageNumber = res.pageNumber + 1;
  174. content.pageTotal = res.pageTotal;
  175. content.total = res.total;
  176. content.sort = res.sort;
  177. res.data = res.data.map(v => {
  178. v.progress = v.stage / v.totalstage * 100;
  179. return v
  180. })
  181. this.data.list = res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  182. this.setListHeight();
  183. this.getTags();
  184. })
  185. },
  186. /* 获取列表标签 */
  187. getTags() {
  188. let list = this.data.list,
  189. ownerids = list.map(v => v.sa_projectid);
  190. _Http.basic({
  191. "id": 20221018102001,
  192. "content": {
  193. nocache: true,
  194. "ownertable": "sa_project",
  195. ownerids
  196. }
  197. }).then(res => {
  198. for (let key in res.data) {
  199. let index = list.findIndex(v => v.sa_projectid == key);
  200. list[index].tags = res.data[key]
  201. };
  202. this.setData({
  203. list,
  204. content: this.data.content
  205. })
  206. })
  207. },
  208. /* 添加 */
  209. toAdd() {
  210. wx.navigateTo({
  211. url: '/packageA/project/addAndEdit'
  212. })
  213. },
  214. /* 处理筛选 */
  215. handleFilter({
  216. detail
  217. }) {
  218. detail.condition = this.data.content.where.condition;
  219. this.data.content.where = detail;
  220. console.log(detail)
  221. this.getList(true);
  222. },
  223. /* 顶部条件导航回调 */
  224. navClick({
  225. detail
  226. }) {
  227. switch (detail.id) {
  228. case '1':
  229. this.setData({
  230. classShow: true
  231. })
  232. break;
  233. case '2':
  234. this.setData({
  235. filterShow: true
  236. })
  237. break;
  238. }
  239. },
  240. classClose() {
  241. this.setData({
  242. classShow: false
  243. })
  244. },
  245. classSelect({
  246. detail
  247. }) {
  248. if (this.data.content.type == detail.index) return this.classClose();
  249. this.setData({
  250. "content.type": detail.index,
  251. 'navList[0].label': detail.name
  252. })
  253. this.classClose();
  254. this.getList(true)
  255. },
  256. onReady() {
  257. this.setListHeight();
  258. },
  259. setListHeight() {
  260. this.selectComponent("#ListBox").setHeight(".total", this);
  261. }
  262. })