فهرست منبع

更新学校上传相关

wuhongyuq 5 سال پیش
والد
کامیت
5d464ee55f
6فایلهای تغییر یافته به همراه190 افزوده شده و 5 حذف شده
  1. 6 0
      src/router/index.js
  2. 3 1
      src/store/index.js
  3. 38 0
      src/store/schoolimport.js
  4. 139 0
      src/views/scganli/detail.vue
  5. 3 3
      src/views/scganli/index.vue
  6. 1 1
      vue.config.js

+ 6 - 0
src/router/index.js

@@ -33,6 +33,12 @@ const routes = [
         meta: { title: '上传学生', sub: '管理' },
         component: () => import('@/views/scganli/index.vue'),
       },
+      {
+        path: '/scganli/detail',
+        name: 'teacher_list',
+        meta: { title: '上传学生', sub: '详情' },
+        component: () => import('@/views/scganli/detail.vue'),
+      },
       {
         path: '/teacher/detail',
         name: 'teacher_detail',

+ 3 - 1
src/store/index.js

@@ -4,11 +4,13 @@ import student from '@center/src/store/student';
 import teacher from '@center/src/store/teacher';
 import trainplan from '@center/src/store/trainplan';
 import schPlan from './sch-plan';
+import schoolimport from './schoolimport';
+
 Vue.use(Vuex);
 
 export default new Vuex.Store({
   state: {},
   mutations: {},
   actions: {},
-  modules: { student, teacher, trainplan, schPlan },
+  modules: { student, teacher, trainplan, schPlan, schoolimport },
 });

+ 38 - 0
src/store/schoolimport.js

@@ -0,0 +1,38 @@
+import Vue from 'vue';
+import Vuex from 'vuex';
+import _ from 'lodash';
+Vue.use(Vuex);
+const api = {
+  interface: `/api/train/school/import`,
+};
+const state = () => ({});
+const mutations = {};
+
+const actions = {
+  async query({ commit }, { skip = 0, limit, ...info } = {}) {
+    const res = await this.$axios.$get(`${api.interface}`, { skip, limit, ...info });
+    return res;
+  },
+  async create({ commit }, payload) {
+    const res = await this.$axios.$post(`${api.interface}`, payload);
+    return res;
+  },
+  async fetch({ commit }, payload) {
+    const res = await this.$axios.$get(`${api.interface}/${payload}`);
+    return res;
+  },
+  async update({ commit }, { id, ...data }) {
+    const res = await this.$axios.$post(`${api.interface}/update/${id}`, data);
+    return res;
+  },
+  async delete({ commit }, payload) {
+    const res = await this.$axios.$delete(`${api.interface}/${payload}`);
+    return res;
+  },
+};
+export default {
+  namespaced: true,
+  state,
+  mutations,
+  actions,
+};

+ 139 - 0
src/views/scganli/detail.vue

@@ -0,0 +1,139 @@
+<template>
+  <div id="detail">
+    <detail-frame :title="mainTitle" returns="/teacher/list">
+      <data-form :data="info" :fields="fields" :rules="rules" @save="handleSave" :isNew="isNew">
+        <!-- <template #custom="{ item, form }"> </template> -->
+        <template #options="{item}">
+          <template v-if="item.model === 'tramid'">
+            <el-option v-for="(item, index) in deptList" :key="index" :label="item.name" :value="item.newTermnum"></el-option>
+          </template>
+        </template>
+
+        <template #custom="{ item, form }">
+          <el-upload
+            class="upload-demo"
+            action="/files/train/upload"
+            :on-preview="handlePreview"
+            :on-remove="handleRemove"
+            :before-remove="beforeRemove"
+            multiple
+            :limit="3"
+            :on-exceed="handleExceed"
+          >
+            <el-button size="small" type="primary">点击上传</el-button>
+            <div slot="tip" class="el-upload__tip">不超过500kb</div>
+          </el-upload>
+        </template>
+      </data-form>
+    </detail-frame>
+  </div>
+</template>
+
+<script>
+import detailFrame from '@frame/layout/admin/detail-frame';
+import dataForm from '@frame/components/form';
+import { createNamespacedHelpers } from 'vuex';
+const { mapActions } = createNamespacedHelpers('schoolimport');
+const { mapActions: mapDept } = createNamespacedHelpers('schPlan');
+export default {
+  metaInfo: { title: '教师信息' },
+  name: 'detail',
+  props: {},
+  components: { detailFrame, dataForm },
+  data: () => ({
+    deptList: [],
+    info: {},
+
+    fields: [
+      { label: '期次', model: 'tramid', type: 'select' },
+      // { label: '学校', model: 'schid', type: 'select' },
+      { label: '上传学生名单', model: 'filepath', type: 'upload', custom: true },
+    ],
+    rules: {},
+    loading: true,
+  }),
+  created() {
+    this.otherList();
+  },
+  computed: {
+    isNew() {
+      return this.$route.query.id ? false : true;
+    },
+    id() {
+      return this.$route.query.id;
+    },
+    mainTitle() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      let sub = meta.sub || '';
+      return `${main}${sub}`;
+    },
+    keyWord() {
+      let meta = this.$route.meta;
+      let main = meta.title || '';
+      return main;
+    },
+  },
+  watch: {
+    id: {
+      immediate: true,
+      handler(val) {
+        if (val) this.loading = false;
+        else this.search();
+      },
+    },
+  },
+
+  methods: {
+    ...mapDept({ dept: 'query' }),
+    ...mapActions(['fetch', 'create', 'update']),
+    async search() {
+      // const res = await this.fetch(this.id);
+      // if (this.$checkRes(res)) this.$set(this, `info`, res.data);
+      // this.loading = false;
+    },
+    async handleSave({ isNew, data }) {
+      let res;
+      let msg;
+      if (isNew) {
+        res = await this.create(data);
+        msg = `${this.keyWord}添加成功`;
+      } else {
+        res = await this.update(data);
+        msg = `${this.keyWord}修改成功`;
+      }
+      if (this.$checkRes(res, msg)) this.$router.push({ path: '/dept/index' });
+    },
+    async otherList() {
+      const res = await this.dept({ planid: this.info.id, schname: '测试学校' });
+      if (this.$checkRes(res)) {
+        for (let val of res.data) {
+          console.log(val.term);
+          for (let lets of val.term) {
+            console.log(lets);
+            val.newTermnum = lets.termnum;
+          }
+        }
+        console.log(res.data);
+        this.$set(this, `deptList`, res.data);
+        console.log(res.data.length);
+        console.log(res.data);
+      }
+    },
+    handleRemove(file, fileList) {
+      console.log(file, fileList);
+    },
+    handlePreview(file) {
+      console.log(file);
+    },
+    handleExceed(files, fileList) {
+      this.$message.warning(`当前限制选择 3 个文件,本次选择了 ${files.length} 个文件,共选择了 ${files.length + fileList.length} 个文件`);
+    },
+    beforeRemove(file, fileList) {
+      return this.$confirm(`确定移除 ${file.name}?`);
+    },
+  },
+};
+</script>
+
+<style lang="less" scoped></style>

+ 3 - 3
src/views/scganli/index.vue

@@ -1,6 +1,6 @@
 <template>
   <div id="index">
-    <list-frame :title="mainTitle" @query="search" :total="total" :needFilter="false" :needAdd="false">
+    <list-frame :title="mainTitle" @query="search" :total="total" :needFilter="false" :needAdd="false" @add="$router.push({ path: '/dept/detail' })">
       <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit" @update="toUpdate"></data-table>
     </list-frame>
   </div>
@@ -32,7 +32,7 @@ export default {
       //   method: 'update',
       // },
     ],
-    fields: [{ label: '批次', prop: 'newTermnum' }],
+    fields: [{ label: '期数', prop: 'newTermnum' }],
     list: [{ term: {} }],
     total: 0,
   }),
@@ -87,7 +87,7 @@ export default {
     },
     toEdit({ data }) {
       //TODO 该把详情做成什么样的比较好,是和大日历在一起选择还是其他形式
-      this.$router.push({ path: '/plan/detail', query: { id: data.id } });
+      this.$router.push({ path: '/scganli/detail' });
     },
 
     async toUpdate({ data }) {

+ 1 - 1
vue.config.js

@@ -29,7 +29,7 @@ module.exports = {
         ws: true,
       },
       '/files': {
-        target: 'http://smart.cc-lotus.info',
+        target: 'http://free.liaoningdoupo.com',
         changeOrigin: true,
         ws: true,
       },