manageOrgan.vue 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. <template>
  2. <div>
  3. <div
  4. class="wall"
  5. style="height: 68px"
  6. v-if="JSON.stringify(items) == '{}'"
  7. ></div>
  8. <!-- 按月/按天 -->
  9. <div class="wrap">
  10. <!-- v-if="timer == 'day'" :settings="chartSettings" DD-->
  11. <ve-histogram
  12. :data="chartData"
  13. height="524px"
  14. :data-empty="dataEmpty"
  15. :extend="chartExtend"
  16. :legend="legend"
  17. />
  18. <!-- <ve-line
  19. v-else
  20. :data-zoom="dataZoom"
  21. :settings="{
  22. area: true,
  23. }"
  24. :data="chartDataForMoth"
  25. height="350px"
  26. :data-empty="dataEmpty"
  27. :data-zoom="dataZoom"
  28. :extend="chartExtend"
  29. :legend="legend"
  30. /> -->
  31. </div>
  32. </div>
  33. </template>
  34. <script>
  35. import "echarts/lib/component/dataZoom";
  36. import countTo from "vue-count-to";
  37. // import veLine from "v-charts/lib/line.common";
  38. import histogram from "v-charts/lib/histogram.common";
  39. import searchHeader from "./searchHeader";
  40. import { getIndex } from "../../api";
  41. import { getTimes } from "@/utils";
  42. import { descs, chioseNum } from "../../constant";
  43. import { orderType } from "@/constant";
  44. export default {
  45. props: ["data", "search",],
  46. components: {
  47. // "ve-line": veLine,
  48. "count-to": countTo,
  49. "ve-histogram": histogram,
  50. searchHeader,
  51. },
  52. computed: {
  53. legend() {
  54. return {
  55. left: "10px",
  56. };
  57. },
  58. items() {
  59. let obj = {};
  60. let arr = [
  61. "TOTAL_AMOUNT",
  62. "FINANCE_AMOUNT",
  63. "FINANCE_BALANCE_AMOUNT",
  64. "FINANCE_PAY",
  65. ];
  66. arr.forEach((str) => {
  67. if (this.data[str]) {
  68. obj[str] = this.data[str];
  69. }
  70. });
  71. // console.log(obj);
  72. return obj;
  73. },
  74. items2() {
  75. let obj = {};
  76. let arr = [
  77. "APPLY_AMOUNT",
  78. "RENEW_AMOUNT",
  79. "VIP_AMOUNT",
  80. "PRACTICE_AMOUNT",
  81. "OTHER_AMOUNT",
  82. ];
  83. arr.forEach((str) => {
  84. if (this.data[str]) {
  85. obj[str] = this.data[str];
  86. }
  87. });
  88. return obj;
  89. },
  90. chartExtend() {
  91. return {
  92. series: {
  93. smooth: false,
  94. },
  95. yAxis: {
  96. //纵轴标尺固定
  97. minInterval: 1,
  98. type: "value",
  99. scale: true,
  100. min: 0,
  101. axisLabel: {
  102. formatter: "{value}元",
  103. },
  104. },
  105. tooltip: {
  106. axisPointer: {
  107. type: "shadow",
  108. shadowStyle: {
  109. color: "rgba(150,150,150,0.2)",
  110. },
  111. },
  112. formatter: (item) => {
  113. return [
  114. item[0].axisValueLabel,
  115. ...item.map(
  116. (d) => `<br/>${d.marker}${d.seriesName}: ${d.value[1]} 元`
  117. ),
  118. ].join("");
  119. },
  120. },
  121. };
  122. },
  123. dataZoom() {
  124. return [
  125. {
  126. type: "slider",
  127. start: 50,
  128. end: 100,
  129. filterMode: "empty",
  130. },
  131. ];
  132. },
  133. chartData() {
  134. const values = Object.values({ ...this.items, ...this.items2 });
  135. const months = {};
  136. for (const item of values) {
  137. for (const row of item.indexMonthData || []) {
  138. const key = this.$helpers.dayjs(row.month).format("YYYY-MM-DD");
  139. if (!months[key]) {
  140. months[key] = {
  141. 日期: key,
  142. };
  143. }
  144. months[key][item.title] = row.percent;
  145. }
  146. }
  147. // console.log(values);
  148. return {
  149. columns: [
  150. "日期",
  151. "总收入",
  152. "现金收入",
  153. "余额收入",
  154. "财务支出",
  155. "报名缴费收入",
  156. "网管课收入",
  157. "其他收入",
  158. "乐团续费收入",
  159. "VIP课收入",
  160. ],
  161. rows: Object.values(months),
  162. loading: true,
  163. };
  164. },
  165. chartDataForMoth() {
  166. const values = Object.values({ ...this.items, ...this.items2 });
  167. const months = {};
  168. for (const item of values) {
  169. for (const row of item.indexMonthData || []) {
  170. const key = this.$helpers.dayjs(row.month).format("YYYY-MM");
  171. if (!months[key]) {
  172. months[key] = {
  173. 月份: key,
  174. };
  175. months[key][item.title] = row.percent;
  176. } else {
  177. if (months[key][item.title]) {
  178. months[key][item.title] = (
  179. parseFloat(months[key][item.title]) + parseFloat(row.percent)
  180. ).toFixed(2);
  181. } else {
  182. months[key][item.title] = parseFloat(row.percent).toFixed(2);
  183. }
  184. }
  185. }
  186. }
  187. return {
  188. columns: [
  189. "月份",
  190. "总收入",
  191. "现金收入",
  192. "余额收入",
  193. "财务支出",
  194. "报名缴费收入",
  195. "网管课收入",
  196. "其他收入",
  197. "乐团续费收入",
  198. "VIP课收入",
  199. ],
  200. rows: Object.values(months),
  201. loading: true,
  202. };
  203. },
  204. dataEmpty() {
  205. return !this.chartData.rows.length;
  206. },
  207. },
  208. data() {
  209. // this.chartSettings = {
  210. // stack: { 总收入: [`现金收入`, `余额收入`] },
  211. // };
  212. return {
  213. orderType,
  214. active: "SHOULD_INCOME_MONEY",
  215. mdate: [],
  216. loading: false,
  217. endDate: "",
  218. show: true,
  219. activeName: "first",
  220. timer:'day'
  221. };
  222. },
  223. mounted() {
  224. this.init();
  225. },
  226. methods: {
  227. init() {
  228. // this.$refs.searchHeader.initStatue("month");
  229. this.mdate = this.getInitDate();
  230. this.endDate = this.$helpers.dayjs(new Date()).format("YYYY-MM-DD");
  231. this.isDayOrMoth(this.mdate);
  232. // // this.$refs.searchHeader.initStatue()
  233. // this.changeValue(this.mdate);
  234. },
  235. // changeValue(date) {
  236. // // 请求更改数据
  237. // this.mdate = date;
  238. // this.isDayOrMoth(date);
  239. // this.FetchDetail();
  240. // },
  241. // async FetchDetail() {
  242. // this.loading = true;
  243. // let data = [];
  244. // try {
  245. // const { dates, ...rest } = this.search;
  246. // const res = await getIndex({
  247. // ...rest,
  248. // ...getTimes(this.mdate, ["startDate", "endDate"]),
  249. // //
  250. // dataTypes:
  251. // "FINANCE_AMOUNT,FINANCE_BALANCE_AMOUNT,FINANCE_PAY,TOTAL_AMOUNT",
  252. // });
  253. // for (const item of res.data) {
  254. // // 再循环一遍
  255. // for (const key in { ...this.items, ...this.items2 }) {
  256. // // console.log(key);
  257. // if (item.dataType == key) {
  258. // data[item.dataType] = {
  259. // ...item,
  260. // desc: descs[item.dataType],
  261. // };
  262. // }
  263. // }
  264. // }
  265. // } catch (error) {
  266. // console.log(error);
  267. // }
  268. // this.loading = false;
  269. // this.$emit("resetDate", data);
  270. // },
  271. isDayOrMoth(arr) {
  272. if (!arr || arr.length < 1) {
  273. this.timer = "day";
  274. } else {
  275. const count = this.$helpers
  276. .dayjs(arr[0])
  277. .diff(this.$helpers.dayjs(arr[1]), "day");
  278. Math.abs(count) > chioseNum
  279. ? (this.timer = "month")
  280. : (this.timer = "day");
  281. }
  282. },
  283. getInitDate() {
  284. const end = this.$helpers.dayjs(new Date()).format("YYYY-MM-DD");
  285. const start = this.$helpers
  286. .dayjs(new Date())
  287. .set("date", 1)
  288. .format("YYYY-MM-DD");
  289. return [start, end];
  290. },
  291. },
  292. };
  293. </script>
  294. <style lang="less" scoped>
  295. /deep/.description-title {
  296. margin-bottom: 0;
  297. }
  298. #management .statistic .statistic-content > span {
  299. &:first-child {
  300. font-size: 14px !important;
  301. }
  302. font-size: 18px !important;
  303. }
  304. .chioseBox {
  305. position: absolute;
  306. right: 20px;
  307. z-index: 1000;
  308. }
  309. .wrap {
  310. position: relative;
  311. }
  312. .blod {
  313. font-weight: bold;
  314. color: var(--color-primary);
  315. font-size: 22px !important;
  316. }
  317. // .chioseBox {
  318. // position: absolute;
  319. // right: 20px;
  320. // z-index: 1000;
  321. // }
  322. // .wrap {
  323. // position: relative;
  324. // }
  325. .statisticWrap {
  326. // box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.08);
  327. border-radius: 4px;
  328. border: 1px solid #ebeef5;
  329. padding-top: 10px;
  330. margin-bottom: 10px;
  331. position: relative;
  332. &:after {
  333. top: -16px;
  334. margin-left: calc(10% - 14px);
  335. border-top-width: 0;
  336. border-color: transparent;
  337. border-bottom-color: #fff;
  338. content: " ";
  339. border-width: 8px;
  340. position: absolute;
  341. display: block;
  342. width: 0;
  343. height: 0;
  344. border-style: solid;
  345. z-index: 101;
  346. }
  347. &:before {
  348. top: -20px;
  349. margin-left: calc(10% - 16px);
  350. border-top-width: 0;
  351. border-color: transparent;
  352. border-bottom-color: #ebeef5;
  353. content: " ";
  354. border-width: 10px;
  355. position: absolute;
  356. display: block;
  357. width: 0;
  358. height: 0;
  359. border-style: solid;
  360. z-index: 100;
  361. }
  362. }
  363. </style>