|
|
@@ -1,29 +1,19 @@
|
|
|
<template>
|
|
|
<div class="courseware-tab">
|
|
|
- <el-row>
|
|
|
- <el-col :span="3.5">
|
|
|
- <el-button
|
|
|
- @click="uploadDialogVisible = true"
|
|
|
- type="primary"
|
|
|
- icon="el-icon-circle-plus-outline"
|
|
|
- plain>新建</el-button>
|
|
|
- </el-col>
|
|
|
- <el-col :span="15">
|
|
|
- <span style="font-size: smaller; position: absolute; bottom: 25%">(支持拓展名:.pdf .ppt .pptx .doc .docx .xls .jpg .jpeg .png,单次只可上传一个文件)</span>
|
|
|
- </el-col>
|
|
|
- </el-row>
|
|
|
- <el-dialog v-model="uploadDialogVisible" :before-close="handleFormCancel" :width="700">
|
|
|
- <el-form ref="formRef" :model="form" label-width="100px">
|
|
|
-<!-- :rules="formRules"-->
|
|
|
-<!-- <el-form-item label="使用时间" required>-->
|
|
|
-<!-- <el-select v-model="form.useTime" placeholder="时间">-->
|
|
|
-<!-- <el-option key="1" label="课前" value="BEFORE_CLASS"></el-option>-->
|
|
|
-<!-- <el-option key="2" label="课中" value="IN_CLASS"></el-option>-->
|
|
|
-<!-- <el-option key="3" label="课后" value="AFTER_CLASS"></el-option>-->
|
|
|
-<!-- <el-option key="4" label="期末" value="FINISH_CLASS"></el-option>-->
|
|
|
-<!-- </el-select>-->
|
|
|
-<!-- </el-form-item>-->
|
|
|
-
|
|
|
+ <el-row v-if="isCreator">
|
|
|
+ <el-col :span="3.5">
|
|
|
+ <el-button
|
|
|
+ @click="uploadDialogVisible = true"
|
|
|
+ type="primary"
|
|
|
+ icon="el-icon-circle-plus-outline"
|
|
|
+ plain>新建</el-button>
|
|
|
+ </el-col>
|
|
|
+ <el-col :span="15">
|
|
|
+ <span style="font-size: smaller; position: absolute; bottom: 25%">(支持拓展名:.pdf .ppt .pptx .doc .docx .xls .jpg .jpeg .png,单次只可上传一个文件)</span>
|
|
|
+ </el-col>
|
|
|
+ </el-row>
|
|
|
+ <el-dialog v-model="uploadDialogVisible" :before-close="handleCancelUpload" :width="700">
|
|
|
+ <el-form ref="formRef" :model="form" label-width="100px">
|
|
|
<el-form-item label="使用类型" required>
|
|
|
<el-select v-model="form.useMethod" placeholder="类型">
|
|
|
<el-option key="1" label="浏览" value="SCAN"></el-option>
|
|
|
@@ -34,7 +24,7 @@
|
|
|
<el-form-item label="文件" required>
|
|
|
<el-upload
|
|
|
:file-list="fileList"
|
|
|
- :on-change="handleChange"
|
|
|
+ :on-change="handleUploadFile"
|
|
|
action=""
|
|
|
class="upload-demo"
|
|
|
:auto-upload="false"
|
|
|
@@ -45,24 +35,36 @@
|
|
|
type="primary"
|
|
|
class="tabs-function-button"
|
|
|
icon="el-icon-upload"
|
|
|
- >上传文件</el-button>(请选择单个文件)
|
|
|
+ >上传文件</el-button>(仅支持上传单个文件)
|
|
|
</el-upload>
|
|
|
<el-tag
|
|
|
- v-if="isUnique"
|
|
|
- :key="tag"
|
|
|
+ v-if="isNameUnique"
|
|
|
+ :key="fileTag"
|
|
|
color="white"
|
|
|
closable
|
|
|
- @close="handleCloseTag(tag)">
|
|
|
- {{file.name}}</el-tag>
|
|
|
+ @close="handleCloseFileTag(fileTag)">
|
|
|
+ {{file.name}}
|
|
|
+ </el-tag>
|
|
|
+ <el-icon :size="20" style="color: #337ecc; position: absolute; bottom: 10%; margin-left: 5px"
|
|
|
+ v-if="isNameUnique" @click="handleChangeNameWhenUpload()">
|
|
|
+ <Edit />
|
|
|
+ </el-icon>
|
|
|
</el-form-item>
|
|
|
- </el-form>
|
|
|
- <div style="margin: auto;width: fit-content">
|
|
|
- <el-button type="primary" @click="handleFormConfirm">确定</el-button>
|
|
|
- <el-button @click="handleFormCancel">取消</el-button>
|
|
|
- </div>
|
|
|
+ <el-form-item v-if="isChangeNameWhenUpload">
|
|
|
+ <el-input v-model="this.newName" placeholder="请输入新课件名称" style="width: 70%">
|
|
|
+ <template #append>{{nameAppend}}</template>
|
|
|
+ </el-input>
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+ <div style="margin: auto;width: fit-content">
|
|
|
+ <el-button type="primary" @click="handleConfirmUpload">确定</el-button>
|
|
|
+ <el-button @click="handleCancelUpload">取消</el-button>
|
|
|
+ </div>
|
|
|
</el-dialog>
|
|
|
|
|
|
- <el-table :data="fileEntryList">
|
|
|
+
|
|
|
+
|
|
|
+ <el-table :data="fileEntryList">
|
|
|
<el-table-column
|
|
|
type="index"
|
|
|
width="30">
|
|
|
@@ -74,11 +76,10 @@
|
|
|
<template #default="scope">
|
|
|
<el-icon v-if="scope.row['courseWareVO'].useMethod === 'SCAN'" style="color: #337ecc" class="myicon"><Reading /></el-icon>
|
|
|
<el-icon v-if="scope.row['courseWareVO'].useMethod === 'ATTACHMENT'" style="color: green" class="myicon"><Paperclip /></el-icon>
|
|
|
- {{scope.row["courseWareVO"].name}}
|
|
|
-<!-- <el-tag v-if="scope.row['courseWareVO'].useTime === 'BEFORE_CLASS'" type="success" class="mytag" size="mini"> {{getUseTimeTransition(scope.row["courseWareVO"].useTime)}} </el-tag>-->
|
|
|
-<!-- <el-tag v-else-if="scope.row['courseWareVO'].useTime === 'IN_CLASS'" type="warning" class="mytag" size="mini"> {{getUseTimeTransition(scope.row["courseWareVO"].useTime)}} </el-tag>-->
|
|
|
-<!-- <el-tag v-else-if="scope.row['courseWareVO'].useTime === 'AFTER_CLASS'" class="mytag" size="mini"> {{getUseTimeTransition(scope.row["courseWareVO"].useTime)}} </el-tag>-->
|
|
|
-<!-- <el-tag v-else type="danger" class="mytag" size="mini"> {{getUseTimeTransition(scope.row["courseWareVO"].useTime)}} </el-tag>-->
|
|
|
+ {{scope.row['courseWareVO'].name}}
|
|
|
+ <el-icon :size="20" style="color: #337ecc; position: absolute; bottom: 35%; margin-left: 5px" @click="handleChangeName(scope.row['courseWareVO'].id, scope.row['courseWareVO'].name)">
|
|
|
+ <Edit />
|
|
|
+ </el-icon>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
|
@@ -92,9 +93,13 @@
|
|
|
<el-table-column
|
|
|
prop="created_time"
|
|
|
label="上传时间"
|
|
|
- width="160">
|
|
|
+ width="160"
|
|
|
+ :sortable="true"
|
|
|
+ :sort-method="sortByDate2"
|
|
|
+ >
|
|
|
<template #default="scope">
|
|
|
- {{timestampToTime(scope.row["courseWareVO"].createdTime)}}
|
|
|
+<!-- {{timestampToTime(scope.row["courseWareVO"].createdTime)}}-->
|
|
|
+ {{timestampToTime(scope.row["courseWareVO"].createdTime)}}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
|
@@ -107,34 +112,46 @@
|
|
|
size="mini" type="primary" plain style="margin-right: 5px">预览</el-button>
|
|
|
</a>
|
|
|
<el-button v-if="scope.row['courseWareVO'].useMethod === 'SCAN' && isPdfOrPicture(scope.row['courseWareVO'].name) === 'PDF'"
|
|
|
- @click="handleCheck(scope.row['courseWareVO'].fileUrl)"
|
|
|
+ @click="handlePreviewFile(scope.row['courseWareVO'].fileUrl)"
|
|
|
size="mini" type="primary" plain style="margin-right: 5px">预览</el-button>
|
|
|
<el-button v-if="scope.row['courseWareVO'].useMethod === 'SCAN' && isPdfOrPicture(scope.row['courseWareVO'].name) === 'PICTURE'"
|
|
|
- @click="handleCheckPicture(scope.row['courseWareVO'])"
|
|
|
+ @click="handlePreviewPicture(scope.row['courseWareVO'])"
|
|
|
size="mini" type="primary" plain style="margin-right: 5px">预览</el-button>
|
|
|
<a :href="scope.row['courseWareVO'].fileUrl">
|
|
|
<el-button size="mini" type="success" plain style="margin-right: 5px">下载</el-button>
|
|
|
</a>
|
|
|
<el-button v-if="Number(scope.row['courseWareVO'].senderId) === Number(this.$store.state.user.id)"
|
|
|
- size="mini" type="danger" @click="handleRemove(scope.row['courseWareVO'].id)" plain>删除</el-button>
|
|
|
+ size="mini" type="danger" @click="handleRemoveCourseWare(scope.row['courseWareVO'].id)" plain>删除</el-button>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
<el-dialog
|
|
|
- v-model = "pictureDialogVisible"
|
|
|
- width = "80%"
|
|
|
- :before-close = "handleClosePicture"
|
|
|
+ v-model="picturePreviewDialogVisible"
|
|
|
+ width="80%"
|
|
|
+ :before-close="handleClosePreviewPicture"
|
|
|
>
|
|
|
<img :src="pictureUrl" alt="" style="width: 100%" class="image" />
|
|
|
<!-- <el-image style="width: 100px; height: 100px" :src="getPictureUrl" />-->
|
|
|
<template #footer>
|
|
|
<span class="dialog-footer">
|
|
|
- <el-button type="primary" @click="pictureDialogVisible = false" plain>
|
|
|
- 关闭
|
|
|
- </el-button>
|
|
|
+ <el-button type="primary" @click="handleClosePreviewPicture" plain>关闭</el-button>
|
|
|
</span>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
+ <el-dialog
|
|
|
+ v-model="nameChangeDialogVisible"
|
|
|
+ width="30%"
|
|
|
+ :before-close="handleCancelChangeName">
|
|
|
+ <el-input v-model="this.newName" placeholder="请输入新课件名称">
|
|
|
+ <template #append>{{nameAppend}}</template>
|
|
|
+ </el-input>
|
|
|
+ <template #footer>
|
|
|
+ <span class="dialog-footer">
|
|
|
+ <el-button @click="handleCancelChangeName">取消</el-button>
|
|
|
+ <el-button type="primary" @click="handleConfirmChangeName" plain>确定</el-button>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -154,6 +171,7 @@ export default {
|
|
|
required: true,
|
|
|
},
|
|
|
},
|
|
|
+
|
|
|
data() {
|
|
|
return {
|
|
|
form: {
|
|
|
@@ -164,92 +182,156 @@ export default {
|
|
|
fileList: [],
|
|
|
fileEntryList: [],
|
|
|
uploadDialogVisible: false,
|
|
|
- pictureDialogVisible: false,
|
|
|
- isUnique: false,
|
|
|
+ picturePreviewDialogVisible: false,
|
|
|
+ nameChangeDialogVisible: false,
|
|
|
+ isChangeNameWhenUpload: false,
|
|
|
+ isNameUnique: false,
|
|
|
pictureUrl: null,
|
|
|
pictureName: null,
|
|
|
- fileNameTags: [],
|
|
|
- tag: null,
|
|
|
- num: 0,
|
|
|
+ idToBeChangeName: null,
|
|
|
+ newName: null,
|
|
|
+ nameAppend: null,
|
|
|
+ fileTag: null,
|
|
|
+ fileNum: 0,
|
|
|
+
|
|
|
+
|
|
|
};
|
|
|
},
|
|
|
computed: {
|
|
|
- // isCreator(senderId) {
|
|
|
- // return Number(senderId) === Number(this.$store.state.user.id);
|
|
|
- // },
|
|
|
+ isCreator() {
|
|
|
+ return Number(this.teacherId) === Number(this.$store.state.user.id);
|
|
|
+ },
|
|
|
},
|
|
|
mounted() {
|
|
|
this.init();
|
|
|
},
|
|
|
methods: {
|
|
|
- async init() {
|
|
|
- this.fileEntryList = (await this.$apis.getCourseWaresByCourseId(this.courseId)).data.data;
|
|
|
- },
|
|
|
+ sortByDate(obj1, obj2) {
|
|
|
+ console.log(obj1, obj2);
|
|
|
+ let val1 = obj1.deadline;
|
|
|
+ let val2 = obj2.deadline;
|
|
|
+ console.log(val1, val2);
|
|
|
+ console.log(val1 - val2);
|
|
|
+ return val1 - val2;
|
|
|
+ },
|
|
|
|
|
|
- isCreator(senderId) {
|
|
|
- return Number(senderId) === Number(this.$store.state.user.id);
|
|
|
- },
|
|
|
+ sortByDate2(obj1, obj2) {
|
|
|
+ console.log(obj1.courseWareVO, obj2.courseWareVO);
|
|
|
+ let val1 = obj1.courseWareVO.createdTime;
|
|
|
+ let val2 = obj2.courseWareVO.createdTime;
|
|
|
+ console.log(val1, val2);
|
|
|
+ console.log(val2 > val1 ? 1 : -1);
|
|
|
+ return val2 > val1 ? 1 : -1;
|
|
|
+ },
|
|
|
|
|
|
- timestampToTime: portal.functions.timestampToTime,
|
|
|
|
|
|
- async handleChange(file, fileList) {
|
|
|
- const fileType = file.name.substring(file.name.indexOf(".") + 1);
|
|
|
- console.log(this.form.useMethod + " + " + file.name.substring(file.name.indexOf(".") + 1));
|
|
|
- if (!(fileType === "pdf" || fileType === "ppt" || fileType === "pptx" || fileType === "xls"
|
|
|
- || fileType === "doc" || fileType === "docx" || fileType === "png" || fileType === "jpeg" || fileType === "jpg")) {
|
|
|
- this.$message({
|
|
|
- message: "该文件类型不属于支持的课件类型",
|
|
|
- type: "error"
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- // if (this.form.useMethod === "SCAN") {
|
|
|
- // if (!(fileType === "pdf" || fileType === "ppt" || fileType === "pptx" || fileType === "xls"
|
|
|
- // || fileType === "doc" || fileType === "docx" || fileType === "txt")) {
|
|
|
- // this.$message({
|
|
|
- // message: "该文件类型不属于支持的可浏览课件类型",
|
|
|
- // type: "error"
|
|
|
- // });
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // }
|
|
|
- if (this.num === 1) {
|
|
|
- this.$message({
|
|
|
- message: "一次只能选择上传一个课件",
|
|
|
- type: "error"
|
|
|
- });
|
|
|
- return;
|
|
|
- }
|
|
|
- this.file = file;
|
|
|
- this.fileList = fileList;
|
|
|
- console.log(this.file.raw.type);
|
|
|
- const isNameUnique = (await this.$apis.checkCourseWareNameUnique(this.courseId, this.file.name)).data.data;
|
|
|
- if (!isNameUnique) {
|
|
|
- console.log("notunique");
|
|
|
- this.$message({
|
|
|
- message: "该课程下已存在同名课件",
|
|
|
- type: "error"
|
|
|
- });
|
|
|
- } else {
|
|
|
- this.isUnique = true;
|
|
|
- this.num = 1;
|
|
|
+ async init() {
|
|
|
+ this.fileEntryList = (await this.$apis.getCourseWaresByCourseId(this.courseId)).data.data;
|
|
|
+ console.log(this.fileEntryList);
|
|
|
+ },
|
|
|
+
|
|
|
+ handleChangeNameWhenUpload() {
|
|
|
+ this.isChangeNameWhenUpload = true;
|
|
|
+ this.nameAppend = this.file.name.substring(this.file.name.lastIndexOf("."));
|
|
|
+ },
|
|
|
+
|
|
|
+ handleChangeName(id, oldName) {
|
|
|
+ this.nameChangeDialogVisible = true;
|
|
|
+ this.idToBeChangeName = id;
|
|
|
+ this.nameAppend = oldName.substring(oldName.lastIndexOf("."));
|
|
|
+ },
|
|
|
+
|
|
|
+ handleCancelChangeName() {
|
|
|
+ ElMessageBox.confirm("确定取消修改课件名称?")
|
|
|
+ .then(() => {
|
|
|
+ this.newName = null;
|
|
|
+ this.nameAppend = null;
|
|
|
+ this.nameChangeDialogVisible = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ handleConfirmChangeName() {
|
|
|
+ ElMessageBox.confirm("确定修改课件名称?")
|
|
|
+ .then(async () => {
|
|
|
+ const isNameUnique = (await this.$apis.checkCourseWareNameUnique(this.courseId, this.newName + this.nameAppend)).data.data;
|
|
|
+ if (!isNameUnique) {
|
|
|
+ this.$message({
|
|
|
+ message: "该课程下已存在同名课件",
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.$apis.changeCourseWareName(this.idToBeChangeName, this.newName + this.nameAppend)
|
|
|
+ .then(async () => {
|
|
|
+ console.log("1");
|
|
|
+ this.fileEntryList = (await this.$apis.getCourseWaresByCourseId(this.courseId)).data.data;
|
|
|
+ });
|
|
|
+ this.newName = null;
|
|
|
+ this.nameAppend = null;
|
|
|
+ this.nameChangeDialogVisible = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
+ timestampToTime: portal.functions.timestampToTime,
|
|
|
+
|
|
|
+ async handleUploadFile(file, fileList) {
|
|
|
+ const fileType = file.name.substring(file.name.lastIndexOf(".") + 1);
|
|
|
+ console.log(this.form.useMethod + " + " + file.name.substring(file.name.lastIndexOf(".") + 1));
|
|
|
+ if (!(fileType === "pdf" || fileType === "ppt" || fileType === "pptx" || fileType === "xls"
|
|
|
+ || fileType === "doc" || fileType === "docx" || fileType === "png" || fileType === "jpeg" || fileType === "jpg")) {
|
|
|
+ this.$message({
|
|
|
+ message: "该文件类型不属于支持的课件类型",
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (this.fileNum === 1) {
|
|
|
+ this.$message({
|
|
|
+ message: "一次只能选择上传一个课件",
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ this.file = file;
|
|
|
+ this.fileList = fileList;
|
|
|
+ const isNameUnique = (await this.$apis.checkCourseWareNameUnique(this.courseId, this.file.name)).data.data;
|
|
|
+ if (!isNameUnique) {
|
|
|
+ this.$message({
|
|
|
+ message: "该课程下已存在同名课件",
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ } else {
|
|
|
+ this.isNameUnique = true;
|
|
|
+ this.fileNum = 1;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ async handleConfirmUpload() {
|
|
|
+ if (this.newName !== null) {
|
|
|
+ const isNameUnique = (await this.$apis.checkCourseWareNameUnique(this.courseId, this.newName + this.nameAppend)).data.data;
|
|
|
+ if (!isNameUnique) {
|
|
|
+ this.$message({
|
|
|
+ message: "该课程下已存在同名课件",
|
|
|
+ type: "error"
|
|
|
+ });
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
- },
|
|
|
|
|
|
- async handleFormConfirm() {
|
|
|
if (this.file === null) {
|
|
|
this.$message({
|
|
|
message: "尚未上传课件",
|
|
|
type: "error"
|
|
|
});
|
|
|
} else {
|
|
|
- const fileUrl = (await this.$apis.uploadCourseWareFile(this.courseId + "/" + this.file.name, this.fileList[0].raw)).data.data;
|
|
|
+ const fileUrl = (await this.$apis.uploadCourseWareFile(this.courseId + "/" + (this.newName == null ? this.file.name : (this.newName + this.nameAppend)), this.fileList[0].raw)).data.data;
|
|
|
this.$message({
|
|
|
message: "上传课件成功",
|
|
|
type: "success"
|
|
|
});
|
|
|
this.$apis.createCourseWare({
|
|
|
- name: this.file.name,
|
|
|
+ name: this.newName === null ? this.file.name : (this.newName + this.nameAppend),
|
|
|
size: this.file.size,
|
|
|
senderId: this.$store.state.user.id,
|
|
|
courseId: this.courseId,
|
|
|
@@ -261,84 +343,90 @@ export default {
|
|
|
this.fileEntryList = (await this.$apis.getCourseWaresByCourseId(this.courseId)).data.data;
|
|
|
});
|
|
|
this.uploadDialogVisible = false;
|
|
|
- this.isUnique = false;
|
|
|
- this.num = 0;
|
|
|
+ this.isChangeNameWhenUpload = false;
|
|
|
+ this.isNameUnique = false;
|
|
|
+ this.fileNum = 0;
|
|
|
+ this.newName = null;
|
|
|
+ this.nameAppend = null;
|
|
|
}
|
|
|
- },
|
|
|
+ },
|
|
|
|
|
|
- handleFormCancel(done) {
|
|
|
- ElMessageBox.confirm("是否确认退出?退出后将不保存表格信息。", "提示", {
|
|
|
+ handleCancelUpload(done) {
|
|
|
+ ElMessageBox.confirm("是否确认退出?退出后将不保存表格信息。", "提示", {
|
|
|
confirmButtonText: "确认退出",
|
|
|
cancelButtonText: "我再想想",
|
|
|
type: "warning",
|
|
|
center: true,
|
|
|
- })
|
|
|
- .then(() => {
|
|
|
- this.uploadDialogVisible = false;
|
|
|
- this.clearForm();
|
|
|
- // Zhurui修改,关闭dialog
|
|
|
- done();
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- console.log(err);
|
|
|
- });
|
|
|
- },
|
|
|
+ })
|
|
|
+ .then(() => {
|
|
|
+ this.uploadDialogVisible = false;
|
|
|
+ this.isChangeNameWhenUpload = false;
|
|
|
+ this.isNameUnique = false;
|
|
|
+ this.fileNum = 0;
|
|
|
+ this.newName = null;
|
|
|
+ this.nameAppend = null;
|
|
|
+ this.clearForm();
|
|
|
+ // Zhurui修改,关闭dialog
|
|
|
+ done();
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
- handleCloseTag() {
|
|
|
+ handleCloseFileTag() {
|
|
|
ElMessageBox.confirm("是否确认取消选择该课件?", "提示", {
|
|
|
confirmButtonText: "确认取消",
|
|
|
cancelButtonText: "我再想想",
|
|
|
type: "warning",
|
|
|
center: true,
|
|
|
})
|
|
|
- .then(() => {
|
|
|
- this.isUnique = false;
|
|
|
- this.file = null;
|
|
|
- this.num = 0;
|
|
|
- this.clearForm();
|
|
|
- done();
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- console.log(err);
|
|
|
- });
|
|
|
- },
|
|
|
+ .then(() => {
|
|
|
+ this.isNameUnique = false;
|
|
|
+ this.file = null;
|
|
|
+ this.fileNum = 0;
|
|
|
+ this.clearForm();
|
|
|
+ done();
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
- handleRemove(id) {
|
|
|
+ handleRemoveCourseWare(id) {
|
|
|
ElMessageBox.confirm("是否确认删除该课件?", "提示", {
|
|
|
confirmButtonText: "确认删除",
|
|
|
cancelButtonText: "我再想想",
|
|
|
type: "warning",
|
|
|
center: true,
|
|
|
})
|
|
|
- .then(() => {
|
|
|
- this.$apis.deleteCourseWare(id).then(async () => {
|
|
|
- this.fileEntryList = (await this.$apis.getCourseWaresByCourseId(this.courseId)).data.data;
|
|
|
- });
|
|
|
- this.uploadDialogVisible = false;
|
|
|
- this.num = 0;
|
|
|
- this.clearForm();
|
|
|
- // Zhurui修改,关闭dialog
|
|
|
- done();
|
|
|
- })
|
|
|
- .catch((err) => {
|
|
|
- console.log(err);
|
|
|
+ .then(() => {
|
|
|
+ this.$apis.deleteCourseWare(id).then(async () => {
|
|
|
+ this.fileEntryList = (await this.$apis.getCourseWaresByCourseId(this.courseId)).data.data;
|
|
|
});
|
|
|
- },
|
|
|
+ this.uploadDialogVisible = false;
|
|
|
+ this.fileNum = 0;
|
|
|
+ this.clearForm();
|
|
|
+ // Zhurui修改,关闭dialog
|
|
|
+ done();
|
|
|
+ })
|
|
|
+ .catch((err) => {
|
|
|
+ console.log(err);
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
- handleCheck(fileUrl) {
|
|
|
- console.log("check" + fileUrl);
|
|
|
- //this.$router.push({ name: "courseWare", params: { courseWareId: id, page: "1"} });
|
|
|
+ handlePreviewFile(fileUrl) {
|
|
|
window.open(fileUrl);
|
|
|
- },
|
|
|
+ },
|
|
|
|
|
|
- handleCheckPicture(courseWareVO) {
|
|
|
- this.pictureDialogVisible = true;
|
|
|
+ handlePreviewPicture(courseWareVO) {
|
|
|
+ this.picturePreviewDialogVisible = true;
|
|
|
this.pictureUrl = courseWareVO.fileUrl;
|
|
|
this.pictureName = courseWareVO.name;
|
|
|
- },
|
|
|
+ },
|
|
|
|
|
|
- isPdfOrPicture(name) {
|
|
|
- const fileType = name.substring(name.indexOf(".") + 1);
|
|
|
+ isPdfOrPicture(name) {
|
|
|
+ const fileType = name.substring(name.lastIndexOf(".") + 1);
|
|
|
if (fileType === "pdf") {
|
|
|
return "PDF";
|
|
|
} else if (fileType === "png" || fileType === "jpg" || fileType === "jpeg") {
|
|
|
@@ -346,68 +434,22 @@ export default {
|
|
|
} else {
|
|
|
return "OTHER";
|
|
|
}
|
|
|
- },
|
|
|
-
|
|
|
- getUseTimeTransition(useTime) {
|
|
|
- switch (useTime) {
|
|
|
- case "BEFORE_CLASS":
|
|
|
- return "课前";
|
|
|
- case "IN_CLASS":
|
|
|
- return "课中";
|
|
|
- case "AFTER_CLASS":
|
|
|
- return "课后";
|
|
|
- case "FINISH_CLASS":
|
|
|
- return "期末";
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- getSizeTransition(size) {
|
|
|
- if (size < 1000000) {
|
|
|
- return (size * 1.0 / 1000).toFixed(2) + " MB";
|
|
|
- } else {
|
|
|
- return (size * 1.0 / 1000000).toFixed(2) + " GB";
|
|
|
- }
|
|
|
- },
|
|
|
+ },
|
|
|
|
|
|
- handleClosePicture() {
|
|
|
- ElMessageBox.confirm("Are you sure to close this dialog?")
|
|
|
- .then(() => {
|
|
|
- this.pictureDialogVisible = false;
|
|
|
- });
|
|
|
- },
|
|
|
+ getSizeTransition(size) {
|
|
|
+ if (size < 1024 * 1024) {
|
|
|
+ return (size * 1.0 / 1024).toFixed(2) + " KB";
|
|
|
+ } else {
|
|
|
+ return (size * 1.0 / 1024 / 1024).toFixed(2) + " MB";
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
- Previewf(file) {
|
|
|
- console.log(file);
|
|
|
- // window.open(file.response)
|
|
|
- if (file) {
|
|
|
- const addTypeArray = file.name.split(".");
|
|
|
- const addType = addTypeArray[addTypeArray.length - 1];
|
|
|
- console.log(addType);
|
|
|
- if (addType === "pdf") {
|
|
|
- let routeData = this.$router.resolve({
|
|
|
- path: "/insurancePdf",
|
|
|
- query: { url: file.response, showBack: false },
|
|
|
- });
|
|
|
- window.open(routeData.href, "_blank");
|
|
|
- }
|
|
|
- //".rar, .zip, .doc, .docx, .xls, .txt, .pdf, .jpg, .png, .jpeg,"
|
|
|
- else if (addType === "doc" || addType === "docx" || addType === "xls") {
|
|
|
- window.open(
|
|
|
- "http://view.officeapps.live.com/op/view.aspx?src=" + file.response
|
|
|
- );
|
|
|
- } else if (addType === "txt") {
|
|
|
- window.open(file.response);
|
|
|
- } else if (["png", "jpg", "jpeg"].includes(addType)) {
|
|
|
- window.open(file.response);
|
|
|
- } else if (addType === "rar" || addType === "zip") {
|
|
|
- this.$message({
|
|
|
- message: "该文件类型暂不支持预览",
|
|
|
- type: "warning",
|
|
|
- });
|
|
|
- return false;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+ handleClosePreviewPicture() {
|
|
|
+ ElMessageBox.confirm("确定关闭图片预览?")
|
|
|
+ .then(() => {
|
|
|
+ this.picturePreviewDialogVisible = false;
|
|
|
+ });
|
|
|
+ },
|
|
|
|
|
|
// handleDownload(id) {
|
|
|
// this.$apis.downloadCourseWare(id, {responseType: "blob"})
|