index.vue 6.5 KB

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