瀏覽代碼

12/21 09:35

11
mo 4 年之前
父節點
當前提交
41fd6d5569

+ 1 - 18
src/App.vue

@@ -6,9 +6,8 @@
 </template>
 
 <script>
-import version from '@/utils/version.js'
 import Vue from 'vue'
-Vue.use(version)
+
 
 export default {
   name: 'App',
@@ -20,26 +19,10 @@ export default {
   data () {
     return {
       isRouterAlive: true,
-      ver: '1.0.0'
     }
   },
   created () {
-    let version = this.version
 
-    if (version !== this.ver) {
-      this.$confirm("网站有更新请点击确定刷新页面?", "更新提示", {
-        confirmButtonText: "确定",
-        cancelButtonText: "取消",
-        type: "warning"
-      })
-        .then(() => {
-          // router.replace(targetPath);
-          location.reload()
-        })
-        .catch(() => {
-          return
-        });
-    }
   },
   methods: {
     reloads () {

+ 15 - 0
src/components/remote-search/README.md

@@ -0,0 +1,15 @@
+
+### remote-search
+背景:指导老师,乐团主管数量过多 一次加载会导致页面卡顿
+封装此组件默认加载number 不填则默认加载50条
+
+
+### 使用方法
+``` html
+  <remoteSearch :commit='"setEducations"'  v-model='form.educations' />
+
+```
+commit:传入selectStore里的获取 数据源方法 现在暂时支持 setEducations 和 setTeachers
+number:为可选参数 默认50条 默认加载的selet数量
+
+

+ 77 - 0
src/components/remote-search/index.vue

@@ -0,0 +1,77 @@
+<template>
+  <div>
+    <el-select
+    :value="value"
+      filterable
+      remote
+      reserve-keyword
+      :placeholder="placeholder"
+      :remote-method="remoteMethod"
+      :loading="loading"
+      @change="changeValue"
+    >
+      <el-option
+        v-for="(item, index) in options"
+        :key="index"
+        :label="item.userName"
+        :value="item.userId"
+      >
+      </el-option>
+    </el-select>
+  </div>
+</template>
+<script>
+const placeholder = {
+  setTeachers: "请选择老师",
+  setEducations: "请选乐团主管",
+};
+import { throttle, slice } from "lodash";
+import selects from "@/store/modules/selects";
+export default {
+  props: ["commit", "number","value"],
+  data() {
+    return {
+      options: [],
+      list: [],
+      loading: false,
+      constant: this.number || 50,
+      placeholder:placeholder[this.commit]
+    };
+  },
+  async mounted() {
+    await this.$store.dispatch(this.commit);
+    this.list = this.selects[this.enumer[this.commit]];
+    this.options =
+      this.list.length <= this.constant
+        ? this.list
+        : slice(this.list, 0, this.constant);
+
+    // console.log(this.options)
+  },
+  methods: {
+    remoteMethod(query) {
+      // throttle
+      throttle(this.getOptions,800)(query)
+
+    },
+    getOptions(query) {
+      this.options = this.list.filter(item=>{
+        return item.userName.toLowerCase().indexOf(query.toLowerCase())>-1
+      })
+    },
+    changeValue(val){
+       this.$emit("input", val);
+    }
+  },
+  computed: {
+    enumer() {
+      return {
+        setTeachers: "teachers",
+        setEducations: "educations",
+      };
+    },
+  }
+};
+</script>
+<style lang="scss" scoped>
+</style>

+ 24 - 3
src/store/modules/selects.js

@@ -1,6 +1,6 @@
 /* eslint-disable no-empty */
 import { branchQueryPage } from '@/api/specialSetting'
-import { getSubject, getTeacher } from '@/api/buildTeam'
+import { getSubject, getTeacher,findEducationUsers } from '@/api/buildTeam'
 import { getSchool } from '@/api/systemManage'
 import { vipGroupCategory } from "@/api/vipSeting"
 
@@ -21,7 +21,8 @@ export default {
     subjects: [],
     teachers: [],
     schools: [],
-    vipGroupCategory: []
+    vipGroupCategory: [],
+    educations:[]
   },
   mutations: {
     commit_branchs: (state, branchs) => {
@@ -31,13 +32,23 @@ export default {
       state.subjects = subjects
     },
     commit_teachers: (state, teachers) => {
-      state.teachers = teachers
+      state.teachers = teachers.map(teacher=>{
+        return {
+          id:teacher.id,
+          userId:teacher.id,
+          userName:teacher.realName,
+          realName:teacher.realName
+        }
+      })
     },
     commit_schools: (state, schools) => {
       state.schools = schools
     },
     commit_vip_group_category: (state, vipGroupCategory) => {
       state.vipGroupCategory = vipGroupCategory
+    },
+    commit_educations:(state,educations)=>{
+      state.educations = educations
     }
   },
   actions: {
@@ -59,6 +70,7 @@ export default {
     },
     async setTeachers ({ commit, state }, force) {
       if (!state.teachers.length || force === true) {
+
         try {
           const res = await getTeacher()
           commit('commit_teachers', res.data)
@@ -81,5 +93,14 @@ export default {
         } catch (error) { }
       }
     },
+    async setEducations({commit,state},force){
+      if (!state.educations.length || force === true) {
+        try {
+
+          const res = await findEducationUsers()
+          commit('commit_educations', res.data)
+        } catch (error) { }
+      }
+    }
   }
 }

+ 12 - 2
src/views/save-form-test/index.vue

@@ -53,6 +53,12 @@
             end-placeholder="结束日期">
           </el-date-picker>
         </el-form-item>
+        <el-form-item>
+          <remoteSearch :commit='"setEducations"'  v-model='form.educations' />
+        </el-form-item>
+         <el-form-item>
+          <remoteSearch :commit='"setTeachers"' v-model='form.educations' />
+        </el-form-item>
         <div>
           <el-button type="primary" native-type="submit">提交</el-button>
           <el-button type="danger" native-type="reset">重置</el-button>
@@ -102,10 +108,12 @@
 <script>
 import pagination from "@/components/Pagination/index";
 import test from './modals/test'
+import remoteSearch from "@/components/remote-search"
 export default {
   components: {
     test,
-    pagination
+    pagination,
+    remoteSearch
   },
   data() {
     return {
@@ -127,7 +135,8 @@ export default {
         type: [],
         resource: '',
         desc: '',
-        times: []
+        times: [],
+        educations:''
       },
       list: [{
         id: 1,
@@ -149,6 +158,7 @@ export default {
       return Promise.resolve()
     },
     submit(evt) {
+      console.log(this.form.educations)
       console.log(evt)
     },
     reset() {

+ 0 - 1
src/views/teacherManager/teacherList.vue

@@ -85,7 +85,6 @@
               :key="item.id"
               :label="item.name"
               :value="item.id"> </el-option>
-            ></el-option>
           </el-select>
         </el-form-item>
         <el-form-item>