statistics.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  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>
  10. </view>
  11. <view class="body-box" style="margin-top: 100px">
  12. <view class=" dis j-s a-c" style="padding: 10px 10px 0 0;">
  13. <view class="statistics-title">新增人员汇总统计</view>
  14. <!-- 时间快捷选择 -->
  15. <view class="quickSwitchDate dis a-c j-c ">
  16. <view class="tab" :class="{active:summaryDateIndex==index}" v-for="(item,index) in quickSwitchDate"
  17. :key="index" @click="SwitchDateclick(item,index)">
  18. {{item.name}}
  19. </view>
  20. </view>
  21. </view>
  22. <!-- 人员汇总 -->
  23. <view class="statistics-number ">
  24. <view v-for="(item,index) in statistics" :key="index">
  25. <text>{{ item.count }}</text>
  26. <text>{{item.gradeName}}</text>
  27. </view>
  28. </view>
  29. <view class="partner-type dis">
  30. <view style="width: 650px;overflow-x: auto;">
  31. <text :class="summarygrade == val.grade ? 'selected' : ''" v-for="(val,index) in partnerTypeOption"
  32. :key="index" @click="getPartnerType(val,val.grade)">{{ val.gradeName }}</text>
  33. </view>
  34. </view>
  35. <o-empty v-if=" chartData1.categories && chartData1.categories.length==0" height="20vh" />
  36. <qiun-data-charts v-else type="area" :ontouch="true" :opts="opts1" :chartData="chartData1" />
  37. </view>
  38. <view class="body-box">
  39. <view class=" dis j-s a-c" style="padding: 10px 10px 0 0;">
  40. <view class="statistics-title">新增人员占比分析</view>
  41. <!-- 时间快捷选择 -->
  42. <view class="quickSwitchDate dis a-c j-c ">
  43. <view class="tab" :class="{active:ratioDateIndex==index}" v-for="(item,index) in quickSwitchDate"
  44. :key="index" @click="SwitchDateclick1(item,index)">
  45. {{item.name}}
  46. </view>
  47. </view>
  48. </view>
  49. <view class="partner-type dis">
  50. <view style="width: 650px;overflow-x: auto;">
  51. <text :class="ratiograde == val.grade ? 'selected' : ''" v-for="(val,index) in partnerTypeOption1"
  52. :key="index" @click="getPartnerType2(val,val.grade)">{{ val.gradeName }}</text>
  53. </view>
  54. </view>
  55. <view class="charts-box" style="height: 200px;">
  56. <qiun-data-charts type="ring" :eopts="ringOpts" :chartData="chartsDataPie2" />
  57. </view>
  58. </view>
  59. <view class="body-box" style="padding-bottom: 10px;">
  60. <view class=" dis j-s a-c" style="padding: 10px 10px 0 0;">
  61. <view class="statistics-title">排名</view>
  62. </view>
  63. <view class="partner-type dis">
  64. <view style="width: 650px;overflow-x: auto;">
  65. <text :class="rankgrade == val.grade ? 'selected' : ''" v-for="(val,index) in personRankingOption"
  66. :key="index" @click="getPartnerType3(val,val.grade)">{{ val.gradeName }}</text>
  67. </view>
  68. </view>
  69. <view class="teamStatistics ">
  70. <view class="statisticsTitle">
  71. <view>排名</view>
  72. <view>姓名</view>
  73. <view>人数</view>
  74. <view>详情</view>
  75. </view>
  76. <block v-for="(item, index) in directLsit" :key="index">
  77. <view>
  78. <view class="statisticsContent ">
  79. <view>
  80. <image v-if="index == 0" src="/static/icon/paiming1.png" mode=""></image>
  81. <image v-else-if="index == 1" src="/static/icon/paiming2.png" mode=""></image>
  82. <image v-else-if="index == 2" src="/static/icon/paiming3.png" mode=""></image>
  83. <text v-else>{{ index + 1 }}</text>
  84. </view>
  85. <view>{{ item.userName }}</view>
  86. <view>{{ item.number }}</view>
  87. <view style="color:#739EFF;" @click="directDetail(item.id)">查看</view>
  88. </view>
  89. </view>
  90. </block>
  91. </view>
  92. </view>
  93. </view>
  94. </template>
  95. <script>
  96. import {
  97. mapState,
  98. } from "vuex"
  99. import levertab from "../components/leverStaff.vue" //等级切换组件
  100. import tabDate from "../components/year.vue" //日期快捷选择
  101. export default {
  102. components: {
  103. levertab,
  104. tabDate
  105. },
  106. data() {
  107. return {
  108. statistics: [], //各等级人员统计
  109. summaryDateIndex: 1, //人员
  110. ratioDateIndex: 1, //汇总
  111. summarygrade: null, //汇总选中等级
  112. ratiograde: null, //占比选中等级
  113. rankgrade: null, //排名选中等级
  114. summaryCountCycle: "Week", //汇总日期选择
  115. ratioCountCycle: "Week", //占比日期选择
  116. quickSwitchDate: [{
  117. name: "日",
  118. value: "Day"
  119. },
  120. {
  121. name: "周",
  122. value: "Week"
  123. },
  124. {
  125. name: "月",
  126. value: "Month"
  127. }
  128. ],
  129. ringOpts: {
  130. color: ['#02CDFF ', '#2D97FF'],
  131. legend: {
  132. show: false // 设置图例不显示
  133. },
  134. dataLabel: true,
  135. },
  136. chartsDataPie2: {}, //图表2显示
  137. echartsList2: {},
  138. level: '',
  139. type: null,
  140. typeStatistics: 1,
  141. typeStatistics2: 1,
  142. typeStatistics3: 1,
  143. option: {},
  144. supportStaffUrl: '',
  145. headerStyle: {
  146. backgroundColor: 'transparent',
  147. backgroundImage: 'url("/static/beijing (2).png")',
  148. backgroundSize: 'cover',
  149. backgroundPosition: '',
  150. boxShadow: ''
  151. // 其他样式属性...
  152. },
  153. year: [{
  154. lable: '日',
  155. startShow: false
  156. }, {
  157. lable: '周',
  158. startShow: false
  159. }, {
  160. lable: '月',
  161. startShow: false
  162. }],
  163. echartsList: {},
  164. analysisEchartsList: {},
  165. partnerTypeOption: [],
  166. partnerTypeOption1: [], //人员占比数据
  167. personRankingOption: [], //人员排名集合
  168. directLsit: [], //排名列表数据
  169. opts1: { //图表1配置参数
  170. enableScroll: true,
  171. padding: [15, 10, 15, 0],
  172. legend: {
  173. show: false // 设置图例不显示
  174. },
  175. xAxis: {
  176. disableGrid: true,
  177. type: 'grid',
  178. gridType: 'dash',
  179. itemCount: 4, //x轴单屏显示数据的数量,默认为5个
  180. scrollShow: true, //新增是否显示滚动条,默认false
  181. scrollAlign: 'left', //滚动条初始位置
  182. scrollBackgroundColor: '#F7F7FF', //默认为 #EFEBEF
  183. scrollColor: '#A6A6A6', //默认为 #A6A6A6,
  184. fontSize: 11,
  185. },
  186. yAxis: {
  187. gridType: "dash",
  188. dashLength: 2,
  189. },
  190. extra: {
  191. area: {
  192. type: "curve",
  193. opacity: 0.2,
  194. addLine: true,
  195. width: 2,
  196. gradient: true,
  197. activeType: "hollow"
  198. },
  199. },
  200. },
  201. chartData1: {},
  202. }
  203. },
  204. computed: {
  205. ...mapState(['userInfo']),
  206. },
  207. onLoad() {
  208. this.level = this.userInfo.sysUser.level
  209. this.$http.get('/sys/qy/wechat/find/picture').then(res => {
  210. this.supportStaffUrl = res.data.supportStaffUrl
  211. })
  212. },
  213. onShow() {
  214. this.type = uni.getStorageSync('type')
  215. this.newPersonCount() //图表1
  216. this.newPersonRatioAnalysis() //图表2
  217. this.personRanking() //排名
  218. },
  219. methods: {
  220. //汇总日期切换
  221. SwitchDateclick(item, index) {
  222. this.summaryDateIndex = index;
  223. this.summaryCountCycle = item.value;
  224. this.newPersonCount();
  225. },
  226. //占比日期切换
  227. SwitchDateclick1(item, index) {
  228. this.ratioDateIndex = index;
  229. this.ratioCountCycle = item.value;
  230. this.newPersonRatioAnalysis()
  231. },
  232. canvasInit(canvas, width, height) {
  233. // 初始化画布
  234. this.canvas2d = canvas;
  235. },
  236. directDetail(val) {
  237. console.log(val);
  238. uni.navigateTo({
  239. url: "/pages/statistics/statisticsDetail?id=" + val,
  240. })
  241. },
  242. //人员汇总数据切换
  243. getPartnerType(item, type) {
  244. this.summarygrade = type;
  245. let rualit = {
  246. categories: item.data.dataTime,
  247. series: [{
  248. name: "人数",
  249. // type: "line",
  250. data: item.data.data
  251. }]
  252. };
  253. this.chartData1 = JSON.parse(JSON.stringify(rualit)); //更新图表数据
  254. },
  255. //人员占比图数据切换
  256. getPartnerType2(item, type) {
  257. this.ratiograde = type;
  258. this.chartsDataPie2 = {
  259. series: [{
  260. "data": [{
  261. name: `新增`,
  262. value: item.data.newNum,
  263. labelText: `${item.data.newNum?'新增:'+item.data.newNum+'%':'新增:0%'}`
  264. },
  265. {
  266. name: "历史",
  267. value: item.data.number,
  268. labelText: `${item.data.number?'历史:'+item.data.number+'%':'历史:0%'}`
  269. }
  270. ]
  271. }]
  272. }
  273. },
  274. //人员排名数据切换
  275. getPartnerType3(item, type) {
  276. this.rankgrade = type;
  277. this.directLsit = item.data;
  278. },
  279. //图表2
  280. async newPersonRatioAnalysis() {
  281. let params = {
  282. countCycle: this.ratioCountCycle || 'Week',
  283. }
  284. let res = await this.$http.post('/newAppPartner/userCountProportionVo', params);
  285. if (res.code == '200') {
  286. this.partnerTypeOption1 = res.data
  287. this.ratiograde = this.partnerTypeOption1[0].grade; //默认获取最高身份等级
  288. this.chartsDataPie2 = {
  289. series: [{
  290. "data": [{
  291. name: `新增`,
  292. value: res.data[0].data.newNum,
  293. labelText: `${res.data[0].data.newNum?'新增:'+res.data[0].data.newNum+'%':'新增:0%'}`
  294. },
  295. {
  296. name: "历史",
  297. value: res.data[0].data.number,
  298. labelText: `${res.data[0].data.number?'历史:'+res.data[0].data.number+'%':'历史:0%'}`
  299. }
  300. ]
  301. }]
  302. }
  303. }
  304. },
  305. //排名
  306. async personRanking() {
  307. let res = await this.$http.post('/newAppPartner/userCountRankingVo', {});
  308. if (res.code == '200') {
  309. this.personRankingOption = res.data;
  310. this.directLsit = res.data[0].data;
  311. this.rankgrade = this.personRankingOption[0].grade; //默认获取最高身份等级
  312. }
  313. },
  314. getTime(beginTime, endTime) {
  315. this.beginTime = beginTime
  316. this.endTime = endTime
  317. },
  318. //图表1
  319. async newPersonCount() {
  320. let params = {
  321. countCycle: this.summaryCountCycle || 'Week',
  322. }
  323. let res = await this.$http.post('/newAppPartner/userCountStatisticsVo', params);
  324. if (res.code == '200') {
  325. this.statistics = res.data.vo1; //统计
  326. this.partnerTypeOption = res.data.vo2; //图表数据
  327. let rualit = {
  328. categories: this.partnerTypeOption[0].data.dataTime,
  329. series: [{
  330. name: "人数",
  331. // type: "line",
  332. data: this.partnerTypeOption[0].data.data
  333. }]
  334. };
  335. this.chartData1 = JSON.parse(JSON.stringify(rualit)); //默认显示最高等级数据
  336. console.log(this.chartData1);
  337. this.summarygrade = this.partnerTypeOption[0].grade; //默认获取最高身份等级
  338. }
  339. }
  340. }
  341. }
  342. </script>
  343. <style lang="scss" scoped>
  344. .headers {
  345. position: fixed;
  346. top: 0;
  347. left: 0;
  348. height: auto;
  349. width: 100%;
  350. z-index: 999999;
  351. padding: 16px;
  352. padding-top: 40px;
  353. text {
  354. font-size: 18px;
  355. font-weight: 700;
  356. color: #333333;
  357. }
  358. }
  359. .headers-right {
  360. position: absolute;
  361. right: 15px;
  362. display: flex;
  363. align-items: center;
  364. text {
  365. font-size: 13px;
  366. color: #666666;
  367. }
  368. image {
  369. // right: 0;
  370. width: 15px;
  371. height: 15px;
  372. margin-right: 5px;
  373. }
  374. }
  375. .body-box {
  376. background: #ffffff;
  377. margin: 15px
  378. }
  379. .statistics-title {
  380. font-size: 16px;
  381. color: #333333;
  382. }
  383. .statistics-title::before {
  384. content: " ";
  385. display: inline-block;
  386. width: 4px;
  387. height: 12px;
  388. background: linear-gradient(132deg, #2DD9FF 0%, #2D6DFF 100%);
  389. border-radius: 5px 5px 5px 5px;
  390. margin-right: 4px;
  391. margin-top: 2px;
  392. }
  393. .quickSwitchDate {
  394. border: 1rpx solid #eee;
  395. border-radius: 4rpx;
  396. .tab {
  397. padding: 6rpx 12rpx;
  398. box-sizing: border-box;
  399. font-size: 27rpx;
  400. color: #666;
  401. }
  402. .active {
  403. color: #FFFFFF;
  404. background: linear-gradient(132deg, #2DD9FF 0%, #2D6DFF 100%);
  405. }
  406. }
  407. .statistics-number {
  408. margin: 10px 10px 20px 10px;
  409. background: #FBFBFB;
  410. border-radius: 4px 4px 4px 4px;
  411. text-align: center;
  412. padding: 15px 0;
  413. overflow: hidden;
  414. view {
  415. width: 33.33%;
  416. float: left;
  417. }
  418. text {
  419. display: block;
  420. }
  421. text:first-child {
  422. font-size: 25px;
  423. color: #333333;
  424. }
  425. text:last-child {
  426. font-size: 13px;
  427. color: #999999;
  428. }
  429. }
  430. .statistics-type {
  431. text-align: center;
  432. margin-bottom: 20px;
  433. text {
  434. display: inline-block;
  435. width: 80px;
  436. height: 30px;
  437. line-height: 30px;
  438. text-align: center;
  439. font-size: 16px;
  440. color: #666666;
  441. background: #F4F4F4;
  442. }
  443. .selected {
  444. color: #FFFFFF;
  445. background: linear-gradient(132deg, #2DD9FF 0%, #2D6DFF 100%);
  446. }
  447. // text:first-child{
  448. // color: #FFFFFF;
  449. // background: linear-gradient( 132deg, #2DD9FF 0%, #2D6DFF 100%);
  450. // }
  451. }
  452. .partner-type {
  453. margin: 10px;
  454. width: 97%;
  455. overflow: hidden;
  456. white-space: nowrap;
  457. text {
  458. display: inline-block;
  459. border-radius: 14px 14px 14px 14px;
  460. font-size: 14px;
  461. color: #666666;
  462. padding: 1px 10px;
  463. background: #F4F4F4;
  464. margin-right: 8px;
  465. }
  466. .selected {
  467. color: #FFFFFF;
  468. background: linear-gradient(132deg, #2DD9FF 0%, #2D6DFF 100%);
  469. }
  470. }
  471. .teamStatistics {
  472. margin: 10px;
  473. background: #FFFFFF;
  474. // box-shadow: 0px 4px 10px 0px #DAE3F4;
  475. border-radius: 2px 2px 2px 2px;
  476. border: 1px solid #C8D8FF;
  477. }
  478. .statisticsContent {
  479. box-sizing: border-box;
  480. height: 70upx;
  481. text-align: center;
  482. line-height: 70upx;
  483. font-size: 26rpx;
  484. color: #666666;
  485. display: flex;
  486. flex-wrap: nowrap;
  487. justify-content: space-around;
  488. view {
  489. text-align: center;
  490. line-height: 70upx;
  491. width: 25%;
  492. font-size: 12px;
  493. }
  494. image {
  495. display: inline-block;
  496. width: 21px;
  497. height: 21px;
  498. vertical-align: middle;
  499. }
  500. }
  501. .statisticsTitle {
  502. display: flex;
  503. flex-wrap: nowrap;
  504. justify-content: space-around;
  505. height: 70upx;
  506. box-sizing: border-box;
  507. line-height: 70upx;
  508. font-size: 24rpx;
  509. color: #232832;
  510. background: linear-gradient(180deg, #DAE0EE 0%, #E9ECF4 100%);
  511. // border-radius: 6px 6px 0 0;
  512. view {
  513. text-align: center;
  514. line-height: 35px;
  515. color: #2D6DFF;
  516. width: 25%;
  517. font-size: 12px;
  518. }
  519. }
  520. .charts-box {
  521. width: 100%;
  522. height: 300px;
  523. }
  524. </style>