Merge pull request 'lyc-dev' (#16) from lyc-dev into main
This commit is contained in:
commit
938872d8a4
|
@ -0,0 +1,193 @@
|
|||
<template>
|
||||
<el-dialog v-model="dialogValue" width="600" :before-close="beforeClose">
|
||||
<div class="file-dialog">
|
||||
<el-form>
|
||||
<el-form-item label="文件">
|
||||
<div class="create-item file-item flex">
|
||||
<el-upload action="" multiple :before-upload="hanleFileBefore" :auto-upload="true">
|
||||
<el-button slot="trigger">选择文件</el-button>
|
||||
</el-upload>
|
||||
<span class="upload-desc">说明:一次最多上传5个文件,单个文件大小不能大于100M</span>
|
||||
</div>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<div class="file-list">
|
||||
<div class="file-list-item flex" v-for="(item, index) in fileList" :key="item.uid">
|
||||
<div class="file-name">
|
||||
<span class="name">标题:</span>
|
||||
<span>{{ item.name }}</span>
|
||||
</div>
|
||||
<div class="flex-type flex">
|
||||
<span class="name">类别:</span>
|
||||
<el-dropdown>
|
||||
<span class="el-dropdown-link">
|
||||
Dropdown List
|
||||
<!-- <el-icon class="el-icon--right">
|
||||
|
||||
</el-icon> -->
|
||||
</span>
|
||||
<template #dropdown>
|
||||
<el-dropdown-menu>
|
||||
<el-dropdown-item v-for="item in resourceType" :key="item in value">Action 1</el-dropdown-item>
|
||||
<el-dropdown-item>Action 2</el-dropdown-item>
|
||||
<el-dropdown-item>Action 3</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</template>
|
||||
</el-dropdown>
|
||||
</div>
|
||||
<el-button type="primary" link @click="delFile(index)">删除</el-button>
|
||||
</div>
|
||||
</div>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button @click="closeDialog">关闭</el-button>
|
||||
<el-button type="primary">
|
||||
确定
|
||||
</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref, defineProps, defineEmits, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
|
||||
const props = defineProps({
|
||||
modelValue: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
})
|
||||
const dialogValue = ref(false)
|
||||
// 定义要发送的emit事件
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
// 文件列表
|
||||
const fileList = ref([])
|
||||
// 资源类型
|
||||
const resourceType = ref([
|
||||
{
|
||||
label: '课件',
|
||||
value: 1
|
||||
},
|
||||
{
|
||||
label: '教案',
|
||||
value: 2
|
||||
},
|
||||
{
|
||||
label: '素材',
|
||||
value: 3
|
||||
}
|
||||
])
|
||||
|
||||
|
||||
|
||||
const hanleFileBefore = (rawFile) => {
|
||||
|
||||
// 音频 类型
|
||||
const audioTypes = ['audio/mpeg', 'audio/wav', 'audio/ogg', 'audio/aac']
|
||||
// 视频 类型
|
||||
const videoTypes = ['video/mp4', 'video/webm', 'video/ogg']
|
||||
// word 类型
|
||||
const wordTypes = ['application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document']
|
||||
// ppt 类型
|
||||
const pptTypes = ['application/vnd.ms-powerpoint', 'application/vnd.openxmlformats-officedocument.presentationml.presentation']
|
||||
// pdf 类型
|
||||
const pdfTypes = ['application/pdf']
|
||||
|
||||
const fileType = rawFile.type
|
||||
if (!(audioTypes.includes(fileType) || videoTypes.includes(fileType) || wordTypes.includes(fileType) || pptTypes.includes(fileType) || pdfTypes.includes(fileType))) {
|
||||
ElMessage.error('文件格式错误! 请上传音频、视频、word、ppt、pdf文件!')
|
||||
return false
|
||||
}
|
||||
// 验证文件大小
|
||||
const fileSize = rawFile.size / 1024 / 1024 > 100
|
||||
if (fileSize) {
|
||||
ElMessage.error('文件大小错误! 请上传小于100M的文件!')
|
||||
return false
|
||||
}
|
||||
|
||||
console.log(rawFile)
|
||||
fileList.value.push(rawFile)
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
const delFile = (index) => {
|
||||
fileList.value.splice(index, 1)
|
||||
}
|
||||
|
||||
|
||||
|
||||
watch(() => props.modelValue, (newVal) => {
|
||||
dialogValue.value = newVal
|
||||
})
|
||||
|
||||
const beforeClose = (done) => {
|
||||
fileList.value = []
|
||||
emit('update:modelValue', false)
|
||||
done()
|
||||
}
|
||||
|
||||
const closeDialog = () => {
|
||||
fileList.value = []
|
||||
emit('update:modelValue', false)
|
||||
}
|
||||
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.file-dialog {
|
||||
padding: 10px;
|
||||
|
||||
.file-item {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
|
||||
.upload-desc {
|
||||
font-size: 12px;
|
||||
color: #9e9e9e;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.file-list {
|
||||
width: 100%;
|
||||
|
||||
.file-list-item {
|
||||
width: 100%;
|
||||
justify-content: space-between;
|
||||
.file-name {
|
||||
margin-right: 20px;
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.flex-type {
|
||||
align-items: center;
|
||||
margin-right: 20px;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.name {
|
||||
|
||||
position: relative;
|
||||
|
||||
&::after {
|
||||
content: '*';
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: -8px;
|
||||
color: red;
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
|
@ -51,9 +51,7 @@ const pageSize = ref(100)
|
|||
const handleSizeChange = () => { }
|
||||
const handleCurrentChange = () => { }
|
||||
|
||||
const openDrawer = ()=>{
|
||||
drawer.value = true
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<style lang="scss">
|
||||
|
|
|
@ -12,7 +12,8 @@
|
|||
</el-row>
|
||||
<el-row class="resoure-btns">
|
||||
<el-col :span="24" class="query-row flex">
|
||||
<div class="flex"> <el-select v-model="sourceStore.curFormat" placeholder="Select" size="small" style="width: 100px">
|
||||
<div class="flex"> <el-select v-model="sourceStore.curFormat" placeholder="Select" size="small"
|
||||
style="width: 100px">
|
||||
<el-option v-for="item in sourceStore.formatList" :key="item.value" :label="item.label"
|
||||
:value="item.value" />
|
||||
</el-select>
|
||||
|
@ -22,21 +23,30 @@
|
|||
item.text }}</el-button>
|
||||
</div>
|
||||
<div>
|
||||
<el-button type="primary" round size="small" @click="sourceStore.isCreate = true">
|
||||
|
||||
<el-button type="primary" round size="small" @click="openDialog">
|
||||
<i class="iconfont icon-jiahao"></i>
|
||||
新建资源</el-button>
|
||||
</div>
|
||||
</el-col>
|
||||
</el-row>
|
||||
<uploadDialog v-model="isDialogOpen"/>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
import useResoureStore from '../store'
|
||||
import uploadDialog from '@/components/upload-dialog/index.vue'
|
||||
|
||||
const sourceStore = useResoureStore()
|
||||
const isDialogOpen = ref(false)
|
||||
|
||||
const openDialog = ()=>{
|
||||
isDialogOpen.value = true
|
||||
}
|
||||
|
||||
</script>
|
||||
ziy
|
||||
<style lang="scss" scoped>
|
||||
.resoure-search {
|
||||
padding: 20px;
|
||||
|
@ -55,15 +65,18 @@ ziy
|
|||
.resoure-btns {
|
||||
margin-top: 15px;
|
||||
justify-content: center;
|
||||
|
||||
.query-row {
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.line {
|
||||
width: 1px;
|
||||
height: 80%;
|
||||
background-color: #d9dce2;
|
||||
margin: 0 10px;
|
||||
}
|
||||
|
||||
.icon-jiahao {
|
||||
font-size: 12px;
|
||||
margin-right: 3px;
|
||||
|
|
Loading…
Reference in New Issue