|
|
@@ -56,7 +56,7 @@
|
|
|
</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>
|
|
|
@@ -113,30 +113,27 @@
|
|
|
<!-- <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>-->
|
|
|
<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 +148,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 +173,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 +212,13 @@ export default {
|
|
|
idToBeChangeName: null,
|
|
|
newName: null,
|
|
|
nameAppend: null,
|
|
|
+ fileType: null,
|
|
|
fileTag: null,
|
|
|
fileNum: 0,
|
|
|
- picturesFromPDF: [],
|
|
|
pdfName: "",
|
|
|
- downloadValue: true
|
|
|
+ downloadValue: true,
|
|
|
+ canDownloadList: [],
|
|
|
+ courseWareNum: 0
|
|
|
};
|
|
|
},
|
|
|
|
|
|
@@ -231,8 +234,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 +350,7 @@ export default {
|
|
|
} else {
|
|
|
this.isNameUnique = true;
|
|
|
this.fileNum = 1;
|
|
|
+ this.fileType = "." + fileType;
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
@@ -373,7 +377,7 @@ export default {
|
|
|
.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 +385,13 @@ export default {
|
|
|
useTime: "BEFORE_CLASS",
|
|
|
useMethod: this.form.useMethod,
|
|
|
fileUrl: fileUrl,
|
|
|
- canDownload: this.downloadValue
|
|
|
}).then(res => {
|
|
|
+ console.log(res.data.data.id);
|
|
|
+ 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"
|
|
|
@@ -415,7 +421,7 @@ export default {
|
|
|
.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 +429,13 @@ export default {
|
|
|
useTime: "BEFORE_CLASS",
|
|
|
useMethod: this.form.useMethod,
|
|
|
fileUrl: fileUrl,
|
|
|
- canDownload: this.downloadValue
|
|
|
}).then(res => {
|
|
|
+ //console.log(res.data.data.id);
|
|
|
+ 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"
|
|
|
@@ -441,9 +449,6 @@ export default {
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
},
|
|
|
|
|
|
handleCancelUpload(done) {
|
|
|
@@ -479,6 +484,7 @@ export default {
|
|
|
.then(() => {
|
|
|
this.isChangeNameWhenUpload = false;
|
|
|
this.nameAppend = null;
|
|
|
+ this.fileType = null;
|
|
|
this.isNameUnique = false;
|
|
|
this.file = null;
|
|
|
this.fileNum = 0;
|
|
|
@@ -500,6 +506,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;
|
|
|
@@ -562,7 +569,38 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
|
|
|
+ // getCanDownloadById(id) {
|
|
|
+ // this.$apis.getCanDownloadById(id).then(res => {
|
|
|
+ // console.log(res.data.data);
|
|
|
+ // return res.data.data;
|
|
|
+ // });
|
|
|
+ // },
|
|
|
+
|
|
|
+ async getCanDownloadById(id) {
|
|
|
+ const canDownload = (await this.$apis.getCanDownloadById(id)).data.data;
|
|
|
+ //console.log(id + ": " + canDownload);
|
|
|
+ return canDownload === true;
|
|
|
+ },
|
|
|
|
|
|
+ checkDownloadButton(id, name){
|
|
|
+ this.$apis.getCanDownloadById(id).then(res => {
|
|
|
+ const canDownload = res.data.data;
|
|
|
+ const isPdf = this.isPdfOrPicture(name);
|
|
|
+ if ((isPdf === "PDF") && (canDownload.toString() === "true")) {
|
|
|
+ return "1";
|
|
|
+ } else {
|
|
|
+ return "0";
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // const isPdf = this.isPdfOrPicture(name);
|
|
|
+ // const canDownload = (await this.$apis.getCanDownloadById(id)).data.data;
|
|
|
+ // if ((isPdf === "PDF") && (canDownload.toString() === "true")) {
|
|
|
+ // return "1";
|
|
|
+ // } else {
|
|
|
+ // return "0";
|
|
|
+ // }
|
|
|
+ //return "1";
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
};
|