|
|
@@ -8,7 +8,7 @@
|
|
|
plain>新建</el-button>
|
|
|
</el-col>
|
|
|
<el-col :span="15">
|
|
|
- <span style="font-size: smaller; position: absolute; bottom: 25%">(支持拓展名:.pdf .jpg .jpeg .png .exe .zip)</span>
|
|
|
+ <span style="font-size: smaller; position: absolute; bottom: 25%">(支持拓展名:.pdf .jpg .jpeg .png .exe .zip,最大文件大小:100MB)</span>
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
<el-dialog v-model="uploadDialogVisible" :before-close="handleCancelUpload" :width="700">
|
|
|
@@ -29,7 +29,8 @@
|
|
|
:auto-upload="false"
|
|
|
:show-file-list="false"
|
|
|
>
|
|
|
- <el-button plain type="primary" class="tabs-function-button">上传文件</el-button>(仅支持上传单个文件)
|
|
|
+ <el-button plain type="primary" class="tabs-function-button" size="small"
|
|
|
+ >上传文件</el-button>(仅支持上传单个文件,最大文件大小:100MB)
|
|
|
</el-upload>
|
|
|
<el-tag
|
|
|
v-if="isNameUnique"
|
|
|
@@ -56,14 +57,16 @@
|
|
|
</el-col>
|
|
|
</el-row>
|
|
|
</el-form-item>
|
|
|
- <el-form-item label="允许下载" required>
|
|
|
+ <el-form-item label="允许下载" required v-if="fileType === '.pdf'">
|
|
|
<el-switch v-model="downloadValue" />
|
|
|
</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 style="margin: auto; width: fit-content">
|
|
|
+ <el-button type="primary" @click="handleConfirmUpload" size="small">确定</el-button>
|
|
|
+ <el-button @click="handleCancelUpload" size="small">取消</el-button>
|
|
|
</div>
|
|
|
+ <el-progress v-if="percentageVisible" :indeterminate="true" :percentage="100" status="warning"
|
|
|
+ style="width: 40%; margin-top: 20px; margin-left: 30%"></el-progress>
|
|
|
</el-dialog>
|
|
|
|
|
|
<el-table :data="fileEntryList" style="width: 100%">
|
|
|
@@ -75,7 +78,7 @@
|
|
|
<el-table-column
|
|
|
prop="name"
|
|
|
label="文件名"
|
|
|
- width="260"
|
|
|
+ width="280"
|
|
|
>
|
|
|
<template #default="scope">
|
|
|
<el-icon v-if="scope.row['courseWareVO'].useMethod === 'SCAN'" style="color: #337ecc" class="myicon"><Reading /></el-icon>
|
|
|
@@ -113,30 +116,31 @@
|
|
|
<!-- <el-button style="color: #409EFF; margin-right: 10px" type="text">预览</el-button>-->
|
|
|
<!-- </a>-->
|
|
|
|
|
|
- <el-button v-if="isPdfOrPicture(scope.row['courseWareVO'].name) === 'OFFICE'"
|
|
|
- @click="handlePreviewFile(scope.row['courseWareVO'].id)"
|
|
|
- style="color: #409EFF; margin-right: 10px" type="text">预览</el-button>
|
|
|
- <a v-if="isPdfOrPicture(scope.row['courseWareVO'].name) === 'OFFICE'"
|
|
|
- :href="getOfficeFileUrl(scope.row['courseWareVO'].fileUrl)">点击预览</a>
|
|
|
-
|
|
|
- <a :href="scope.row['courseWareVO'].fileUrl" v-if="isPdfOrPicture(scope.row['courseWareVO'].name) === 'OFFICE'">
|
|
|
- <el-button style="color: #67C23A" type="text">下载</el-button>
|
|
|
- </a>
|
|
|
-
|
|
|
+<!-- <el-button v-if="isPdfOrPicture(scope.row['courseWareVO'].name) === 'OFFICE'"-->
|
|
|
+<!-- @click="handlePreviewFile(scope.row['courseWareVO'].id)"-->
|
|
|
+<!-- style="color: #409EFF; margin-right: 10px" type="text">预览</el-button>-->
|
|
|
+<!-- <a v-if="isPdfOrPicture(scope.row['courseWareVO'].name) === 'OFFICE'"-->
|
|
|
+<!-- :href="getOfficeFileUrl(scope.row['courseWareVO'].fileUrl)">点击预览</a>-->
|
|
|
+<!-- <a :href="scope.row['courseWareVO'].fileUrl" v-if="isPdfOrPicture(scope.row['courseWareVO'].name) === 'OFFICE'">-->
|
|
|
+<!-- <el-button style="color: #67C23A" type="text">下载</el-button>-->
|
|
|
+<!-- </a>-->
|
|
|
<el-button v-if="isPdfOrPicture(scope.row['courseWareVO'].name) === 'PDF'"
|
|
|
@click="handlePreviewFile(scope.row['courseWareVO'].id)"
|
|
|
- style="color: #409EFF" type="text">预览</el-button>
|
|
|
- <el-button v-if="Number(scope.row['courseWareVO'].senderId) === Number(this.$store.state.user.id) && isPdfOrPicture(scope.row['courseWareVO'].name) === 'PDF'
|
|
|
- && scope.row['courseWareVO'].canDownload === true"
|
|
|
- @click="handleDownloadPdfFile(scope.row['courseWareVO'].fileUrl)"
|
|
|
- style="color: #67C23A" type="text">下载</el-button>
|
|
|
-
|
|
|
+ style="color: #409EFF" type="text">打开</el-button>
|
|
|
<el-button v-if="scope.row['courseWareVO'].useMethod === 'SCAN' && isPdfOrPicture(scope.row['courseWareVO'].name) === 'PICTUREandATTACHMENT'"
|
|
|
- @click="handlePreviewPicture(scope.row['courseWareVO'])"
|
|
|
- style="color: #409EFF; margin-right: 10px" type="text">预览</el-button>
|
|
|
- <a :href="scope.row['courseWareVO'].fileUrl" v-if="isPdfOrPicture(scope.row['courseWareVO'].name) === 'PICTUREandATTACHMENT'">
|
|
|
- <el-button style="color: #67C23A" type="text">下载</el-button>
|
|
|
- </a>
|
|
|
+ @click="handlePreviewPicture(scope.row['courseWareVO'])"
|
|
|
+ style="color: #409EFF" type="text">打开</el-button>
|
|
|
+
|
|
|
+<!-- <el-button v-if="checkDownloadButton(scope.row['courseWareVO'].id, scope.row['courseWareVO'].name) === '1'"-->
|
|
|
+<!-- <el-button v-if="getCanDownloadById(scope.row['courseWareVO'].id) === true-->
|
|
|
+<!-- <el-button v-if="canDownloadList === '1'-->
|
|
|
+<!-- && isPdfOrPicture(scope.row['courseWareVO'].name) === 'PDF'"-->
|
|
|
+<!-- @click="handleDownloadPdfFile(scope.row['courseWareVO'].fileUrl)"-->
|
|
|
+<!-- style="color: #67C23A" type="text">下载</el-button>-->
|
|
|
+ <a :href="scope.row['courseWareVO'].fileUrl"
|
|
|
+ v-if="scope.row['courseWareVO'].useMethod === 'ATTACHMENT' && isPdfOrPicture(scope.row['courseWareVO'].name) === 'PICTUREandATTACHMENT'">
|
|
|
+ <el-button style="color: #67C23A" type="text">下载</el-button>
|
|
|
+ </a>
|
|
|
<el-button v-if="Number(scope.row['courseWareVO'].senderId) === Number(this.$store.state.user.id)"
|
|
|
style="color: #F56C6C; margin-left: 10px" type="text"
|
|
|
@click="handleRemoveCourseWare(scope.row['courseWareVO'].id)">删除</el-button>
|
|
|
@@ -151,7 +155,10 @@
|
|
|
<img :src="pictureUrl" alt="" style="width: 100%" class="image" />
|
|
|
<template #footer>
|
|
|
<span class="dialog-footer">
|
|
|
- <el-button type="primary" @click="handleClosePreviewPicture" plain>关闭</el-button>
|
|
|
+ <a :href="pictureUrl">
|
|
|
+ <el-button type="success" style="margin-right: 10px" size="small">下载</el-button>
|
|
|
+ </a>
|
|
|
+ <el-button type="primary" @click="handleClosePreviewPicture" plain size="small">关闭</el-button>
|
|
|
</span>
|
|
|
</template>
|
|
|
</el-dialog>
|
|
|
@@ -173,11 +180,12 @@
|
|
|
</template>
|
|
|
|
|
|
<script>
|
|
|
-import portal from "@/utils/portal/portal";
|
|
|
-import {ElMessage, ElMessageBox} from "element-plus";
|
|
|
-import * as pdfjs from "pdfjs-dist";
|
|
|
-import * as pdfjsWorker from "pdfjs-dist/build/pdf.worker.entry";
|
|
|
-pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
|
|
|
+ import portal from "@/utils/portal/portal";
|
|
|
+ import {ElMessageBox} from "element-plus";
|
|
|
+ import * as pdfjs from "pdfjs-dist";
|
|
|
+ import * as pdfjsWorker from "pdfjs-dist/build/pdf.worker.entry";
|
|
|
+
|
|
|
+ pdfjs.GlobalWorkerOptions.workerSrc = pdfjsWorker;
|
|
|
|
|
|
export default {
|
|
|
name: "CoursewareTab",
|
|
|
@@ -211,11 +219,15 @@ export default {
|
|
|
idToBeChangeName: null,
|
|
|
newName: null,
|
|
|
nameAppend: null,
|
|
|
+ fileType: null,
|
|
|
fileTag: null,
|
|
|
fileNum: 0,
|
|
|
- picturesFromPDF: [],
|
|
|
pdfName: "",
|
|
|
- downloadValue: true
|
|
|
+ downloadValue: true,
|
|
|
+ canDownloadList: [],
|
|
|
+ courseWareNum: 0,
|
|
|
+ //percentage: 0,
|
|
|
+ percentageVisible: false
|
|
|
};
|
|
|
},
|
|
|
|
|
|
@@ -231,8 +243,8 @@ export default {
|
|
|
init() {
|
|
|
this.$apis.getCourseWaresByCourseId(this.courseId).then(res => {
|
|
|
this.fileEntryList = res.data.data;
|
|
|
+ this.courseWareNum = this.fileEntryList.length;
|
|
|
});
|
|
|
- console.log(this.fileEntryList);
|
|
|
},
|
|
|
|
|
|
handleChangeNameWhenUpload() {
|
|
|
@@ -347,6 +359,7 @@ export default {
|
|
|
} else {
|
|
|
this.isNameUnique = true;
|
|
|
this.fileNum = 1;
|
|
|
+ this.fileType = "." + fileType;
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
@@ -369,11 +382,13 @@ export default {
|
|
|
});
|
|
|
this.newName = null;
|
|
|
} else {
|
|
|
+ //this.percentage= 0;
|
|
|
+ this.percentageVisible = true;
|
|
|
this.$apis.uploadCourseWareFile(this.courseId + "/" + this.newName + this.nameAppend, this.file.raw)
|
|
|
.then(res => {
|
|
|
const fileUrl = res.data.data;
|
|
|
this.$apis.createCourseWare({
|
|
|
- name: this.newName === null ? this.file.name : (this.newName + this.nameAppend),
|
|
|
+ name: this.newName + this.nameAppend,
|
|
|
size: this.file.size,
|
|
|
senderId: this.$store.state.user.id,
|
|
|
courseId: this.courseId,
|
|
|
@@ -381,11 +396,13 @@ export default {
|
|
|
useTime: "BEFORE_CLASS",
|
|
|
useMethod: this.form.useMethod,
|
|
|
fileUrl: fileUrl,
|
|
|
- canDownload: this.downloadValue
|
|
|
}).then(res => {
|
|
|
+ //this.percentage= 100;
|
|
|
+ this.$apis.setCanDownloadById(res.data.data.id, this.downloadValue);
|
|
|
this.$apis.getCourseWaresByCourseId(this.courseId)
|
|
|
.then(res => {
|
|
|
this.fileEntryList = res.data.data;
|
|
|
+ this.courseWareNum = this.fileEntryList.length;
|
|
|
this.$message({
|
|
|
message: "上传课件成功",
|
|
|
type: "success"
|
|
|
@@ -397,6 +414,8 @@ export default {
|
|
|
this.newName = null;
|
|
|
this.nameAppend = null;
|
|
|
this.file = null;
|
|
|
+ this.fileType = null;
|
|
|
+ this.percentageVisible = false;
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
@@ -411,11 +430,18 @@ export default {
|
|
|
this.nameAppend = null;
|
|
|
}
|
|
|
else {
|
|
|
+ //this.percentage= 0;
|
|
|
+ this.percentageVisible = true;
|
|
|
+ this.$message({
|
|
|
+ message: "上传中,请稍候",
|
|
|
+ type: "warning",
|
|
|
+ duration: 5000
|
|
|
+ });
|
|
|
this.$apis.uploadCourseWareFile(this.courseId + "/" + this.file.name, this.file.raw)
|
|
|
.then(res => {
|
|
|
const fileUrl = res.data.data;
|
|
|
this.$apis.createCourseWare({
|
|
|
- name: this.newName === null ? this.file.name : (this.newName + this.nameAppend),
|
|
|
+ name: this.file.name,
|
|
|
size: this.file.size,
|
|
|
senderId: this.$store.state.user.id,
|
|
|
courseId: this.courseId,
|
|
|
@@ -423,11 +449,13 @@ export default {
|
|
|
useTime: "BEFORE_CLASS",
|
|
|
useMethod: this.form.useMethod,
|
|
|
fileUrl: fileUrl,
|
|
|
- canDownload: this.downloadValue
|
|
|
}).then(res => {
|
|
|
+ //this.percentage= 100;
|
|
|
+ this.$apis.setCanDownloadById(res.data.data.id, this.downloadValue);
|
|
|
this.$apis.getCourseWaresByCourseId(this.courseId)
|
|
|
.then(res => {
|
|
|
this.fileEntryList = res.data.data;
|
|
|
+ this.courseWareNum = this.fileEntryList.length;
|
|
|
this.$message({
|
|
|
message: "上传课件成功",
|
|
|
type: "success"
|
|
|
@@ -437,13 +465,12 @@ export default {
|
|
|
this.isNameUnique = false;
|
|
|
this.fileNum = 0;
|
|
|
this.file = null;
|
|
|
+ this.fileType = null;
|
|
|
+ this.percentageVisible = false;
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
},
|
|
|
|
|
|
handleCancelUpload(done) {
|
|
|
@@ -460,6 +487,8 @@ export default {
|
|
|
this.fileNum = 0;
|
|
|
this.newName = null;
|
|
|
this.nameAppend = null;
|
|
|
+ this.fileType = null;
|
|
|
+ this.percentageVisible = false;
|
|
|
this.clearForm();
|
|
|
// Zhurui修改,关闭dialog
|
|
|
done();
|
|
|
@@ -479,6 +508,7 @@ export default {
|
|
|
.then(() => {
|
|
|
this.isChangeNameWhenUpload = false;
|
|
|
this.nameAppend = null;
|
|
|
+ this.fileType = null;
|
|
|
this.isNameUnique = false;
|
|
|
this.file = null;
|
|
|
this.fileNum = 0;
|
|
|
@@ -500,6 +530,7 @@ export default {
|
|
|
.then(() => {
|
|
|
this.$apis.deleteCourseWare(id).then(async () => {
|
|
|
this.fileEntryList = (await this.$apis.getCourseWaresByCourseId(this.courseId)).data.data;
|
|
|
+ this.courseWareNum = this.fileEntryList.length;
|
|
|
});
|
|
|
this.uploadDialogVisible = false;
|
|
|
this.fileNum = 0;
|
|
|
@@ -560,10 +591,7 @@ export default {
|
|
|
.then(() => {
|
|
|
this.picturePreviewDialogVisible = false;
|
|
|
});
|
|
|
- },
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
</script>
|