lrf402788946 5 年 前
コミット
2a26444796

+ 1 - 0
package.json

@@ -15,6 +15,7 @@
     "@stomp/stompjs": "^5.4.3",
     "axios": "^0.19.2",
     "core-js": "^3.4.4",
+    "echarts": "^4.7.0",
     "element-ui": "^2.13.0",
     "lodash": "^4.17.15",
     "moment": "^2.24.0",

+ 5 - 0
src/router/index.js

@@ -33,6 +33,11 @@ const routes = [
     component: () => import('@/views/index.vue'),
     children: [
       ...newPlan,
+      {
+        path: '/',
+        name: 'home',
+        component: () => import('@/views/home.vue'),
+      },
       {
         path: '/plan/index',
         name: 'plan_list',

+ 2 - 0
src/store/index.js

@@ -9,6 +9,7 @@ import leave from '@frame/store/leave';
 import schPlan from '@frame/store/sch-plan';
 import schimport from '@frame/store/sch-import';
 import login from '@frame/store/login';
+import count from '@frame/store/count';
 import dirPlan from '@frame/store/dir-plan';
 import attendance from '@frame/store/attendance';
 
@@ -31,6 +32,7 @@ export default new Vuex.Store({
     dirPlan,
     util,
     attendance, //考勤
+    count,
   },
   state: { ...ustate },
   mutations: { ...umutations },

+ 74 - 0
src/views/home.vue

@@ -0,0 +1,74 @@
+<template>
+  <div id="home">
+    <el-card v-if="!loading" shadow="hover">
+      <el-row type="flex" align="middle" justify="center" style="margin:10px">
+        <el-col :span="12">
+          <el-card shadow="hover" style="text-align:center">全年计划共计: {{ data.planstu }} 人 </el-card>
+        </el-col>
+      </el-row>
+      <el-row :gutter="20">
+        <el-col :span="12">
+          <el-card shadow="hover">
+            <iscome :istrain="data.trainstu" :nottrain="data.notrainstu"></iscome>
+          </el-card>
+        </el-col>
+        <el-col :span="12">
+          <el-card shadow="hover">
+            <leave :qj="data.levelqj" :exit="data.levelexit"></leave>
+          </el-card>
+        </el-col>
+      </el-row>
+    </el-card>
+  </div>
+</template>
+
+<script>
+import iscome from './home/iscome.vue';
+import leave from './home/leave.vue';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: count } = createNamespacedHelpers('count');
+export default {
+  name: 'home',
+  props: {},
+  components: { leave, iscome },
+  data: function() {
+    return {
+      loading: true,
+      data: {},
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    ...count(['schoolQuery']),
+    async search() {
+      let res = await this.schoolQuery(this.user.code);
+      // 柱状图
+      //levelexit:退出;
+      //levelqj:请假;
+      //饼形图
+      //notrainstu:没参加培训的;
+      //trainstu:已参加学生数;
+
+      //planstu:计划总人数;
+
+      //饼形图,哪个学校多少人
+      //schstu:学校上报人数;
+      if (this.$checkRes(res)) this.$set(this, `data`, res.data);
+      this.loading = false;
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 81 - 0
src/views/home/iscome.vue

@@ -0,0 +1,81 @@
+<template>
+  <div id="iscome">
+    <div id="chartPie" style="height:350px;"></div>
+  </div>
+</template>
+
+<script>
+import _ from 'lodash';
+import echarts from 'echarts/lib/echarts';
+import 'echarts/lib/chart/pie';
+import 'echarts/lib/component/title';
+import 'echarts/lib/component/legend';
+import 'echarts/lib/component/toolbox';
+import 'echarts/lib/component/markPoint';
+import 'echarts/lib/component/tooltip';
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'iscome',
+  props: {
+    istrain: { type: Number, default: 0 },
+    nottrain: { type: Number, default: 0 },
+  },
+  components: {},
+  data: function() {
+    return {
+      myPie: null,
+    };
+  },
+  created() {
+    this.$nextTick(() => {
+      this.init();
+    });
+  },
+  methods: {
+    init(type) {
+      this.myPie = echarts.init(document.getElementById('chartPie'));
+      const option = {
+        title: { text: '当前学生参加培训情况' },
+        tooltip: { trigger: 'item', formatter: '{a} <br/>{b} : {c} ({d}%)' },
+        legend: {
+          data: ['已参加培训', '未参加培训'],
+        },
+        series: [
+          {
+            name: '统计',
+            label: {
+              show: true,
+              position: 'top',
+            },
+            type: 'pie',
+            data: [
+              { name: '已参加培训', value: this.istrain, itemStyle: { color: '#7cb5ec' } },
+              { name: '未参加培训', value: this.nottrain, itemStyle: { color: '#ffa94b' } },
+            ],
+            animationType: 'scale',
+          },
+        ],
+        toolbox: {
+          show: true,
+          feature: {
+            dataView: { readOnly: false },
+            saveAsImage: {},
+          },
+        },
+      };
+      this.myPie.setOption(option);
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 98 - 0
src/views/home/leave.vue

@@ -0,0 +1,98 @@
+<template>
+  <div id="leave">
+    <div id="chartLinebar" style="height:350px;"></div>
+  </div>
+</template>
+
+<script>
+import _ from 'lodash';
+import echarts from 'echarts/lib/echarts';
+import 'echarts/lib/chart/line';
+import 'echarts/lib/chart/bar';
+import 'echarts/lib/component/title';
+import 'echarts/lib/component/legend';
+import 'echarts/lib/component/toolbox';
+import 'echarts/lib/component/markPoint';
+import 'echarts/lib/component/tooltip';
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'leave',
+  props: {
+    qj: { type: Number, default: 0 }, //请假
+    exit: { type: Number, default: 0 }, //退出
+  },
+  components: {},
+  data: function() {
+    return {
+      mychart: null,
+    };
+  },
+  created() {
+    this.$nextTick(() => {
+      this.init();
+    });
+  },
+  methods: {
+    init() {
+      const option = {
+        title: { text: '请假/退出统计' },
+        tooltip: { trigger: 'axis' },
+        legend: {
+          data: ['请假/退出统计'],
+        },
+        xAxis: {
+          boundaryGap: true,
+          // nameLocation: 'center',
+          data: ['请假', '退出'],
+        },
+        yAxis: {},
+        series: [
+          {
+            name: '请假',
+            step: true,
+            label: {
+              show: true,
+              position: 'top',
+            },
+            type: 'bar',
+            data: [this.qj],
+            color: ['#333ceb'],
+          },
+          {
+            name: '退出',
+            label: {
+              show: true,
+              position: 'top',
+            },
+            type: 'bar',
+            data: [this.exit],
+            color: ['#acaecce'],
+          },
+        ],
+        toolbox: {
+          show: true,
+          feature: {
+            dataView: { readOnly: false },
+            saveAsImage: {},
+            restore: {},
+            // magicType: { type: ['bar'] },
+          },
+        },
+      };
+      this.mychart = echarts.init(document.getElementById('chartLinebar'));
+      this.mychart.setOption(option);
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 80 - 0
src/views/home/school.vue

@@ -0,0 +1,80 @@
+<template>
+  <div id="school">
+    <div id="schoolPie" style="height:350px;"></div>
+  </div>
+</template>
+
+<script>
+import _ from 'lodash';
+import echarts from 'echarts/lib/echarts';
+import 'echarts/lib/chart/pie';
+import 'echarts/lib/component/title';
+import 'echarts/lib/component/legend';
+import 'echarts/lib/component/toolbox';
+import 'echarts/lib/component/markPoint';
+import 'echarts/lib/component/tooltip';
+import { mapState, createNamespacedHelpers } from 'vuex';
+export default {
+  name: 'school',
+  props: {
+    school: { type: Array, default: () => [] },
+  },
+  components: {},
+  data: function() {
+    return {
+      myPie: null,
+    };
+  },
+  created() {
+    this.$nextTick(() => {
+      this.init();
+    });
+  },
+  methods: {
+    init(type) {
+      let data = this.school.map(i => {
+        return { name: i.schname, value: i.schnum };
+      });
+      this.myPie = echarts.init(document.getElementById('schoolPie'));
+      const option = {
+        title: { text: '学校上报统计' },
+        tooltip: { trigger: 'item', formatter: '{a} <br/>{b} : {c} ({d}%)' },
+        legend: {
+          data: data.map(i => i.name),
+        },
+        series: [
+          {
+            name: '统计',
+            label: {
+              show: true,
+              position: 'top',
+            },
+            type: 'pie',
+            data: data,
+            animationType: 'scale',
+          },
+        ],
+        toolbox: {
+          show: true,
+          feature: {
+            dataView: { readOnly: false },
+            saveAsImage: {},
+          },
+        },
+      };
+      this.myPie.setOption(option);
+    },
+  },
+  computed: {
+    ...mapState(['user']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 37 - 7
src/views/kaoqin/index.vue

@@ -1,19 +1,41 @@
 <template>
   <div id="index">
-    <list-frame title="题库列表页" @query="onsearch" :total="total" :needFilter="false" :needAdd="false">
-      <el-select v-model="form.id" size="mini" placeholder="请选择计划" @change="changejh">
-        <el-option v-for="(i, index) in planList" :key="index" :label="i.title" :value="i.id"></el-option>
-      </el-select>
+    <list-frame title="考勤管理" @query="onsearch" :total="total" :needFilter="false" :needAdd="false">
+      <el-form :inline="true" size="mini">
+        <el-form-item label="计划">
+          <el-select v-model="form.id" size="mini" placeholder="请选择计划" @change="changejh">
+            <el-option v-for="(i, index) in planList" :key="index" :label="i.title" :value="i.id"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="期">
+          <el-select v-model="form.termid" placeholder="请选择期数" @change="getBatch">
+            <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="批次">
+          <el-select v-model="form.batchid" placeholder="请先选择期数" @change="getClasses">
+            <el-option v-for="(i, index) in batchList" :key="index" :label="i.name" :value="i._id"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="班级">
+          <el-select v-model="form.classid" placeholder="请先选择批次">
+            <el-option v-for="(i, index) in classList" :key="index" :label="i.name" :value="i._id"></el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="">
+          <el-button type="primary" size="mini" @click="onsearch()"> 查询</el-button>
+        </el-form-item>
+      </el-form>
 
-      <el-select v-model="form.termid" size="mini" placeholder="请选择期" @change="changeqi">
+      <!-- <el-select v-model="form.termid" size="mini" placeholder="请选择期" @change="changeqi">
         <el-option label="请选择" value="shanghai"></el-option>
         <el-option v-for="(m, index) in termList" :key="index" :label="m.termnum" :value="m.termid"></el-option>
       </el-select>
 
       <el-select v-model="form.name" size="mini" placeholder="请选择班">
         <el-option v-for="(m, index) in classList" :key="index" :label="m.name" :value="m.id"></el-option>
-      </el-select>
-      <el-button type="primary" size="mini" @click="onsearch()"> 查询</el-button>
+      </el-select> -->
+      <!-- <el-button type="primary" size="mini" @click="onsearch()"> 查询</el-button> -->
       <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit" @delete="toDelete"> </data-table>
     </list-frame>
   </div>
@@ -38,6 +60,7 @@ export default {
   },
   data: () => ({
     classList: [],
+    batchList: [],
     termList: [],
     planList: [],
     opera: [
@@ -97,6 +120,13 @@ export default {
 
       this.$set(this, `termList`, res.data.term);
     },
+    getBatch(termid) {
+      let batchs = this.termList.filter(f => f._id === termid);
+      if (batchs.length > 0) {
+        let { batchnum } = batchs[0];
+        this.$set(this, `batchList`, batchnum);
+      }
+    },
     async changeqi(termid) {
       const res = await this.classesquery({ termid });
       console.log(res.data);