lrf402788946 5 năm trước cách đây
mục cha
commit
427cb80dea

+ 1 - 1
package.json

@@ -19,7 +19,7 @@
     "element-ui": "^2.13.0",
     "element-ui": "^2.13.0",
     "jsonwebtoken": "^8.5.1",
     "jsonwebtoken": "^8.5.1",
     "lodash": "^4.17.15",
     "lodash": "^4.17.15",
-    "moment": "^2.24.0",
+    "moment": "^2.26.0",
     "naf-core": "^0.1.2",
     "naf-core": "^0.1.2",
     "qrcode": "^1.4.4",
     "qrcode": "^1.4.4",
     "vue": "^2.6.10",
     "vue": "^2.6.10",

+ 5 - 0
src/router/index.js

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

+ 2 - 0
src/store/index.js

@@ -20,6 +20,7 @@ import lesson from '@frame/store/lesson';
 import trainTemplate from '@frame/store/train-template';
 import trainTemplate from '@frame/store/train-template';
 import leave from '@frame/store/leave';
 import leave from '@frame/store/leave';
 import util from '@frame/store/util';
 import util from '@frame/store/util';
+import count from '@frame/store/count';
 
 
 import nation from '@frame/store/nation';
 import nation from '@frame/store/nation';
 import completion from '@frame/store/question-completion';
 import completion from '@frame/store/question-completion';
@@ -60,6 +61,7 @@ export default new Vuex.Store({
     trainTemplate,
     trainTemplate,
     other,
     other,
     util,
     util,
+    count,
   },
   },
   state: { ...ustate },
   state: { ...ustate },
   mutations: { ...umutations },
   mutations: { ...umutations },

+ 4 - 0
src/views/bedroom/detail.vue

@@ -7,6 +7,10 @@
             <el-radio label="男">男</el-radio>
             <el-radio label="男">男</el-radio>
             <el-radio label="女">女</el-radio>
             <el-radio label="女">女</el-radio>
           </template>
           </template>
+          <template v-if="item.model === 'status'">
+            <el-radio label="0">启用</el-radio>
+            <el-radio label="1">禁用</el-radio>
+          </template>
           <template v-if="item.model === 'floor'">
           <template v-if="item.model === 'floor'">
             <el-radio v-for="i in 5" :key="i" :label="`${i}楼`">{{ `${i}楼` }}</el-radio>
             <el-radio v-for="i in 5" :key="i" :label="`${i}楼`">{{ `${i}楼` }}</el-radio>
           </template>
           </template>

+ 60 - 0
src/views/home.vue

@@ -0,0 +1,60 @@
+<template>
+  <div id="home">
+    <el-card v-if="!loading">
+      <iscome :istrain="data.trainstu" :nottrain="data.notrainstu"></iscome>
+      <school :school="data.schs"></school>
+      <leave :qj="data.levelqj" :exit="data.levelexit"></leave>
+    </el-card>
+  </div>
+</template>
+
+<script>
+import school from './home/school.vue';
+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, school },
+  data: function() {
+    return {
+      loading: true,
+      data: {},
+    };
+  },
+  created() {
+    this.search();
+  },
+  methods: {
+    ...count(['query']),
+    async search() {
+      let res = await this.query();
+      // 柱状图
+      //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>

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

@@ -0,0 +1,93 @@
+<template>
+  <div id="iscome">
+    <el-card style="padding:10px;margin:5px">
+      <el-row :gutter="20">
+        <el-col :span="14">
+          <div id="chartPie" style="height:350px;"></div>
+        </el-col>
+        <el-col :span="10">
+          <ul>
+            <li>已参加培训:{{ istrain }} 人</li>
+            <li>未参加培训:{{ nottrain }} 人</li>
+          </ul>
+        </el-col>
+      </el-row>
+    </el-card>
+  </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>

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

@@ -0,0 +1,110 @@
+<template>
+  <div id="leave">
+    <el-card style="padding:10px;margin:5px">
+      <el-row :gutter="20">
+        <el-col :span="14">
+          <div id="chartLinebar" style="height:350px;"></div>
+        </el-col>
+        <el-col :span="10">
+          <ul>
+            <li>请假:{{ qj }} 人</li>
+            <li>退出:{{ exit }} 人</li>
+          </ul>
+        </el-col>
+      </el-row>
+    </el-card>
+  </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>

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

@@ -0,0 +1,91 @@
+<template>
+  <div id="school">
+    <el-card style="padding:10px;margin:5px">
+      <el-row :gutter="20">
+        <el-col :span="14">
+          <ul>
+            <li v-for="(i, index) in school" :key="index">{{ i.schname }}:{{ i.schnum }} 人</li>
+          </ul>
+        </el-col>
+        <el-col :span="10">
+          <div id="schoolPie" style="height:350px;"></div>
+        </el-col>
+      </el-row>
+    </el-card>
+  </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>