index.js 9.3 KB

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