|
@@ -8,18 +8,17 @@
|
|
|
plain>新建</el-button>
|
|
plain>新建</el-button>
|
|
|
</el-col>
|
|
</el-col>
|
|
|
<el-col :span="15">
|
|
<el-col :span="15">
|
|
|
- <span style="font-size: smaller; position: absolute; bottom: 25%">(支持拓展名:.pdf .ppt .pptx .doc .docx .xls .jpg .jpeg .png,单次只可上传一个文件)</span>
|
|
|
|
|
|
|
+ <span style="font-size: smaller; position: absolute; bottom: 25%">(支持拓展名:.pdf .ppt .pptx .doc .docx .xls .jpg .jpeg .png .exe .zip,仅支持单次上传一个文件)</span>
|
|
|
</el-col>
|
|
</el-col>
|
|
|
</el-row>
|
|
</el-row>
|
|
|
<el-dialog v-model="uploadDialogVisible" :before-close="handleCancelUpload" :width="700">
|
|
<el-dialog v-model="uploadDialogVisible" :before-close="handleCancelUpload" :width="700">
|
|
|
- <el-form ref="formRef" :model="form" label-width="100px">
|
|
|
|
|
|
|
+ <el-form ref="formRef" :model="form" label-width="100px" style="margin-top: 10px">
|
|
|
<el-form-item label="使用类型" required>
|
|
<el-form-item label="使用类型" required>
|
|
|
<el-select v-model="form.useMethod" placeholder="类型">
|
|
<el-select v-model="form.useMethod" placeholder="类型">
|
|
|
- <el-option key="1" label="浏览" value="SCAN"></el-option>
|
|
|
|
|
- <el-option key="2" label="附件" value="ATTACHMENT"></el-option>
|
|
|
|
|
|
|
+ <el-option key="1" label="浏览(支持拓展名:.pdf .ppt .pptx .doc .docx .xls .jpg .jpeg .png)" value="SCAN"></el-option>
|
|
|
|
|
+ <el-option key="2" label="附件(支持拓展名:.exe .zip)" value="ATTACHMENT"></el-option>
|
|
|
</el-select>
|
|
</el-select>
|
|
|
</el-form-item>
|
|
</el-form-item>
|
|
|
-
|
|
|
|
|
<el-form-item label="文件" required>
|
|
<el-form-item label="文件" required>
|
|
|
<el-upload
|
|
<el-upload
|
|
|
:file-list="fileList"
|
|
:file-list="fileList"
|
|
@@ -29,11 +28,7 @@
|
|
|
:auto-upload="false"
|
|
:auto-upload="false"
|
|
|
:show-file-list="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">上传文件</el-button>(仅支持上传单个文件)
|
|
|
</el-upload>
|
|
</el-upload>
|
|
|
<el-tag
|
|
<el-tag
|
|
|
v-if="isNameUnique"
|
|
v-if="isNameUnique"
|
|
@@ -60,8 +55,6 @@
|
|
|
</div>
|
|
</div>
|
|
|
</el-dialog>
|
|
</el-dialog>
|
|
|
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
<el-table :data="fileEntryList">
|
|
<el-table :data="fileEntryList">
|
|
|
<el-table-column
|
|
<el-table-column
|
|
|
type="index"
|
|
type="index"
|
|
@@ -75,11 +68,10 @@
|
|
|
<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 === '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>
|
|
<el-icon v-if="scope.row['courseWareVO'].useMethod === 'ATTACHMENT'" style="color: green" class="myicon"><Paperclip /></el-icon>
|
|
|
{{scope.row['courseWareVO'].name}}
|
|
{{scope.row['courseWareVO'].name}}
|
|
|
- <el-link v-if="Number(scope.row['courseWareVO'].senderId) === Number(this.$store.state.user.id)"
|
|
|
|
|
- @click="handleChangeName(scope.row['courseWareVO'].id, scope.row['courseWareVO'].name)"
|
|
|
|
|
- :underline="false">
|
|
|
|
|
- <el-icon :size="20" style="color: #337ecc; margin-left: 5px"><Edit /></el-icon>
|
|
|
|
|
- </el-link>
|
|
|
|
|
|
|
+ <el-button v-if="Number(scope.row['courseWareVO'].senderId) === Number(this.$store.state.user.id)"
|
|
|
|
|
+ @click="handleChangeName(scope.row['courseWareVO'].id, scope.row['courseWareVO'].name)"
|
|
|
|
|
+ type="text" icon="el-icon-edit-outline" style="color: #337ecc; font-size: 18px">
|
|
|
|
|
+ </el-button>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
<el-table-column
|
|
<el-table-column
|
|
@@ -95,10 +87,8 @@
|
|
|
label="上传时间"
|
|
label="上传时间"
|
|
|
width="160"
|
|
width="160"
|
|
|
:sortable="true"
|
|
:sortable="true"
|
|
|
- :sort-method="sortByDate2"
|
|
|
|
|
>
|
|
>
|
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
|
-<!-- {{timestampToTime(scope.row["courseWareVO"].createdTime)}}-->
|
|
|
|
|
{{timestampToTime(scope.row["courseWareVO"].createdTime)}}
|
|
{{timestampToTime(scope.row["courseWareVO"].createdTime)}}
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
@@ -107,29 +97,29 @@
|
|
|
label="操作"
|
|
label="操作"
|
|
|
width="200">
|
|
width="200">
|
|
|
<template #default="scope">
|
|
<template #default="scope">
|
|
|
- <a :href="scope.row['courseWareVO'].fileUrl" v-if="isPdfOrPicture(scope.row['courseWareVO'].name) === 'OTHER'">
|
|
|
|
|
- <el-link v-if="scope.row['courseWareVO'].useMethod === 'SCAN'"
|
|
|
|
|
- size="mini" style="color: #409EFF" :underline="false">预览</el-link>
|
|
|
|
|
|
|
+ <a :href="scope.row['courseWareVO'].fileUrl" v-if="isPdfOrPicture(scope.row['courseWareVO'].name) === 'OTHER'">
|
|
|
|
|
+ <el-button v-if="scope.row['courseWareVO'].useMethod === 'SCAN'"
|
|
|
|
|
+ style="color: #409EFF; margin-right: 10px" type="text">预览</el-button>
|
|
|
</a>
|
|
</a>
|
|
|
- <el-link v-if="scope.row['courseWareVO'].useMethod === 'SCAN' && isPdfOrPicture(scope.row['courseWareVO'].name) === 'PDF'"
|
|
|
|
|
|
|
+ <el-button v-if="scope.row['courseWareVO'].useMethod === 'SCAN' && isPdfOrPicture(scope.row['courseWareVO'].name) === 'PDF'"
|
|
|
@click="handlePreviewFile(scope.row['courseWareVO'].fileUrl)"
|
|
@click="handlePreviewFile(scope.row['courseWareVO'].fileUrl)"
|
|
|
- size="mini" style="color: #409EFF" :underline="false">预览</el-link>
|
|
|
|
|
- <el-link v-if="scope.row['courseWareVO'].useMethod === 'SCAN' && isPdfOrPicture(scope.row['courseWareVO'].name) === 'PICTURE'"
|
|
|
|
|
|
|
+ style="color: #409EFF" type="text">预览</el-button>
|
|
|
|
|
+ <el-button v-if="scope.row['courseWareVO'].useMethod === 'SCAN' && isPdfOrPicture(scope.row['courseWareVO'].name) === 'PICTURE'"
|
|
|
@click="handlePreviewPicture(scope.row['courseWareVO'])"
|
|
@click="handlePreviewPicture(scope.row['courseWareVO'])"
|
|
|
- size="mini" style="color: #409EFF" :underline="false">预览</el-link>
|
|
|
|
|
|
|
+ style="color: #409EFF; margin-right: 10px" type="text">预览</el-button>
|
|
|
<a :href="scope.row['courseWareVO'].fileUrl" v-if="isPdfOrPicture(scope.row['courseWareVO'].name) === 'OTHER'">
|
|
<a :href="scope.row['courseWareVO'].fileUrl" v-if="isPdfOrPicture(scope.row['courseWareVO'].name) === 'OTHER'">
|
|
|
- <el-link v-if="scope.row['courseWareVO'].useMethod === 'SCAN'"
|
|
|
|
|
- size="mini" style="color: #67C23A; margin-left: 10px" :underline="false">下载</el-link>
|
|
|
|
|
|
|
+ <el-button style="color: #67C23A" type="text">下载</el-button>
|
|
|
</a>
|
|
</a>
|
|
|
- <el-link v-if="scope.row['courseWareVO'].useMethod === 'SCAN' && isPdfOrPicture(scope.row['courseWareVO'].name) === 'PDF'"
|
|
|
|
|
|
|
+ <el-button v-if="isPdfOrPicture(scope.row['courseWareVO'].name) === 'PDF'"
|
|
|
@click="handlePreviewFile(scope.row['courseWareVO'].fileUrl)"
|
|
@click="handlePreviewFile(scope.row['courseWareVO'].fileUrl)"
|
|
|
- size="mini" style="color: #67C23A; margin-left: 10px" :underline="false">下载</el-link>
|
|
|
|
|
|
|
+ style="color: #67C23A" type="text">下载</el-button>
|
|
|
<a :href="scope.row['courseWareVO'].fileUrl"
|
|
<a :href="scope.row['courseWareVO'].fileUrl"
|
|
|
- v-if="scope.row['courseWareVO'].useMethod === 'SCAN' && isPdfOrPicture(scope.row['courseWareVO'].name) === 'PICTURE'">
|
|
|
|
|
- <el-link size="mini" style="color: #67C23A; margin-left: 10px" :underline="false">下载</el-link>
|
|
|
|
|
|
|
+ v-if="isPdfOrPicture(scope.row['courseWareVO'].name) === 'PICTURE'">
|
|
|
|
|
+ <el-button style="color: #67C23A" type="text">下载</el-button>
|
|
|
</a>
|
|
</a>
|
|
|
- <el-link v-if="Number(scope.row['courseWareVO'].senderId) === Number(this.$store.state.user.id)"
|
|
|
|
|
- size="mini" style="color: #F56C6C; margin-left: 10px" :underline="false" @click="handleRemoveCourseWare(scope.row['courseWareVO'].id)">删除</el-link>
|
|
|
|
|
|
|
+ <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>
|
|
|
</template>
|
|
</template>
|
|
|
</el-table-column>
|
|
</el-table-column>
|
|
|
</el-table>
|
|
</el-table>
|
|
@@ -214,25 +204,6 @@ export default {
|
|
|
this.init();
|
|
this.init();
|
|
|
},
|
|
},
|
|
|
methods: {
|
|
methods: {
|
|
|
- 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;
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
- 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;
|
|
|
|
|
- },
|
|
|
|
|
-
|
|
|
|
|
-
|
|
|
|
|
async init() {
|
|
async init() {
|
|
|
this.fileEntryList = (await this.$apis.getCourseWaresByCourseId(this.courseId)).data.data;
|
|
this.fileEntryList = (await this.$apis.getCourseWaresByCourseId(this.courseId)).data.data;
|
|
|
console.log(this.fileEntryList);
|
|
console.log(this.fileEntryList);
|
|
@@ -250,7 +221,12 @@ export default {
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
handleCancelChangeName() {
|
|
handleCancelChangeName() {
|
|
|
- ElMessageBox.confirm("确定取消修改课件名称?")
|
|
|
|
|
|
|
+ ElMessageBox.confirm("是否退出修改课件名称?推出后将不保存已填写信息。", "提示", {
|
|
|
|
|
+ confirmButtonText: "确认退出",
|
|
|
|
|
+ cancelButtonText: "我再想想",
|
|
|
|
|
+ type: "warning",
|
|
|
|
|
+ center: true,
|
|
|
|
|
+ })
|
|
|
.then(() => {
|
|
.then(() => {
|
|
|
this.newName = null;
|
|
this.newName = null;
|
|
|
this.nameAppend = null;
|
|
this.nameAppend = null;
|
|
@@ -259,7 +235,19 @@ export default {
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
handleConfirmChangeName() {
|
|
handleConfirmChangeName() {
|
|
|
- ElMessageBox.confirm("确定修改课件名称?")
|
|
|
|
|
|
|
+ if (this.newName === null && this.nameAppend !== null) {
|
|
|
|
|
+ this.$message({
|
|
|
|
|
+ message: "课件名称不可为空,请重新修改课件名称",
|
|
|
|
|
+ type: "error"
|
|
|
|
|
+ });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ ElMessageBox.confirm("是否确定修改课件名称?", "提示", {
|
|
|
|
|
+ confirmButtonText: "确认修改",
|
|
|
|
|
+ cancelButtonText: "我再想想",
|
|
|
|
|
+ type: "warning",
|
|
|
|
|
+ center: true,
|
|
|
|
|
+ })
|
|
|
.then(async () => {
|
|
.then(async () => {
|
|
|
const isNameUnique = (await this.$apis.checkCourseWareNameUnique(this.courseId, this.newName + this.nameAppend)).data.data;
|
|
const isNameUnique = (await this.$apis.checkCourseWareNameUnique(this.courseId, this.newName + this.nameAppend)).data.data;
|
|
|
if (!isNameUnique) {
|
|
if (!isNameUnique) {
|
|
@@ -286,13 +274,23 @@ export default {
|
|
|
async handleUploadFile(file, fileList) {
|
|
async handleUploadFile(file, fileList) {
|
|
|
const fileType = file.name.substring(file.name.lastIndexOf(".") + 1);
|
|
const fileType = file.name.substring(file.name.lastIndexOf(".") + 1);
|
|
|
console.log(this.form.useMethod + " + " + 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.form.useMethod === "SCAN") {
|
|
|
|
|
+ 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;
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ if (!(fileType === "exe" || fileType === "zip")) {
|
|
|
|
|
+ this.$message({
|
|
|
|
|
+ message: "该文件类型不属于支持的附件类型",
|
|
|
|
|
+ type: "error"
|
|
|
|
|
+ });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
if (this.fileNum === 1) {
|
|
if (this.fileNum === 1) {
|
|
|
this.$message({
|
|
this.$message({
|
|
@@ -316,6 +314,20 @@ export default {
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
async handleConfirmUpload() {
|
|
async handleConfirmUpload() {
|
|
|
|
|
+ if (this.file === null) {
|
|
|
|
|
+ this.$message({
|
|
|
|
|
+ message: "尚未上传课件",
|
|
|
|
|
+ type: "error"
|
|
|
|
|
+ });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (this.newName === null && this.nameAppend !== null) {
|
|
|
|
|
+ this.$message({
|
|
|
|
|
+ message: "课件名称不可为空,请重新修改课件名称",
|
|
|
|
|
+ type: "error"
|
|
|
|
|
+ });
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
if (this.newName !== null) {
|
|
if (this.newName !== null) {
|
|
|
const isNameUnique = (await this.$apis.checkCourseWareNameUnique(this.courseId, this.newName + this.nameAppend)).data.data;
|
|
const isNameUnique = (await this.$apis.checkCourseWareNameUnique(this.courseId, this.newName + this.nameAppend)).data.data;
|
|
|
if (!isNameUnique) {
|
|
if (!isNameUnique) {
|
|
@@ -327,36 +339,30 @@ export default {
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- if (this.file === null) {
|
|
|
|
|
- this.$message({
|
|
|
|
|
- message: "尚未上传课件",
|
|
|
|
|
- type: "error"
|
|
|
|
|
- });
|
|
|
|
|
- } else {
|
|
|
|
|
- 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.newName === null ? this.file.name : (this.newName + this.nameAppend),
|
|
|
|
|
- size: this.file.size,
|
|
|
|
|
- senderId: this.$store.state.user.id,
|
|
|
|
|
- courseId: this.courseId,
|
|
|
|
|
- createdTime: new Date(),
|
|
|
|
|
- useTime: "BEFORE_CLASS",
|
|
|
|
|
- useMethod: this.form.useMethod,
|
|
|
|
|
- fileUrl: fileUrl,
|
|
|
|
|
- }).then(async () => {
|
|
|
|
|
- this.fileEntryList = (await this.$apis.getCourseWaresByCourseId(this.courseId)).data.data;
|
|
|
|
|
- });
|
|
|
|
|
- this.uploadDialogVisible = false;
|
|
|
|
|
- this.isChangeNameWhenUpload = false;
|
|
|
|
|
- this.isNameUnique = false;
|
|
|
|
|
- this.fileNum = 0;
|
|
|
|
|
- this.newName = null;
|
|
|
|
|
- this.nameAppend = null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const fileUrl = (await this.$apis.uploadCourseWareFile(this.courseId + "/" + (this.newName == null ? this.file.name : (this.newName + this.nameAppend)), this.file.raw)).data.data;
|
|
|
|
|
+ this.$apis.createCourseWare({
|
|
|
|
|
+ name: this.newName === null ? this.file.name : (this.newName + this.nameAppend),
|
|
|
|
|
+ size: this.file.size,
|
|
|
|
|
+ senderId: this.$store.state.user.id,
|
|
|
|
|
+ courseId: this.courseId,
|
|
|
|
|
+ createdTime: new Date(),
|
|
|
|
|
+ useTime: "BEFORE_CLASS",
|
|
|
|
|
+ useMethod: this.form.useMethod,
|
|
|
|
|
+ fileUrl: fileUrl,
|
|
|
|
|
+ }).then(async () => {
|
|
|
|
|
+ this.fileEntryList = (await this.$apis.getCourseWaresByCourseId(this.courseId)).data.data;
|
|
|
|
|
+ });
|
|
|
|
|
+ this.$message({
|
|
|
|
|
+ message: "上传课件成功",
|
|
|
|
|
+ type: "success"
|
|
|
|
|
+ });
|
|
|
|
|
+ this.uploadDialogVisible = false;
|
|
|
|
|
+ this.isChangeNameWhenUpload = false;
|
|
|
|
|
+ this.isNameUnique = false;
|
|
|
|
|
+ this.fileNum = 0;
|
|
|
|
|
+ this.newName = null;
|
|
|
|
|
+ this.nameAppend = null;
|
|
|
|
|
+ this.file = null;
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
handleCancelUpload(done) {
|
|
handleCancelUpload(done) {
|
|
@@ -383,8 +389,8 @@ export default {
|
|
|
},
|
|
},
|
|
|
|
|
|
|
|
handleCloseFileTag() {
|
|
handleCloseFileTag() {
|
|
|
- ElMessageBox.confirm("是否确认取消选择该课件?", "提示", {
|
|
|
|
|
- confirmButtonText: "确认取消",
|
|
|
|
|
|
|
+ ElMessageBox.confirm("是否取消上传该课件?", "提示", {
|
|
|
|
|
+ confirmButtonText: "确定",
|
|
|
cancelButtonText: "我再想想",
|
|
cancelButtonText: "我再想想",
|
|
|
type: "warning",
|
|
type: "warning",
|
|
|
center: true,
|
|
center: true,
|