lrf402788946 4 роки тому
батько
коміт
01b010b9ec

+ 310 - 272
src/views/train-plan/bedroom.vue

@@ -1,272 +1,310 @@
-<template>
-  <div id="bedroom">
-    <detail-frame :title="pageTitle" v-show="view == 'list'">
-      <el-alert type="warning" title="请确认好学生已经报到后再进行分寝" center :closable="false" class="btn_bar"></el-alert>
-      <el-row type="flex" align="middle" justify="end" class="btn_bar">
-        <el-col :span="2">
-          <el-button type="primary" size="mini" @click="toApart">一键分寝</el-button>
-        </el-col>
-      </el-row>
-      <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit" :usePage="false"></data-table>
-    </detail-frame>
-    <detail-frame :title="classInfo.name" :returns="toReturns" v-if="view != 'list'">
-      <el-row type="flex" justify="center">
-        <el-col :span="4">
-          <el-link :underline="false" type="primary" style="font-size:18px">男:{{ getGender('男') }}人</el-link>
-        </el-col>
-        <el-col :span="4">
-          <el-link :underline="false" type="success" style="font-size:18px">女:{{ getGender('女') }}人</el-link>
-        </el-col>
-      </el-row>
-      <el-row :gutter="10" class="schrow">
-        <el-col :span="4">本班学生来源:</el-col>
-        <el-col :span="4" v-for="(sch, index) in schList" :key="index">{{ sch }}</el-col>
-      </el-row>
-      <el-row style="padding:10px">
-        <el-col :span="2">
-          <el-button type="primary" size="mini" @click="toSelect">批量分配选择寝室</el-button>
-        </el-col>
-      </el-row>
-
-      <el-checkbox-group v-model="stuList">
-        <el-table :data="stuBedroom" size="mini" border stripe>
-          <el-table-column align="center" label="寝室号" prop="code" width="100" sortable></el-table-column>
-          <el-table-column align="center" label="楼层" prop="floor" width="100" sortable></el-table-column>
-          <el-table-column align="center" label="男女限制" prop="gender" width="100"></el-table-column>
-          <el-table-column align="center" label="人数" prop="number" width="100"></el-table-column>
-          <el-table-column align="center" label="学生">
-            <template v-slot="{ row }">
-              <el-row>
-                <el-col v-for="(i, index) in row.list" :key="index" :span="6">
-                  <el-checkbox :label="i.id" :disabled="checkSelect(i)">
-                    <el-link :type="i.gender.includes('男') ? 'primary' : 'success'">{{ i.name }}({{ i.gender }})</el-link>
-                  </el-checkbox>
-                </el-col>
-              </el-row>
-            </template>
-          </el-table-column>
-        </el-table>
-      </el-checkbox-group>
-    </detail-frame>
-    <el-dialog :visible.sync="selectDialog" title="批量修改寝室" center @close="toClose" width="30%">
-      <el-row>
-        <el-col :span="24" style="font-size:18px">
-          选择寝室:
-          <el-select v-model="bedroomCode" placeholder="请选择寝室" filterable>
-            <el-option v-for="(i, index) in assignList" :key="index" :label="i.name" :value="i.code"></el-option>
-          </el-select>
-        </el-col>
-      </el-row>
-      <template #footer>
-        <el-button type="primary" @click="toAllSave">批量保存</el-button>
-      </template>
-    </el-dialog>
-  </div>
-</template>
-
-<script>
-import _ from 'lodash';
-import axios from 'axios';
-import dataForm from '@frame/components/form';
-import dataTable from '@frame/components/filter-page-table';
-import detailFrame from '@frame/layout/admin/detail-frame';
-import { mapState, createNamespacedHelpers } from 'vuex';
-const { mapActions: classes } = createNamespacedHelpers('classes');
-const { mapActions: student } = createNamespacedHelpers('student');
-const { mapActions: bedroom } = createNamespacedHelpers('bedroom');
-const { mapActions: util } = createNamespacedHelpers('util');
-export default {
-  name: 'bedroom',
-  props: {},
-  components: { detailFrame, dataTable }, //dataForm
-  data: function() {
-    return {
-      view: 'list',
-      dialog: false,
-      selectDialog: false,
-      bedroomCode: undefined,
-      form: {},
-      list: [],
-      stuList: [],
-      stuBedroom: [],
-      bedroomList: [],
-      classInfo: {},
-      opera: [
-        {
-          label: '查看寝室',
-          icon: 'el-icon-view',
-          method: 'edit',
-        },
-      ],
-      fields: [
-        { label: '期', prop: 'term' },
-        { label: '批', prop: 'batch' },
-        { label: '班级', prop: 'name' },
-      ],
-      options: undefined,
-      ostuList: [],
-      assignList: [],
-      schList: [],
-    };
-  },
-  created() {},
-  methods: {
-    ...classes(['query']),
-    ...student({ getStudentList: 'query', updateStudent: 'update' }),
-    ...bedroom({ bedroomApart: 'apart', getBedroomList: 'query', classstuList: 'classstuList', updateBat: 'updateBat', getAssignRoom: 'getAssignRoom' }),
-    ...util({ modelFetch: 'fetch', utilMethod: 'utilMethod' }),
-    async search() {
-      let termid = _.get(this.defaultOption, 'termid');
-      if (!termid) return;
-      let res = await this.query({ termid });
-      if (this.$checkRes(res)) {
-        this.$set(this, `list`, res.data);
-      }
-      let bedres = await this.getBedroomList();
-      if (this.$checkRes(bedres)) this.$set(this, `bedroomList`, bedres.data);
-    },
-    toEdit({ data }) {
-      this.$set(this, `classInfo`, data);
-      this.view = 'class';
-      this.getSL();
-    },
-    async getSL() {
-      let res = await this.getStuList();
-      if (this.$checkRes(res)) {
-        // 获取班级里的学生的学校列表
-        let schGroup = _.groupBy(res.data, 'schid');
-        const schkeys = Object.keys(schGroup);
-        let schList = [];
-        for (const key of schkeys) {
-          const sg = schGroup[key];
-          const h = _.head(sg);
-          if (h) schList.push(_.get(h, 'school_name'));
-        }
-        this.$set(this, `schList`, schList);
-        let group = _.groupBy(res.data, 'bedroomid');
-        let keys = Object.keys(group);
-        // 组织数据
-        let arr = [];
-        for (const key of keys) {
-          if (key === undefined || key === `${undefined}` || key === null || key === 'null') {
-            let obj = { code: '未分寝' };
-            obj.list = group[`${key}`];
-            arr.push(obj);
-            continue;
-          }
-          const bedroom = this.bedroomList.find(f => f._id == key);
-          console.log(bedroom);
-          bedroom.list = group[key];
-          arr.push(bedroom);
-        }
-        this.$set(this, 'stuBedroom', arr);
-      }
-    },
-    async getStuList() {
-      let res = await this.getStudentList({ classid: this.classInfo._id });
-      if (this.$checkRes(res)) this.$set(this, `ostuList`, res.data);
-      return res;
-    },
-    async toApart() {
-      let { planid: trainplanid, termid } = this.options;
-      let batchList = _.uniq(this.list.map(i => i.batchid));
-      let axiosArr = [];
-      batchList.map(batchid => {
-        axiosArr.push(this.bedroomApart({ trainplanid, termid, batchid }));
-      });
-      axios.all(axiosArr).then(
-        axios.spread((...res) => {
-          let r = res.every(e => e && e.errcode == '0');
-          this.$message({
-            type: r ? 'success' : 'error',
-            message: r ? '分寝成功' : '分寝失败',
-          });
-        })
-      );
-    },
-    toReturns() {
-      this.view = 'list';
-      this.$set(this, `classInfo`, {});
-      this.$set(this, `stuBedroom`, []);
-    },
-    toClose() {
-      this.stuList = [];
-      this.selectDialog = false;
-      this.dialog = false;
-      this.form = {};
-    },
-    // 批量保存
-    async toAllSave() {
-      const msg = this.$message({ duration: 0, message: '正在处理,请稍后...' });
-      let code = _.clone(this.bedroomCode);
-      let ids = _.cloneDeep(this.stuList);
-      let bedroom = this.bedroomList.find(f => code == f.code);
-      if (bedroom) {
-        let termid = _.get(this.defaultOption, 'termid');
-        let res = await this.updateBat({ code, ids, bedroomid: bedroom.id, termid });
-        msg.close();
-        this.$checkRes(res, '保存成功', res.errmsg || '保存失败');
-      }
-      this.toClose();
-      this.getSL();
-    },
-    async toSelect() {
-      const msg = this.$message({ duration: 0, message: '正在查找寝室,请稍后...' });
-      const { termid } = this.defaultOption;
-      const res = await this.getAssignRoom({ termid });
-      if (res.errcode == '0') this.$set(this, `assignList`, res.data);
-      msg.close();
-      this.selectDialog = true;
-    },
-    getGender(gender) {
-      const r = this.ostuList.filter(f => f.gender.includes(gender));
-      return r.length;
-    },
-    // 性别多选过滤
-    checkSelect(i) {
-      if (this.stuList.length > 0) {
-        const h = _.head(this.stuList);
-        const stu = this.ostuList.find(f => f._id === h);
-        if (stu) return !i.gender.includes(stu.gender);
-      } else return false;
-    },
-  },
-  watch: {
-    defaultOption: {
-      immediate: true,
-      deep: true,
-      handler(val) {
-        if (!_.get(this, 'options')) {
-          this.$set(this, `options`, _.cloneDeep(val));
-          this.search();
-        } else {
-          let ntermid = _.get(val, 'termid');
-          let otermid = _.get(this.options, 'termid');
-          if (ntermid && !_.isEqual(ntermid, otermid)) {
-            this.$set(this, `options`, _.cloneDeep(val));
-            this.search();
-          }
-        }
-      },
-    },
-  },
-  computed: {
-    ...mapState(['user', 'defaultOption']),
-    pageTitle() {
-      return `${this.$route.meta.title}`;
-    },
-  },
-  metaInfo() {
-    return { title: this.$route.meta.title };
-  },
-};
-</script>
-
-<style lang="less" scoped>
-.schrow {
-  padding: 10px;
-  .el-col {
-    font-size: 20px;
-  }
-}
-</style>
+<template>
+  <div id="bedroom">
+    <detail-frame :title="pageTitle" v-show="view == 'list'">
+      <el-alert type="warning" title="请确认好学生已经报到后再进行分寝" center :closable="false" class="btn_bar"></el-alert>
+      <el-row type="flex" align="middle" justify="end" class="btn_bar">
+        <el-col :span="2">
+          <el-button type="primary" size="mini" @click="toApart">一键分寝</el-button>
+        </el-col>
+      </el-row>
+      <data-table :fields="fields" :data="list" :opera="opera" @edit="toEdit" :usePage="false"></data-table>
+    </detail-frame>
+    <detail-frame :title="classInfo.name" :returns="toReturns" v-if="view != 'list'">
+      <el-row type="flex" justify="center">
+        <el-col :span="4">
+          <el-link :underline="false" type="primary" style="font-size:18px">男:{{ getGender('男') }}人</el-link>
+        </el-col>
+        <el-col :span="4">
+          <el-link :underline="false" type="success" style="font-size:18px">女:{{ getGender('女') }}人</el-link>
+        </el-col>
+      </el-row>
+      <el-form :inline="true">
+        <el-form-item label="本班学生来源(可显示 未分寝中 指定 学校 的学生)">
+          <el-radio-group v-model="selectSchool">
+            <el-radio :label="undefined">全部</el-radio>
+            <el-radio v-for="(sch, index) in schList" :key="index" :label="sch.schid">
+              <span :style="`color:${schColor[sch.schid]}`">{{ sch.school_name }}</span>
+            </el-radio>
+          </el-radio-group>
+        </el-form-item>
+      </el-form>
+      <el-row style="padding:10px">
+        <el-col :span="2">
+          <el-button type="primary" size="mini" @click="toSelect">批量分配选择寝室</el-button>
+        </el-col>
+      </el-row>
+
+      <el-checkbox-group v-model="stuList">
+        <el-table :data="stuBedroom" size="mini" border stripe>
+          <el-table-column align="center" label="寝室号" prop="code" width="100" sortable></el-table-column>
+          <el-table-column align="center" label="楼层" prop="floor" width="100" sortable></el-table-column>
+          <el-table-column align="center" label="男女限制" prop="gender" width="100"></el-table-column>
+          <el-table-column align="center" label="人数" prop="number" width="100"></el-table-column>
+          <el-table-column align="center" label="学生">
+            <template v-slot="{ row }">
+              <el-row>
+                <el-col v-for="(i, index) in getList(row)" :key="index" :span="6">
+                  <el-checkbox :label="i.id" :disabled="checkSelect(i)">
+                    <el-link>
+                      <span :style="getColor(i)">{{ i.name }}({{ i.gender }})</span>
+                    </el-link>
+                  </el-checkbox>
+                </el-col>
+              </el-row>
+            </template>
+          </el-table-column>
+        </el-table>
+      </el-checkbox-group>
+    </detail-frame>
+    <el-dialog :visible.sync="selectDialog" title="批量修改寝室" center @close="toClose" width="30%">
+      <el-row>
+        <el-col :span="24" style="font-size:18px">
+          选择寝室:
+          <el-select v-model="bedroomCode" placeholder="请选择寝室" filterable>
+            <el-option v-for="(i, index) in assignList" :key="index" :label="i.name" :value="i.code"></el-option>
+          </el-select>
+        </el-col>
+      </el-row>
+      <template #footer>
+        <el-button type="primary" @click="toAllSave">批量保存</el-button>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script>
+import _ from 'lodash';
+import axios from 'axios';
+import dataForm from '@frame/components/form';
+import dataTable from '@frame/components/filter-page-table';
+import detailFrame from '@frame/layout/admin/detail-frame';
+import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: classes } = createNamespacedHelpers('classes');
+const { mapActions: student } = createNamespacedHelpers('student');
+const { mapActions: bedroom } = createNamespacedHelpers('bedroom');
+const { mapActions: util } = createNamespacedHelpers('util');
+export default {
+  name: 'bedroom',
+  props: {},
+  components: { detailFrame, dataTable }, //dataForm
+  data: function() {
+    return {
+      view: 'list',
+      dialog: false,
+      selectDialog: false,
+      bedroomCode: undefined,
+      form: {},
+      list: [],
+      stuList: [],
+      stuBedroom: [],
+      bedroomList: [],
+      classInfo: {},
+      opera: [
+        {
+          label: '查看寝室',
+          icon: 'el-icon-view',
+          method: 'edit',
+        },
+      ],
+      fields: [
+        { label: '期', prop: 'term' },
+        { label: '批', prop: 'batch' },
+        { label: '班级', prop: 'name' },
+      ],
+      options: undefined,
+      ostuList: [],
+      assignList: [],
+      schList: [],
+      schColor: {},
+      selectSchool: undefined,
+    };
+  },
+  created() {},
+  methods: {
+    ...classes(['query']),
+    ...student({ getStudentList: 'query', updateStudent: 'update' }),
+    ...bedroom({ bedroomApart: 'apart', getBedroomList: 'query', classstuList: 'classstuList', updateBat: 'updateBat', getAssignRoom: 'getAssignRoom' }),
+    ...util({ modelFetch: 'fetch', utilMethod: 'utilMethod' }),
+    async search() {
+      let termid = _.get(this.defaultOption, 'termid');
+      if (!termid) return;
+      let res = await this.query({ termid });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+      }
+      let bedres = await this.getBedroomList();
+      if (this.$checkRes(bedres)) this.$set(this, `bedroomList`, bedres.data);
+    },
+    toEdit({ data }) {
+      this.$set(this, `classInfo`, data);
+      this.view = 'class';
+      this.getSL();
+    },
+    async getSL() {
+      let res = await this.getStuList();
+      if (this.$checkRes(res)) {
+        // 获取班级里的学生的学校列表
+        let schGroup = _.groupBy(res.data, 'schid');
+        const schkeys = Object.keys(schGroup);
+        let schList = [];
+        for (const key of schkeys) {
+          const sg = schGroup[key];
+          const h = _.head(sg);
+          if (h) {
+            if (!this.schColor[key]) this.schColor[key] = this.rgb();
+            const school_name = _.get(h, 'school_name');
+            schList.push({ school_name, schid: key });
+          }
+        }
+        this.$set(this, `schList`, schList);
+        let group = _.groupBy(res.data, 'bedroomid');
+        let keys = Object.keys(group);
+        // 组织数据
+        let arr = [];
+        for (const key of keys) {
+          if (key === undefined || key === `${undefined}` || key === null || key === 'null') {
+            let obj = { code: '未分寝' };
+            obj.list = group[`${key}`];
+            arr.push(obj);
+            continue;
+          }
+          const bedroom = this.bedroomList.find(f => f._id == key);
+          console.log(bedroom);
+          bedroom.list = group[key];
+          arr.push(bedroom);
+        }
+        this.$set(this, 'stuBedroom', arr);
+      }
+    },
+    async getStuList() {
+      let res = await this.getStudentList({ classid: this.classInfo._id });
+      if (this.$checkRes(res)) this.$set(this, `ostuList`, res.data);
+      return res;
+    },
+    async toApart() {
+      let { planid: trainplanid, termid } = this.options;
+      let batchList = _.uniq(this.list.map(i => i.batchid));
+      let axiosArr = [];
+      batchList.map(batchid => {
+        axiosArr.push(this.bedroomApart({ trainplanid, termid, batchid }));
+      });
+      axios.all(axiosArr).then(
+        axios.spread((...res) => {
+          let r = res.every(e => e && e.errcode == '0');
+          this.$message({
+            type: r ? 'success' : 'error',
+            message: r ? '分寝成功' : '分寝失败',
+          });
+        })
+      );
+    },
+    toReturns() {
+      this.view = 'list';
+      this.$set(this, `classInfo`, {});
+      this.$set(this, `stuBedroom`, []);
+      this.selectSchool = undefined;
+      this.$set(this, `schColor`, {});
+    },
+    toClose() {
+      this.stuList = [];
+      this.selectDialog = false;
+      this.dialog = false;
+      this.form = {};
+    },
+    // 批量保存
+    async toAllSave() {
+      const msg = this.$message({ duration: 0, message: '正在处理,请稍后...' });
+      let code = _.clone(this.bedroomCode);
+      let ids = _.cloneDeep(this.stuList);
+      let bedroom = this.bedroomList.find(f => code == f.code);
+      if (bedroom) {
+        let termid = _.get(this.defaultOption, 'termid');
+        let res = await this.updateBat({ code, ids, bedroomid: bedroom.id, termid });
+        msg.close();
+        this.$checkRes(res, '保存成功', res.errmsg || '保存失败');
+      }
+      this.toClose();
+      this.getSL();
+    },
+    async toSelect() {
+      const msg = this.$message({ duration: 0, message: '正在查找寝室,请稍后...' });
+      const { termid } = this.defaultOption;
+      const res = await this.getAssignRoom({ termid });
+      if (res.errcode == '0') this.$set(this, `assignList`, res.data);
+      msg.close();
+      this.selectDialog = true;
+    },
+    getGender(gender) {
+      const r = this.ostuList.filter(f => f.gender.includes(gender));
+      return r.length;
+    },
+    // 性别多选过滤
+    checkSelect(i) {
+      if (this.stuList.length > 0) {
+        const h = _.head(this.stuList);
+        const stu = this.ostuList.find(f => f._id === h);
+        if (stu) return !i.gender.includes(stu.gender);
+      } else return false;
+    },
+    // 随机生成颜色
+    rgb() {
+      let r = Math.floor(Math.random() * 255);
+      let g = Math.floor(Math.random() * 255);
+      let b = Math.floor(Math.random() * 255);
+      let rgb = `rgb(${r},${g},${b})`;
+      return rgb;
+    },
+    // 取出指定学校的颜色
+    getColor(data) {
+      const style = { color: 'blue' };
+      const color = this.schColor[data.schid];
+      if (color) style.color = color;
+      return style;
+    },
+    // 过滤未分寝的学生名单
+    getList(row) {
+      if (row.code !== '未分寝') return _.get(row, 'list', []);
+      if (!this.selectSchool) return _.get(row, 'list', []);
+      const list = row.list.filter(f => f.schid === this.selectSchool);
+      return list;
+    },
+  },
+  watch: {
+    defaultOption: {
+      immediate: true,
+      deep: true,
+      handler(val) {
+        if (!_.get(this, 'options')) {
+          this.$set(this, `options`, _.cloneDeep(val));
+          this.search();
+        } else {
+          let ntermid = _.get(val, 'termid');
+          let otermid = _.get(this.options, 'termid');
+          if (ntermid && !_.isEqual(ntermid, otermid)) {
+            this.$set(this, `options`, _.cloneDeep(val));
+            this.search();
+          }
+        }
+      },
+    },
+  },
+  computed: {
+    ...mapState(['user', 'defaultOption']),
+    pageTitle() {
+      return `${this.$route.meta.title}`;
+    },
+  },
+  metaInfo() {
+    return { title: this.$route.meta.title };
+  },
+};
+</script>
+
+<style lang="less" scoped>
+.schrow {
+  padding: 10px;
+  .el-col {
+    font-size: 20px;
+  }
+}
+</style>

+ 2 - 2
src/views/train-plan/parts/excel-term-lesson.vue

@@ -378,7 +378,7 @@ export default {
     // 点击事件
     // 修改教师
     clickTeacher(date, cla) {
-      const { lesson } = cla;
+      const { lesson, type } = cla;
       if (!lesson) return '-';
       const { lessons } = lesson;
       if (!lessons) return '-';
@@ -399,7 +399,7 @@ export default {
       } else {
         const { _id } = lesson;
         let h = _.head(lessonDay);
-        h = { ...h, lessonObjectId: _id, classname: cla.name };
+        h = { ...h, lessonObjectId: _id, classname: cla.name, classtype: type };
         if (cla.enddate === h.date) h.is_last = true;
         this.$emit('lessonChange', h);
       }

+ 11 - 2
src/views/train-plan/parts/term-lesson-form.vue

@@ -4,8 +4,8 @@
       <el-form-item label="班级">{{ form.classname.includes('班') ? form.classname : `${form.classname}班` }}</el-form-item>
       <el-form-item label="日期">{{ form.date }}</el-form-item>
       <el-form-item label="课程安排">
-        <el-select v-model="form.subid" placeholder="请选择课程">
-          <el-option v-for="(i, index) in subjectList" :key="index" :label="i.name" :value="i.id"></el-option>
+        <el-select v-model="form.subid" placeholder="请选择课程" :disabled="true">
+          <el-option v-for="(i, index) in selectSubject" :key="index" :label="i.name" :value="i.id"></el-option>
         </el-select>
       </el-form-item>
       <el-form-item label="教师安排">
@@ -113,6 +113,15 @@ export default {
     pageTitle() {
       return `${this.$route.meta.title}`;
     },
+    selectSubject() {
+      let subs = _.cloneDeep(this.subjectList);
+      const ctype = _.get(this.data, 'classtype');
+      console.log(subs, ctype);
+      if (ctype) {
+        subs = subs.filter(f => f.type === ctype);
+      }
+      return subs;
+    },
   },
   metaInfo() {
     return { title: this.$route.meta.title };