index.js 9.4 KB

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