dev_202412
yujialong 2 months ago
parent e8eddd1486
commit 894d5fbe9e
  1. 2
      src/api/index.js
  2. 105
      src/pages/resourse/list/index.vue
  3. 82
      src/pages/resourse/upload.vue

@ -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`,

@ -31,7 +31,7 @@
</div>
<div class="tool mul">
<ul class="filter">
<li v-if="active !== 2">
<li v-if="!active">
<label>课程</label>
<el-select v-if="!active" v-model="form.cid" filterable clearable @change="initData">
<el-option v-for="(item, i) in courses" :key="i" :label="item.curriculumName" :value="item.cid"></el-option>
@ -47,12 +47,12 @@
<el-option v-for="(item, i) in types" :key="i" :label="item.name" :value="item.name"></el-option>
</el-select>
</li>
<li>
<!-- <li>
<label>编辑人</label>
<el-select v-model="form.editor" clearable @change="initData">
<el-option v-for="(item, i) in types" :key="i" :label="item.name" :value="item.id"></el-option>
</el-select>
</li>
</li> -->
</ul>
<div>
<el-button v-if="active === 2" type="primary" @click="uploadFile">上传文件</el-button>
@ -98,21 +98,6 @@
</el-pagination>
</div>
<el-dialog title="修改资源名称" :visible.sync="sectionNameVisible" width="540px" :close-on-click-modal="false">
<el-form @submit.native.prevent>
<el-form-item>
<el-input placeholder="请输入资源名称" v-model="sectionForm.sectionName" maxlength="50"
@keyup.enter.native="sectionNameSubmit()"></el-input>
</el-form-item>
</el-form>
<span slot="footer" class="dialog-footer">
<el-button @click="sectionNameVisible = false">取消</el-button>
<el-button type="primary" @click="sectionNameSubmit">确定</el-button>
</span>
</el-dialog>
<div v-show="previewImg" class="el-image-viewer__wrapper" :class="{ active: previewImg }" style="z-index: 2000">
<div class="el-image-viewer__mask"></div>
<span class="el-image-viewer__btn el-image-viewer__close" @click="previewImg = ''"><i class="el-icon-circle-close"
@ -158,7 +143,7 @@
<Pdf :visible.sync="pdfVisible" :src.sync="pdfSrc" />
<div class="player-download" id="playerDownload"></div>
<Upload :visible.sync="uploadVisible" />
<Upload :visible.sync="uploadVisible" :row.sync="curRow" />
</div>
</template>
@ -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 () {

@ -20,11 +20,11 @@
<el-input v-model="form.resourceName" placeholder="请输入资源名称" />
</el-form-item>
<el-form-item label="资源类型">
<el-select v-model="form.resourceType" disabled>
<el-option v-for="(item, i) in types" :key="i" :label="item.name" :value="item.id"></el-option>
<el-select v-model="form.displayFileType" disabled>
<el-option v-for="(item, i) in types" :key="i" :label="item.name" :value="item.name"></el-option>
</el-select>
</el-form-item>
<el-form-item label="资源描述">
<el-form-item v-if="$parent.active === 2" label="资源描述">
<el-input type="textarea" :rows="3" v-model="form.resourceDescription" placeholder="请输入资源描述" />
</el-form-item>
</el-form>
@ -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
},

Loading…
Cancel
Save