lrf402788946 5 rokov pred
rodič
commit
65728a07fb

+ 2 - 1
src/views/new-plan/arrange.vue

@@ -443,7 +443,8 @@ export default {
     },
     },
     returns() {
     returns() {
       if (this.view == 'plan') this.$router.push({ path: './index' });
       if (this.view == 'plan') this.$router.push({ path: './index' });
-      else this.view = 'plan';
+      else if (this.view == 'school') this.view = 'plan';
+      else this.view = 'school';
     },
     },
     changeView() {
     changeView() {
       this.savePlan();
       this.savePlan();

+ 15 - 5
src/views/new-plan/class/classes.vue

@@ -16,7 +16,7 @@
               </el-select>
               </el-select>
             </el-form-item>
             </el-form-item>
             <el-form-item>
             <el-form-item>
-              <el-button type="primary" @click="toSetClass">一键分班</el-button>
+              <el-button type="primary" @click="toAutoSetClass">一键分班</el-button>
             </el-form-item>
             </el-form-item>
           </el-form>
           </el-form>
           <el-form :inline="true" size="mini">
           <el-form :inline="true" size="mini">
@@ -26,7 +26,7 @@
               </el-select>
               </el-select>
             </el-form-item>
             </el-form-item>
             <el-form-item label="班级">
             <el-form-item label="班级">
-              <el-select v-model="selectInfo.classname" placeholder="请先选择批次" @change="getLimit">
+              <el-select v-model="selectInfo.classid" placeholder="请先选择批次" @change="getLimit">
                 <el-option v-for="(i, index) in classList" :key="index" :label="i.name" :value="i._id"></el-option>
                 <el-option v-for="(i, index) in classList" :key="index" :label="i.name" :value="i._id"></el-option>
               </el-select>
               </el-select>
             </el-form-item>
             </el-form-item>
@@ -104,7 +104,7 @@ export default {
     ...trainPlan(['fetch']),
     ...trainPlan(['fetch']),
     ...schPlan({ schQuery: 'query' }),
     ...schPlan({ schQuery: 'query' }),
     ...student({ getStudentList: 'noClass' }), //noClass
     ...student({ getStudentList: 'noClass' }), //noClass
-    ...classes({ getClassesList: 'query', createClass: 'divide' }),
+    ...classes({ getClassesList: 'query', createClass: 'divide', addStudent: 'addStudent' }),
     ...director({ getDirectorList: 'query' }),
     ...director({ getDirectorList: 'query' }),
     ...dept({ getDeptList: 'query' }),
     ...dept({ getDeptList: 'query' }),
     async search({ skip = 0, limit = 10, ...info } = {}) {
     async search({ skip = 0, limit = 10, ...info } = {}) {
@@ -118,13 +118,13 @@ export default {
     async stuSearch({ skip = 0, limit = 10, ...info } = {}) {
     async stuSearch({ skip = 0, limit = 10, ...info } = {}) {
       // let { termid } = info;
       // let { termid } = info;
       // this.selectInfo.termid = termid;
       // this.selectInfo.termid = termid;
+      this.getBatch(this.selectInfo.termid);
       const res = await this.getStudentList({ termid: this.selectInfo.termid, skip, limit });
       const res = await this.getStudentList({ termid: this.selectInfo.termid, skip, limit });
       if (this.$checkRes(res)) {
       if (this.$checkRes(res)) {
         this.$set(this, `list`, res.data);
         this.$set(this, `list`, res.data);
         this.$set(this, `total`, res.total);
         this.$set(this, `total`, res.total);
       }
       }
       if (skip !== 0) return;
       if (skip !== 0) return;
-      this.getBatch(this.selectInfo.termid);
     },
     },
     getBatch(termid) {
     getBatch(termid) {
       let batchs = this.termList.filter(f => f._id === termid);
       let batchs = this.termList.filter(f => f._id === termid);
@@ -180,7 +180,7 @@ export default {
       this.$set(this.selectInfo, `male`, male);
       this.$set(this.selectInfo, `male`, male);
       this.$set(this.selectInfo, `female`, female);
       this.$set(this.selectInfo, `female`, female);
     },
     },
-    async toSetClass() {
+    async toAutoSetClass() {
       // 整理数据生成班级;将学生列表重新查询=>为了将已经有班级的学生剔除,以便继续分班(重新查询)
       // 整理数据生成班级;将学生列表重新查询=>为了将已经有班级的学生剔除,以便继续分班(重新查询)
       let info = JSON.parse(JSON.stringify(_.omit(this.selectInfo, ['male', 'female', 'personReq', 'students'])));
       let info = JSON.parse(JSON.stringify(_.omit(this.selectInfo, ['male', 'female', 'personReq', 'students'])));
       info.planid = this.id;
       info.planid = this.id;
@@ -198,6 +198,16 @@ export default {
       // this.selected = [];
       // this.selected = [];
       // this.$refs.table.selectReset();
       // this.$refs.table.selectReset();
     },
     },
+    async toSetClass() {
+      let data = {};
+      data.id = _.pick(this.selectInfo, ['classid']).classid;
+      let stuList = JSON.parse(JSON.stringify(this.selected));
+      data.ids = stuList.map(i => i._id);
+      let res = await this.addStudent(data);
+      if (this.$checkRes(res, '分配成功', res.errmsg || '分配失败')) {
+        this.$router.push({ path: './index' });
+      }
+    },
     isOutRange(selected) {
     isOutRange(selected) {
       let res = true;
       let res = true;
       if (selected.length <= 0) this.$message.warning('请选择学生');
       if (selected.length <= 0) this.$message.warning('请选择学生');

+ 12 - 1
src/views/new-plan/class/lesson/lesson-table.vue

@@ -11,7 +11,14 @@
       </template>
       </template>
       <el-table :data="lessonList" border stripe @cell-click="cellClick">
       <el-table :data="lessonList" border stripe @cell-click="cellClick">
         <el-table-column align="center" label="时间" prop="time"></el-table-column>
         <el-table-column align="center" label="时间" prop="time"></el-table-column>
-        <el-table-column align="center" v-for="(i, index) in dateList" :key="index" :label="i" :prop="`subname_day${index + 1}`"></el-table-column>
+        <el-table-column align="center" v-for="(i, index) in dateList" :key="index" :label="i" :prop="`subname_day${index + 1}`">
+          <template v-slot="{ row, $index }">
+            <el-row>
+              <el-col :span="24">{{ getProp(row, `subname_day${index + 1}`) }}</el-col>
+              <el-col :span="24" v-if="getProp(row, `teaname_day${index + 1}`)">{{ getProp(row, `teaname_day${index + 1}`) }}</el-col>
+            </el-row>
+          </template>
+        </el-table-column>
       </el-table>
       </el-table>
     </el-card>
     </el-card>
 
 
@@ -312,6 +319,10 @@ export default {
       this.dialog = false;
       this.dialog = false;
       this.$set(this, `form`, { ...this.form, ...data });
       this.$set(this, `form`, { ...this.form, ...data });
     },
     },
+    //显示
+    getProp(data, prop) {
+      return _.get(data, prop);
+    },
   },
   },
   computed: {
   computed: {
     ...mapState(['user']),
     ...mapState(['user']),

+ 102 - 34
src/views/new-plan/class/name-list.vue

@@ -1,29 +1,45 @@
 <template>
 <template>
   <div id="name-list">
   <div id="name-list">
-    <list-frame :title="pageTitle" @query="classSearch" :total="total" :needAdd="false" :needFilter="false" returns="./index">
+    <list-frame :title="pageTitle" @query="getStudent" :total="total" :needAdd="false" :needFilter="false" returns="./index">
       <el-card style="padding:10px">
       <el-card style="padding:10px">
         <el-row>
         <el-row>
-          <el-form :inline="true" size="mini">
-            <el-form-item label="期">
-              <el-select v-model="selectInfo.termid" placeholder="请选择期数" @change="getBatch">
-                <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
-              </el-select>
-            </el-form-item>
-            <el-form-item label="批次">
-              <el-select v-model="selectInfo.batchid" placeholder="请先选择期数" @change="getClasses">
-                <el-option v-for="(i, index) in batchList" :key="index" :label="i.name" :value="i._id"></el-option>
-              </el-select>
-            </el-form-item>
-            <el-form-item label="班级">
-              <el-select v-model="selectInfo.classname" placeholder="请先选择批次" @change="getStudent">
-                <el-option v-for="(i, index) in classList" :key="index" :label="i.name" :value="i._id"></el-option>
-              </el-select>
-            </el-form-item>
-          </el-form>
+          <el-col :span="20">
+            <el-form :inline="true" size="mini">
+              <el-form-item label="期">
+                <el-select v-model="selectInfo.termid" placeholder="请选择期数" @change="getBatch">
+                  <el-option v-for="(i, index) in termList" :key="index" :label="`第${i.term}期`" :value="i._id"></el-option>
+                </el-select>
+              </el-form-item>
+              <el-form-item label="批次">
+                <el-select v-model="selectInfo.batchid" placeholder="请先选择期数" @change="getClasses">
+                  <el-option v-for="(i, index) in batchList" :key="index" :label="i.name" :value="i._id"></el-option>
+                </el-select>
+              </el-form-item>
+              <el-form-item label="班级">
+                <el-select v-model="selectInfo.classid" placeholder="请先选择批次" @change="getStudent()">
+                  <el-option v-for="(i, index) in classList" :key="index" :label="i.name" :value="i._id"></el-option>
+                </el-select>
+              </el-form-item>
+            </el-form>
+          </el-col>
+          <el-col :span="2">
+            <el-button type="danger" plain @click="toDelete" size="mini" v-if="list.length > 0" :disabled="selected.length <= 0">
+              {{ selected.length > 0 ? `将选中的 ${selected.length}名学生 从班级移除` : '请选择要从班级移除的学生' }}
+            </el-button>
+          </el-col>
         </el-row>
         </el-row>
-        <data-table :fields="fields" :data="list" :opera="opera" @turn="toTurn" @delete="toDelete"></data-table>
+        <data-table :fields="fields" :select="true" :selected="selected" @handleSelect="toSelect" :data="list" :opera="opera" @turn="toTurn"></data-table>
       </el-card>
       </el-card>
     </list-frame>
     </list-frame>
+    <el-dialog :visible.sync="dialog" title="转班" @close="toClose" width="30%">
+      <data-form :data="form" :fields="turnFields" :rules="{}" @save="turnSave">
+        <template #options="{item,form}">
+          <template v-if="item.model == 'classid'">
+            <el-option v-for="(i, index) in allTermClass" :key="index" :label="`第${i.batch}批-${i.name}`" :value="i._id"></el-option>
+          </template>
+        </template>
+      </data-form>
+    </el-dialog>
   </div>
   </div>
 </template>
 </template>
 
 
@@ -31,6 +47,7 @@
 import _ from 'lodash';
 import _ from 'lodash';
 import listFrame from '@frame/layout/admin/list-frame';
 import listFrame from '@frame/layout/admin/list-frame';
 import dataTable from '@frame/components/data-table';
 import dataTable from '@frame/components/data-table';
+import dataForm from '@frame/components/form';
 import { mapState, createNamespacedHelpers } from 'vuex';
 import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions: trainPlan } = createNamespacedHelpers('trainplan');
 const { mapActions: trainPlan } = createNamespacedHelpers('trainplan');
 const { mapActions: classes } = createNamespacedHelpers('classes');
 const { mapActions: classes } = createNamespacedHelpers('classes');
@@ -38,12 +55,15 @@ const { mapActions: student } = createNamespacedHelpers('student');
 export default {
 export default {
   name: 'name-list',
   name: 'name-list',
   props: {},
   props: {},
-  components: { listFrame, dataTable },
+  components: { listFrame, dataTable, dataForm },
   data: function() {
   data: function() {
     return {
     return {
+      dialog: false,
+      form: {},
       termList: [],
       termList: [],
       batchList: [],
       batchList: [],
       classList: [],
       classList: [],
+      allTermClass: [],
       list: [],
       list: [],
       opera: [
       opera: [
         {
         {
@@ -51,29 +71,26 @@ export default {
           icon: 'el-icon-refresh',
           icon: 'el-icon-refresh',
           method: 'turn',
           method: 'turn',
         },
         },
-        {
-          label: '移除该班',
-          icon: 'el-icon-delete',
-          method: 'delete',
-          confirm: true,
-        },
       ],
       ],
       fields: [
       fields: [
         { label: '姓名', prop: 'name' },
         { label: '姓名', prop: 'name' },
         { label: '性别', prop: 'gender' },
         { label: '性别', prop: 'gender' },
         { label: '民族', prop: 'nation' },
         { label: '民族', prop: 'nation' },
         { label: '身份证号', prop: 'id_number' },
         { label: '身份证号', prop: 'id_number' },
-        { label: '期', prop: 'term' },
-        { label: '批次', prop: 'batch' },
-        { label: '班级', prop: 'class' },
         { label: '学校', prop: 'school_name' },
         { label: '学校', prop: 'school_name' },
         { label: '院系', prop: 'faculty' },
         { label: '院系', prop: 'faculty' },
         { label: '专业', prop: 'major' },
         { label: '专业', prop: 'major' },
         { label: '手机号', prop: 'phone' },
         { label: '手机号', prop: 'phone' },
         { label: '邮箱', prop: 'email' },
         { label: '邮箱', prop: 'email' },
       ],
       ],
+      turnFields: [
+        { label: '姓名', model: 'name', type: 'text' },
+        { label: '学校', model: 'school_name', type: 'text' },
+        { label: '班级', model: 'classid', type: 'select' },
+      ],
       selectInfo: {},
       selectInfo: {},
       total: 0,
       total: 0,
+      selected: [],
     };
     };
   },
   },
   created() {
   created() {
@@ -82,7 +99,7 @@ export default {
   methods: {
   methods: {
     ...trainPlan(['fetch']),
     ...trainPlan(['fetch']),
     ...classes({ getClassesList: 'query' }),
     ...classes({ getClassesList: 'query' }),
-    ...student({ getStudentList: 'query' }),
+    ...student({ getStudentList: 'query', updateStudent: 'update', removeClass: 'removeClass' }),
     async search({ skip = 0, limit = 10, ...info } = {}) {
     async search({ skip = 0, limit = 10, ...info } = {}) {
       const res = await this.fetch(this.id);
       const res = await this.fetch(this.id);
       if (this.$checkRes(res)) {
       if (this.$checkRes(res)) {
@@ -104,12 +121,63 @@ export default {
         this.$set(this, `classList`, res.data);
         this.$set(this, `classList`, res.data);
       }
       }
     },
     },
-    async getStudent(batchid) {
-      let res = await this.getStudentList({ batchid });
+    async getStudent({ skip = 0, limit = 10, ...info } = {}) {
+      let res = await this.getStudentList({ classid: this.selectInfo.classid, skip, limit, ...info });
+      if (this.$checkRes(res)) {
+        this.$set(this, `list`, res.data);
+        this.$set(this, `total`, res.total);
+      }
     },
     },
     async classSearch({ skip = 0, limit = 10, ...info } = {}) {},
     async classSearch({ skip = 0, limit = 10, ...info } = {}) {},
-    toTurn({ data }) {},
-    toDelete({ data }) {},
+    toTurn({ data }) {
+      let duplicate = _.cloneDeep(data);
+      let batch = this.batchList.find(f => f._id == data.batchid);
+      if (batch) duplicate.batch = batch.batch;
+      this.$set(this, `form`, duplicate);
+      this.dialog = true;
+      this.getAllTermClass();
+    },
+    async turnSave({ data }) {
+      let res = await this.updateStudent(data);
+      if (this.$checkRes(res, '转班成功', res.errmsg || '转班失败')) {
+        this.getStudent();
+        this.toClose();
+      }
+    },
+    async toDelete() {
+      if (this.selected.length <= 0) {
+        this.$message.warning('您没有选择要移出该班的学生');
+        return;
+      }
+      this.$confirm('您确定要从该班移除这些学生吗?', '移出班级', {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        type: 'warning',
+      }).then(async () => {
+        let ids = this.selected.map(i => i._id);
+        let res = await this.removeClass(ids);
+        if (this.$checkRes(res, '移除成功', res.errmsg || '移除失败')) this.getStudent();
+      });
+    },
+    async getAllTermClass() {
+      let res = await this.getClassesList({ termid: this.selectInfo.termid });
+      if (this.$checkRes(res)) {
+        let duplicate = _.cloneDeep(res.data);
+        duplicate = duplicate.map(i => {
+          let r = this.batchList.find(bf => bf._id == i.batchid);
+          if (r) i.batch = r.batch;
+          return i;
+        });
+        this.$set(this, `allTermClass`, duplicate);
+      }
+    },
+    toClose() {
+      this.dialog = false;
+      this.form = {};
+    },
+    toSelect(selecteds) {
+      this.$set(this, `selected`, selecteds);
+    },
   },
   },
   computed: {
   computed: {
     ...mapState(['user']),
     ...mapState(['user']),

+ 41 - 5
src/views/new-plan/class/setting.vue

@@ -18,7 +18,13 @@
       <data-table ref="table" :fields="fields" :data="list" :opera="opera" @setting="toSetting"></data-table>
       <data-table ref="table" :fields="fields" :data="list" :opera="opera" @setting="toSetting"></data-table>
     </list-frame>
     </list-frame>
     <detail-frame v-else title="返回" :returns="deReturn">
     <detail-frame v-else title="返回" :returns="deReturn">
-      <setting-detail @save="toSave" :classInfo="classInfo" :locationList="locationList" :lyTeacherList="lyTeacherList"></setting-detail>
+      <setting-detail
+        @save="toSave"
+        :classInfo="classInfo"
+        :locationList="locationList"
+        :lyTeacherList="lyTeacherList"
+        :headTeacherList="headTeacherList"
+      ></setting-detail>
     </detail-frame>
     </detail-frame>
   </div>
   </div>
 </template>
 </template>
@@ -38,6 +44,8 @@ const { mapActions: location } = createNamespacedHelpers('location'); //地点
 const { mapActions: teacher } = createNamespacedHelpers('teacher'); //教师
 const { mapActions: teacher } = createNamespacedHelpers('teacher'); //教师
 const { mapActions: dept } = createNamespacedHelpers('dept'); //配合教师表使用的部门表
 const { mapActions: dept } = createNamespacedHelpers('dept'); //配合教师表使用的部门表
 const { mapActions: dirPlan } = createNamespacedHelpers('dirPlan'); //班主任不能上课的列表
 const { mapActions: dirPlan } = createNamespacedHelpers('dirPlan'); //班主任不能上课的列表
+const { mapActions: teaplan } = createNamespacedHelpers('teaPlan');
+const { mapActions: mapDept } = createNamespacedHelpers('dept');
 
 
 export default {
 export default {
   name: 'setting',
   name: 'setting',
@@ -65,6 +73,8 @@ export default {
       //setting-detail list:
       //setting-detail list:
       locationList: [],
       locationList: [],
       lyTeacherList: [],
       lyTeacherList: [],
+      headTeacherList: [],
+      deptList: [],
     };
     };
   },
   },
   created() {
   created() {
@@ -78,6 +88,8 @@ export default {
     ...location({ getLocationList: 'query' }),
     ...location({ getLocationList: 'query' }),
     ...teacher({ getTeacherList: 'query' }),
     ...teacher({ getTeacherList: 'query' }),
     ...dirPlan({ dirQuery: 'getDirTeacher' }),
     ...dirPlan({ dirQuery: 'getDirTeacher' }),
+    ...mapDept({ getDept: 'query' }),
+    ...teaplan(['findTeacher']),
     async search({ skip = 0, limit = 10, ...info } = {}) {
     async search({ skip = 0, limit = 10, ...info } = {}) {
       let res = await this.getTrainPlan(this.id);
       let res = await this.getTrainPlan(this.id);
       if (this.$checkRes(res)) {
       if (this.$checkRes(res)) {
@@ -86,7 +98,7 @@ export default {
     },
     },
     async toSetting({ data }) {
     async toSetting({ data }) {
       this.view = 'class';
       this.view = 'class';
-      this.getSettingLists();
+      this.getSettingLists(data);
       this.$set(this, `classInfo`, JSON.parse(JSON.stringify(data)));
       this.$set(this, `classInfo`, JSON.parse(JSON.stringify(data)));
     },
     },
     async toGetClass(data) {
     async toGetClass(data) {
@@ -98,7 +110,7 @@ export default {
     deReturn() {
     deReturn() {
       this.view = 'list';
       this.view = 'list';
     },
     },
-    async getSettingLists() {
+    async getSettingLists(data) {
       let res;
       let res;
       if (this.locationList.length <= 0) {
       if (this.locationList.length <= 0) {
         res = await this.getLocationList();
         res = await this.getLocationList();
@@ -109,8 +121,32 @@ export default {
         if (this.$checkRes(res)) this.$set(this, `lyTeacherList`, res.data);
         if (this.$checkRes(res)) this.$set(this, `lyTeacherList`, res.data);
       }
       }
       //TODO 需要重写这个方法,班主任上报的是日期,不是批次,需要查出该班主任上报的事件在不在批次时间中
       //TODO 需要重写这个方法,班主任上报的是日期,不是批次,需要查出该班主任上报的事件在不在批次时间中
-      res = await this.dirQuery({ batchid: this.batchid });
-      console.log(res);
+      if (this.headTeacherList.length <= 0) {
+        res = await this.findTeacher({ planid: data.planid, termid: data.termid, batchid: data.batchid });
+        let duplicate = _.cloneDeep(res.data);
+        if (this.$checkRes(res)) {
+          if (this.deptList.length <= 0) {
+            let dept = await this.getDept();
+            if (this.$checkRes(res)) this.$set(this, `deptList`, dept.data);
+          }
+          //班主任按部门分组
+          let group = _.groupBy(res.data, 'department');
+          let keys = Object.keys(group);
+          let arr = keys.map(key => {
+            let r = this.deptList.find(f => f.id == key);
+            let obj = {};
+            if (r) {
+              obj.name = r.name;
+              obj.list = group[key];
+            }
+            return obj;
+          });
+          this.$set(this, `headTeacherList`, arr);
+          //班主任筛选可以当礼仪老师列表,和 礼仪教师列表合并
+          duplicate = duplicate.filter(f => f.islyteacher == '1');
+          this.$set(this, `lyTeacherList`, [...this.lyTeacherList, ...duplicate]);
+        }
+      }
     },
     },
     async toSave(data) {
     async toSave(data) {
       console.log(data);
       console.log(data);

+ 5 - 1
src/views/new-plan/class/setting/detail.vue

@@ -3,7 +3,9 @@
     <data-form :data="form" :fields="fields" :rules="{}" @save="handleSave" :reset="false">
     <data-form :data="form" :fields="fields" :rules="{}" @save="handleSave" :reset="false">
       <template #options="{item, form}">
       <template #options="{item, form}">
         <template v-if="item.model == 'headteacherid'">
         <template v-if="item.model == 'headteacherid'">
-          班主任
+          <el-option-group v-for="(dept, index) in headTeacherList" :label="dept.name" :key="index">
+            <el-option v-for="(i, tIndex) in dept.list" :key="`${index}-${tIndex}`" :label="i.name" :value="i._id"></el-option>
+          </el-option-group>
         </template>
         </template>
         <template v-if="item.model == 'lyteacherid'">
         <template v-if="item.model == 'lyteacherid'">
           <el-option v-for="(tea, index) in lyTeacherList" :key="`${item.model}${index}`" :label="tea.name" :value="tea.id"></el-option>
           <el-option v-for="(tea, index) in lyTeacherList" :key="`${item.model}${index}`" :label="tea.name" :value="tea.id"></el-option>
@@ -29,12 +31,14 @@
 import _ from 'lodash';
 import _ from 'lodash';
 import dataForm from '@frame/components/form';
 import dataForm from '@frame/components/form';
 import { mapState, createNamespacedHelpers } from 'vuex';
 import { mapState, createNamespacedHelpers } from 'vuex';
+const { mapActions: classes } = createNamespacedHelpers('classes');
 export default {
 export default {
   name: 'detail',
   name: 'detail',
   props: {
   props: {
     classInfo: { type: Object, default: () => {} },
     classInfo: { type: Object, default: () => {} },
     locationList: { type: Array, default: () => [] },
     locationList: { type: Array, default: () => [] },
     lyTeacherList: { type: Array, default: () => [] },
     lyTeacherList: { type: Array, default: () => [] },
+    headTeacherList: { type: Array, default: () => [] },
   },
   },
   components: { dataForm },
   components: { dataForm },
   data: function() {
   data: function() {

+ 17 - 6
src/views/new-plan/parts/director-arrange.vue

@@ -8,7 +8,7 @@
         <el-button type="primary" size="mini" @click="toArrange">一键分配</el-button>
         <el-button type="primary" size="mini" @click="toArrange">一键分配</el-button>
       </el-col>
       </el-col>
     </el-row>
     </el-row>
-    <data-table :fields="fields" :data="classList" :opera="opera" @edit="toEdit" :toFormat="toFormat"></data-table>
+    <data-table v-loading="loading" :fields="fields" :data="classList" :opera="opera" @edit="toEdit" :toFormat="toFormat"></data-table>
     <el-dialog title="选择班主任" :visible.sync="dialog" width="20%">
     <el-dialog title="选择班主任" :visible.sync="dialog" width="20%">
       <data-form :data="form" :fields="fields" :rules="{}" @save="handleSave">
       <data-form :data="form" :fields="fields" :rules="{}" @save="handleSave">
         <template #options="{item,form}">
         <template #options="{item,form}">
@@ -31,6 +31,7 @@ import { mapState, createNamespacedHelpers } from 'vuex';
 const { mapActions } = createNamespacedHelpers('teaPlan');
 const { mapActions } = createNamespacedHelpers('teaPlan');
 const { mapActions: classes } = createNamespacedHelpers('classes');
 const { mapActions: classes } = createNamespacedHelpers('classes');
 const { mapActions: mapDept } = createNamespacedHelpers('dept');
 const { mapActions: mapDept } = createNamespacedHelpers('dept');
+const { mapActions: director } = createNamespacedHelpers('director');
 export default {
 export default {
   name: 'director-arrange',
   name: 'director-arrange',
   props: {
   props: {
@@ -39,10 +40,12 @@ export default {
   components: { dataTable, dataForm },
   components: { dataTable, dataForm },
   data: function() {
   data: function() {
     return {
     return {
+      loading: true,
       dialog: false,
       dialog: false,
       form: {},
       form: {},
       classList: [],
       classList: [],
       htList: [],
       htList: [],
+      dirList: [],
       deptList: [],
       deptList: [],
       fields: [
       fields: [
         { label: '期', prop: 'term', model: 'term', type: 'text' },
         { label: '期', prop: 'term', model: 'term', type: 'text' },
@@ -64,9 +67,10 @@ export default {
     this.search();
     this.search();
   },
   },
   methods: {
   methods: {
+    ...director({ getDirList: 'query' }),
     ...mapDept({ getDept: 'query' }),
     ...mapDept({ getDept: 'query' }),
     ...mapActions(['divide', 'findTeacher']),
     ...mapActions(['divide', 'findTeacher']),
-    ...classes(['query']),
+    ...classes(['query', 'upHeadTea']),
     async search() {
     async search() {
       let res = await this.query({ planid: this.id });
       let res = await this.query({ planid: this.id });
       if (this.$checkRes(res)) {
       if (this.$checkRes(res)) {
@@ -79,11 +83,12 @@ export default {
           return i;
           return i;
         });
         });
         arr = _.reverse(arr.sort((a, b) => a.term - b.term && a.batch - b.batch));
         arr = _.reverse(arr.sort((a, b) => a.term - b.term && a.batch - b.batch));
-        // arr = _.orderBy(arr, ['term', 'batch'], ['asc', 'asc']);
         this.$set(this, `classList`, arr);
         this.$set(this, `classList`, arr);
+        this.loading = false;
       }
       }
     },
     },
     async toArrange() {
     async toArrange() {
+      this.loading = true;
       let res = await this.divide({ trainplanid: this.id });
       let res = await this.divide({ trainplanid: this.id });
       if (this.$checkRes(res)) {
       if (this.$checkRes(res)) {
         let arr = this.classList.map(i => {
         let arr = this.classList.map(i => {
@@ -93,6 +98,7 @@ export default {
         });
         });
         this.$set(this, `classList`, arr);
         this.$set(this, `classList`, arr);
       }
       }
+      this.loading = false;
     },
     },
     async toEdit({ data, index }) {
     async toEdit({ data, index }) {
       let res = await this.findTeacher({ planid: data.planid, termid: data.termid, batchid: data.batchid });
       let res = await this.findTeacher({ planid: data.planid, termid: data.termid, batchid: data.batchid });
@@ -118,15 +124,20 @@ export default {
       this.$set(this.classList, index, info);
       this.$set(this.classList, index, info);
       this.dialog = false;
       this.dialog = false;
     },
     },
-    async toSave() {},
+    async toSave() {
+      let data = JSON.parse(JSON.stringify(this.classList));
+      let res = await this.upHeadTea(data);
+      if (this.$checkRes(res, '保存成功', res.errmsg || '保存失败')) console.log(res);
+    },
     async getOtherList() {
     async getOtherList() {
       let res = await this.getDept();
       let res = await this.getDept();
       if (this.$checkRes(res)) this.$set(this, `deptList`, res.data);
       if (this.$checkRes(res)) this.$set(this, `deptList`, res.data);
+      res = await this.getDirList();
+      if (this.$checkRes(res)) this.$set(this, `dirList`, res.data);
     },
     },
     toFormat({ model, value }) {
     toFormat({ model, value }) {
       if (model == 'headteacherid') {
       if (model == 'headteacherid') {
-        let arr = _.flatten(this.htList.map(i => i.list));
-        let r = arr.find(f => f._id == value);
+        let r = this.dirList.find(f => f._id == value);
         if (r) return r.name;
         if (r) return r.name;
       }
       }
     },
     },

+ 1 - 3
src/views/new-plan/parts/school-arrange.vue

@@ -184,7 +184,6 @@ export default {
           else i.remaining = 0;
           else i.remaining = 0;
           return i;
           return i;
         });
         });
-        console.log(school);
         this.$set(this, `list`, school);
         this.$set(this, `list`, school);
         await this.getSchoolPlan();
         await this.getSchoolPlan();
         await this.getTotal();
         await this.getTotal();
@@ -258,10 +257,9 @@ export default {
       });
       });
       schPlan = _.compact(schPlan);
       schPlan = _.compact(schPlan);
       schPlan = schPlan.map(i => {
       schPlan = schPlan.map(i => {
-        i.term = this.checkTerm(i.term);
+        i.term = _.uniqBy(this.checkTerm(i.term), '_id');
         return i;
         return i;
       });
       });
-      console.log(schPlan);
       this.$emit('toSave', schPlan);
       this.$emit('toSave', schPlan);
     },
     },
     //手动更改
     //手动更改

+ 8 - 1
src/views/questionnaire/detail.vue

@@ -15,10 +15,17 @@
             <el-radio label="2">教师问卷</el-radio>
             <el-radio label="2">教师问卷</el-radio>
           </el-radio-group>
           </el-radio-group>
         </el-form-item>
         </el-form-item>
+        <el-form-item label="状态" required prop="type">
+          <el-radio-group v-model="info.type">
+            <el-radio label="0" v-if="isNew == true">草稿</el-radio>
+            <el-radio label="1">发布</el-radio>
+            <el-radio label="2">禁用</el-radio>
+          </el-radio-group>
+        </el-form-item>
         <el-form-item label="题目" prop="question">
         <el-form-item label="题目" prop="question">
           <el-row>
           <el-row>
             <el-col :span="24" style="text-align:right;padding-bottom:10px">
             <el-col :span="24" style="text-align:right;padding-bottom:10px">
-              <el-button type="primary" size="mini" @click="addQuestion()">添加题目</el-button>
+              <el-button type="primary" size="mini" @click="addQuestion()" v-if="isNew == true">添加题目</el-button>
             </el-col>
             </el-col>
             <el-col :span="24">
             <el-col :span="24">
               <el-table :data="info.question" border stripe size="mini">
               <el-table :data="info.question" border stripe size="mini">

+ 1 - 1
src/views/questionnaire/index.vue

@@ -35,7 +35,7 @@ export default {
     fields: [
     fields: [
       { label: '问卷序号', prop: 'num' },
       { label: '问卷序号', prop: 'num' },
       { label: '问卷标题', prop: 'name' },
       { label: '问卷标题', prop: 'name' },
-      { label: '问卷类型', prop: 'type' },
+      { label: '问卷类型', prop: 'type', format: i => (i == '0' ? '常用问卷' : i == '1' ? '非常用问题' : '教师问卷') },
     ],
     ],
     filFields: [
     filFields: [
       { label: '问卷名', model: 'name' },
       { label: '问卷名', model: 'name' },