index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <div class="container main">
  3. <save-form
  4. inline
  5. :model="search"
  6. @submit="FetchDetail"
  7. @reset="reset"
  8. saveKey="/main/main/baseInfo"
  9. >
  10. <!-- <el-form-item prop="year">
  11. <el-date-picker
  12. v-model="search.dates"
  13. type="daterange"
  14. align="right"
  15. unlink-panels
  16. range-separator="至"
  17. start-placeholder="开始日期"
  18. end-placeholder="结束日期"
  19. :picker-options="pickerOptions">
  20. </el-date-picker>
  21. </el-form-item> -->
  22. <el-form-item prop="organId">
  23. <el-select
  24. clearable
  25. filterable
  26. placeholder="请选择分部"
  27. v-model="search.organId"
  28. >
  29. <el-option
  30. v-for="(item, index) in selects.branchs"
  31. :key="index"
  32. :label="item.name"
  33. :value="item.id"
  34. ></el-option>
  35. </el-select>
  36. </el-form-item>
  37. <el-button native-type="submit" type="primary">搜索</el-button>
  38. <el-button native-type="reset" type="danger">重置</el-button>
  39. </save-form>
  40. <!-- <el-alert type="info" :closable="false" style="margin-bottom: 20px;">
  41. 每日0点更新前一日数据
  42. </el-alert> -->
  43. <!-- 这里显示选项卡 -->
  44. <empty desc="暂无统计数据" v-if="isEmpty" />
  45. <el-row v-else class="rows" :gutter="20">
  46. <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
  47. <studentbaseinfo :data="dataInfo" />
  48. </el-col>
  49. <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="8">
  50. <operate :data="dataInfo" />
  51. </el-col>
  52. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="8">
  53. <hrdata :data="dataInfo" />
  54. </el-col>
  55. <!-- <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
  56. <surplusCourse :data="dataInfo" />
  57. </el-col>
  58. <el-col :xs="24" :sm="24" :md="24" :lg="12" :xl="12">
  59. <useCourse :data="dataInfo" />
  60. </el-col> -->
  61. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  62. <management
  63. ref="management"
  64. :data="dataInfo"
  65. :search="search"
  66. @resetDate="resetDate"
  67. />
  68. </el-col>
  69. <el-col
  70. :xs="24"
  71. :sm="24"
  72. :md="24"
  73. :lg="24"
  74. :xl="24"
  75. v-if="$helpers.tanentId == 1"
  76. >
  77. <business
  78. ref="business"
  79. :data="dataInfo"
  80. :search="search"
  81. @resetDate="resetDate"
  82. />
  83. </el-col>
  84. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  85. <curriculum
  86. :data="dataInfo"
  87. ref="curriculum"
  88. :search="search"
  89. @resetDate="resetDate"
  90. />
  91. </el-col>
  92. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  93. <student
  94. :data="dataInfo"
  95. ref="student"
  96. :search="search"
  97. @resetDate="resetDate"
  98. />
  99. </el-col>
  100. <!-- <el-col :xs="24" :sm="24" :md="12">
  101. <operate :data="dataInfo"/>
  102. </el-col> -->
  103. <!-- <el-col :xs="24" :sm="24" :md="12">
  104. <hrdata :data="dataInfo"/>
  105. </el-col> -->
  106. </el-row>
  107. </div>
  108. </template>
  109. <script>
  110. import { getIndex } from "../api";
  111. import operate from "./operate";
  112. import business from "./business";
  113. import management from "./management";
  114. import hrdata from "./hr";
  115. import student from "./student";
  116. import curriculum from "./curriculum";
  117. import studentbaseinfo from "./studentBaseinfo";
  118. import surplusCourse from "./surplusCourse";
  119. import useCourse from "./useCourse";
  120. import { getTimes } from "@/utils";
  121. import { descs } from "../constant";
  122. export default {
  123. components: {
  124. operate,
  125. business,
  126. management,
  127. hrdata,
  128. student,
  129. curriculum,
  130. studentbaseinfo,
  131. surplusCourse,
  132. useCourse,
  133. },
  134. data() {
  135. return {
  136. pickerOptions: {
  137. firstDayOfWeek: 1,
  138. disabledDate: (a) => {
  139. const { dayjs } = this.$helpers;
  140. return dayjs(a).isAfter(dayjs().subtract(1, "day"));
  141. },
  142. shortcuts: [
  143. {
  144. text: "最近一周",
  145. onClick(picker) {
  146. const end = new Date();
  147. const start = new Date();
  148. end.setTime(end.getTime() - 3600 * 1000 * 24 * 1);
  149. start.setTime(start.getTime() - 3600 * 1000 * 24 * 8);
  150. picker.$emit("pick", [start, end]);
  151. },
  152. },
  153. {
  154. text: "最近一个月",
  155. onClick(picker) {
  156. const end = new Date();
  157. const start = new Date();
  158. end.setTime(end.getTime() - 3600 * 1000 * 24 * 1);
  159. start.setTime(start.getTime() - 3600 * 1000 * 24 * 31);
  160. picker.$emit("pick", [start, end]);
  161. },
  162. },
  163. {
  164. text: "最近三个月",
  165. onClick(picker) {
  166. const end = new Date();
  167. const start = new Date();
  168. end.setTime(end.getTime() - 3600 * 1000 * 24 * 1);
  169. start.setTime(start.getTime() - 3600 * 1000 * 24 * 91);
  170. picker.$emit("pick", [start, end]);
  171. },
  172. },
  173. ],
  174. },
  175. search: {
  176. dates: [],
  177. organId: null,
  178. },
  179. dataInfo: {},
  180. business: {},
  181. loading: false,
  182. };
  183. },
  184. computed: {
  185. isEmpty() {
  186. return !Object.keys(this.dataInfo).length;
  187. },
  188. },
  189. created() {},
  190. async mounted() {
  191. this.$set(this.search, "dates", this.getInitDate());
  192. await this.$store.dispatch("setBranchs");
  193. this.FetchDetail();
  194. },
  195. methods: {
  196. getInitDate() {
  197. const end = this.$helpers
  198. .dayjs(new Date())
  199. .subtract(1, "day")
  200. .format("YYYY-MM-DD");
  201. const start = this.$helpers
  202. .dayjs(new Date())
  203. .subtract(1, "day")
  204. .set("date", 1)
  205. .format("YYYY-MM-DD");
  206. return [start, end];
  207. },
  208. reset() {
  209. this.$set(this.search, "dates", this.getInitDate());
  210. this.$set(this.search, "organId", null);
  211. this.FetchDetail();
  212. },
  213. async FetchDetail() {
  214. // 这里改变就通知子组件重置
  215. const data = {};
  216. try {
  217. const { dates, ...rest } = this.search;
  218. const res = await getIndex({
  219. ...rest,
  220. ...getTimes(dates, ["startDate", "endDate"]),
  221. });
  222. for (const item of res.data) {
  223. data[item.dataType] = {
  224. ...item,
  225. desc: descs[item.dataType],
  226. };
  227. }
  228. } catch (error) {
  229. console.log(error);
  230. }
  231. this.dataInfo = data;
  232. if (this.$refs.business) {
  233. this.$refs["business"].init();
  234. }
  235. if (this.$refs.management) {
  236. this.$refs["management"].init();
  237. }
  238. },
  239. resetDate(data) {
  240. let arr = null;
  241. for (let item in data) {
  242. // console.log(item)
  243. if (item == "VIP_GROUP_COURSE") {
  244. arr = data[item].indexMonthData;
  245. }
  246. this.dataInfo[item] = data[item];
  247. }
  248. this.dataInfo = { ...this.dataInfo };
  249. },
  250. },
  251. };
  252. </script>
  253. <style lang="less" scoped>
  254. .container {
  255. overflow: hidden;
  256. .rows {
  257. > div {
  258. margin-bottom: 20px;
  259. }
  260. }
  261. /deep/ .el-card__body .statistic {
  262. margin-bottom: 15px;
  263. padding: 0;
  264. }
  265. }
  266. /deep/.el-card__header {
  267. padding: 0 20px !important;
  268. }
  269. </style>
  270. <style lang="scss">
  271. .main {
  272. .statistic {
  273. .statistic-content > span {
  274. font-size: 22px !important;
  275. &:first-child {
  276. font-size: 14px !important;
  277. }
  278. }
  279. }
  280. }
  281. .box {
  282. display: flex;
  283. flex-direction: row;
  284. align-items: center;
  285. height: 55px;
  286. line-height: 55px;
  287. .shape {
  288. margin-right: 10px;
  289. height: 18px;
  290. width: 4px;
  291. background-color: var(--color-primary);
  292. }
  293. }
  294. .wall {
  295. display: flex;
  296. flex-direction: row;
  297. align-items: center;
  298. justify-content: center;
  299. color: #888;
  300. font-size: 14px;
  301. }
  302. </style>