|
@@ -9,207 +9,53 @@
|
|
:close-on-press-escape="false"
|
|
:close-on-press-escape="false"
|
|
append-to-body
|
|
append-to-body
|
|
destroy-on-close
|
|
destroy-on-close
|
|
- @open="visibleChange"
|
|
|
|
>
|
|
>
|
|
- <!-- <div class="mb-4 tab-btns">
|
|
|
|
- <el-button
|
|
|
|
- v-for="tab in tabs"
|
|
|
|
- :key="tab.val"
|
|
|
|
- size="medium"
|
|
|
|
- :type="curTab == tab.val ? 'primary' : 'default'"
|
|
|
|
- @click="selectMenu(tab.val)"
|
|
|
|
- >{{ tab.name }}
|
|
|
|
- </el-button>
|
|
|
|
- </div> -->
|
|
|
|
- <!-- input -->
|
|
|
|
- <div v-if="curTab === 'input'" class="tab-body">
|
|
|
|
- <el-form
|
|
|
|
- ref="modalFormComp"
|
|
|
|
- :model="modalForm"
|
|
|
|
- :rules="rules"
|
|
|
|
- :key="modalForm.id"
|
|
|
|
- label-width="60px"
|
|
|
|
- >
|
|
|
|
- <el-form-item prop="studentName" label="姓名:">
|
|
|
|
- <el-input
|
|
|
|
- v-model.trim="modalForm.studentName"
|
|
|
|
- placeholder="请输入姓名"
|
|
|
|
- clearable
|
|
|
|
- ></el-input>
|
|
|
|
- </el-form-item>
|
|
|
|
- <el-form-item prop="studentCode" label="学号:">
|
|
|
|
- <el-input
|
|
|
|
- v-model.trim="modalForm.studentCode"
|
|
|
|
- placeholder="请输入学号"
|
|
|
|
- clearable
|
|
|
|
- ></el-input>
|
|
|
|
- </el-form-item>
|
|
|
|
- </el-form>
|
|
|
|
- </div>
|
|
|
|
<!-- select -->
|
|
<!-- select -->
|
|
- <div v-if="curTab === 'select'" class="tab-body">
|
|
|
|
- <select-simple-student
|
|
|
|
- ref="SelectSimpleStudent"
|
|
|
|
- v-model="selectedStudentIds"
|
|
|
|
- ></select-simple-student>
|
|
|
|
- </div>
|
|
|
|
- <!-- import -->
|
|
|
|
- <div v-if="curTab === 'import'" class="tab-body">
|
|
|
|
- <el-button
|
|
|
|
- type="success"
|
|
|
|
- icon="el-icon-download"
|
|
|
|
- @click="downloadTemplate('teachClassStudent')"
|
|
|
|
- >模板下载</el-button
|
|
|
|
- >
|
|
|
|
- <upload-button
|
|
|
|
- btn-icon="el-icon-circle-plus-outline"
|
|
|
|
- btn-content="批量导入"
|
|
|
|
- btn-type="success"
|
|
|
|
- :upload-url="uploadUrl"
|
|
|
|
- :upload-data="uploadData"
|
|
|
|
- :format="['xls', 'xlsx']"
|
|
|
|
- accept=".xls,.xlsx"
|
|
|
|
- @valid-error="validError"
|
|
|
|
- @upload-success="uploadSuccess"
|
|
|
|
- >
|
|
|
|
- </upload-button>
|
|
|
|
- </div>
|
|
|
|
|
|
+ <select-simple-student
|
|
|
|
+ ref="SelectSimpleStudent"
|
|
|
|
+ v-model="selectedStudentIds"
|
|
|
|
+ :exam-id="clazz.examId"
|
|
|
|
+ ></select-simple-student>
|
|
|
|
|
|
- <div v-if="!IS_IMPORT" slot="footer">
|
|
|
|
|
|
+ <div slot="footer">
|
|
<el-button type="primary" :disabled="isSubmit" @click="submit"
|
|
<el-button type="primary" :disabled="isSubmit" @click="submit"
|
|
>确认</el-button
|
|
>确认</el-button
|
|
>
|
|
>
|
|
<el-button @click="cancel">取消</el-button>
|
|
<el-button @click="cancel">取消</el-button>
|
|
</div>
|
|
</div>
|
|
- <div v-else slot="footer"></div>
|
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
-import { updateStudentSimple, batchAddStudentSimple } from "../../api";
|
|
|
|
-import UploadButton from "@/components/UploadButton";
|
|
|
|
|
|
+import { batchAddStudentSimple } from "../../api";
|
|
import SelectSimpleStudent from "./SelectSimpleStudent.vue";
|
|
import SelectSimpleStudent from "./SelectSimpleStudent.vue";
|
|
-import templateDownload from "@/mixins/templateDownload";
|
|
|
|
-
|
|
|
|
-const initModalForm = {
|
|
|
|
- id: null,
|
|
|
|
- teachClazzId: null,
|
|
|
|
- studentName: "",
|
|
|
|
- studentCode: "",
|
|
|
|
-};
|
|
|
|
|
|
|
|
export default {
|
|
export default {
|
|
name: "modify-student-simple",
|
|
name: "modify-student-simple",
|
|
- components: { UploadButton, SelectSimpleStudent },
|
|
|
|
- mixins: [templateDownload],
|
|
|
|
|
|
+ components: { SelectSimpleStudent },
|
|
props: {
|
|
props: {
|
|
- instance: {
|
|
|
|
|
|
+ clazz: {
|
|
type: Object,
|
|
type: Object,
|
|
default() {
|
|
default() {
|
|
return {};
|
|
return {};
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
- computed: {
|
|
|
|
- IS_IMPORT() {
|
|
|
|
- return this.curTab === "import";
|
|
|
|
- },
|
|
|
|
- },
|
|
|
|
data() {
|
|
data() {
|
|
return {
|
|
return {
|
|
modalIsShow: false,
|
|
modalIsShow: false,
|
|
isSubmit: false,
|
|
isSubmit: false,
|
|
- curTab: "select",
|
|
|
|
- tabs: [
|
|
|
|
- {
|
|
|
|
- name: "手动添加",
|
|
|
|
- val: "input",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: "从课程班级添加",
|
|
|
|
- val: "select",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- name: "批量导入",
|
|
|
|
- val: "import",
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- modalForm: { ...initModalForm },
|
|
|
|
- rules: {
|
|
|
|
- studentName: [
|
|
|
|
- {
|
|
|
|
- required: true,
|
|
|
|
- message: "请输入姓名",
|
|
|
|
- trigger: "change",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- message: "姓名不能超过50个字",
|
|
|
|
- max: 50,
|
|
|
|
- trigger: "change",
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- studentCode: [
|
|
|
|
- {
|
|
|
|
- required: true,
|
|
|
|
- message: "请输入学号",
|
|
|
|
- trigger: "change",
|
|
|
|
- },
|
|
|
|
- {
|
|
|
|
- message: "学号不能超过50个字",
|
|
|
|
- max: 50,
|
|
|
|
- trigger: "change",
|
|
|
|
- },
|
|
|
|
- ],
|
|
|
|
- },
|
|
|
|
selectedStudentIds: [],
|
|
selectedStudentIds: [],
|
|
- // import
|
|
|
|
- uploadData: {},
|
|
|
|
- uploadUrl: "/api/admin/teach/student/import",
|
|
|
|
- dfilename: "教学班级学生导入模板.xlsx",
|
|
|
|
};
|
|
};
|
|
},
|
|
},
|
|
methods: {
|
|
methods: {
|
|
- initData(val) {
|
|
|
|
- this.modalForm = this.$objAssign(initModalForm, val);
|
|
|
|
- this.uploadData = {
|
|
|
|
- teachClazzId: val.teachClazzId,
|
|
|
|
- };
|
|
|
|
- },
|
|
|
|
- visibleChange() {
|
|
|
|
- this.initData(this.instance);
|
|
|
|
- },
|
|
|
|
cancel() {
|
|
cancel() {
|
|
this.modalIsShow = false;
|
|
this.modalIsShow = false;
|
|
},
|
|
},
|
|
open() {
|
|
open() {
|
|
this.modalIsShow = true;
|
|
this.modalIsShow = true;
|
|
},
|
|
},
|
|
- selectMenu(tab) {
|
|
|
|
- this.curTab = tab;
|
|
|
|
- },
|
|
|
|
- submit() {
|
|
|
|
- const submitFunc = {
|
|
|
|
- input: this.submitInput,
|
|
|
|
- select: this.submitSelect,
|
|
|
|
- };
|
|
|
|
- submitFunc[this.curTab]();
|
|
|
|
- },
|
|
|
|
- async submitInput() {
|
|
|
|
- const valid = await this.$refs.modalFormComp.validate().catch(() => {});
|
|
|
|
- if (!valid) return;
|
|
|
|
-
|
|
|
|
- if (this.isSubmit) return;
|
|
|
|
- this.isSubmit = true;
|
|
|
|
- const data = await updateStudentSimple(this.modalForm).catch(() => {});
|
|
|
|
- this.isSubmit = false;
|
|
|
|
-
|
|
|
|
- if (!data) return;
|
|
|
|
-
|
|
|
|
- this.$message.success("添加成功!");
|
|
|
|
- this.$emit("modified");
|
|
|
|
- this.modalForm = this.$objAssign(initModalForm, this.instance);
|
|
|
|
- },
|
|
|
|
- async submitSelect() {
|
|
|
|
|
|
+ async submit() {
|
|
if (!this.selectedStudentIds.length) {
|
|
if (!this.selectedStudentIds.length) {
|
|
this.$message.error("请选择学生");
|
|
this.$message.error("请选择学生");
|
|
return;
|
|
return;
|
|
@@ -218,24 +64,16 @@ export default {
|
|
if (this.isSubmit) return;
|
|
if (this.isSubmit) return;
|
|
this.isSubmit = true;
|
|
this.isSubmit = true;
|
|
const data = await batchAddStudentSimple({
|
|
const data = await batchAddStudentSimple({
|
|
- teachClazzId: this.instance.teachClazzId,
|
|
|
|
- basicStudentIdSet: this.selectedStudentIds,
|
|
|
|
|
|
+ teachClazzId: this.clazz.id,
|
|
|
|
+ basicExamStudentIdList: this.selectedStudentIds,
|
|
}).catch(() => {});
|
|
}).catch(() => {});
|
|
this.isSubmit = false;
|
|
this.isSubmit = false;
|
|
|
|
|
|
if (!data) return;
|
|
if (!data) return;
|
|
|
|
|
|
this.$message.success("添加成功!");
|
|
this.$message.success("添加成功!");
|
|
- this.$emit("modified");
|
|
|
|
this.selectedStudentIds = [];
|
|
this.selectedStudentIds = [];
|
|
this.$refs.SelectSimpleStudent.clearSelection();
|
|
this.$refs.SelectSimpleStudent.clearSelection();
|
|
- },
|
|
|
|
- // import
|
|
|
|
- validError(errorData) {
|
|
|
|
- this.$message.error(errorData.message);
|
|
|
|
- },
|
|
|
|
- uploadSuccess(data) {
|
|
|
|
- this.$message.success(data.data || "学生导入成功!");
|
|
|
|
this.$emit("modified");
|
|
this.$emit("modified");
|
|
this.cancel();
|
|
this.cancel();
|
|
},
|
|
},
|