123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374 |
- <template >
- <el-card id="management">
- <div slot="header" class="clearfix">
- <searchHeader
- :dates="mdate"
- :title="'经营数据'"
- @changeValue="changeValue"
- :isShowQuert="true"
- :endDate="endDate"
- ref="searchHeader"
- />
- </div>
- <el-tabs v-model="activeName">
- <el-tab-pane label="总览" name="first">
- <div v-if="activeName == 'first'">
- <manageOrganAll :data="data" :search="search" ref='manageOrganAll'/>
- </div>
- </el-tab-pane>
- <el-tab-pane label="分部数据" name="second">
- <div v-if="activeName == 'second'">
- <manageOrgan :data="data" :search="search" ref='manageOrgan'/>
- </div>
- </el-tab-pane>
- </el-tabs>
- </el-card>
- </template>
- <script>
- import "echarts/lib/component/dataZoom";
- import countTo from "vue-count-to";
- import veLine from "v-charts/lib/line.common";
- import histogram from "v-charts/lib/histogram.common";
- import searchHeader from "./modals/searchDayHeader";
- import { getIndex } from "../api";
- import { getTimes } from "@/utils";
- import { descs, chioseNum } from "../constant";
- import { orderType } from "@/constant";
- import manageOrganAll from "./modals/manageOrganAll";
- import manageOrgan from "./modals/manageOrgan";
- export default {
- props: ["data", "search"],
- components: {
- "ve-line": veLine,
- "count-to": countTo,
- "ve-histogram": histogram,
- searchHeader,
- manageOrganAll,
- manageOrgan
- },
- computed: {
- legend() {
- return {
- left: "10px",
- };
- },
- items() {
- let obj = {};
- let arr = [
- "TOTAL_AMOUNT",
- "FINANCE_AMOUNT",
- "FINANCE_BALANCE_AMOUNT",
- "FINANCE_PAY",
- ];
- arr.forEach((str) => {
- if (this.data[str]) {
- obj[str] = this.data[str];
- }
- });
- // console.log(obj);
- return obj;
- },
- items2() {
- let obj = {};
- let arr = [
- "APPLY_AMOUNT",
- "RENEW_AMOUNT",
- "VIP_AMOUNT",
- "PRACTICE_AMOUNT",
- "OTHER_AMOUNT",
- ];
- arr.forEach((str) => {
- if (this.data[str]) {
- obj[str] = this.data[str];
- }
- });
- return obj;
- },
- chartExtend() {
- return {
- series: {
- smooth: false,
- },
- yAxis: {
- //纵轴标尺固定
- minInterval: 1,
- type: "value",
- scale: true,
- min: 0,
- axisLabel: {
- formatter: "{value}元",
- },
- },
- tooltip: {
- axisPointer: {
- type: "shadow",
- shadowStyle: {
- color: "rgba(150,150,150,0.2)",
- },
- },
- formatter: (item) => {
- return [
- item[0].axisValueLabel,
- ...item.map(
- (d) => `<br/>${d.marker}${d.seriesName}: ${d.value[1]} 元`
- ),
- ].join("");
- },
- },
- };
- },
- dataZoom() {
- return [
- {
- type: "slider",
- start: 50,
- end: 100,
- filterMode: "empty",
- },
- ];
- },
- chartData() {
- const values = Object.values({ ...this.items, ...this.items2 });
- const months = {};
- for (const item of values) {
- for (const row of item.indexMonthData || []) {
- const key = this.$helpers.dayjs(row.month).format("YYYY-MM-DD");
- if (!months[key]) {
- months[key] = {
- 日期: key,
- };
- }
- months[key][item.title] = row.percent;
- }
- }
- // console.log(values);
- return {
- columns: [
- "日期",
- "总收入",
- "现金收入",
- "余额收入",
- "财务支出",
- "报名缴费收入",
- "网管课收入",
- "其他收入",
- "乐团续费收入",
- "VIP课收入",
- ],
- rows: Object.values(months),
- loading: true,
- };
- },
- chartDataForMoth() {
- const values = Object.values({ ...this.items, ...this.items2 });
- const months = {};
- for (const item of values) {
- for (const row of item.indexMonthData || []) {
- const key = this.$helpers.dayjs(row.month).format("YYYY-MM");
- if (!months[key]) {
- months[key] = {
- 月份: key,
- };
- months[key][item.title] = row.percent;
- } else {
- if (months[key][item.title]) {
- months[key][item.title] = (
- parseFloat(months[key][item.title]) + parseFloat(row.percent)
- ).toFixed(2);
- } else {
- months[key][item.title] = parseFloat(row.percent).toFixed(2);
- }
- }
- }
- }
- return {
- columns: [
- "月份",
- "总收入",
- "现金收入",
- "余额收入",
- "财务支出",
- "报名缴费收入",
- "网管课收入",
- "其他收入",
- "乐团续费收入",
- "VIP课收入",
- ],
- rows: Object.values(months),
- loading: true,
- };
- },
- dataEmpty() {
- return !this.chartData.rows.length;
- },
- },
- data() {
- // this.chartSettings = {
- // stack: { 总收入: [`现金收入`, `余额收入`] },
- // };
- return {
- orderType,
- active: "SHOULD_INCOME_MONEY",
- timer: "day",
- mdate: [],
- loading: false,
- endDate: "",
- show: true,
- activeName: "first",
- };
- },
- mounted() {
- this.init();
- },
- methods: {
- init() {
- this.$refs.searchHeader.initStatue("month");
- this.mdate = this.getInitDate();
- this.endDate = this.$helpers.dayjs(new Date()).format("YYYY-MM-DD");
- // this.$refs.searchHeader.initStatue()
- this.changeValue(this.mdate);
- },
- changeValue(date) {
- // 请求更改数据
- this.mdate = date;
- // this.isDayOrMoth(date);
- if(this.$refs.manageOrganAll&&this.$refs.manageOrganAll.isDayOrMoth){
- this.$refs.manageOrganAll.isDayOrMoth(date)
- }
- this.FetchDetail();
- },
- async FetchDetail() {
- this.loading = true;
- let data = [];
- try {
- const { dates, ...rest } = this.search;
- const res = await getIndex({
- ...rest,
- ...getTimes(this.mdate, ["startDate", "endDate"]),
- //
- dataTypes:
- "FINANCE_AMOUNT,FINANCE_BALANCE_AMOUNT,FINANCE_PAY,TOTAL_AMOUNT",
- });
- for (const item of res.data) {
- // 再循环一遍
- for (const key in { ...this.items, ...this.items2 }) {
- // console.log(key);
- if (item.dataType == key) {
- data[item.dataType] = {
- ...item,
- desc: descs[item.dataType],
- };
- }
- }
- }
- } catch (error) {
- console.log(error);
- }
- this.loading = false;
- this.$emit("resetDate", data);
- },
- isDayOrMoth(arr) {
- if (!arr || arr.length < 1) {
- this.timer = "day";
- } else {
- const count = this.$helpers
- .dayjs(arr[0])
- .diff(this.$helpers.dayjs(arr[1]), "day");
- Math.abs(count) > chioseNum
- ? (this.timer = "month")
- : (this.timer = "day");
- }
- },
- getInitDate() {
- const end = this.$helpers.dayjs(new Date()).format("YYYY-MM-DD");
- const start = this.$helpers
- .dayjs(new Date())
- .set("date", 1)
- .format("YYYY-MM-DD");
- return [start, end];
- },
- changeTimer(val){
- this.timer = val
- }
- },
- };
- </script>
- <style lang="less" scoped>
- /deep/.description-title {
- margin-bottom: 0;
- }
- #management .statistic .statistic-content > span {
- &:first-child {
- font-size: 14px !important;
- }
- font-size: 18px !important;
- }
- .chioseBox {
- position: absolute;
- right: 20px;
- z-index: 1000;
- }
- .wrap {
- position: relative;
- }
- .blod {
- font-weight: bold;
- color: var(--color-primary);
- font-size: 22px !important;
- }
- // .chioseBox {
- // position: absolute;
- // right: 20px;
- // z-index: 1000;
- // }
- // .wrap {
- // position: relative;
- // }
- .statisticWrap {
- // box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.08);
- border-radius: 4px;
- border: 1px solid #ebeef5;
- padding-top: 10px;
- margin-bottom: 10px;
- position: relative;
- &:after {
- top: -16px;
- margin-left: calc(10% - 14px);
- border-top-width: 0;
- border-color: transparent;
- border-bottom-color: #fff;
- content: " ";
- border-width: 8px;
- position: absolute;
- display: block;
- width: 0;
- height: 0;
- border-style: solid;
- z-index: 101;
- }
- &:before {
- top: -20px;
- margin-left: calc(10% - 16px);
- border-top-width: 0;
- border-color: transparent;
- border-bottom-color: #ebeef5;
- content: " ";
- border-width: 10px;
- position: absolute;
- display: block;
- width: 0;
- height: 0;
- border-style: solid;
- z-index: 100;
- }
- }
- </style>
|