|
|
@@ -0,0 +1,147 @@
|
|
|
+<template>
|
|
|
+ <div class="resources-operate">
|
|
|
+ <el-tooltip effect="dark" placement="top" content="提交到资源库">
|
|
|
+ <SvgIcon
|
|
|
+ v-if="isEnable(projectResourcePopedom.is_can_upload) && data.file_id"
|
|
|
+ icon-class="upload"
|
|
|
+ @click="handleSubmitToResource(data)"
|
|
|
+ />
|
|
|
+ </el-tooltip>
|
|
|
+ <SvgIcon
|
|
|
+ v-if="isEnable(projectResourcePopedom.is_can_download) && data.file_id"
|
|
|
+ icon-class="download"
|
|
|
+ @click="downLoad(data)"
|
|
|
+ />
|
|
|
+ <el-dialog
|
|
|
+ :visible.sync="visibleSubmitResource"
|
|
|
+ width="500px"
|
|
|
+ append-to-body
|
|
|
+ :show-close="true"
|
|
|
+ title="提交到资源库"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ >
|
|
|
+ <el-form ref="resourceForm" :model="resourceForm" :rules="resourceRules" label-width="60px">
|
|
|
+ <el-form-item prop="position" label="位置">
|
|
|
+ <el-radio-group v-model="resourceForm.position" size="medium">
|
|
|
+ <el-radio border v-for="node in node_list" :label="node.node_id">{{ node.node_name }}</el-radio>
|
|
|
+ </el-radio-group>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="name" label="名称">
|
|
|
+ <el-input v-model="resourceForm.name" placeholder="请输入名称" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="label" label="标签">
|
|
|
+ <el-input v-model="resourceForm.label" placeholder="请输入标签" />
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item prop="intro" label="简介">
|
|
|
+ <el-input v-model="resourceForm.intro" type="textarea" :rows="4" placeholder="请输入简介" />
|
|
|
+ </el-form-item>
|
|
|
+ </el-form>
|
|
|
+
|
|
|
+ <template #footer>
|
|
|
+ <el-button @click="visibleSubmitResource = false">取 消</el-button>
|
|
|
+ <el-button :loading="loading" type="primary" @click="SubmitToResource">确 定</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+
|
|
|
+<script>
|
|
|
+import { SubmitFileToResourceStore, GetBookCoursewarePath } from '@/api/book';
|
|
|
+import { getToken } from '@/utils/auth';
|
|
|
+import { isEnable } from '@/views/book/courseware/data/common';
|
|
|
+
|
|
|
+export default {
|
|
|
+ name: 'ResourcesOperate',
|
|
|
+ props: ['data'],
|
|
|
+ inject: ['courseware_id', 'project_id', 'getProjectResourcePopedom'],
|
|
|
+
|
|
|
+ data() {
|
|
|
+ return {
|
|
|
+ isEnable,
|
|
|
+ visibleSubmitResource: false,
|
|
|
+ node_list: [],
|
|
|
+ resourceForm: {
|
|
|
+ position: '',
|
|
|
+ name: '',
|
|
|
+ label: '',
|
|
|
+ intro: '',
|
|
|
+ },
|
|
|
+ resourceRules: {
|
|
|
+ position: [{ required: true, message: '请选择位置', trigger: 'blur' }],
|
|
|
+ name: [{ required: true, message: '请输入名称', trigger: 'blur' }],
|
|
|
+ },
|
|
|
+ };
|
|
|
+ },
|
|
|
+ computed: {
|
|
|
+ projectResourcePopedom() {
|
|
|
+ return this.getProjectResourcePopedom();
|
|
|
+ },
|
|
|
+ },
|
|
|
+ methods: {
|
|
|
+ // 提交到资源库
|
|
|
+ handleSubmitToResource(file) {
|
|
|
+ this.visibleSubmitResource = true;
|
|
|
+ this.curFile = file;
|
|
|
+ this.resourceForm = {
|
|
|
+ position: '',
|
|
|
+ name: file.name || '',
|
|
|
+ label: file.label || '',
|
|
|
+ intro: file.intro || '',
|
|
|
+ };
|
|
|
+ GetBookCoursewarePath({ id: this.courseware_id }).then((res) => {
|
|
|
+ this.node_list = res.path_list;
|
|
|
+ });
|
|
|
+ },
|
|
|
+ SubmitToResource() {
|
|
|
+ this.$refs.resourceForm.validate((valid) => {
|
|
|
+ if (valid) {
|
|
|
+ this.loading = true;
|
|
|
+ let data = {
|
|
|
+ project_id: this.project_id,
|
|
|
+ book_chapter_node_id: this.resourceForm.position || '',
|
|
|
+ file_id: this.curFile.file_id,
|
|
|
+ resource_info: {
|
|
|
+ name: this.resourceForm.name,
|
|
|
+ label: this.resourceForm.label,
|
|
|
+ intro: this.resourceForm.intro,
|
|
|
+ },
|
|
|
+ };
|
|
|
+
|
|
|
+ SubmitFileToResourceStore(data)
|
|
|
+ .then((res) => {
|
|
|
+ this.$message.success('操作成功!');
|
|
|
+ this.visibleSubmitResource = false;
|
|
|
+ })
|
|
|
+ .catch(() => {
|
|
|
+ this.loading = false;
|
|
|
+ })
|
|
|
+ .finally(() => {
|
|
|
+ this.loading = false;
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
+ // 下载文件
|
|
|
+ downLoad(file) {
|
|
|
+ let userInfor = getToken();
|
|
|
+ let AccessToken = '';
|
|
|
+ if (userInfor) {
|
|
|
+ AccessToken = userInfor.access_token;
|
|
|
+ }
|
|
|
+ let FileID = file.file_id;
|
|
|
+ let data = {
|
|
|
+ AccessToken,
|
|
|
+ FileID,
|
|
|
+ };
|
|
|
+ location.href = `${process.env.VUE_APP_EEP}/FileServer/WebFileDownload?AccessToken=${data.AccessToken}&FileID=${data.FileID}`;
|
|
|
+ },
|
|
|
+ },
|
|
|
+};
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.resources-operate {
|
|
|
+ display: flex;
|
|
|
+ column-gap: 12px;
|
|
|
+}
|
|
|
+</style>
|