|
@@ -1,19 +1,19 @@
|
|
|
<template>
|
|
|
<div id="tsbattendance">
|
|
|
- <list-frame title="特殊班考勤管理" @query="onsearch" :total="total" :needFilter="false" :needAdd="false">
|
|
|
+ <list-frame title="特殊班考勤管理" @query="onsearch" :total="total" :needPag="false" :needFilter="false" :needAdd="false">
|
|
|
<el-form :inline="true" size="mini">
|
|
|
<el-form-item label="期">
|
|
|
- <el-select v-model="form.termid" placeholder="请选择期数" @change="getBatch">
|
|
|
+ <el-select v-model="form.termid" placeholder="请选择期数" @change="getClasses">
|
|
|
<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-form-item label="批次">
|
|
|
<el-select v-model="form.batchid" placeholder="请先选择期数" @change="getClasses">
|
|
|
- <el-option v-for="(i, index) in batchList" :key="index" :label="i.name" :value="i._id"></el-option>
|
|
|
+ <el-option v-for="(i, index) in batchList" :key="index" :label="i.batch" :value="i._id"></el-option>
|
|
|
</el-select>
|
|
|
- </el-form-item>
|
|
|
+ </el-form-item> -->
|
|
|
<el-form-item label="班级">
|
|
|
- <el-select v-model="form.classid" placeholder="请先选择批次">
|
|
|
+ <el-select v-model="form.classid" placeholder="请先选择期数" @change="changeClass">
|
|
|
<el-option v-for="(i, index) in classList" :key="index" :label="i.name" :value="i._id"></el-option>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
@@ -22,7 +22,7 @@
|
|
|
</el-form-item>
|
|
|
</el-form>
|
|
|
<el-col :span="24" class="btn">
|
|
|
- <el-button type="primary" size="mini" @click="onekeyBtn">一键签到</el-button>
|
|
|
+ <el-button type="primary" size="mini" @click="onekeyBtn" :disabled="!allowSign && selected.length <= 0">一键签到</el-button>
|
|
|
</el-col>
|
|
|
<data-table :fields="fields" :data="list" :select="true" :selected="selected" @handleSelect="toSelect"> </data-table>
|
|
|
</list-frame>
|
|
@@ -37,6 +37,7 @@ const { mapActions: attendance } = createNamespacedHelpers('attendance');
|
|
|
const { mapActions: student } = createNamespacedHelpers('student');
|
|
|
const { mapActions: trainplan } = createNamespacedHelpers('trainplan');
|
|
|
const { mapActions: classes } = createNamespacedHelpers('classes');
|
|
|
+const { mapActions: classtype } = createNamespacedHelpers('classtype');
|
|
|
|
|
|
export default {
|
|
|
metaInfo: { title: '特殊班考勤管理' },
|
|
@@ -47,26 +48,27 @@ export default {
|
|
|
dataTable,
|
|
|
},
|
|
|
data: () => ({
|
|
|
+ allowSign: false,
|
|
|
classList: [],
|
|
|
batchList: [],
|
|
|
termList: [],
|
|
|
fields: [
|
|
|
- { label: '学生姓名', prop: 'stuname' },
|
|
|
- { label: '日期', prop: 'date' },
|
|
|
- { label: '时间', prop: 'time' },
|
|
|
- {
|
|
|
- label: '类型',
|
|
|
- prop: 'type',
|
|
|
- format: item => {
|
|
|
- return item === '0' ? '上课考勤' : item === '1' ? '上课考勤' : '';
|
|
|
- },
|
|
|
- },
|
|
|
+ { label: '学生姓名', prop: 'name' },
|
|
|
+ // { label: '日期', prop: 'date' },
|
|
|
+ // { label: '时间', prop: 'time' },
|
|
|
+ // {
|
|
|
+ // label: '类型',
|
|
|
+ // prop: 'type',
|
|
|
+ // format: item => {
|
|
|
+ // return item === '0' ? '上课考勤' : item === '1' ? '上课考勤' : '';
|
|
|
+ // },
|
|
|
+ // },
|
|
|
{
|
|
|
label: '状态',
|
|
|
- prop: 'status',
|
|
|
- format: item => {
|
|
|
- return item === '0' ? '未签到' : item === '1' ? '签到' : '迟到';
|
|
|
- },
|
|
|
+ prop: 'signStatus',
|
|
|
+ // format: item => {
|
|
|
+ // return item === '0' ? '未签到' : item === '1' ? '签到' : '迟到';
|
|
|
+ // },
|
|
|
},
|
|
|
],
|
|
|
form: {},
|
|
@@ -74,12 +76,15 @@ export default {
|
|
|
total: 0,
|
|
|
// 特殊班一键签到选中列表
|
|
|
selected: [],
|
|
|
+ classTypeList: [],
|
|
|
}),
|
|
|
created() {
|
|
|
this.searchinfo();
|
|
|
+ this.getOtherList();
|
|
|
},
|
|
|
computed: { ...mapState(['user', 'defaultOption']) },
|
|
|
methods: {
|
|
|
+ ...classtype({ getClassType: 'query' }),
|
|
|
...attendance(['query', 'delete', 'attendancecreateList']),
|
|
|
...student({ stuquery: 'query' }),
|
|
|
...trainplan({ planfetch: 'fetch' }),
|
|
@@ -90,7 +95,7 @@ export default {
|
|
|
this.$set(this, `termList`, terms);
|
|
|
if (this.defaultOption.termid) {
|
|
|
this.form.termid = this.defaultOption.termid;
|
|
|
- this.getBatch(this.form.termid);
|
|
|
+ this.getClasses(this.form.termid);
|
|
|
}
|
|
|
},
|
|
|
getBatch(termid) {
|
|
@@ -100,24 +105,31 @@ export default {
|
|
|
this.$set(this, `batchList`, batchnum);
|
|
|
}
|
|
|
},
|
|
|
- async getClasses(batchid) {
|
|
|
- const res = await this.classesquery({ batchid });
|
|
|
- var arr = res.data.filter(item => item.type === '1');
|
|
|
+ async getClasses(termid) {
|
|
|
+ const res = await this.classesquery({ termid });
|
|
|
+ var arr = res.data.filter(item => item.type != '0');
|
|
|
this.$set(this, `classList`, arr);
|
|
|
},
|
|
|
async onsearch({ skip = 0, limit = 10, ...info } = {}) {
|
|
|
- const res = await this.query({ termid: this.form.termid, classid: this.form.classid, ...info });
|
|
|
- const newdatas = [];
|
|
|
- for (const data of res.data) {
|
|
|
- for (const attend of data.attend) {
|
|
|
- let newdata = { stuname: data.stuname, ...attend };
|
|
|
- newdatas.push(newdata);
|
|
|
- }
|
|
|
+ const res = await this.stuquery({ termid: this.form.termid, classid: this.form.classid, ...info });
|
|
|
+ if (this.$checkRes(res)) {
|
|
|
+ this.$set(this, `list`, res.data);
|
|
|
}
|
|
|
+ this.checkSign();
|
|
|
+ },
|
|
|
+ async checkSign() {
|
|
|
+ const res = await this.query({ termid: this.form.termid, classid: this.form.classid });
|
|
|
if (this.$checkRes(res)) {
|
|
|
- this.$set(this, `total`, newdatas.length);
|
|
|
- let _newdatas = newdatas.splice(skip, skip + limit);
|
|
|
- this.$set(this, `list`, _newdatas);
|
|
|
+ let signList = _.cloneDeep(res.data);
|
|
|
+ let dl = _.cloneDeep(this.list);
|
|
|
+ for (const stu of dl) {
|
|
|
+ let r = signList.find(f => f.studentid == stu._id);
|
|
|
+ if (r) {
|
|
|
+ // TODO 这个地方没有考勤记录,只是生成了这个学生的考勤数据,
|
|
|
+ stu.signStatus = '已签到';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ this.$set(this, `list`, dl);
|
|
|
}
|
|
|
},
|
|
|
// 选中签到学生
|
|
@@ -136,6 +148,24 @@ export default {
|
|
|
});
|
|
|
}
|
|
|
},
|
|
|
+ async getOtherList() {
|
|
|
+ const res = await this.getClassType();
|
|
|
+ if (this.$checkRes(res)) this.$set(this, `classTypeList`, res.data);
|
|
|
+ },
|
|
|
+ changeClass(classid) {
|
|
|
+ let r = this.classList.find(f => f._id == classid);
|
|
|
+ if (r) {
|
|
|
+ let { type } = r;
|
|
|
+ r = this.classTypeList.find(f => f.code == type);
|
|
|
+ if (r) {
|
|
|
+ let { sign } = r;
|
|
|
+ if (sign == '0') {
|
|
|
+ this.allowSign = false;
|
|
|
+ this.$message.warning('该班级设置为学生签到,无法一键签到!');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
},
|
|
|
watch: {
|
|
|
defaultOption: {
|