index.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260
  1. <template>
  2. <div class="container">
  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="9" :xl="9">
  47. <studentbaseinfo :data="dataInfo" />
  48. </el-col>
  49. <el-col :xs="24" :sm="24" :md="24" :lg="6" :xl="6">
  50. <operate :data="dataInfo" />
  51. </el-col>
  52. <el-col :xs="24" :sm="24" :md="24" :lg="9" :xl="9">
  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="12">
  62. <management
  63. ref="management"
  64. :data="dataInfo"
  65. :search="search"
  66. @resetDate="resetDate"
  67. />
  68. </el-col>
  69. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="12">
  70. <business
  71. ref="business"
  72. :data="dataInfo"
  73. :search="search"
  74. @resetDate="resetDate"
  75. />
  76. </el-col>
  77. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  78. <curriculum :data="dataInfo" :search="search" @resetDate="resetDate" />
  79. </el-col>
  80. <el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
  81. <student :data="dataInfo" :search="search" @resetDate="resetDate" />
  82. </el-col>
  83. <!-- <el-col :xs="24" :sm="24" :md="12">
  84. <operate :data="dataInfo"/>
  85. </el-col> -->
  86. <!-- <el-col :xs="24" :sm="24" :md="12">
  87. <hrdata :data="dataInfo"/>
  88. </el-col> -->
  89. </el-row>
  90. </div>
  91. </template>
  92. <script>
  93. import { getIndex } from "../api";
  94. import operate from "./operate";
  95. import business from "./business";
  96. import management from "./management";
  97. import hrdata from "./hr";
  98. import student from "./student";
  99. import curriculum from "./curriculum";
  100. import studentbaseinfo from "./studentBaseinfo";
  101. import surplusCourse from "./surplusCourse";
  102. import useCourse from "./useCourse";
  103. import { getTimes } from "@/utils";
  104. import { descs } from "../constant";
  105. export default {
  106. components: {
  107. operate,
  108. business,
  109. management,
  110. hrdata,
  111. student,
  112. curriculum,
  113. studentbaseinfo,
  114. surplusCourse,
  115. useCourse,
  116. },
  117. data() {
  118. return {
  119. pickerOptions: {
  120. firstDayOfWeek: 1,
  121. disabledDate: (a) => {
  122. const { dayjs } = this.$helpers;
  123. return dayjs(a).isAfter(dayjs().subtract(1, "day"));
  124. },
  125. shortcuts: [
  126. {
  127. text: "最近一周",
  128. onClick(picker) {
  129. const end = new Date();
  130. const start = new Date();
  131. end.setTime(end.getTime() - 3600 * 1000 * 24 * 1);
  132. start.setTime(start.getTime() - 3600 * 1000 * 24 * 8);
  133. picker.$emit("pick", [start, end]);
  134. },
  135. },
  136. {
  137. text: "最近一个月",
  138. onClick(picker) {
  139. const end = new Date();
  140. const start = new Date();
  141. end.setTime(end.getTime() - 3600 * 1000 * 24 * 1);
  142. start.setTime(start.getTime() - 3600 * 1000 * 24 * 31);
  143. picker.$emit("pick", [start, end]);
  144. },
  145. },
  146. {
  147. text: "最近三个月",
  148. onClick(picker) {
  149. const end = new Date();
  150. const start = new Date();
  151. end.setTime(end.getTime() - 3600 * 1000 * 24 * 1);
  152. start.setTime(start.getTime() - 3600 * 1000 * 24 * 91);
  153. picker.$emit("pick", [start, end]);
  154. },
  155. },
  156. ],
  157. },
  158. search: {
  159. dates: [],
  160. organId: null,
  161. },
  162. dataInfo: {},
  163. business: {},
  164. loading: false,
  165. };
  166. },
  167. computed: {
  168. isEmpty() {
  169. return !Object.keys(this.dataInfo).length;
  170. },
  171. },
  172. created() {},
  173. mounted() {
  174. this.$set(this.search, "dates", this.getInitDate());
  175. this.$store.dispatch("setBranchs");
  176. this.FetchDetail();
  177. },
  178. methods: {
  179. getInitDate() {
  180. const end = this.$helpers
  181. .dayjs(new Date())
  182. .subtract(1, "day")
  183. .format("YYYY-MM-DD");
  184. const start = this.$helpers
  185. .dayjs(new Date())
  186. .subtract(1, "day")
  187. .set("date", 1)
  188. .format("YYYY-MM-DD");
  189. return [start, end];
  190. },
  191. reset() {
  192. this.$set(this.search, "dates", this.getInitDate());
  193. this.$set(this.search, "organId", null);
  194. this.FetchDetail();
  195. },
  196. async FetchDetail() {
  197. const data = {};
  198. try {
  199. const { dates, ...rest } = this.search;
  200. const res = await getIndex({
  201. ...rest,
  202. ...getTimes(dates, ["startDate", "endDate"]),
  203. });
  204. for (const item of res.data) {
  205. data[item.dataType] = {
  206. ...item,
  207. desc: descs[item.dataType],
  208. };
  209. }
  210. } catch (error) {
  211. console.log(error);
  212. }
  213. this.dataInfo = data;
  214. if (this.$refs.business) {
  215. this.$refs["business"].init();
  216. }
  217. if (this.$refs.management) {
  218. this.$refs["management"].init();
  219. }
  220. },
  221. resetDate(data) {
  222. this.dataInfo = {...this.dataInfo,...data};
  223. },
  224. },
  225. };
  226. </script>
  227. <style lang="less" scoped>
  228. .container {
  229. overflow: hidden;
  230. .rows {
  231. > div {
  232. margin-bottom: 20px;
  233. }
  234. }
  235. /deep/ .el-card__body .statistic {
  236. margin-bottom: 15px;
  237. padding: 0;
  238. }
  239. }
  240. /deep/.el-card__header {
  241. padding: 0 20px !important;
  242. }
  243. </style>
  244. <style lang="scss">
  245. .box {
  246. display: flex;
  247. flex-direction: row;
  248. align-items: center;
  249. height: 55px;
  250. line-height: 55px;
  251. .shape {
  252. margin-right: 10px;
  253. height: 18px;
  254. width: 4px;
  255. background-color: #14928a;
  256. }
  257. }
  258. </style>