operateEcharts.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. <template>
  2. <div>
  3. <div class="eachartTop">
  4. <SearchHeader
  5. title="时间筛选: "
  6. :isShowQuert="true"
  7. :dates="mdate"
  8. :endDate="endDate"
  9. @changeValue="changeValue"
  10. />
  11. </div>
  12. <statistic :col="6" class="statistic" :cols="12">
  13. <statistic-item>
  14. <span>
  15. 现金总收入: (元)
  16. </span>
  17. <span>
  18. <count-to
  19. :endVal="totalAmount"
  20. :duration="300"
  21. :decimals="2"
  22. class="blod"
  23. />
  24. </span>
  25. </statistic-item>
  26. <statistic-item>
  27. <span>
  28. 管乐迷现金收入: (元)
  29. </span>
  30. <span>
  31. <count-to
  32. :endVal="gymTotal"
  33. :duration="300"
  34. :decimals="2"
  35. :class="'des'"
  36. />
  37. </span>
  38. </statistic-item>
  39. <statistic-item>
  40. <span>
  41. 酷乐秀现金收入: (元)
  42. </span>
  43. <span>
  44. <count-to
  45. :endVal="colexiuTotal"
  46. :duration="300"
  47. :decimals="2"
  48. :class="'des'"
  49. />
  50. </span>
  51. </statistic-item>
  52. <statistic-item>
  53. <span>
  54. 管乐团现金收入: (元)
  55. </span>
  56. <span>
  57. <count-to
  58. :endVal="gytTotal"
  59. :duration="300"
  60. :decimals="2"
  61. :class="'des'"
  62. />
  63. </span>
  64. </statistic-item>
  65. <statistic-item>
  66. <span>
  67. 课堂乐器现金收入: (元)
  68. </span>
  69. <span>
  70. <count-to
  71. :endVal="ktyqTotal"
  72. :duration="300"
  73. :decimals="2"
  74. :class="'des'"
  75. />
  76. </span>
  77. </statistic-item>
  78. <statistic-item>
  79. <span>
  80. 酷乐秀机构版现金收入: (元)
  81. </span>
  82. <span>
  83. <count-to
  84. :endVal="colexiuTenantTotal"
  85. :duration="300"
  86. :decimals="2"
  87. :class="'des'"
  88. />
  89. </span>
  90. </statistic-item>
  91. </statistic>
  92. <div></div>
  93. <div class="operateEcharts">
  94. <div class="eachartTitle">
  95. <div>
  96. 管乐迷现金收入:
  97. <count-to
  98. :endVal="gymTotal"
  99. :duration="300"
  100. :decimals="2"
  101. class="des"
  102. />
  103. </div>
  104. <el-select
  105. clearable
  106. filterable
  107. placeholder="请选择分部"
  108. v-model="organId"
  109. @change="
  110. () => {
  111. this.isChangeOrgan = true;
  112. this.getData();
  113. }
  114. "
  115. >
  116. <el-option
  117. v-for="(item, index) in selects.branchs"
  118. :key="index"
  119. :label="item.name"
  120. :value="item.id"
  121. ></el-option>
  122. </el-select>
  123. </div>
  124. <div class="gym-echarts"></div>
  125. <div class="eachartTitle">
  126. <div>
  127. 酷乐秀现金收入:
  128. <count-to
  129. :endVal="colexiuTotal"
  130. :duration="300"
  131. :decimals="2"
  132. class="des"
  133. />
  134. </div>
  135. </div>
  136. <div class="colexiu-echarts"></div>
  137. <div class="eachartTitle">
  138. <div>
  139. 管乐团现金收入:
  140. <count-to
  141. :endVal="gytTotal"
  142. :duration="300"
  143. :decimals="2"
  144. class="des"
  145. />
  146. </div>
  147. </div>
  148. <div class="gyt-echarts"></div>
  149. <div class="eachartTitle">
  150. <div>
  151. 课堂乐器现金收入:
  152. <count-to
  153. :endVal="ktyqTotal"
  154. :duration="300"
  155. :decimals="2"
  156. class="des"
  157. />
  158. </div>
  159. </div>
  160. <div class="ktyq-echarts"></div>
  161. <div class="eachartTitle">
  162. <div>
  163. 酷乐秀机构版现金收入:
  164. <count-to
  165. :endVal="colexiuTenantTotal"
  166. :duration="300"
  167. :decimals="2"
  168. class="des"
  169. />
  170. </div>
  171. </div>
  172. <div class="colexiu-tenant-echarts"></div>
  173. </div>
  174. </div>
  175. </template>
  176. <script>
  177. import echarts from "echarts";
  178. import CountTo from "vue-count-to";
  179. import { multiDataSourceHomeStatsSummerIncome } from "../../api";
  180. import SearchHeader from "./searchDayHeader";
  181. import { getTimes } from "@/utils";
  182. export default {
  183. components: {
  184. CountTo,
  185. SearchHeader
  186. },
  187. data() {
  188. return {
  189. organId: "",
  190. mdate: [],
  191. endDate: "",
  192. gymECharts: null,
  193. gymData: [],
  194. gymTotal: 0,
  195. gytEcharts: null,
  196. gytData: [],
  197. gytTotal: 0,
  198. colexiuEcharts: null,
  199. colexiuData: [],
  200. colexiuTotal: 0,
  201. ktyqEcharts: null,
  202. ktyqData: [],
  203. ktyqTotal: 0,
  204. colexiuTenantEcharts: null,
  205. colexiuTenantData: [],
  206. colexiuTenantTotal: 0,
  207. isChangeOrgan: false
  208. };
  209. },
  210. mounted() {
  211. this.mdate = this.getInitDate();
  212. this.endDate = this.$helpers.dayjs(new Date()).format("YYYY-MM-DD");
  213. this.getData();
  214. window.addEventListener("resize", this.resize);
  215. },
  216. beforeDestroy() {
  217. window.removeEventListener("resize", this.resize);
  218. },
  219. methods: {
  220. getInitDate() {
  221. const end = this.$helpers.dayjs(new Date()).format("YYYY-MM-DD");
  222. const start = this.$helpers
  223. .dayjs(new Date())
  224. // .set("month", 1)
  225. .subtract(1, "month")
  226. .format("YYYY-MM-DD");
  227. return [start, end];
  228. },
  229. getData() {
  230. multiDataSourceHomeStatsSummerIncome({
  231. ...getTimes(this.mdate, ["startTime", "endTime"]),
  232. organIds: this.organId
  233. }).then(res => {
  234. if (Array.isArray(res.data)) {
  235. const gym = res.data.find(item => item.platform == "gym");
  236. if (gym) {
  237. this.gymTotal = gym.totalAmount;
  238. this.gymData = gym.incomeByDates;
  239. }
  240. // 切换分部只更新管乐迷数据
  241. if (this.isChangeOrgan) {
  242. this.isChangeOrgan = false;
  243. this.createGym();
  244. return;
  245. }
  246. const gyt = res.data.find(item => item.platform == "gyt");
  247. if (gyt) {
  248. this.gytTotal = gyt.totalAmount;
  249. this.gytData = gyt.incomeByDates;
  250. }
  251. const clx = res.data.find(item => item.platform == "cls");
  252. if (clx) {
  253. this.colexiuTotal = clx.totalAmount;
  254. this.colexiuData = clx.incomeByDates;
  255. }
  256. const ktyq = res.data.find(item => item.platform == "kt");
  257. if (ktyq) {
  258. this.ktyqTotal = ktyq.totalAmount;
  259. this.ktyqData = ktyq.incomeByDates;
  260. }
  261. const clxt = res.data.find(item => item.platform == "clsOrg");
  262. if (clxt) {
  263. this.colexiuTenantTotal = clxt.totalAmount;
  264. this.colexiuTenantData = clxt.incomeByDates;
  265. }
  266. this.$nextTick(() => {
  267. this.init();
  268. });
  269. }
  270. });
  271. },
  272. changeValue(date) {
  273. // 请求更改数据
  274. this.mdate = date;
  275. this.getData();
  276. },
  277. resize() {
  278. this.gymECharts.resize();
  279. this.gytEcharts.resize();
  280. this.colexiuEcharts.resize();
  281. this.ktyqEcharts.resize();
  282. this.colexiuTenantEcharts.resize();
  283. },
  284. init() {
  285. this.createGym();
  286. this.createGyt();
  287. this.createColexiu();
  288. this.createColexiuTenant();
  289. this.createKtyq();
  290. },
  291. createGym() {
  292. if (this.gymECharts) {
  293. this.gymECharts.dispose();
  294. }
  295. this.gymECharts = echarts.init(document.querySelector(".gym-echarts"));
  296. const option = {
  297. title: {
  298. top: "0%",
  299. text: "",
  300. textStyle: {
  301. color: "#333",
  302. fontSize: 14
  303. }
  304. },
  305. tooltip: {
  306. trigger: "axis",
  307. formatter: function(data) {
  308. const item = data[0];
  309. return `${item.axisValue}<br /> ${item.marker} ${item.value.toFixed(
  310. 2
  311. )}元`;
  312. }
  313. },
  314. grid: {
  315. left: 5,
  316. top: 30,
  317. right: 5,
  318. bottom: 5,
  319. containLabel: true
  320. },
  321. xAxis: {
  322. type: "category",
  323. data: this.gymData.map(item => item.date),
  324. axisLabel: {
  325. color: "#333",
  326. fontSize: 10
  327. }
  328. },
  329. yAxis: {
  330. type: "value",
  331. axisLabel: { formatter: "{value}元" }
  332. },
  333. series: [
  334. {
  335. data: this.gymData.map(item => item.totalAmount),
  336. type: "bar",
  337. color: "#00a79d",
  338. barMaxWidth: 40
  339. }
  340. ]
  341. };
  342. option && this.gymECharts.setOption(option);
  343. },
  344. createGyt() {
  345. if (this.gytEcharts) {
  346. this.gytEcharts.dispose();
  347. }
  348. this.gytEcharts = echarts.init(document.querySelector(".gyt-echarts"));
  349. const option = {
  350. grid: {
  351. left: 5,
  352. top: 30,
  353. right: 5,
  354. bottom: 5,
  355. containLabel: true
  356. },
  357. tooltip: {
  358. trigger: "axis",
  359. formatter: function(data) {
  360. const item = data[0];
  361. return `${item.axisValue}<br /> ${item.marker} ${item.value.toFixed(
  362. 2
  363. )}元`;
  364. }
  365. },
  366. xAxis: {
  367. type: "category",
  368. data: this.gytData.map(item => item.date),
  369. axisLabel: {
  370. color: "#333",
  371. fontSize: 10
  372. }
  373. },
  374. yAxis: {
  375. type: "value",
  376. axisLabel: { formatter: "{value}元" }
  377. },
  378. series: [
  379. {
  380. data: this.gytData.map(item => item.totalAmount),
  381. type: "bar",
  382. color: "#00a79d",
  383. barMaxWidth: 40
  384. }
  385. ]
  386. };
  387. option && this.gytEcharts.setOption(option);
  388. },
  389. createColexiu() {
  390. if (this.colexiuEcharts) {
  391. this.colexiuEcharts.dispose();
  392. }
  393. this.colexiuEcharts = echarts.init(
  394. document.querySelector(".colexiu-echarts")
  395. );
  396. const option = {
  397. grid: {
  398. left: 5,
  399. top: 30,
  400. right: 5,
  401. bottom: 5,
  402. containLabel: true
  403. },
  404. tooltip: {
  405. trigger: "axis",
  406. formatter: function(data) {
  407. const item = data[0];
  408. return `${item.axisValue}<br /> ${item.marker} ${item.value.toFixed(
  409. 2
  410. )}元`;
  411. }
  412. },
  413. xAxis: {
  414. type: "category",
  415. data: this.colexiuData.map(item => item.date),
  416. axisLabel: {
  417. color: "#333",
  418. fontSize: 10
  419. }
  420. },
  421. yAxis: {
  422. type: "value",
  423. axisLabel: { formatter: "{value}元" }
  424. },
  425. series: [
  426. {
  427. data: this.colexiuData.map(item => item.totalAmount),
  428. type: "bar",
  429. color: "#00a79d",
  430. barMaxWidth: 40
  431. }
  432. ]
  433. };
  434. option && this.colexiuEcharts.setOption(option);
  435. },
  436. createColexiuTenant() {
  437. if (this.colexiuTenantEcharts) {
  438. this.colexiuTenantEcharts.dispose();
  439. }
  440. this.colexiuTenantEcharts = echarts.init(
  441. document.querySelector(".colexiu-tenant-echarts")
  442. );
  443. const option = {
  444. grid: {
  445. left: 5,
  446. top: 30,
  447. right: 5,
  448. bottom: 5,
  449. containLabel: true
  450. },
  451. tooltip: {
  452. trigger: "axis",
  453. formatter: function(data) {
  454. const item = data[0];
  455. return `${item.axisValue}<br /> ${item.marker} ${item.value.toFixed(
  456. 2
  457. )}元`;
  458. }
  459. },
  460. xAxis: {
  461. type: "category",
  462. data: this.colexiuTenantData.map(item => item.date),
  463. axisLabel: {
  464. color: "#333",
  465. fontSize: 10
  466. }
  467. },
  468. yAxis: {
  469. type: "value",
  470. axisLabel: { formatter: "{value}元" }
  471. },
  472. series: [
  473. {
  474. data: this.colexiuTenantData.map(item => item.totalAmount),
  475. type: "bar",
  476. color: "#00a79d",
  477. barMaxWidth: 40
  478. }
  479. ]
  480. };
  481. option && this.colexiuTenantEcharts.setOption(option);
  482. },
  483. createKtyq() {
  484. if (this.ktyqEcharts) {
  485. this.ktyqEcharts.dispose();
  486. }
  487. this.ktyqEcharts = echarts.init(document.querySelector(".ktyq-echarts"));
  488. const option = {
  489. grid: {
  490. left: 5,
  491. top: 30,
  492. right: 5,
  493. bottom: 5,
  494. containLabel: true
  495. },
  496. tooltip: {
  497. trigger: "axis",
  498. formatter: function(data) {
  499. const item = data[0];
  500. return `${item.axisValue}<br /> ${item.marker} ${item.value.toFixed(
  501. 2
  502. )}元`;
  503. }
  504. },
  505. xAxis: {
  506. type: "category",
  507. data: this.ktyqData.map(item => item.date),
  508. axisLabel: {
  509. color: "#333",
  510. fontSize: 10
  511. }
  512. },
  513. yAxis: {
  514. type: "value",
  515. axisLabel: { formatter: "{value}元" }
  516. },
  517. series: [
  518. {
  519. data: this.ktyqData.map(item => item.totalAmount),
  520. type: "bar",
  521. color: "#00a79d",
  522. barMaxWidth: 40
  523. }
  524. ]
  525. };
  526. option && this.ktyqEcharts.setOption(option);
  527. }
  528. },
  529. computed: {
  530. totalAmount() {
  531. return this.gymTotal + this.gytTotal + this.colexiuTotal;
  532. }
  533. }
  534. };
  535. </script>
  536. <style lang="less" scoped>
  537. .eachartTop {
  538. margin-bottom: 20px;
  539. // display: flex;
  540. // align-items: center;
  541. // justify-content: space-between;
  542. // flex-wrap: wrap;
  543. // ::v-deep .box {
  544. // margin-right: 5px;
  545. // }
  546. // ::v-deep .shape {
  547. // display: none;
  548. // }
  549. }
  550. .eachartTitle {
  551. display: flex;
  552. align-items: center;
  553. justify-content: space-between;
  554. }
  555. .operateEcharts {
  556. // display: flex;
  557. .gym-echarts,
  558. .gyt-echarts,
  559. .colexiu-echarts,
  560. .ktyq-echarts,
  561. .colexiu-tenant-echarts {
  562. width: 100%;
  563. height: 350px;
  564. margin-bottom: 24px;
  565. }
  566. }
  567. .statistic .statistic-content > span {
  568. &:first-child {
  569. font-size: 14px !important;
  570. }
  571. font-size: 18px !important;
  572. }
  573. .blod {
  574. font-weight: bold !important;
  575. color: var(--color-primary) !important;
  576. font-size: 22px !important;
  577. }
  578. .des {
  579. font-size: 18px !important;
  580. color: var(--color-primary);
  581. }
  582. </style>