statistics.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684
  1. <template>
  2. <view>
  3. <!-- 公共组件-每个页面必须引入 -->
  4. <public-module></public-module>
  5. <!-- 头部信息Start -->
  6. <view class="headers " :style="headerStyle">
  7. <view class="dis a-c j-c">
  8. <text>统计</text>
  9. <!-- <view class="headers-right">
  10. <image @click="weChatService" src="/static/image/my/kefu.png" mode="">
  11. </image>
  12. <text>客服</text>
  13. </view> -->
  14. </view>
  15. </view>
  16. <view class="body-box" style="margin-top: 100px" v-if="type == 1">
  17. <view class=" dis j-s a-c" style="padding: 10px 10px 0 0;">
  18. <view class="statistics-title">新增人员汇总统计</view>
  19. <view class="search-data">
  20. <text v-for="(val, index) in year" :key="index" :class="val.startShow ? 'active' : ''"
  21. @click="onSeachYear(val, index, 1)">{{ val.lable }}</text>
  22. </view>
  23. </view>
  24. <view class="statistics-number ">
  25. <view v-if="level <= 4">
  26. <text>{{ echartsList.onePartnerNum || 0 }}</text>
  27. <text>一级合伙人</text>
  28. </view>
  29. <view v-if="level <= 3">
  30. <text>{{ echartsList.twoPartnerNum || 0 }}</text>
  31. <text>二级合伙人</text>
  32. </view>
  33. <view v-if="level <= 2">
  34. <text>{{ echartsList.threePartnerNum || 0 }}</text>
  35. <text>三级合伙人</text>
  36. </view>
  37. <view v-if="level == 1">
  38. <text>{{ echartsList.fourPartnerNum || 0 }}</text>
  39. <text>四级合伙人</text>
  40. </view>
  41. <!-- <view v-if="level==1">
  42. <text>{{ echartsList.onePartnerNum || 0 }}</text>
  43. <text>一级合伙人</text>
  44. </view>
  45. <view v-if="level<=2">
  46. <text>{{ echartsList.twoPartnerNum || 0 }}</text>
  47. <text>{{level==2?'一级合伙人':'二级合伙人'}}</text>
  48. </view>
  49. <view v-if="level<=3">
  50. <text>{{ echartsList.threePartnerNum || 0 }}</text>
  51. <text>{{level==3?'一级合伙人':level==2?'二级合伙人':'三级合伙人'}}</text>
  52. </view>
  53. <view v-if="level<=4">
  54. <text>{{ echartsList.fourPartnerNum || 0 }}</text>
  55. <text>{{level==4?'一级合伙人':level==3?'二级合伙人':level==2?'三级合伙人':'四级合伙人'}}</text>
  56. </view> -->
  57. <view>
  58. <text>{{ echartsList.workSum || 0 }}</text>
  59. <text>工作室</text>
  60. </view>
  61. <view>
  62. <text>{{ echartsList.deptSum || 0 }}</text>
  63. <text>团队</text>
  64. </view>
  65. <view>
  66. <text>{{ echartsList.deptManSum || 0 }}</text>
  67. <text>代理人</text>
  68. </view>
  69. </view>
  70. <view class="partner-type dis">
  71. <view style="width: 650px;overflow-x: auto;">
  72. <text :class="typeStatistics == val.value ? 'selected' : ''" v-for="val in partnerTypeOption"
  73. :key="val.value" @click="getPartnerType(val.value)">{{ val.lable }}</text>
  74. </view>
  75. </view>
  76. <o-empty v-if="echartsList.countUserNumVoList && echartsList.countUserNumVoList.length == 0" height="20vh" />
  77. <qiun-data-charts v-else type="area" :opts="opts1" :chartData="chartData1" />
  78. </view>
  79. <view class="body-box" v-if="type == 1">
  80. <view class=" dis j-s a-c" style="padding: 10px 10px 0 0;">
  81. <view class="statistics-title">新增人员占比分析</view>
  82. <view class="search-data">
  83. <text v-for="(val, index) in year" :key="index" :class="val.startShow ? 'active' : ''"
  84. @click="onSeachYear(val, index, 2)">{{ val.lable }}</text>
  85. </view>
  86. </view>
  87. <leverStaff @getPartnerType="getPartnerType2"></leverStaff>
  88. <!-- <o-empty v-if="echartsList.countUserNumVoList && echartsList.countUserNumVoList.length==0" height="20vh" /> -->
  89. <view class="charts-box" style="height: 200px;">
  90. <qiun-data-charts type="ring" :eopts="ringOpts" :chartData="chartsDataPie2" />
  91. </view>
  92. </view>
  93. <view class="body-box" style="padding-bottom: 10px;" v-if="type == 1">
  94. <view class=" dis j-s a-c" style="padding: 10px 10px 0 0;">
  95. <view class="statistics-title">排名</view>
  96. </view>
  97. <leverStaff @getPartnerType="getPartnerType3"></leverStaff>
  98. <view class="teamStatistics ">
  99. <view class="statisticsTitle">
  100. <view>排名</view>
  101. <view>姓名</view>
  102. <view>人数</view>
  103. <view>详情</view>
  104. </view>
  105. <block v-for="(item, index) in directLsit" :key="index">
  106. <view>
  107. <view class="statisticsContent ">
  108. <view>
  109. <image v-if="index == 0" src="/static/icon/paiming1.png" mode=""></image>
  110. <image v-else-if="index == 1" src="/static/icon/paiming2.png" mode=""></image>
  111. <image v-else-if="index == 2" src="/static/icon/paiming3.png" mode=""></image>
  112. <text v-else>{{ index + 1 }}</text>
  113. </view>
  114. <view>{{ item.userName }}</view>
  115. <view>{{ item.deptManNum }}</view>
  116. <view style="color:#739EFF ">查看</view>
  117. </view>
  118. </view>
  119. </block>
  120. <!-- <o-empty v-if="directLsit.length==0" /> -->
  121. </view>
  122. </view>
  123. <view class="body-box" style="margin-top: 100px;" v-if="type == 2">
  124. <view class=" dis j-s a-c" style="padding: 10px 10px 0 0;">
  125. <view class="statistics-title">新增人员汇总统计</view>
  126. <view class="search-data">
  127. <text v-for="(val, index) in year" :key="index" :class="val.startShow ? 'active' : ''"
  128. @click="onSeachYear(val, index, 1)">{{ val.lable }}</text>
  129. </view>
  130. </view>
  131. <view class="statistics-number ">
  132. <view>
  133. <text>{{ echartsList.countSum || 0 }}</text>
  134. <text>新增人员</text>
  135. </view>
  136. <view>
  137. <text>{{ echartsList.deptSum || 0 }}</text>
  138. <text>团队</text>
  139. </view>
  140. <view>
  141. <text>{{ echartsList.deptManSum || 0 }}</text>
  142. <text>代理人</text>
  143. </view>
  144. </view>
  145. <view class="statistics-type">
  146. <text :class="typeStatistics == 1 ? 'selected' : ''" @click="getStatistics(1)">团队</text>
  147. <text :class="typeStatistics == 2 ? 'selected' : ''" @click="getStatistics(2)">代理人</text>
  148. </view>
  149. <o-empty v-if="echartsList.countUserNumVoList && echartsList.countUserNumVoList.length == 0" height="20vh" />
  150. <qiun-data-charts v-else type="area" :opts="opts1" :chartData="chartData1" />
  151. </view>
  152. </view>
  153. </template>
  154. <script>
  155. import {
  156. mapState,
  157. } from "vuex"
  158. import leverStaff from "../components/leverStaff.vue"
  159. export default {
  160. components: {
  161. leverStaff
  162. },
  163. data() {
  164. return {
  165. beginTime: '',
  166. endTime: '',
  167. ringOpts: {
  168. color: [ '#02CDFF ','#2D97FF'],
  169. legend: {
  170. show: false // 设置图例不显示
  171. },
  172. dataLabel: true,
  173. },
  174. chartsDataPie2: {},
  175. level: '',
  176. type: null,
  177. typeStatistics: 1,
  178. typeStatistics2: 1,
  179. typeStatistics3: 1,
  180. option: {},
  181. supportStaffUrl: '',
  182. headerStyle: {
  183. backgroundColor: 'transparent',
  184. backgroundImage: 'url("/static/beijing (2).png")',
  185. backgroundSize: 'cover',
  186. backgroundPosition: '',
  187. boxShadow: ''
  188. // 其他样式属性...
  189. },
  190. year: [{
  191. lable: '日',
  192. startShow: false
  193. }, {
  194. lable: '周',
  195. startShow: false
  196. }, {
  197. lable: '月',
  198. startShow: false
  199. }],
  200. echartsList: {},
  201. analysisEchartsList: {},
  202. partnerTypeOption: [
  203. {
  204. lable: '一级合伙人',
  205. value: '1'
  206. }, {
  207. lable: '二级合伙人',
  208. value: '2'
  209. }, {
  210. lable: '三级合伙人',
  211. value: '3'
  212. }, {
  213. lable: '四级合伙人',
  214. value: '4'
  215. },
  216. ],
  217. // optsMax:10,
  218. opts1: {
  219. legend: {
  220. show: false // 设置图例不显示
  221. },
  222. yAxis: {
  223. gridType: "dash",
  224. dashLength: 2,
  225. data: [
  226. {
  227. min: 0,
  228. max: 10
  229. }
  230. ]
  231. },
  232. extra: {
  233. area: {
  234. type: "curve",
  235. opacity: 0.2,
  236. addLine: true,
  237. width: 2,
  238. gradient: true,
  239. activeType: "hollow"
  240. }
  241. // line: {
  242. // type: "curve",
  243. // width: 2,
  244. // activeType: "hollow",
  245. // linearType: "custom"
  246. // }
  247. }
  248. },
  249. chartData1: {},
  250. directLsit: []
  251. }
  252. },
  253. computed: {
  254. ...mapState(['userInfo']),
  255. },
  256. onLoad() {
  257. this.level = this.userInfo.sysUser.level
  258. if (this.level == 2) {
  259. this.partnerTypeOption = this.partnerTypeOption.slice(0, -1);
  260. }
  261. if (this.level == 3) {
  262. this.partnerTypeOption = this.partnerTypeOption.slice(0, -2);
  263. }
  264. if (this.level == 4) {
  265. this.partnerTypeOption = this.partnerTypeOption.slice(0, 1);
  266. }
  267. this.$http.get('/sys/qy/wechat/find/picture').then(res => {
  268. this.supportStaffUrl = res.data.supportStaffUrl
  269. })
  270. },
  271. onShow() {
  272. this.type = uni.getStorageSync('type')
  273. // if(this.type ==2){
  274. // this.queryData({type:1})
  275. // }
  276. // else{
  277. // this.queryData({type:1})
  278. // }
  279. this.queryData()
  280. if (this.type == 1) {
  281. this.analysisQueryData()
  282. this.rankingQueryData()
  283. }
  284. },
  285. methods: {
  286. canvasInit(canvas, width, height) {
  287. // 初始化画布
  288. this.canvas2d = canvas;
  289. },
  290. getPartnerType2(type) {
  291. this.typeStatistics2 = type
  292. this.analysisQueryData()
  293. },
  294. getPartnerType3(type) {
  295. this.typeStatistics3 = type
  296. this.rankingQueryData()
  297. },
  298. getPartnerType(type) {
  299. this.typeStatistics = type
  300. this.queryData()
  301. },
  302. getStatistics(type) {
  303. // uni.navigateTo({
  304. // url: "/pages/tools/achievement/achievement"
  305. // })
  306. // this.studioType=type
  307. this.typeStatistics = type
  308. this.queryData()
  309. },
  310. //点击跳转企业微信客服
  311. weChatService() {
  312. uni.share({
  313. provider: "weixin",
  314. openCustomerServiceChat: true,
  315. customerUrl: this.supportStaffUrl, //企业微信地址
  316. corpid: 'wwfe67d19509d43ec5', //企业id
  317. success: (res) => { },
  318. fail: (err) => { }
  319. });
  320. },
  321. onSeachYear(val, index, type) {
  322. this.year.map((value, i) => i === index ? value.startShow = !value.startShow : value.startShow = false);
  323. let now = new Date();
  324. let year = now.getFullYear();
  325. let month = now.getMonth() + 1; // 月份是从0开始的,所以需要加1
  326. let day = now.getDate();
  327. if (index == 0 && val.startShow) {
  328. let theDay = `${year}-${month.toString().padStart(2, '0')}-${day.toString().padStart(2, '0')}`;
  329. this.beginTime = theDay + ' 00:00:01'
  330. this.endTime = theDay + ' 23:59:59'
  331. type == 1 ? this.queryData() : this.analysisQueryData()
  332. }
  333. else if (index == 1 && val.startShow) {
  334. let dayOfWeek = now.getDay();
  335. let firstDayOfWeek = new Date(year, now.getMonth(), day - dayOfWeek + 1);
  336. let lastDayOfWeek = new Date(year, now.getMonth(), day + (7 - dayOfWeek));
  337. let monday = this.formatDate(firstDayOfWeek);
  338. let sunday = this.formatDate(lastDayOfWeek);
  339. this.beginTime = monday + ' 00:00:01'
  340. this.endTime = sunday + ' 23:59:59'
  341. type == 1 ? this.queryData() : this.analysisQueryData()
  342. }
  343. else if (index == 2 && val.startShow) {
  344. this.beginTime = this.getCurrentMonthFirst() + ' 00:00:01'
  345. this.endTime = this.getCurrentMonthLast() + ' 23:59:59'
  346. type == 1 ? this.queryData() : this.analysisQueryData()
  347. }
  348. else {
  349. this.beginTime = ''
  350. this.endTime = ''
  351. type == 1 ? this.queryData() : this.analysisQueryData()
  352. }
  353. },
  354. formatDate(date) {
  355. let year = date.getFullYear();
  356. let month = date.getMonth() + 1;
  357. let day = date.getDate();
  358. month = month < 10 ? '0' + month : month;
  359. day = day < 10 ? '0' + day : day;
  360. return year + '-' + month + '-' + day;
  361. },
  362. getCurrentMonthFirst() {
  363. // 获取当月第一天数据
  364. let date = new Date()
  365. date.setDate(1)
  366. let month = parseInt(date.getMonth() + 1)
  367. let day = date.getDate()
  368. if (month < 10) month = '0' + month
  369. if (day < 10) day = '0' + day
  370. return date.getFullYear() + '-' + month + '-' + day
  371. },
  372. getCurrentMonthLast() {
  373. // 获取当月最后一天数据
  374. let date = new Date()
  375. let year = date.getFullYear()
  376. let month = date.getMonth() + 1
  377. month = month < 10 ? '0' + month : month
  378. let day = new Date(year, month, 0)
  379. return year + '-' + month + '-' + day.getDate()
  380. },
  381. async analysisQueryData() {
  382. let params = {
  383. beginTime: this.beginTime,
  384. endTime: this.endTime,
  385. type: this.typeStatistics2,
  386. }
  387. let res = await this.$http.post('/APPPartner/getPartnerProportion', params);
  388. if (res.code == '200') {
  389. this.chartsDataPie2 = {
  390. series: [{
  391. // "data": [
  392. // { name: `新增`, value: res.data.newProportion, labelText: `
  393. // ${res.data.newProportion?'新增:'+res.data.newProportion+'%':false}
  394. // ` },
  395. // { name: "历史", value: res.data.oldProportion, labelText: `历史:${res.data.oldProportion}%` }
  396. // ]
  397. "data": [
  398. { name: `新增`, value: res.data.newProportion},
  399. { name: "历史", value: res.data.oldProportion}
  400. ]
  401. }]
  402. }
  403. }
  404. },
  405. async rankingQueryData() {
  406. let params = {
  407. type: this.typeStatistics3,
  408. }
  409. let res = await this.$http.get('/APPPartner/getLevelPartner', params);
  410. if (res.code == '200') {
  411. this.directLsit = res.data
  412. }
  413. },
  414. async queryData() {
  415. let params = {
  416. beginTime: this.beginTime,
  417. endTime: this.endTime,
  418. type: this.typeStatistics,
  419. }
  420. let res = {}
  421. if (this.type == 1) {
  422. res = await this.$http.post('/APPPartner/getPartnerCount', params);
  423. }
  424. else {
  425. res = await this.$http.post('/APPPartner/getCountUser', params);
  426. }
  427. if (res.code == '200') {
  428. this.echartsList = res.data
  429. if (res.data.countUserNumVoList && res.data.countUserNumVoList.length > 0) {
  430. let dateList = res.data.countUserNumVoList.map(function (item) {
  431. // return item.time.split(" ")[1] ? item.time.split(" ")[1] + ':00' : item.time.split(" ")[0]
  432. return item.time
  433. });
  434. let valueList = res.data.countUserNumVoList.map(function (item) {
  435. return item.countNum;
  436. });
  437. let rualit = {
  438. categories: dateList,
  439. series: [
  440. {
  441. name: "人数",
  442. // type: "line",
  443. data: valueList
  444. },
  445. ]
  446. };
  447. valueList.sort((a, b) => a - b)
  448. this.opts1.yAxis.data[0].max = valueList[valueList.length - 1];
  449. this.chartData1 = JSON.parse(JSON.stringify(rualit));
  450. }
  451. else {
  452. this.echartsList.countUserNumVoList = []
  453. }
  454. }
  455. }
  456. }
  457. }
  458. </script>
  459. <style lang="scss" scoped>
  460. .headers {
  461. position: fixed;
  462. top: 0;
  463. left: 0;
  464. height: auto;
  465. width: 100%;
  466. z-index: 999999;
  467. padding: 16px;
  468. padding-top: 40px;
  469. text {
  470. font-size: 18px;
  471. font-weight: 700;
  472. color: #333333;
  473. }
  474. }
  475. .headers-right {
  476. position: absolute;
  477. right: 15px;
  478. display: flex;
  479. align-items: center;
  480. text {
  481. font-size: 13px;
  482. color: #666666;
  483. }
  484. image {
  485. // right: 0;
  486. width: 15px;
  487. height: 15px;
  488. margin-right: 5px;
  489. }
  490. }
  491. .body-box {
  492. background: #ffffff;
  493. margin: 15px
  494. }
  495. .statistics-title {
  496. font-size: 16px;
  497. color: #333333;
  498. }
  499. .statistics-title::before {
  500. content: " ";
  501. display: inline-block;
  502. width: 4px;
  503. height: 12px;
  504. background: linear-gradient(132deg, #2DD9FF 0%, #2D6DFF 100%);
  505. border-radius: 5px 5px 5px 5px;
  506. margin-right: 4px;
  507. margin-top: 2px;
  508. }
  509. .search-data {
  510. color: #666666;
  511. border: 1px solid #EEEEEE;
  512. .active {
  513. color: #FFFFFF;
  514. background: linear-gradient(132deg, #2DD9FF 0%, #2D6DFF 100%);
  515. }
  516. text {
  517. padding: 5px 6px;
  518. border-left: 1px solid #EEEEEE;
  519. }
  520. text:first-child {
  521. border-left: none
  522. }
  523. }
  524. .statistics-number {
  525. margin: 10px 10px 20px 10px;
  526. background: #FBFBFB;
  527. border-radius: 4px 4px 4px 4px;
  528. text-align: center;
  529. padding: 15px 0;
  530. overflow: hidden;
  531. view {
  532. width: 33.33%;
  533. float: left;
  534. }
  535. text {
  536. display: block;
  537. }
  538. text:first-child {
  539. font-size: 25px;
  540. color: #333333;
  541. }
  542. text:last-child {
  543. font-size: 13px;
  544. color: #999999;
  545. }
  546. }
  547. .statistics-type {
  548. text-align: center;
  549. text {
  550. display: inline-block;
  551. width: 80px;
  552. height: 30px;
  553. line-height: 30px;
  554. text-align: center;
  555. font-size: 16px;
  556. color: #666666;
  557. background: #F4F4F4;
  558. }
  559. .selected {
  560. color: #FFFFFF;
  561. background: linear-gradient(132deg, #2DD9FF 0%, #2D6DFF 100%);
  562. }
  563. // text:first-child{
  564. // color: #FFFFFF;
  565. // background: linear-gradient( 132deg, #2DD9FF 0%, #2D6DFF 100%);
  566. // }
  567. }
  568. .partner-type {
  569. margin: 10px;
  570. width: 97%;
  571. overflow: hidden;
  572. white-space: nowrap;
  573. text {
  574. display: inline-block;
  575. border-radius: 14px 14px 14px 14px;
  576. font-size: 14px;
  577. color: #666666;
  578. padding: 1px 10px;
  579. background: #F4F4F4;
  580. margin-right: 8px;
  581. }
  582. .selected {
  583. color: #FFFFFF;
  584. background: linear-gradient(132deg, #2DD9FF 0%, #2D6DFF 100%);
  585. }
  586. }
  587. .teamStatistics {
  588. margin: 10px;
  589. background: #FFFFFF;
  590. // box-shadow: 0px 4px 10px 0px #DAE3F4;
  591. border-radius: 2px 2px 2px 2px;
  592. border: 1px solid #C8D8FF;
  593. }
  594. .statisticsContent {
  595. box-sizing: border-box;
  596. height: 70upx;
  597. text-align: center;
  598. line-height: 70upx;
  599. font-size: 26rpx;
  600. color: #666666;
  601. display: flex;
  602. flex-wrap: nowrap;
  603. justify-content: space-around;
  604. view {
  605. text-align: center;
  606. line-height: 70upx;
  607. width: 25%;
  608. font-size: 12px;
  609. }
  610. image {
  611. display: inline-block;
  612. width: 21px;
  613. height: 21px;
  614. vertical-align: middle;
  615. }
  616. }
  617. .statisticsTitle {
  618. display: flex;
  619. flex-wrap: nowrap;
  620. justify-content: space-around;
  621. height: 70upx;
  622. box-sizing: border-box;
  623. line-height: 70upx;
  624. font-size: 24rpx;
  625. color: #232832;
  626. background: linear-gradient(180deg, #DAE0EE 0%, #E9ECF4 100%);
  627. border-radius: 6px 6px 0 0;
  628. view {
  629. text-align: center;
  630. line-height: 35px;
  631. color: #2D6DFF;
  632. width: 25%;
  633. font-size: 12px;
  634. }
  635. }
  636. .charts-box {
  637. width: 100%;
  638. height: 300px;
  639. }
  640. </style>