|
@@ -79,7 +79,7 @@
|
|
|
size="small"
|
|
|
type="primary"
|
|
|
icon="el-icon-upload2"
|
|
|
- @click="importSetting"
|
|
|
+ @click="settingDialogOpen"
|
|
|
>导入设置</el-button
|
|
|
>
|
|
|
<el-button
|
|
@@ -120,6 +120,70 @@
|
|
|
></el-pagination>
|
|
|
</div>
|
|
|
</div>
|
|
|
+
|
|
|
+ <el-dialog
|
|
|
+ title="导入配置"
|
|
|
+ width="520px"
|
|
|
+ :visible.sync="settingDialog"
|
|
|
+ @close="settingDialogClose"
|
|
|
+ >
|
|
|
+ <el-form>
|
|
|
+ <el-row>
|
|
|
+ <el-form-item style="margin-left: 20px">
|
|
|
+ <el-upload
|
|
|
+ ref="upload"
|
|
|
+ class="form_left"
|
|
|
+ accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
|
|
|
+ action="/api/ecs_exam_work/exam/course/import/weixinAnswerEnabledSetting"
|
|
|
+ :file-list="fileList"
|
|
|
+ :data="uploadData"
|
|
|
+ :headers="uploadHeaders"
|
|
|
+ :on-success="uploadSuccess"
|
|
|
+ :on-error="uploadError"
|
|
|
+ :auto-upload="false"
|
|
|
+ :multiple="false"
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ slot="trigger"
|
|
|
+ size="small"
|
|
|
+ type="primary"
|
|
|
+ icon="el-icon-search"
|
|
|
+ >
|
|
|
+ 选择文件
|
|
|
+ </el-button>
|
|
|
+
|
|
|
+ <el-button
|
|
|
+ size="small"
|
|
|
+ type="primary"
|
|
|
+ icon="el-icon-check"
|
|
|
+ @click="doUpload"
|
|
|
+ >
|
|
|
+ 确认上传
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ size="small"
|
|
|
+ type="primary"
|
|
|
+ icon="el-icon-refresh"
|
|
|
+ @click="clearFiles"
|
|
|
+ >
|
|
|
+ 清空文件
|
|
|
+ </el-button>
|
|
|
+ <el-button
|
|
|
+ size="small"
|
|
|
+ type="primary"
|
|
|
+ icon="el-icon-download"
|
|
|
+ @click="downloadTemplate"
|
|
|
+ >
|
|
|
+ 下载模板
|
|
|
+ </el-button>
|
|
|
+ <div slot="tip" class="el-upload__tip">
|
|
|
+ 只能上传xlsx格式的文件!
|
|
|
+ </div>
|
|
|
+ </el-upload>
|
|
|
+ </el-form-item>
|
|
|
+ </el-row>
|
|
|
+ </el-form>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</section>
|
|
|
</template>
|
|
@@ -143,6 +207,12 @@ export default {
|
|
|
tableData: [],
|
|
|
totalElements: 0,
|
|
|
selectedCourseIds: [],
|
|
|
+ settingDialog: false,
|
|
|
+ fileList: [],
|
|
|
+ uploadHeaders: {},
|
|
|
+ uploadData: {
|
|
|
+ examId: null,
|
|
|
+ },
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
@@ -168,9 +238,84 @@ export default {
|
|
|
this.totalElements = response.data.totalElements;
|
|
|
});
|
|
|
},
|
|
|
- importSetting() {
|
|
|
- console.log("examId", this.searchForm.examId);
|
|
|
- console.log("courseIds", JSON.stringify(this.selectedCourseIds));
|
|
|
+ settingDialogOpen() {
|
|
|
+ this.settingDialog = true;
|
|
|
+ this.fileList = [];
|
|
|
+ this.uploadData.examId = this.searchForm.examId;
|
|
|
+ this.uploadHeaders = {
|
|
|
+ key: this.user.key,
|
|
|
+ token: this.user.token,
|
|
|
+ };
|
|
|
+ },
|
|
|
+ settingDialogClose() {
|
|
|
+ this.settingDialog = false;
|
|
|
+ },
|
|
|
+ doUpload() {
|
|
|
+ if (!this.checkUpload()) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$refs.upload.submit();
|
|
|
+ },
|
|
|
+ checkUpload() {
|
|
|
+ let fileList = this.$refs.upload.uploadFiles;
|
|
|
+ if (fileList.length == 0) {
|
|
|
+ this.$notify({
|
|
|
+ message: "上传文件不能为空!",
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (fileList.length > 1) {
|
|
|
+ this.$notify({
|
|
|
+ message: "每次只能上传一个文件!",
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ for (let file of fileList) {
|
|
|
+ if (!file.name.endsWith(".xlsx")) {
|
|
|
+ this.$notify({
|
|
|
+ message: "只能上传xlsx格式的文件!",
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
+
|
|
|
+ this.clearFiles();
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+ uploadSuccess(response) {
|
|
|
+ console.log(response);
|
|
|
+ this.$notify({
|
|
|
+ message: "上传成功!",
|
|
|
+ type: "success",
|
|
|
+ });
|
|
|
+
|
|
|
+ this.settingDialogClose();
|
|
|
+ this.doSearch(1);
|
|
|
+ },
|
|
|
+ uploadError(response) {
|
|
|
+ // console.log(response);
|
|
|
+ let json = JSON.parse(response.message);
|
|
|
+ if (response.status != 200) {
|
|
|
+ this.$notify({
|
|
|
+ message: "上传失败!" + json.desc,
|
|
|
+ type: "error",
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ clearFiles() {
|
|
|
+ this.fileList = [];
|
|
|
+ this.$refs.upload.clearFiles();
|
|
|
+ },
|
|
|
+ downloadTemplate() {
|
|
|
+ window.location.href =
|
|
|
+ EXAM_WORK_API + "/exam/course/download/weixinAnswerEnabledTemplate";
|
|
|
},
|
|
|
exportSetting() {
|
|
|
this.$confirm("确认导出设置?", "提示", {
|