index.js 9.5 KB

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