lrf402788946 4 years ago
parent
commit
c2315472f8

+ 0 - 130
src/components/HelloWorld.vue

@@ -1,130 +0,0 @@
-<template>
-  <div class="hello">
-    <h1>{{ msg }}</h1>
-    <p>
-      For a guide and recipes on how to configure / customize this project,<br />
-      check out the
-      <a href="https://cli.vuejs.org" target="_blank" rel="noopener"
-        >vue-cli documentation</a
-      >.
-    </p>
-    <h3>Installed CLI Plugins</h3>
-    <ul>
-      <li>
-        <a
-          href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel"
-          target="_blank"
-          rel="noopener"
-          >babel</a
-        >
-      </li>
-      <li>
-        <a
-          href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-router"
-          target="_blank"
-          rel="noopener"
-          >router</a
-        >
-      </li>
-      <li>
-        <a
-          href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-vuex"
-          target="_blank"
-          rel="noopener"
-          >vuex</a
-        >
-      </li>
-      <li>
-        <a
-          href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-eslint"
-          target="_blank"
-          rel="noopener"
-          >eslint</a
-        >
-      </li>
-    </ul>
-    <h3>Essential Links</h3>
-    <ul>
-      <li>
-        <a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a>
-      </li>
-      <li>
-        <a href="https://forum.vuejs.org" target="_blank" rel="noopener"
-          >Forum</a
-        >
-      </li>
-      <li>
-        <a href="https://chat.vuejs.org" target="_blank" rel="noopener"
-          >Community Chat</a
-        >
-      </li>
-      <li>
-        <a href="https://twitter.com/vuejs" target="_blank" rel="noopener"
-          >Twitter</a
-        >
-      </li>
-      <li>
-        <a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a>
-      </li>
-    </ul>
-    <h3>Ecosystem</h3>
-    <ul>
-      <li>
-        <a href="https://router.vuejs.org" target="_blank" rel="noopener"
-          >vue-router</a
-        >
-      </li>
-      <li>
-        <a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a>
-      </li>
-      <li>
-        <a
-          href="https://github.com/vuejs/vue-devtools#vue-devtools"
-          target="_blank"
-          rel="noopener"
-          >vue-devtools</a
-        >
-      </li>
-      <li>
-        <a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener"
-          >vue-loader</a
-        >
-      </li>
-      <li>
-        <a
-          href="https://github.com/vuejs/awesome-vue"
-          target="_blank"
-          rel="noopener"
-          >awesome-vue</a
-        >
-      </li>
-    </ul>
-  </div>
-</template>
-
-<script>
-export default {
-  name: "HelloWorld",
-  props: {
-    msg: String
-  }
-};
-</script>
-
-<!-- Add "scoped" attribute to limit CSS to this component only -->
-<style scoped lang="less">
-h3 {
-  margin: 40px 0 0;
-}
-ul {
-  list-style-type: none;
-  padding: 0;
-}
-li {
-  display: inline-block;
-  margin: 0 10px;
-}
-a {
-  color: #42b983;
-}
-</style>

+ 7 - 16
src/views/train-plan/parts/experience-export.vue

@@ -2,10 +2,10 @@
   <div id="experience-export">
     <el-row class="btn_bar" type="flex" justify="end">
       <el-col :span="2">
-        <el-button type="primary" size="small" @click="dialog = true">导出培训心得</el-button>
+        <el-button type="primary" size="small" @click="dialog = true">导出</el-button>
       </el-col>
     </el-row>
-    <el-dialog title="请选择要导出培训心得的范围" width="30%" :visible.sync="dialog" center @close="toClose">
+    <el-dialog title="请选择要导出的范围" width="30%" :visible.sync="dialog" center @close="toClose">
       <el-form size="small">
         <el-form-item label="年度计划">
           <el-select clearable v-model="form.planid" @change="toGetTerm">
@@ -48,10 +48,11 @@ import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: experience } = createNamespacedHelpers('experience');
 const { mapActions: classes } = createNamespacedHelpers('classes');
 const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
-const { mapActions: student } = createNamespacedHelpers('student');
 export default {
   name: 'experience-export',
-  props: {},
+  props: {
+    studentList: { type: Array, default: () => [] },
+  },
   components: {},
   data: function() {
     return {
@@ -61,7 +62,6 @@ export default {
       termList: [],
       batchList: [],
       classList: [],
-      studentList: [],
     };
   },
   async created() {
@@ -69,7 +69,6 @@ export default {
   },
   methods: {
     ...experience(['export']),
-    ...student({ getStudent: 'query' }),
     ...trainplan({ getPlan: 'query' }),
     ...classes({ getClass: 'query' }),
     // 查询年度计划
@@ -107,19 +106,11 @@ export default {
     },
     // 找到班级的班长,学委
     async selectClass(classid) {
-      const bzres = await this.getStudent({ classid, job: '班长' });
-      const xwres = await this.getStudent({ classid, job: '学委' });
-      let arr = [];
-      if (this.$checkRes(bzres)) arr = [...arr, ...bzres.data];
-      if (this.$checkRes(xwres)) arr = [...arr, ...xwres.data];
-      this.$set(this, `studentList`, arr);
+      this.$emit('getStudent', classid);
     },
     //导出
     async toExport() {
-      const res = await this.export(this.form);
-      if (this.$checkRes(res, '导出成功', res.errmsg || '导出失败')) {
-        window.open(res.data);
-      }
+      this.$emit('toExport', this.form);
     },
     toClose() {
       this.dialog = false;

+ 2 - 0
src/store/index.js

@@ -43,6 +43,7 @@ import personalscore from '@frame/store/personalscore';
 import groupscore from '@frame/store/groupscore';
 import cerconfirm from '@frame/store/cerconfirm';
 import experience from '@frame/store/experience';
+import talented from '@frame/store/talented';
 import * as ustate from '@frame/store/user/state';
 import * as umutations from '@frame/store/user/mutations';
 import * as dostate from '@frame/store/setting/state';
@@ -98,6 +99,7 @@ export default new Vuex.Store({
     groupscore,
     cerconfirm,
     experience,
+    talented,
   },
   state: { ...ustate, ...dostate },
   mutations: { ...umutations, ...domutations },

+ 82 - 14
src/views/newspaper/index.vue

@@ -1,16 +1,28 @@
 <template>
   <div id="index">
     <list-frame title="新人才报" @query="search" :total="total" :needFilter="false" :needAdd="false">
-      <data-table :fields="fields" :data="list" :opera="opera" @download="download" @delete="toDelete"></data-table>
+      <el-form size="small" :inline="true">
+        <el-form-item label="班级">
+          <el-select v-model="searchInfo.classid" placeholder="请选择班级">
+            <el-option v-for="(c, index) in classList" :key="index" :label="`${c.name.includes('班') ? c.name : `${c.name}班`}`" :value="c._id"></el-option>
+          </el-select>
+        </el-form-item>
+      </el-form>
+      <export-range @getStudent="toGetStudent" :studentList="studentList" @toExport="toExport"></export-range>
+      <data-table :fields="fields" :data="list" :opera="opera" @download="download"></data-table>
     </list-frame>
   </div>
 </template>
 
 <script>
 import _ from 'lodash';
+import exportRange from '@/components/export-range.vue';
 import listFrame from '@frame/layout/admin/list-frame';
 import dataTable from '@frame/components/data-table';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: talented } = createNamespacedHelpers('talented');
+const { mapActions: classes } = createNamespacedHelpers('classes');
+const { mapActions: student } = createNamespacedHelpers('student');
 
 export default {
   metaInfo: { title: '新人才报' },
@@ -19,6 +31,7 @@ export default {
   components: {
     listFrame,
     dataTable,
+    exportRange,
   },
   data: () => ({
     opera: [
@@ -27,27 +40,82 @@ export default {
         icon: 'el-icon-download',
         method: 'download',
       },
-      {
-        label: '删除',
-        icon: 'el-icon-delete',
-        method: 'delete',
-      },
     ],
-    fields: [{ label: '姓名', prop: 'name' }],
+    fields: [{ label: '姓名', prop: 'stuname' }],
     list: [],
-
+    classList: [],
+    searchInfo: {},
+    studentList: [],
     total: 0,
   }),
-  created() {},
+  async created() {
+    await this.getOtherList();
+  },
   computed: { ...mapState(['user', 'defaultOption']) },
   methods: {
+    ...classes({ getClass: 'query' }),
+    ...student({ getStudent: 'query' }),
+    ...talented(['query', 'export']),
+    async search({ skip = 0, limit = 10, ...info } = {}) {
+      this.$set(this, `total`, 0);
+      const res = await this.query({ ...this.searchInfo, skip, limit });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
+    },
+    async getOtherList() {
+      const { termid } = this.defaultOption;
+      if (!termid) return;
+      const res = await this.getClass({ termid });
+      if (this.$checkRes(res)) {
+        let duplicate = _.cloneDeep(res.data);
+        duplicate = duplicate.map(i => {
+          if (parseInt(i.name)) {
+            i.order = parseInt(i.name);
+          } else {
+            // i.order = i.name;
+          }
+          return i;
+        });
+        duplicate = _.orderBy(duplicate, ['order'], ['asc']);
+        this.$set(this, `classList`, duplicate);
+      }
+    },
     // 下载
-    download({ data }) {
-      console.log(data);
+    async download({ data }) {
+      const { id } = data;
+      const r = await this.export({ id });
+      if (this.$checkRes(r)) {
+        window.open(r.data);
+      }
     },
-    // 删除
-    toDelete({ data }) {
-      console.log(data);
+    async toGetStudent(classid) {
+      const res = await this.getStudent({ classid, job: '宣传委员' });
+      if (this.$checkRes(res)) this.$set(this, `studentList`, res.data);
+    },
+    async toExport(data) {
+      const r = await this.export(data);
+      if (this.$checkRes(r)) {
+        window.open(r.data);
+      }
+    },
+  },
+  watch: {
+    defaultOption: {
+      deep: true,
+      handler(val, oval) {
+        this.getOtherList();
+      },
+    },
+    searchInfo: {
+      deep: true,
+      handler(val) {
+        if (val) {
+          const keys = Object.keys(val);
+          if (keys.length > 0) this.search();
+        }
+      },
     },
   },
 };

+ 27 - 4
src/views/train-plan/experience.vue

@@ -8,7 +8,7 @@
           </el-select>
         </el-form-item>
       </el-form>
-      <to-export></to-export>
+      <export-range @getStudent="toGetStudent" :studentList="studentList" @toExport="toExport"></export-range>
       <data-table :fields="fields" :data="list" :opera="opera" @view="toView" @delete="toDelete"></data-table>
     </list-frame>
     <el-dialog :visible.sync="dialog" title="培训心得" @close="toClose" width="30%">
@@ -25,7 +25,7 @@
 
 <script>
 import _ from 'lodash';
-import toExport from './parts/experience-export.vue';
+import exportRange from '@/components/export-range.vue';
 import listFrame from '@frame/layout/admin/list-frame';
 import dataForm from '@frame/components/form';
 import dataTable from '@frame/components/data-table';
@@ -33,6 +33,7 @@ import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: experience } = createNamespacedHelpers('experience');
 const { mapActions: classes } = createNamespacedHelpers('classes');
 const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
+const { mapActions: student } = createNamespacedHelpers('student');
 export default {
   metaInfo: { title: '培训心得' },
   name: 'experience',
@@ -41,7 +42,7 @@ export default {
     listFrame,
     dataTable,
     dataForm,
-    toExport,
+    exportRange,
   },
   data: () => ({
     opera: [
@@ -62,6 +63,7 @@ export default {
     ],
     list: [],
     classList: [],
+    studentList: [],
     searchInfo: {},
     total: 0,
     dialog: false,
@@ -79,7 +81,8 @@ export default {
   computed: { ...mapState(['user', 'defaultOption']) },
   methods: {
     ...classes({ getClass: 'query' }),
-    ...experience(['query']),
+    ...student({ getStudent: 'query' }),
+    ...experience(['query', 'export']),
     async search({ skip = 0, limit = 10, ...info } = {}) {
       this.$set(this, `total`, 0);
       const res = await this.query({ ...this.searchInfo, skip, limit });
@@ -106,6 +109,20 @@ export default {
         this.$set(this, `classList`, duplicate);
       }
     },
+    async toGetStudent(classid) {
+      const bzres = await this.getStudent({ classid, job: '班长' });
+      const xwres = await this.getStudent({ classid, job: '学委' });
+      let arr = [];
+      if (this.$checkRes(bzres)) arr = [...arr, ...bzres.data];
+      if (this.$checkRes(xwres)) arr = [...arr, ...xwres.data];
+      this.$set(this, `studentList`, arr);
+    },
+    async toExport(data) {
+      const res = await this.export(this.form);
+      if (this.$checkRes(res, '导出成功', res.errmsg || '导出失败')) {
+        window.open(res.data);
+      }
+    },
     // 查看
     toView({ data }) {
       this.$set(this, `form`, data);
@@ -124,6 +141,12 @@ export default {
     },
   },
   watch: {
+    defaultOption: {
+      deep: true,
+      handler(val, oval) {
+        this.getOtherList();
+      },
+    },
     searchInfo: {
       deep: true,
       handler(val) {

+ 1 - 1
vue.config.js

@@ -35,7 +35,7 @@ module.exports = {
     //api地址前缀
     proxy: {
       '/api/train': {
-        target: 'http://free.liaoningdoupo.com', ///api/train
+        target: 'http://127.0.0.1:2001', ///api/train http://free.liaoningdoupo.com http://jytz.jilinjobs.cn
         changeOrigin: true,
         ws: true,
       },