|
|
@@ -1,17 +1,28 @@
|
|
|
<template>
|
|
|
<div class="courseware-tab">
|
|
|
- <el-button @click="uploadDialogVisible = true" type="primary" plain>添加课件</el-button>
|
|
|
- <el-dialog v-model="uploadDialogVisible" :before-close="handleFormCancel" :width="700">
|
|
|
+ <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-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-form-item label="使用类型" required>
|
|
|
<el-select v-model="form.useMethod" placeholder="类型">
|
|
|
@@ -27,8 +38,14 @@
|
|
|
action=""
|
|
|
class="upload-demo"
|
|
|
:auto-upload="false"
|
|
|
- :show-file-list="false">
|
|
|
- <el-button plain type="primary" class="tabs-function-button">上传文件<i class="el-icon-upload"></i></el-button>(请选择单个文件)
|
|
|
+ :show-file-list="false"
|
|
|
+ >
|
|
|
+ <el-button
|
|
|
+ plain
|
|
|
+ type="primary"
|
|
|
+ class="tabs-function-button"
|
|
|
+ icon="el-icon-upload"
|
|
|
+ >上传文件</el-button>(请选择单个文件)
|
|
|
</el-upload>
|
|
|
<el-tag
|
|
|
v-if="isUnique"
|
|
|
@@ -53,15 +70,15 @@
|
|
|
<el-table-column
|
|
|
prop="name"
|
|
|
label="文件名"
|
|
|
- width="220">
|
|
|
+ width="240">
|
|
|
<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>
|
|
|
+<!-- <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>-->
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
|
@@ -69,13 +86,13 @@
|
|
|
label="文件大小"
|
|
|
width="100">
|
|
|
<template #default="scope">
|
|
|
- <span>{{scope.row["courseWareVO"].size}} KB</span>
|
|
|
+ {{getSizeTransition(scope.row["courseWareVO"].size)}}
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
|
prop="created_time"
|
|
|
label="上传时间"
|
|
|
- width="180">
|
|
|
+ width="160">
|
|
|
<template #default="scope">
|
|
|
{{timestampToTime(scope.row["courseWareVO"].createdTime)}}
|
|
|
</template>
|
|
|
@@ -85,8 +102,16 @@
|
|
|
label="操作"
|
|
|
width="220">
|
|
|
<template #default="scope">
|
|
|
- <el-button v-if="scope.row['courseWareVO'].useMethod === 'SCAN'"
|
|
|
- size="mini" type="primary" @click="handleCheck(scope.row['courseWareVO'].id)" plain style="margin-right: 5px">查看</el-button>
|
|
|
+ <a :href="scope.row['courseWareVO'].fileUrl" v-if="isPdfOrPicture(scope.row['courseWareVO'].name) === 'OTHER'">
|
|
|
+ <el-button v-if="scope.row['courseWareVO'].useMethod === 'SCAN'"
|
|
|
+ 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)"
|
|
|
+ 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'])"
|
|
|
+ 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>
|
|
|
@@ -95,6 +120,21 @@
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
</el-table>
|
|
|
+ <el-dialog
|
|
|
+ v-model = "pictureDialogVisible"
|
|
|
+ width = "80%"
|
|
|
+ :before-close = "handleClosePicture"
|
|
|
+ >
|
|
|
+ <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>
|
|
|
+ </span>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
|
@@ -124,7 +164,10 @@ export default {
|
|
|
fileList: [],
|
|
|
fileEntryList: [],
|
|
|
uploadDialogVisible: false,
|
|
|
+ pictureDialogVisible: false,
|
|
|
isUnique: false,
|
|
|
+ pictureUrl: null,
|
|
|
+ pictureName: null,
|
|
|
fileNameTags: [],
|
|
|
tag: null,
|
|
|
num: 0,
|
|
|
@@ -134,7 +177,7 @@ export default {
|
|
|
// isCreator(senderId) {
|
|
|
// return Number(senderId) === Number(this.$store.state.user.id);
|
|
|
// },
|
|
|
-},
|
|
|
+ },
|
|
|
mounted() {
|
|
|
this.init();
|
|
|
},
|
|
|
@@ -150,6 +193,26 @@ export default {
|
|
|
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: "一次只能选择上传一个课件",
|
|
|
@@ -159,14 +222,10 @@ export default {
|
|
|
}
|
|
|
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");
|
|
|
- // await ElMessageBox.alert("该课程下已存在同名课件", "提示", {
|
|
|
- // confirmButtonText: "重新选择",
|
|
|
- // type: "warning",
|
|
|
- // center: true,
|
|
|
- // });
|
|
|
this.$message({
|
|
|
message: "该课程下已存在同名课件",
|
|
|
type: "error"
|
|
|
@@ -184,7 +243,7 @@ export default {
|
|
|
type: "error"
|
|
|
});
|
|
|
} else {
|
|
|
- const fileUrl = (await this.$apis.uploadCourseWareFile(this.file.name, this.fileList[0].raw)).data.data;
|
|
|
+ const fileUrl = (await this.$apis.uploadCourseWareFile(this.courseId + "/" + this.file.name, this.fileList[0].raw)).data.data;
|
|
|
this.$message({
|
|
|
message: "上传课件成功",
|
|
|
type: "success"
|
|
|
@@ -195,7 +254,7 @@ export default {
|
|
|
senderId: this.$store.state.user.id,
|
|
|
courseId: this.courseId,
|
|
|
createdTime: new Date(),
|
|
|
- useTime: this.form.useTime,
|
|
|
+ useTime: "BEFORE_CLASS",
|
|
|
useMethod: this.form.useMethod,
|
|
|
fileUrl: fileUrl,
|
|
|
}).then(async () => {
|
|
|
@@ -203,6 +262,7 @@ export default {
|
|
|
});
|
|
|
this.uploadDialogVisible = false;
|
|
|
this.isUnique = false;
|
|
|
+ this.num = 0;
|
|
|
}
|
|
|
},
|
|
|
|
|
|
@@ -265,16 +325,28 @@ export default {
|
|
|
});
|
|
|
},
|
|
|
|
|
|
- handleCheck(id) {
|
|
|
- console.log("check" + id);
|
|
|
- this.$router.push({ name: "courseWare", params: { courseWareId: id, page: "1"} });
|
|
|
+ handleCheck(fileUrl) {
|
|
|
+ console.log("check" + fileUrl);
|
|
|
+ //this.$router.push({ name: "courseWare", params: { courseWareId: id, page: "1"} });
|
|
|
+ window.open(fileUrl);
|
|
|
},
|
|
|
|
|
|
- // handleExceed(files) {
|
|
|
- // console.log(files);
|
|
|
- // ElMessage.error("一次只能上传一个文件");
|
|
|
- // this.fileList = null;
|
|
|
- // },
|
|
|
+ handleCheckPicture(courseWareVO) {
|
|
|
+ this.pictureDialogVisible = true;
|
|
|
+ this.pictureUrl = courseWareVO.fileUrl;
|
|
|
+ this.pictureName = courseWareVO.name;
|
|
|
+ },
|
|
|
+
|
|
|
+ isPdfOrPicture(name) {
|
|
|
+ const fileType = name.substring(name.indexOf(".") + 1);
|
|
|
+ if (fileType === "pdf") {
|
|
|
+ return "PDF";
|
|
|
+ } else if (fileType === "png" || fileType === "jpg" || fileType === "jpeg") {
|
|
|
+ return "PICTURE";
|
|
|
+ } else {
|
|
|
+ return "OTHER";
|
|
|
+ }
|
|
|
+ },
|
|
|
|
|
|
getUseTimeTransition(useTime) {
|
|
|
switch (useTime) {
|
|
|
@@ -289,46 +361,80 @@ export default {
|
|
|
}
|
|
|
},
|
|
|
|
|
|
- getUseTimeColor(useTime) {
|
|
|
- switch (useTime) {
|
|
|
- case "BEFORE_CLASS":
|
|
|
- return "green";
|
|
|
- case "IN_CLASS":
|
|
|
- return "orange";
|
|
|
- case "AFTER_CLASS":
|
|
|
- return "blue";
|
|
|
- case "FINISH_CLASS":
|
|
|
- return "red";
|
|
|
- }
|
|
|
+ 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;
|
|
|
+ });
|
|
|
},
|
|
|
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
- // handleDownload(id) {
|
|
|
- // this.$apis.downloadCourseWare(id, {responseType: "blob"})
|
|
|
- // .then((res) => {
|
|
|
- // let data = res.data;
|
|
|
- // console.log(data);
|
|
|
- // if(!data){
|
|
|
- // return;
|
|
|
- // }
|
|
|
- // let fileName = res.headers["content-disposition"].split(";")[1];
|
|
|
- // console.log(fileName);
|
|
|
- // //构造a标签 通过a标签来下载
|
|
|
- // let url = window.URL.createObjectURL(new Blob([data]));
|
|
|
- // let a = document.createElement("a");
|
|
|
- // a.style.display = "none";
|
|
|
- // a.href = url;
|
|
|
- // //此处的download是a标签的内容,固定写法,不是后台api接口
|
|
|
- // a.setAttribute("download",fileName);
|
|
|
- // document.body.appendChild(a);
|
|
|
- // //点击下载
|
|
|
- // a.click();
|
|
|
- // // 下载完成移除元素
|
|
|
- // document.body.removeChild(a);
|
|
|
- // // 释放掉blob对象
|
|
|
- // window.URL.revokeObjectURL(url);
|
|
|
- // });
|
|
|
- // }
|
|
|
+ // handleDownload(id) {
|
|
|
+ // this.$apis.downloadCourseWare(id, {responseType: "blob"})
|
|
|
+ // .then((res) => {
|
|
|
+ // let data = res.data;
|
|
|
+ // console.log(data);
|
|
|
+ // if(!data){
|
|
|
+ // return;
|
|
|
+ // }
|
|
|
+ // let fileName = res.headers["content-disposition"].split(";")[1];
|
|
|
+ // console.log(fileName);
|
|
|
+ // //构造a标签 通过a标签来下载
|
|
|
+ // let url = window.URL.createObjectURL(new Blob([data]));
|
|
|
+ // let a = document.createElement("a");
|
|
|
+ // a.style.display = "none";
|
|
|
+ // a.href = url;
|
|
|
+ // //此处的download是a标签的内容,固定写法,不是后台api接口
|
|
|
+ // a.setAttribute("download",fileName);
|
|
|
+ // document.body.appendChild(a);
|
|
|
+ // //点击下载
|
|
|
+ // a.click();
|
|
|
+ // // 下载完成移除元素
|
|
|
+ // document.body.removeChild(a);
|
|
|
+ // // 释放掉blob对象
|
|
|
+ // window.URL.revokeObjectURL(url);
|
|
|
+ // });
|
|
|
+ // }
|
|
|
|
|
|
// handleDownloadFileIconClick(url) {
|
|
|
// },
|