statistics.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560
  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. },
  210. onShow() {
  211. this.type = uni.getStorageSync('type')
  212. this.newPersonCount() //图表1
  213. this.newPersonRatioAnalysis() //图表2
  214. this.personRanking() //排名
  215. },
  216. methods: {
  217. //汇总日期切换
  218. SwitchDateclick(item, index) {
  219. this.summaryDateIndex = index;
  220. this.summaryCountCycle = item.value;
  221. this.newPersonCount();
  222. },
  223. //占比日期切换
  224. SwitchDateclick1(item, index) {
  225. this.ratioDateIndex = index;
  226. this.ratioCountCycle = item.value;
  227. this.newPersonRatioAnalysis()
  228. },
  229. canvasInit(canvas, width, height) {
  230. // 初始化画布
  231. this.canvas2d = canvas;
  232. },
  233. directDetail(val) {
  234. console.log(val);
  235. uni.navigateTo({
  236. url: "/pages/statistics/statisticsDetail?id=" + val,
  237. })
  238. },
  239. //人员汇总数据切换
  240. getPartnerType(item, type) {
  241. this.summarygrade = type;
  242. let rualit = {
  243. categories: item.data.dataTime,
  244. series: [{
  245. name: "人数",
  246. // type: "line",
  247. data: item.data.data
  248. }]
  249. };
  250. this.chartData1 = JSON.parse(JSON.stringify(rualit)); //更新图表数据
  251. },
  252. //人员占比图数据切换
  253. getPartnerType2(item, type) {
  254. this.ratiograde = type;
  255. this.chartsDataPie2 = {
  256. series: [{
  257. "data": [{
  258. name: `新增`,
  259. value: item.data.newNum,
  260. labelText: `${item.data.newNum?'新增:'+item.data.newNum+'%':'新增:0%'}`
  261. },
  262. {
  263. name: "历史",
  264. value: item.data.number,
  265. labelText: `${item.data.number?'历史:'+item.data.number+'%':'历史:0%'}`
  266. }
  267. ]
  268. }]
  269. }
  270. },
  271. //人员排名数据切换
  272. getPartnerType3(item, type) {
  273. this.rankgrade = type;
  274. this.directLsit = item.data;
  275. },
  276. //图表2
  277. async newPersonRatioAnalysis() {
  278. let params = {
  279. countCycle: this.ratioCountCycle || 'Week',
  280. }
  281. let res = await this.$http.post('/newAppPartner/userCountProportionVo', params);
  282. if (res.code == '200') {
  283. this.partnerTypeOption1 = res.data
  284. this.ratiograde = this.partnerTypeOption1[0].grade; //默认获取最高身份等级
  285. this.chartsDataPie2 = {
  286. series: [{
  287. "data": [{
  288. name: `新增`,
  289. value: res.data[0].data.newNum,
  290. labelText: `${res.data[0].data.newNum?'新增:'+res.data[0].data.newNum+'%':'新增:0%'}`
  291. },
  292. {
  293. name: "历史",
  294. value: res.data[0].data.number,
  295. labelText: `${res.data[0].data.number?'历史:'+res.data[0].data.number+'%':'历史:0%'}`
  296. }
  297. ]
  298. }]
  299. }
  300. }
  301. },
  302. //排名
  303. async personRanking() {
  304. let res = await this.$http.post('/newAppPartner/userCountRankingVo', {});
  305. if (res.code == '200') {
  306. this.personRankingOption = res.data;
  307. this.directLsit = res.data[0].data;
  308. this.rankgrade = this.personRankingOption[0].grade; //默认获取最高身份等级
  309. }
  310. },
  311. getTime(beginTime, endTime) {
  312. this.beginTime = beginTime
  313. this.endTime = endTime
  314. },
  315. //图表1
  316. async newPersonCount() {
  317. let params = {
  318. countCycle: this.summaryCountCycle || 'Week',
  319. }
  320. let res = await this.$http.post('/newAppPartner/userCountStatisticsVo', params);
  321. if (res.code == '200') {
  322. this.statistics = res.data.vo1; //统计
  323. this.partnerTypeOption = res.data.vo2; //图表数据
  324. let rualit = {
  325. categories: this.partnerTypeOption[0].data.dataTime,
  326. series: [{
  327. name: "人数",
  328. // type: "line",
  329. data: this.partnerTypeOption[0].data.data
  330. }]
  331. };
  332. this.chartData1 = JSON.parse(JSON.stringify(rualit)); //默认显示最高等级数据
  333. console.log(this.chartData1);
  334. this.summarygrade = this.partnerTypeOption[0].grade; //默认获取最高身份等级
  335. }
  336. }
  337. }
  338. }
  339. </script>
  340. <style lang="scss" scoped>
  341. .headers {
  342. position: fixed;
  343. top: 0;
  344. left: 0;
  345. height: auto;
  346. width: 100%;
  347. z-index: 999999;
  348. padding: 16px;
  349. padding-top: 40px;
  350. text {
  351. font-size: 18px;
  352. font-weight: 700;
  353. color: #333333;
  354. }
  355. }
  356. .headers-right {
  357. position: absolute;
  358. right: 15px;
  359. display: flex;
  360. align-items: center;
  361. text {
  362. font-size: 13px;
  363. color: #666666;
  364. }
  365. image {
  366. // right: 0;
  367. width: 15px;
  368. height: 15px;
  369. margin-right: 5px;
  370. }
  371. }
  372. .body-box {
  373. background: #ffffff;
  374. margin: 15px
  375. }
  376. .statistics-title {
  377. font-size: 16px;
  378. color: #333333;
  379. }
  380. .statistics-title::before {
  381. content: " ";
  382. display: inline-block;
  383. width: 4px;
  384. height: 12px;
  385. background: linear-gradient(132deg, #2DD9FF 0%, #2D6DFF 100%);
  386. border-radius: 5px 5px 5px 5px;
  387. margin-right: 4px;
  388. margin-top: 2px;
  389. }
  390. .quickSwitchDate {
  391. border: 1rpx solid #eee;
  392. border-radius: 4rpx;
  393. .tab {
  394. padding: 6rpx 12rpx;
  395. box-sizing: border-box;
  396. font-size: 27rpx;
  397. color: #666;
  398. }
  399. .active {
  400. color: #FFFFFF;
  401. background: linear-gradient(132deg, #2DD9FF 0%, #2D6DFF 100%);
  402. }
  403. }
  404. .statistics-number {
  405. margin: 10px 10px 20px 10px;
  406. background: #FBFBFB;
  407. border-radius: 4px 4px 4px 4px;
  408. text-align: center;
  409. padding: 15px 0;
  410. overflow: hidden;
  411. view {
  412. width: 33.33%;
  413. float: left;
  414. }
  415. text {
  416. display: block;
  417. }
  418. text:first-child {
  419. font-size: 25px;
  420. color: #333333;
  421. }
  422. text:last-child {
  423. font-size: 13px;
  424. color: #999999;
  425. }
  426. }
  427. .statistics-type {
  428. text-align: center;
  429. margin-bottom: 20px;
  430. text {
  431. display: inline-block;
  432. width: 80px;
  433. height: 30px;
  434. line-height: 30px;
  435. text-align: center;
  436. font-size: 16px;
  437. color: #666666;
  438. background: #F4F4F4;
  439. }
  440. .selected {
  441. color: #FFFFFF;
  442. background: linear-gradient(132deg, #2DD9FF 0%, #2D6DFF 100%);
  443. }
  444. // text:first-child{
  445. // color: #FFFFFF;
  446. // background: linear-gradient( 132deg, #2DD9FF 0%, #2D6DFF 100%);
  447. // }
  448. }
  449. .partner-type {
  450. margin: 10px;
  451. width: 97%;
  452. overflow: hidden;
  453. white-space: nowrap;
  454. text {
  455. display: inline-block;
  456. border-radius: 14px 14px 14px 14px;
  457. font-size: 14px;
  458. color: #666666;
  459. padding: 1px 10px;
  460. background: #F4F4F4;
  461. margin-right: 8px;
  462. }
  463. .selected {
  464. color: #FFFFFF;
  465. background: linear-gradient(132deg, #2DD9FF 0%, #2D6DFF 100%);
  466. }
  467. }
  468. .teamStatistics {
  469. margin: 10px;
  470. background: #FFFFFF;
  471. // box-shadow: 0px 4px 10px 0px #DAE3F4;
  472. border-radius: 2px 2px 2px 2px;
  473. border: 1px solid #C8D8FF;
  474. }
  475. .statisticsContent {
  476. box-sizing: border-box;
  477. height: 70upx;
  478. text-align: center;
  479. line-height: 70upx;
  480. font-size: 26rpx;
  481. color: #666666;
  482. display: flex;
  483. flex-wrap: nowrap;
  484. justify-content: space-around;
  485. view {
  486. text-align: center;
  487. line-height: 70upx;
  488. width: 25%;
  489. font-size: 12px;
  490. }
  491. image {
  492. display: inline-block;
  493. width: 21px;
  494. height: 21px;
  495. vertical-align: middle;
  496. }
  497. }
  498. .statisticsTitle {
  499. display: flex;
  500. flex-wrap: nowrap;
  501. justify-content: space-around;
  502. height: 70upx;
  503. box-sizing: border-box;
  504. line-height: 70upx;
  505. font-size: 24rpx;
  506. color: #232832;
  507. background: linear-gradient(180deg, #DAE0EE 0%, #E9ECF4 100%);
  508. // border-radius: 6px 6px 0 0;
  509. view {
  510. text-align: center;
  511. line-height: 35px;
  512. color: #2D6DFF;
  513. width: 25%;
  514. font-size: 12px;
  515. }
  516. }
  517. .charts-box {
  518. width: 100%;
  519. height: 300px;
  520. }
  521. </style>