index.js 8.8 KB

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