diff --git a/src/api/index.js b/src/api/index.js
index 65ada5c..e534e76 100644
--- a/src/api/index.js
+++ b/src/api/index.js
@@ -349,6 +349,7 @@ export default {
deleteSubsection: `occupationlab/occupationlab/theoreticalCourseSubsection/deleteSubsection`, // 根据id删除小节
editSubsection: `occupationlab/occupationlab/theoreticalCourseSubsection/editSubsection`, // 修改小节
getSubsection: `occupationlab/occupationlab/theoreticalCourseSubsection/getSubsection`, // 根据小节id获取预览文件地址
+ batchDeletionTheoretical: `occupationlab/occupationlab/theoreticalCourseSubsection/batchDeletion`,
queryProvince: `nakadai/nakadai/province/queryProvince`, //查询省份
queryCity: `nakadai/nakadai/city/queryCity`, //查询城市
@@ -550,6 +551,7 @@ export default {
resourceDel: `nakadai/resourceLibrary/batchDeletion`,
resourceFind: `nakadai/resourceLibrary/findById`,
resourceSave: `nakadai/resourceLibrary/saveOrUpdate`,
+ getFileType: `nakadai/resourceLibrary/getFileType`,
// 教师评语
addComment: `evaluation/cevaluation/comment/addComment`,
diff --git a/src/pages/resourse/list/index.vue b/src/pages/resourse/list/index.vue
index 2f30c7a..d9b1373 100644
--- a/src/pages/resourse/list/index.vue
+++ b/src/pages/resourse/list/index.vue
@@ -31,7 +31,7 @@
- -
+
-
@@ -47,12 +47,12 @@
- -
+
上传文件
@@ -98,21 +98,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -225,14 +210,11 @@ export default {
pageSize: 10,
total: 0,
modifyVisible: false,
- curRow: {
- playingStages: []
- },
+ curRow: null,
loading: false,
now: '',
- sectionNameVisible: false,
sectionForm: {
sectionName: ''
},
@@ -243,8 +225,6 @@ export default {
player: null,
previewImg: "",
iframeSrc: "",
- curFile: {},
- isAddSection: false,
isWord: false,
isPPT: false,
isExcel: false,
@@ -321,15 +301,15 @@ export default {
}
// 精品课程
- if (!this.theoreticalCourses.length) {
- const { page } = await this.$post(this.api.listTheoreticalCourse, {
- pageNum: 1,
- pageSize: 1000,
- createPlatform: 1,
- platformSource: Setting.platformSource,
- })
- this.theoreticalCourses = page.records
- }
+ // if (!this.theoreticalCourses.length) {
+ // const { page } = await this.$post(this.api.listTheoreticalCourse, {
+ // pageNum: 1,
+ // pageSize: 1000,
+ // createPlatform: 1,
+ // platformSource: Setting.platformSource,
+ // })
+ // this.theoreticalCourses = page.records
+ // }
},
tabChange (id) {
this.active = id
@@ -346,7 +326,7 @@ export default {
},
changeType () {
this.$refs.table.clearSelection()
- this.initData();
+ this.initData()
},
initData () {
this.page = 1
@@ -362,6 +342,7 @@ export default {
},
// 上传文件
uploadFile () {
+ this.curRow = null
this.uploadVisible = true
},
// 批量删除
@@ -370,23 +351,33 @@ export default {
if (list.length) {
this.$confirm('删除后用户将无法再查看和使用这些资源,确定删除?', '提示', {
type: "warning"
- }).then(() => {
- this.$post(this.api.resourceDel, list.map(e => e.id)).then(res => {
- this.getData()
- this.$message.success("删除成功")
- this.$refs.table.clearSelection()
- }).catch(err => { })
+ }).then(async () => {
+ const ids = list.map(e => e.id)
+ const tab = this.active
+ if (!tab) {
+ // 教学课程
+ await this.$post(this.api.deleteSubsectionBatch, {
+ subsectionIds: ids
+ })
+ } else if (tab === 1) {
+ // 精品课程
+ await this.$post(this.api.batchDeletionTheoretical, ids)
+ } else {
+ // 文件素材
+ await this.$post(this.api.resourceDel, ids)
+ }
+ this.getData()
+ this.$message.success("删除成功")
+ this.$refs.table.clearSelection()
}).catch(() => { })
} else {
this.$message.warning("请先选择数据 !")
}
},
- edit (row, chapterId) {
- this.chapterId = chapterId
- this.sectionId = row.id
- this.sectionForm.sectionName = row.name
- this.sectionNameVisible = true
+ edit (row) {
+ this.curRow = row
+ this.uploadVisible = true
},
// 下载资源
download (row) {
@@ -507,11 +498,23 @@ export default {
del (row) {
this.$confirm('删除后用户将无法再查看和使用此资源,确定删除?', '提示', {
type: 'warning'
- }).then(() => {
- this.$post(this.api.resourceDel, [row.id]).then(res => {
- this.$message.success("删除成功")
- this.getData()
- }).catch(res => { })
+ }).then(async () => {
+ const tab = this.active
+ if (!tab) {
+ // 教学课程
+ await this.$post(this.api.deleteSubsectionBatch, {
+ chapterId: row.chapterId,
+ subsectionIds: [row.id]
+ })
+ } else if (tab === 1) {
+ // 精品课程
+ await this.$post(this.api.batchDeletionTheoretical, [row.id])
+ } else {
+ // 文件素材
+ await this.$post(this.api.resourceDel, [row.id])
+ }
+ this.$message.success("删除成功")
+ this.getData()
}).catch(() => { })
},
sectionNameSubmit () {
diff --git a/src/pages/resourse/upload.vue b/src/pages/resourse/upload.vue
index ccd29ae..75e9db7 100644
--- a/src/pages/resourse/upload.vue
+++ b/src/pages/resourse/upload.vue
@@ -20,11 +20,11 @@
-
-
+
+
-
+
@@ -41,7 +41,7 @@ import SourceConst from '@/const/source'
import _ from 'lodash'
import Oss from '@/components/upload/upload.js'
export default {
- props: ['visible'],
+ props: ['visible', 'row'],
data () {
return {
uploadVisible: false,
@@ -55,7 +55,7 @@ export default {
fileName: '',
originalFileName: '',
resourceName: '',
- resourceType: '',
+ displayFileType: '',
resourceDescription: '',
},
originForm: {},
@@ -72,8 +72,17 @@ export default {
},
methods: {
init () {
- this.uploadList = []
- this.form = _.cloneDeep(this.originForm)
+ const { row } = this
+ if (row) {
+ this.uploadList = [{
+ name: row.originalFileName,
+ url: row.fileUrl
+ }]
+ this.form = _.cloneDeep(this.row)
+ } else {
+ this.uploadList = []
+ this.form = _.cloneDeep(this.originForm)
+ }
},
// 上传文件
@@ -83,25 +92,13 @@ export default {
)
},
// 判断文件类型
- handleType (ext) {
- let type = 6
- if (Util.isVideo(ext)) {
- type = 2
- } else if (Util.isAudio(ext)) {
- type = 5
- } else if (Util.isImg(ext)) {
- type = 3
- } else if (Util.isDoc(ext) || ext === 'pdf') {
- type = 1
- } else if (ext === 'txt') {
- type = 4
- }
- this.form.resourceType = type
+ async handleType (ext) {
+ const res = await this.$post(`${this.api.getFileType}?fileType=${ext}`)
+ this.form.displayFileType = res.data
},
// 自定义上传
async handleRequest ({ file }) {
Oss.upload(file).then(res => {
- console.log("🚀 ~ Oss.upload ~ res:", res, file)
this.uploading = false
this.form.fileType = res.format
this.form.fileUrl = res.url
@@ -126,18 +123,49 @@ export default {
return this.$confirm(`确定移除 ${file.name}?`)
},
handleRemove (file, fileList) {
+ file.url && Oss.del(file.url)
+ this.form.fileUrl = ''
this.uploadList = fileList
},
async submit () {
if (this.submiting) return false
- const { form } = this
+ const { form, row } = this
+ const tab = this.$parent.active
if (!form.fileUrl) return Util.warningMsg('请上传资源')
if (!form.resourceName) return Util.warningMsg('请填写资源名称')
this.submiting = true
- await this.$post(this.api.resourceSave, {
- platformId: Setting.platformId,
- ...form
- })
+
+ if (!tab) {
+ // 教学课程
+ await this.$put(this.api.editSubsectionCurriculm, {
+ id: row.id,
+ cid: row.cid,
+ chapterId: row.chapterId,
+ fileId: row.fileId || '',
+ name: form.resourceName,
+ fileUrl: form.fileUrl,
+ fileName: form.fileName,
+ fileType: form.fileType,
+ originalFileName: form.originalFileName
+ })
+ } else if (tab === 1) {
+ await this.$put(this.api.editSubsection, {
+ id: row.id,
+ // courseId: this.id,
+ chapterId: row.chapterId,
+ fileId: row.fileId || '',
+ name: form.resourceName,
+ fileUrl: form.fileUrl,
+ fileName: form.fileName,
+ fileType: form.fileType,
+ originalFileName: form.originalFileName
+ })
+ } else {
+ await this.$post(this.api.resourceSave, {
+ platformId: Setting.platformId,
+ ...form
+ })
+ }
this.submiting = false
this.uploadVisible = false
},