|
@@ -76,6 +76,17 @@
|
|
@click="closeCoursePropertys"
|
|
@click="closeCoursePropertys"
|
|
><i class="el-icon-close"></i> 禁用</el-button
|
|
><i class="el-icon-close"></i> 禁用</el-button
|
|
>
|
|
>
|
|
|
|
+ <el-button
|
|
|
|
+ size="small"
|
|
|
|
+ type="primary"
|
|
|
|
+ icon="el-icon-upload2"
|
|
|
|
+ @click="impCourseProperty"
|
|
|
|
+ >
|
|
|
|
+ 导入
|
|
|
|
+ </el-button>
|
|
|
|
+ <el-button size="small" type="primary" @click="exportCourseProperty"
|
|
|
|
+ ><i class="el-icon-download"></i>导出</el-button
|
|
|
|
+ >
|
|
</el-form-item>
|
|
</el-form-item>
|
|
</el-row>
|
|
</el-row>
|
|
</el-form>
|
|
</el-form>
|
|
@@ -224,12 +235,86 @@
|
|
</el-row>
|
|
</el-row>
|
|
</el-form>
|
|
</el-form>
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
|
+ <!-- 导入弹窗 -->
|
|
|
|
+ <el-dialog title="导入窗口" width="520px" :visible.sync="impDialog">
|
|
|
|
+ <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="uploadAction"
|
|
|
|
+ :headers="uploadHeaders"
|
|
|
|
+ :data="uploadData"
|
|
|
|
+ :before-upload="beforeUpload"
|
|
|
|
+ :on-progress="uploadProgress"
|
|
|
|
+ :on-success="uploadSuccess"
|
|
|
|
+ :on-error="uploadError"
|
|
|
|
+ :file-list="fileList"
|
|
|
|
+ :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="submitUpload"
|
|
|
|
+ >
|
|
|
|
+ 确认上传
|
|
|
|
+ </el-button>
|
|
|
|
+ <el-button
|
|
|
|
+ size="small"
|
|
|
|
+ type="primary"
|
|
|
|
+ icon="el-icon-refresh"
|
|
|
|
+ @click="removeFile"
|
|
|
|
+ >
|
|
|
|
+ 清空文件
|
|
|
|
+ </el-button>
|
|
|
|
+ <el-button
|
|
|
|
+ size="small"
|
|
|
|
+ type="primary"
|
|
|
|
+ icon="el-icon-download"
|
|
|
|
+ @click="exportFile"
|
|
|
|
+ >
|
|
|
|
+ 下载模板
|
|
|
|
+ </el-button>
|
|
|
|
+ <div slot="tip" class="el-upload__tip">只能上传xlsx文件</div>
|
|
|
|
+ </el-upload>
|
|
|
|
+ </el-form-item>
|
|
|
|
+ </el-row>
|
|
|
|
+ </el-form>
|
|
|
|
+ </el-dialog>
|
|
|
|
+
|
|
|
|
+ <!-- 导入错误信息列表 -->
|
|
|
|
+ <el-dialog title="错误提示" :visible.sync="errDialog">
|
|
|
|
+ <div
|
|
|
|
+ v-for="errMessage in errMessages"
|
|
|
|
+ :key="errMessage.lineNum"
|
|
|
|
+ class="text-danger"
|
|
|
|
+ >
|
|
|
|
+ 第{{ errMessage.lineNum }}行:{{ errMessage.msg }}
|
|
|
|
+ </div>
|
|
|
|
+ <span slot="footer" class="dialog-footer">
|
|
|
|
+ <el-button @click="errDialog = false">确定</el-button>
|
|
|
|
+ </span>
|
|
|
|
+ </el-dialog>
|
|
</section>
|
|
</section>
|
|
</template>
|
|
</template>
|
|
|
|
|
|
<script>
|
|
<script>
|
|
import { CORE_API, QUESTION_API } from "@/constants/constants";
|
|
import { CORE_API, QUESTION_API } from "@/constants/constants";
|
|
import LinkTitlesCustom from "@/components/LinkTitlesCustom.vue";
|
|
import LinkTitlesCustom from "@/components/LinkTitlesCustom.vue";
|
|
|
|
+import { mapState } from "vuex";
|
|
export default {
|
|
export default {
|
|
components: { LinkTitlesCustom },
|
|
components: { LinkTitlesCustom },
|
|
data() {
|
|
data() {
|
|
@@ -238,6 +323,16 @@ export default {
|
|
name: "",
|
|
name: "",
|
|
courseId: "",
|
|
courseId: "",
|
|
},
|
|
},
|
|
|
|
+
|
|
|
|
+ impDialog: false,
|
|
|
|
+ uploadAction: QUESTION_API + "/courseProperty/import",
|
|
|
|
+ uploadHeaders: {},
|
|
|
|
+ uploadData: {},
|
|
|
|
+ errMessages: [],
|
|
|
|
+ errDialog: false,
|
|
|
|
+ fileLoading: false,
|
|
|
|
+ fileList: [],
|
|
|
|
+
|
|
courseList: [],
|
|
courseList: [],
|
|
loading: false,
|
|
loading: false,
|
|
tableData: [],
|
|
tableData: [],
|
|
@@ -260,6 +355,9 @@ export default {
|
|
};
|
|
};
|
|
},
|
|
},
|
|
computed: {
|
|
computed: {
|
|
|
|
+ ...mapState({
|
|
|
|
+ user: (state) => state.user,
|
|
|
|
+ }),
|
|
selectedIds() {
|
|
selectedIds() {
|
|
var selectedIdsStr = "";
|
|
var selectedIdsStr = "";
|
|
for (let id of this.selectedList) {
|
|
for (let id of this.selectedList) {
|
|
@@ -292,9 +390,118 @@ export default {
|
|
},
|
|
},
|
|
created() {
|
|
created() {
|
|
this.initValue();
|
|
this.initValue();
|
|
|
|
+ this.uploadHeaders = {
|
|
|
|
+ key: this.user.key,
|
|
|
|
+ token: this.user.token,
|
|
|
|
+ };
|
|
},
|
|
},
|
|
|
|
|
|
methods: {
|
|
methods: {
|
|
|
|
+ exportCourseProperty() {
|
|
|
|
+ var key = this.user.key;
|
|
|
|
+ var token = this.user.token;
|
|
|
|
+ window.open(
|
|
|
|
+ QUESTION_API +
|
|
|
|
+ "/courseProperty/export?$key=" +
|
|
|
|
+ key +
|
|
|
|
+ "&$token=" +
|
|
|
|
+ token +
|
|
|
|
+ "&name=" +
|
|
|
|
+ this.formSearch.name +
|
|
|
|
+ "&courseId=" +
|
|
|
|
+ this.formSearch.courseId
|
|
|
|
+ );
|
|
|
|
+ },
|
|
|
|
+ //导入
|
|
|
|
+ impCourseProperty() {
|
|
|
|
+ this.impDialog = true;
|
|
|
|
+ this.initUpload();
|
|
|
|
+ },
|
|
|
|
+ initUpload() {
|
|
|
|
+ this.fileList = [];
|
|
|
|
+ },
|
|
|
|
+ beforeUpload(file) {
|
|
|
|
+ console.log(file);
|
|
|
|
+ },
|
|
|
|
+ uploadProgress() {
|
|
|
|
+ console.log("uploadProgress");
|
|
|
|
+ },
|
|
|
|
+ uploadSuccess(response) {
|
|
|
|
+ if (!response.hasError) {
|
|
|
|
+ this.$notify({
|
|
|
|
+ message: "上传成功",
|
|
|
|
+ type: "success",
|
|
|
|
+ });
|
|
|
|
+ this.fileLoading = false;
|
|
|
|
+ this.impDialog = false;
|
|
|
|
+ this.searchCourProperty();
|
|
|
|
+ } else {
|
|
|
|
+ this.fileLoading = false;
|
|
|
|
+ this.impDialog = false;
|
|
|
|
+ this.errMessages = response.failRecords;
|
|
|
|
+ this.errDialog = true;
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ uploadError(response) {
|
|
|
|
+ var json = JSON.parse(response.message);
|
|
|
|
+ if (response.status == 500) {
|
|
|
|
+ this.$notify({
|
|
|
|
+ message: json.desc,
|
|
|
|
+ type: "error",
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ this.fileLoading = false;
|
|
|
|
+ },
|
|
|
|
+ //确定上传
|
|
|
|
+ submitUpload() {
|
|
|
|
+ if (!this.checkUpload()) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ this.$refs.upload.submit();
|
|
|
|
+ this.fileLoading = true;
|
|
|
|
+ },
|
|
|
|
+ checkUpload() {
|
|
|
|
+ var 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.initUpload();
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return true;
|
|
|
|
+ },
|
|
|
|
+ //清空文件
|
|
|
|
+ removeFile() {
|
|
|
|
+ // this.fileList = [];
|
|
|
|
+ this.$refs.upload.clearFiles();
|
|
|
|
+ },
|
|
|
|
+ //下载模板
|
|
|
|
+ exportFile() {
|
|
|
|
+ window.location.href =
|
|
|
|
+ QUESTION_API +
|
|
|
|
+ "/courseProperty/importTemplate?$key=" +
|
|
|
|
+ this.user.key +
|
|
|
|
+ "&$token=" +
|
|
|
|
+ this.user.token;
|
|
|
|
+ },
|
|
//查询所有课程属性
|
|
//查询所有课程属性
|
|
searchFrom() {
|
|
searchFrom() {
|
|
this.currentPage = 1;
|
|
this.currentPage = 1;
|