index.js 8.5 KB

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