index.js 8.0 KB

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