index.js 8.2 KB

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