index.js 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. const _Http = getApp().globalData.http;
  2. Page({
  3. data: {
  4. navList: [{
  5. label: "我负责的",
  6. icon: "icon-webxialaxuanxiangjiantou",
  7. color: "",
  8. width: "",
  9. id: "1"
  10. }, {
  11. label: "排序",
  12. icon: "icon-jiangxu1",
  13. color: "",
  14. width: "",
  15. id: "sort"
  16. }, {
  17. label: "筛选",
  18. icon: "icon-shaixuan",
  19. color: "",
  20. width: "",
  21. id: "2"
  22. }],
  23. classShow: false,
  24. content: {
  25. nocache: true,
  26. deleted: 0,
  27. "type": 1,
  28. "pageNumber": 1,
  29. "pageSize": 20,
  30. "where": {
  31. "condition": "", //模糊搜索
  32. "startdate": "",
  33. "enddate": "",
  34. "status": "", //项目状态
  35. "projecttype": "", //项目类型
  36. "stagename": "", //项目阶段
  37. "tag": "" //标签
  38. },
  39. "sort": []
  40. },
  41. filter: {
  42. show: false,
  43. status: ['跟进中', '已成交', '已失败'], //状态项
  44. statusActive: "",
  45. projectTypeList: [], //项目类型项
  46. typeActive: "",
  47. tagList: [], //标签
  48. tagActive: "",
  49. stageList: [], //项目阶段项目
  50. stageActive: "",
  51. startdate: "",
  52. enddate: ""
  53. }
  54. },
  55. onLoad(options) {
  56. this.setData({
  57. classActions: wx.getStorageSync('templetList').map(v => {
  58. return {
  59. name: v.templetname,
  60. index: v.templetid
  61. }
  62. }),
  63. 'navList[0].label': wx.getStorageSync('templetList')[0].templetname,
  64. "content.type": wx.getStorageSync('templetList')[0].templetid,
  65. insert: wx.getStorageSync('auth').wproject.options.some(v => v == 'insert'), //查询新增权限
  66. });
  67. this.getList();
  68. //获取所有阶段
  69. this.getStage();
  70. //获取所有标签
  71. this.getTagList()
  72. },
  73. /* 处理搜索 */
  74. onSearch({
  75. detail
  76. }) {
  77. this.data.content.where.condition = detail;
  78. this.getList(true);
  79. },
  80. /* 获取列表 */
  81. getList(init = false, data) {
  82. if (init.detail != undefined) init = init.detail;
  83. let content = this.data.content;
  84. if (init) content.pageNumber = 1;
  85. if (content.pageNumber > content.pageTotal) return;
  86. if (data) {
  87. content.where.status = data.statusActive;
  88. content.where.projecttype = data.typeActive;
  89. content.where.stagename = data.stageActive;
  90. content.where.tag = data.tagActive;
  91. content.where.startdate = data.startdate;
  92. content.where.enddate = data.enddate;
  93. }
  94. _Http.basic({
  95. "id": 20221020143502,
  96. content
  97. }).then(res => {
  98. console.log("客户商机列表", res)
  99. this.selectComponent('#ListBox').RefreshToComplete();
  100. if (res.msg != '成功') return wx.showToast({
  101. title: res.msg,
  102. icon: "none"
  103. })
  104. content.pageNumber = res.pageNumber + 1;
  105. content.pageTotal = res.pageTotal;
  106. content.total = res.total;
  107. content.sort = res.sort;
  108. res.data = res.data.map(v => {
  109. v.progress = v.stage / v.totalstage * 100;
  110. return v
  111. })
  112. this.data.list = res.pageNumber == 1 ? res.data : this.data.list.concat(res.data)
  113. this.setListHeight();
  114. this.getTags();
  115. })
  116. },
  117. /* 获取列表标签 */
  118. getTags() {
  119. let list = this.data.list,
  120. ownerids = list.map(v => v.sa_projectid);
  121. _Http.basic({
  122. "id": 20221018102001,
  123. "content": {
  124. nocache: true,
  125. "ownertable": "sa_project",
  126. ownerids
  127. }
  128. }).then(res => {
  129. for (let key in res.data) {
  130. let index = list.findIndex(v => v.sa_projectid == key);
  131. list[index].tags = res.data[key]
  132. };
  133. this.setData({
  134. list,
  135. content: this.data.content
  136. })
  137. })
  138. },
  139. /* 添加 */
  140. toAdd() {
  141. wx.navigateTo({
  142. url: '/packageA/project/addAndEdit'
  143. })
  144. },
  145. /* 处理筛选 */
  146. handleFilter({
  147. detail
  148. }) {
  149. const data = this.data.filter;
  150. switch (detail) {
  151. case 'confirm':
  152. this.setData({
  153. 'filter.show': false
  154. });
  155. this.getList(true, data);
  156. break;
  157. case 'reset':
  158. this.setData({
  159. 'filter.statusActive': "",
  160. 'filter.typeActive': "",
  161. 'filter.tagActive': "",
  162. 'filter.stageActive': "",
  163. 'filter.startdate': "",
  164. 'filter.enddate': "",
  165. });
  166. this.getList(true, this.data.filter)
  167. break;
  168. case 'close':
  169. this.setData({
  170. 'filter.show': false
  171. });
  172. break;
  173. }
  174. },
  175. /* 筛选状态选择 */
  176. selectStatus(e) {
  177. const {
  178. item
  179. } = e.currentTarget.dataset;
  180. this.setData({
  181. "filter.statusActive": this.data.filter.statusActive == item ? "" : item
  182. })
  183. },
  184. /* 筛选标签选择 */
  185. selectTag(e) {
  186. const {
  187. item
  188. } = e.currentTarget.dataset;
  189. this.setData({
  190. "filter.tagActive": this.data.filter.tagActive == item.tag ? "" : item.tag
  191. })
  192. },
  193. /* 筛选项目类 */
  194. selectTypeName(e) {
  195. const {
  196. value
  197. } = e.currentTarget.dataset.item;
  198. if (this.data.filter.typeActive == value) return;
  199. this.setData({
  200. "filter.typeActive": value
  201. });
  202. },
  203. /* 筛选阶段 */
  204. stageStatus(e) {
  205. const {
  206. stagename
  207. } = e.currentTarget.dataset.item;
  208. this.setData({
  209. "filter.stageActive": stagename
  210. })
  211. },
  212. /* 筛选日期范围 */
  213. changeDate(e) {
  214. const name = e.currentTarget.dataset.name,
  215. value = e.detail.value;
  216. this.setData({
  217. [`filter.${name}`]: value
  218. })
  219. },
  220. /* 顶部条件导航回调 */
  221. navClick({
  222. detail
  223. }) {
  224. switch (detail.id) {
  225. case '1':
  226. this.setData({
  227. classShow: true
  228. })
  229. break;
  230. case '2':
  231. _Http.basic({
  232. "classname": "sysmanage.develop.optiontype.optiontype",
  233. "method": "optiontypeselect",
  234. "content": {
  235. nocache: true,
  236. "pageNumber": 1,
  237. "pageSize": 999,
  238. "typename": "projecttype",
  239. "parameter": {
  240. "siteid": wx.getStorageSync('siteP').siteid
  241. }
  242. }
  243. }).then(res => {
  244. console.log("项目类型", res)
  245. if (res.msg != '成功') return wx.showToast({
  246. title: res.data,
  247. icon: "none"
  248. })
  249. this.setData({
  250. 'filter.show': true,
  251. 'filter.projectTypeList': res.data,
  252. })
  253. })
  254. break;
  255. }
  256. },
  257. classClose() {
  258. this.setData({
  259. classShow: false
  260. })
  261. },
  262. classSelect({
  263. detail
  264. }) {
  265. if (this.data.content.type == detail.index) return this.classClose();
  266. this.setData({
  267. "content.type": detail.index,
  268. 'navList[0].label': detail.name
  269. })
  270. this.classClose();
  271. this.getList(true)
  272. },
  273. onReady() {
  274. this.setListHeight();
  275. },
  276. setListHeight() {
  277. this.selectComponent("#ListBox").setHeight(".total", this);
  278. },
  279. /* 获取所有阶段 */
  280. getStage() {
  281. _Http.basic({
  282. "id": 20221116104502,
  283. "content": {
  284. nocache: true,
  285. }
  286. }, false).then(res => {
  287. if (res.msg != '成功') return wx.showToast({
  288. title: res.data,
  289. icon: "none"
  290. })
  291. this.setData({
  292. "filter.stageList": res.data
  293. })
  294. })
  295. },
  296. /* 获取所有标签 */
  297. getTagList() {
  298. _Http.basic({
  299. "id": 20220929085401,
  300. "content": {
  301. "ownertable": 'sa_project',
  302. "ownerid": ""
  303. }
  304. }, false).then(res => {
  305. console.log("标签", res)
  306. this.setData({
  307. "filter.tagList": res.data.option
  308. })
  309. })
  310. },
  311. onShareAppMessage() {}
  312. })