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删除小节 deleteSubsection: `occupationlab/occupationlab/theoreticalCourseSubsection/deleteSubsection`, // 根据id删除小节
editSubsection: `occupationlab/occupationlab/theoreticalCourseSubsection/editSubsection`, // 修改小节 editSubsection: `occupationlab/occupationlab/theoreticalCourseSubsection/editSubsection`, // 修改小节
getSubsection: `occupationlab/occupationlab/theoreticalCourseSubsection/getSubsection`, // 根据小节id获取预览文件地址 getSubsection: `occupationlab/occupationlab/theoreticalCourseSubsection/getSubsection`, // 根据小节id获取预览文件地址
batchDeletionTheoretical: `occupationlab/occupationlab/theoreticalCourseSubsection/batchDeletion`,
queryProvince: `nakadai/nakadai/province/queryProvince`, //查询省份 queryProvince: `nakadai/nakadai/province/queryProvince`, //查询省份
queryCity: `nakadai/nakadai/city/queryCity`, //查询城市 queryCity: `nakadai/nakadai/city/queryCity`, //查询城市
@ -550,6 +551,7 @@ export default {
resourceDel: `nakadai/resourceLibrary/batchDeletion`, resourceDel: `nakadai/resourceLibrary/batchDeletion`,
resourceFind: `nakadai/resourceLibrary/findById`, resourceFind: `nakadai/resourceLibrary/findById`,
resourceSave: `nakadai/resourceLibrary/saveOrUpdate`, resourceSave: `nakadai/resourceLibrary/saveOrUpdate`,
getFileType: `nakadai/resourceLibrary/getFileType`,
// 教师评语 // 教师评语
addComment: `evaluation/cevaluation/comment/addComment`, addComment: `evaluation/cevaluation/comment/addComment`,

@ -31,7 +31,7 @@
</div> </div>
<div class="tool mul"> <div class="tool mul">
<ul class="filter"> <ul class="filter">
<li v-if="active !== 2"> <li v-if="!active">
<label>课程</label> <label>课程</label>
<el-select v-if="!active" v-model="form.cid" filterable clearable @change="initData"> <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> <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-option v-for="(item, i) in types" :key="i" :label="item.name" :value="item.name"></el-option>
</el-select> </el-select>
</li> </li>
<li> <!-- <li>
<label>编辑人</label> <label>编辑人</label>
<el-select v-model="form.editor" clearable @change="initData"> <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-option v-for="(item, i) in types" :key="i" :label="item.name" :value="item.id"></el-option>
</el-select> </el-select>
</li> </li> -->
</ul> </ul>
<div> <div>
<el-button v-if="active === 2" type="primary" @click="uploadFile">上传文件</el-button> <el-button v-if="active === 2" type="primary" @click="uploadFile">上传文件</el-button>
@ -98,21 +98,6 @@
</el-pagination> </el-pagination>
</div> </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 v-show="previewImg" class="el-image-viewer__wrapper" :class="{ active: previewImg }" style="z-index: 2000">
<div class="el-image-viewer__mask"></div> <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" <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" /> <Pdf :visible.sync="pdfVisible" :src.sync="pdfSrc" />
<div class="player-download" id="playerDownload"></div> <div class="player-download" id="playerDownload"></div>
<Upload :visible.sync="uploadVisible" /> <Upload :visible.sync="uploadVisible" :row.sync="curRow" />
</div> </div>
</template> </template>
@ -225,14 +210,11 @@ export default {
pageSize: 10, pageSize: 10,
total: 0, total: 0,
modifyVisible: false, modifyVisible: false,
curRow: { curRow: null,
playingStages: []
},
loading: false, loading: false,
now: '', now: '',
sectionNameVisible: false,
sectionForm: { sectionForm: {
sectionName: '' sectionName: ''
}, },
@ -243,8 +225,6 @@ export default {
player: null, player: null,
previewImg: "", previewImg: "",
iframeSrc: "", iframeSrc: "",
curFile: {},
isAddSection: false,
isWord: false, isWord: false,
isPPT: false, isPPT: false,
isExcel: false, isExcel: false,
@ -321,15 +301,15 @@ export default {
} }
// //
if (!this.theoreticalCourses.length) { // if (!this.theoreticalCourses.length) {
const { page } = await this.$post(this.api.listTheoreticalCourse, { // const { page } = await this.$post(this.api.listTheoreticalCourse, {
pageNum: 1, // pageNum: 1,
pageSize: 1000, // pageSize: 1000,
createPlatform: 1, // createPlatform: 1,
platformSource: Setting.platformSource, // platformSource: Setting.platformSource,
}) // })
this.theoreticalCourses = page.records // this.theoreticalCourses = page.records
} // }
}, },
tabChange (id) { tabChange (id) {
this.active = id this.active = id
@ -346,7 +326,7 @@ export default {
}, },
changeType () { changeType () {
this.$refs.table.clearSelection() this.$refs.table.clearSelection()
this.initData(); this.initData()
}, },
initData () { initData () {
this.page = 1 this.page = 1
@ -362,6 +342,7 @@ export default {
}, },
// //
uploadFile () { uploadFile () {
this.curRow = null
this.uploadVisible = true this.uploadVisible = true
}, },
// //
@ -370,23 +351,33 @@ export default {
if (list.length) { if (list.length) {
this.$confirm('删除后用户将无法再查看和使用这些资源,确定删除?', '提示', { this.$confirm('删除后用户将无法再查看和使用这些资源,确定删除?', '提示', {
type: "warning" type: "warning"
}).then(() => { }).then(async () => {
this.$post(this.api.resourceDel, list.map(e => e.id)).then(res => { const ids = list.map(e => e.id)
this.getData() const tab = this.active
this.$message.success("删除成功") if (!tab) {
this.$refs.table.clearSelection() //
}).catch(err => { }) 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(() => { }) }).catch(() => { })
} else { } else {
this.$message.warning("请先选择数据 !") this.$message.warning("请先选择数据 !")
} }
}, },
edit (row, chapterId) { edit (row) {
this.chapterId = chapterId this.curRow = row
this.sectionId = row.id this.uploadVisible = true
this.sectionForm.sectionName = row.name
this.sectionNameVisible = true
}, },
// //
download (row) { download (row) {
@ -507,11 +498,23 @@ export default {
del (row) { del (row) {
this.$confirm('删除后用户将无法再查看和使用此资源,确定删除?', '提示', { this.$confirm('删除后用户将无法再查看和使用此资源,确定删除?', '提示', {
type: 'warning' type: 'warning'
}).then(() => { }).then(async () => {
this.$post(this.api.resourceDel, [row.id]).then(res => { const tab = this.active
this.$message.success("删除成功") if (!tab) {
this.getData() //
}).catch(res => { }) 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(() => { }) }).catch(() => { })
}, },
sectionNameSubmit () { sectionNameSubmit () {

@ -20,11 +20,11 @@
<el-input v-model="form.resourceName" placeholder="请输入资源名称" /> <el-input v-model="form.resourceName" placeholder="请输入资源名称" />
</el-form-item> </el-form-item>
<el-form-item label="资源类型"> <el-form-item label="资源类型">
<el-select v-model="form.resourceType" disabled> <el-select v-model="form.displayFileType" disabled>
<el-option v-for="(item, i) in types" :key="i" :label="item.name" :value="item.id"></el-option> <el-option v-for="(item, i) in types" :key="i" :label="item.name" :value="item.name"></el-option>
</el-select> </el-select>
</el-form-item> </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-input type="textarea" :rows="3" v-model="form.resourceDescription" placeholder="请输入资源描述" />
</el-form-item> </el-form-item>
</el-form> </el-form>
@ -41,7 +41,7 @@ import SourceConst from '@/const/source'
import _ from 'lodash' import _ from 'lodash'
import Oss from '@/components/upload/upload.js' import Oss from '@/components/upload/upload.js'
export default { export default {
props: ['visible'], props: ['visible', 'row'],
data () { data () {
return { return {
uploadVisible: false, uploadVisible: false,
@ -55,7 +55,7 @@ export default {
fileName: '', fileName: '',
originalFileName: '', originalFileName: '',
resourceName: '', resourceName: '',
resourceType: '', displayFileType: '',
resourceDescription: '', resourceDescription: '',
}, },
originForm: {}, originForm: {},
@ -72,8 +72,17 @@ export default {
}, },
methods: { methods: {
init () { init () {
this.uploadList = [] const { row } = this
this.form = _.cloneDeep(this.originForm) 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) { async handleType (ext) {
let type = 6 const res = await this.$post(`${this.api.getFileType}?fileType=${ext}`)
if (Util.isVideo(ext)) { this.form.displayFileType = res.data
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 handleRequest ({ file }) { async handleRequest ({ file }) {
Oss.upload(file).then(res => { Oss.upload(file).then(res => {
console.log("🚀 ~ Oss.upload ~ res:", res, file)
this.uploading = false this.uploading = false
this.form.fileType = res.format this.form.fileType = res.format
this.form.fileUrl = res.url this.form.fileUrl = res.url
@ -126,18 +123,49 @@ export default {
return this.$confirm(`确定移除 ${file.name}`) return this.$confirm(`确定移除 ${file.name}`)
}, },
handleRemove (file, fileList) { handleRemove (file, fileList) {
file.url && Oss.del(file.url)
this.form.fileUrl = ''
this.uploadList = fileList this.uploadList = fileList
}, },
async submit () { async submit () {
if (this.submiting) return false 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.fileUrl) return Util.warningMsg('请上传资源')
if (!form.resourceName) return Util.warningMsg('请填写资源名称') if (!form.resourceName) return Util.warningMsg('请填写资源名称')
this.submiting = true this.submiting = true
await this.$post(this.api.resourceSave, {
platformId: Setting.platformId, if (!tab) {
...form //
}) 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.submiting = false
this.uploadVisible = false this.uploadVisible = false
}, },

Loading…
Cancel
Save