|
@@ -8,39 +8,64 @@
|
|
<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"></data-table>
|
|
|
|
|
|
+ <data-table :fields="fields" :data="classList" :opera="opera" @edit="toEdit" :toFormat="toFormat"></data-table>
|
|
|
|
+ <el-dialog title="选择班主任" :visible.sync="dialog" width="20%">
|
|
|
|
+ <data-form :data="form" :fields="fields" :rules="{}" @save="handleSave">
|
|
|
|
+ <template #options="{item,form}">
|
|
|
|
+ <template v-if="item.model == 'headteacherid'">
|
|
|
|
+ <el-option-group v-for="(dept, index) in htList" :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>
|
|
|
|
+ </data-form>
|
|
|
|
+ </el-dialog>
|
|
</div>
|
|
</div>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import _ from 'lodash';
|
|
import _ from 'lodash';
|
|
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 } = createNamespacedHelpers('teaPlan');
|
|
const { mapActions } = createNamespacedHelpers('teaPlan');
|
|
const { mapActions: classes } = createNamespacedHelpers('classes');
|
|
const { mapActions: classes } = createNamespacedHelpers('classes');
|
|
|
|
+const { mapActions: mapDept } = createNamespacedHelpers('dept');
|
|
export default {
|
|
export default {
|
|
name: 'director-arrange',
|
|
name: 'director-arrange',
|
|
props: {
|
|
props: {
|
|
events: { type: Array, default: () => [] },
|
|
events: { type: Array, default: () => [] },
|
|
},
|
|
},
|
|
- components: { dataTable },
|
|
|
|
|
|
+ components: { dataTable, dataForm },
|
|
data: function() {
|
|
data: function() {
|
|
return {
|
|
return {
|
|
|
|
+ dialog: false,
|
|
|
|
+ form: {},
|
|
classList: [],
|
|
classList: [],
|
|
|
|
+ htList: [],
|
|
|
|
+ deptList: [],
|
|
fields: [
|
|
fields: [
|
|
- { label: '期', prop: 'term' },
|
|
|
|
- { label: '批', prop: 'batch' },
|
|
|
|
- { label: '班级', prop: 'name' },
|
|
|
|
- { label: '班主任', prop: 'headteacherid' },
|
|
|
|
|
|
+ { label: '期', prop: 'term', model: 'term', type: 'text' },
|
|
|
|
+ { label: '批', prop: 'batch', model: 'batch', type: 'text' },
|
|
|
|
+ { label: '班级', prop: 'name', model: 'name', type: 'text' },
|
|
|
|
+ { label: '班主任', prop: 'headteacherid', model: 'headteacherid', type: 'select', format: true }, //
|
|
|
|
+ ],
|
|
|
|
+ opera: [
|
|
|
|
+ {
|
|
|
|
+ label: '选择班主任',
|
|
|
|
+ icon: 'el-icon-edit',
|
|
|
|
+ method: 'edit',
|
|
|
|
+ },
|
|
],
|
|
],
|
|
- opera: [],
|
|
|
|
};
|
|
};
|
|
},
|
|
},
|
|
- created() {
|
|
|
|
|
|
+ async created() {
|
|
|
|
+ await this.getOtherList();
|
|
this.search();
|
|
this.search();
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- ...mapActions(['divide']),
|
|
|
|
|
|
+ ...mapDept({ getDept: 'query' }),
|
|
|
|
+ ...mapActions(['divide', 'findTeacher']),
|
|
...classes(['query']),
|
|
...classes(['query']),
|
|
async search() {
|
|
async search() {
|
|
let res = await this.query({ planid: this.id });
|
|
let res = await this.query({ planid: this.id });
|
|
@@ -69,7 +94,42 @@ export default {
|
|
this.$set(this, `classList`, arr);
|
|
this.$set(this, `classList`, arr);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
|
|
+ async toEdit({ data, index }) {
|
|
|
|
+ let res = await this.findTeacher({ planid: data.planid, termid: data.termid, batchid: data.batchid });
|
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
|
+ 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, `htList`, arr);
|
|
|
|
+ }
|
|
|
|
+ this.dialog = true;
|
|
|
|
+ this.$set(this, `form`, { ...JSON.parse(JSON.stringify(data)), index });
|
|
|
|
+ },
|
|
|
|
+ handleSave({ data }) {
|
|
|
|
+ let { index, ...info } = data;
|
|
|
|
+ this.$set(this.classList, index, info);
|
|
|
|
+ this.dialog = false;
|
|
|
|
+ },
|
|
async toSave() {},
|
|
async toSave() {},
|
|
|
|
+ async getOtherList() {
|
|
|
|
+ let res = await this.getDept();
|
|
|
|
+ if (this.$checkRes(res)) this.$set(this, `deptList`, res.data);
|
|
|
|
+ },
|
|
|
|
+ toFormat({ model, value }) {
|
|
|
|
+ if (model == 'headteacherid') {
|
|
|
|
+ let arr = _.flatten(this.htList.map(i => i.list));
|
|
|
|
+ let r = arr.find(f => f._id == value);
|
|
|
|
+ if (r) return r.name;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
...mapState(['user']),
|
|
...mapState(['user']),
|