Browse Source

主题库-list/画册

dev
xuhuajiao 3 years ago
parent
commit
de629d102e
  1. 35
      src/api/theme/theme.js
  2. 59
      src/views/ThemeGallery/index.vue
  3. 460
      src/views/components/ThemeGalleryList.vue
  4. 1
      src/views/components/upload.vue

35
src/api/theme/theme.js

@ -45,3 +45,38 @@ export function FetchUpdateThemeState(parameter) {
data: parameter
})
}
// 我的画册
export function FetchMyAlbum(parameter) {
return request({
url: 'api/material/myAlbum',
method: 'post',
data: parameter
})
}
// 添加到画册
export function FetchAddToMyAlbum(parameter) {
return request({
url: 'api/material/addMyAlbum',
method: 'post',
data: parameter
})
}
// 删除我的画册主题素材
export function FetchDeleteMyAlbum(parameter) {
return request({
url: 'api/material/deleteMyAlbum',
method: 'post',
data: parameter
})
}
// 编辑/新增文件夹-主题库
export function FetchSaveThemeFolder(parameter) {
return request({
url: 'api/material/saveThemeFolder',
method: 'post',
data: parameter
})
}

59
src/views/ThemeGallery/index.vue

@ -83,7 +83,7 @@
<el-radio :label="2" value="2">竖屏</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item v-if="isUploadThemeType == 1" label="文件名称">
<el-form-item v-if="isUploadThemeType == 1" prop="material_name" label="文件名称">
<el-input v-model="uploadForm.material_name" style="width:336px" />
</el-form-item>
<el-form-item class="upload_source" label="上传内容" prop="deposit_url">
@ -91,11 +91,11 @@
<img v-if="formatType==0" :src="uploadForm.deposit_url" alt="" width="150" />
<video v-if="formatType==1" :src="uploadForm.deposit_url" controls width="200"></video>
<audio v-if="formatType==2" :src="uploadForm.deposit_url" controls></audio>
<p>文件名{{ fileNames }}</p>
<!-- <p>文件名{{ fileNames }}</p> -->
</div>
<Upload ref="uploadMaterial" :is-theme="isTheme" @saveMaterial="saveMaterial" />
<Upload ref="uploadMaterial" :is-theme="isTheme" @saveMaterial="saveMaterial" @uploadSubmit="uploadSubmit" />
</el-form-item>
<el-form-item v-if="formatType != 0" label="上传封面" prop="img_path">
<el-form-item v-if="formatType != 0" label="添加封面" prop="img_path">
<UploadCover ref="childUpload" />
</el-form-item>
</el-form>
@ -209,8 +209,7 @@ export default {
uploadDialogVisible: false, // -
uploadHistoryVisible: false, // -
uploadTitle: '上传', // -
isUploadThemeType: 0,
isUploadThemeType: 0, // -
uploadForm: { //
class_ids: [
// id
@ -337,6 +336,20 @@ export default {
this.addDialogVisible = false
this.uploadDialogVisible = false
this.searchClassify = []
//
this.selectClassifyList = []
this.uploadForm.device_direction = 0
this.uploadForm.deposit_url = null
this.formatType = -1
this.uploadForm.material_type = null
this.uploadForm.img_path = null
this.materialImgPath = null
this.$nextTick(() => {
this.$refs.uploadMaterial.filePercent = 0
if (this.$refs.childUpload) {
this.$refs.childUpload.imageUrl = null
}
})
this.$refs[formName].resetFields()
},
// list - btn
@ -357,6 +370,7 @@ export default {
this.uploadDialogVisible = true
this.isUploadThemeType = 0
this.uploadTitle = '新增'
this.uploadForm.device_direction = 0
},
// -
editUploadTheme(row) {
@ -381,25 +395,16 @@ export default {
this.fileNames = row.material_name
this.uploadForm.deposit_url = row.deposit_url
const postfix = row.deposit_url.substring(row.deposit_url.lastIndexOf('.') + 1, row.deposit_url.length)
if (postfix == 'mp3') {
this.formatType = 2
this.formatType = row.material_type
if (this.formatType != 0) {
this.$nextTick(() => {
if (this.$refs.childUpload) {
this.$refs.childUpload.imageUrl = row.img_path
}
})
} else if (postfix == 'mp4') {
this.formatType = 1
this.$nextTick(() => {
if (this.$refs.childUpload) {
this.$refs.childUpload.imageUrl = row.img_path
}
})
} else if (postfix == ('jpg' || 'png' || 'gif')) {
this.formatType = 0
} else {
this.uploadForm.img_path = row.deposit_url
}
// this.materialImgPath = row.img_path
this.uploadForm.material_type = this.formatType
this.uploadForm.duration = row.duration
this.uploadForm.file_size = row.file_size
@ -407,8 +412,6 @@ export default {
},
// - info
saveMaterial() {
console.log(this.$refs.uploadMaterial)
console.log(this.$refs.uploadMaterial.uploadFileUrl)
const formatType = this.$refs.uploadMaterial.formatType
const uploadFileUrl = this.$refs.uploadMaterial.uploadFileUrl
//
@ -461,6 +464,20 @@ export default {
})
this.uploadDialogVisible = false
this.getThemeHistoryList()
//
this.selectClassifyList = []
this.uploadForm.device_direction = 0
this.uploadForm.deposit_url = null
this.formatType = -1
this.uploadForm.material_type = null
this.uploadForm.img_path = null
this.materialImgPath = null
this.$nextTick(() => {
this.$refs.uploadMaterial.filePercent = 0
if (this.$refs.childUpload) {
this.$refs.childUpload.imageUrl = null
}
})
this.$refs.uploadForm.resetFields()
} else {
this.$message.error(res.msg)

460
src/views/components/ThemeGalleryList.vue

@ -10,46 +10,57 @@
</el-tabs>
<div class="theme_img">
<!-- 我的画册-创建文件夹btn -->
<div v-if="themeItemActive=='3'" class="theme_mkdir cont_upload" @click="handleMkdir">
<div v-if="themeItemActive=='3'" class="theme_mkdir cont_upload" @click="handleMkdir(0)">
<svg class="font-icon icon" aria-hidden="true">
<use xlink:href="#icon-a-xinzeng" />
</svg>
<el-button class="mkdir_btn" round type="primary">创建文件夹</el-button>
</div>
<!-- 我的画册-某一文件夹 -->
<div v-if="themeItemActive=='3'" class="theme_mkdir folder">
<div class="icon_bg">
<svg class="font-icon icon" aria-hidden="true">
<use xlink:href="#icon-wenjianjia" />
</svg>
<!-- <img src /> -->
<div v-if="themeItemActive=='3'">
<div v-for="(item,index) in materialFolders" :key="item.id" :class="['theme_mkdir', 'folder', { 'item_multi': folderChecked == index }]" @click.stop="editFolder(item,index)" @dblclick="floderDbClick(item,index)">
<div class="icon_bg">
<svg v-if="!item.imgPath" class="font-icon icon" aria-hidden="true">
<use xlink:href="#icon-wenjianjia" />
</svg>
<img v-else :src="item.imgPath" />
</div>
<p class="file_name">{{ item.name }}</p>
<span v-if="folderChecked == index" class="checked_btn"></span>
</div>
<p class="file_name">文件夹</p>
</div>
<!-- 主题库list -->
<div v-for="(item, index) in listThemeData" :key="index" :class="['theme_item', { 'item_multi': selectedListIds.includes(item.id) }]">
<img :src="item.coverImg" alt />
<div v-for="(item, index) in themeGalleryList" :key="index" :class="['theme_item', { 'item_multi': selectedListIds.includes(item.material_id) }]">
<img v-if="item.img_path || item.material_type == 1" :src="item.img_path" :onerror="defaultImg" alt />
<div v-if="!item.img_path && item.material_type == 2" class="radio_img"></div>
<div v-if="showItemInfo" class="item_format">
<span class="item_type">{{ item.type }}</span>
<span v-if="item.type !== 'JPG'" class="item_time">03:00</span>
<span class="item_type">{{ item.deposit_url | getFileFormat }}</span>
<span v-if="item.material_type != 0" class="item_time">{{ item.duration | getSeconds }}</span>
</div>
<div v-if="showItemInfo" class="file_name">{{ item.name }}</div>
<span v-if="isMultiSelected" class="checked_btn" @click="selectedItem(item.id, item.type)"></span>
<div v-if="showItemInfo" class="file_name">{{ item.material_name }}</div>
<span v-if="isMultiSelected" class="checked_btn" @click="selectedItem(item)"></span>
</div>
</div>
<!-- 多选操作 -->
<div v-if="selectedListIds.length !== 0" class="multi_handle">
<el-button type="button" class="mulit_btn" @click="publishHandle(0)">即时发布</el-button>
<el-button type="button" class="mulit_btn" @click="publishHandle(1)">定时发布</el-button>
<el-button type="button" class="mulit_btn">下载</el-button>
<el-button v-if="themeItemActive!='3'" type="button" class="mulit_btn">添加到画册</el-button>
<el-button v-if="themeItemActive=='3'" type="button" class="mulit_btn" @click="moveingTo()">移动</el-button>
<el-button v-if="themeItemActive=='3'" type="button" class="mulit_btn mulit_delt_btn">删除</el-button>
<div v-if="!isEditFolder && folderChecked == -1 && isMultiSelected">
<el-button type="button" class="mulit_btn" @click="publishHandle(0)">即时发布</el-button>
<el-button type="button" class="mulit_btn" @click="publishHandle(1)">定时发布</el-button>
<el-button type="button" class="mulit_btn">下载</el-button>
<el-button v-if="themeItemActive!='3'" type="button" class="mulit_btn" @click="addToAlbum">添加到画册</el-button>
<el-button v-if="themeItemActive=='3'" type="button" class="mulit_btn" @click="moveingTo()">移动</el-button>
<el-button v-if="themeItemActive=='3'" type="button" class="mulit_btn mulit_delt_btn" @click="deltMyAlbumItem">删除</el-button>
</div>
<div v-else>
<el-button type="button" class="mulit_btn" @click="handleMkdir(1)">编辑</el-button>
<el-button type="button" class="mulit_btn mulit_delt_btn" @click="deleteMaterialFolder">删除</el-button>
</div>
</div>
<!-- 创建文件夹layer / 编辑 -->
<div class="publish_layer">
<el-dialog title="创建文件夹" :close-on-click-modal="false" :show-close="false" :visible.sync="mkdirVisible" width="616px" height="384px">
<el-form ref="form" :inline="true" :model="form" size="small" label-width="100px">
<el-form ref="folderForm" :inline="true" :model="folderForm" size="small" label-width="100px">
<el-form-item
label="文件夹名称"
prop="name"
@ -57,23 +68,19 @@
{ required: true, message: '请输入名称', trigger: 'blur' }
]"
>
<el-input v-model="form.name" style="width: 336px" />
<el-input v-model="folderForm.name" style="width: 336px" />
</el-form-item>
<el-form-item label="封面" prop="file">
<el-upload action="#" list-type="picture-card" :auto-upload="false">
<img src="@/assets/images/t-sc.png" alt />
<div slot="file" slot-scope="{file}">
<img class="el-upload-list__item-thumbnail" :src="file.url" alt />
</div>
</el-upload>
<UploadCover ref="childUpload" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" round> </el-button>
<el-button type="primary" round @click="submitFolderForm('folderForm')"> </el-button>
<el-button round @click="mkdirVisible=false"> </el-button>
</div>
</el-dialog>
</div>
<!-- 移动至layer -->
<div class="wjj_layer">
<!-- width="736px" -->
@ -95,10 +102,20 @@
</div>
</template>
<script>
import { FetchThemeClassList, FetchThemeGallery } from '@/api/theme/theme.js'
import { FetchThemeClassList, FetchThemeGallery, FetchMyAlbum, FetchAddToMyAlbum, FetchDeleteMyAlbum, FetchSaveThemeFolder } from '@/api/theme/theme.js'
import { getSeconds, getFileFormat } from '@/utils/index.js'
import UploadCover from './upload_cover'
export default {
name: 'ThemeGalleryList',
components: {},
components: { UploadCover },
filters: {
getSeconds(s) {
return getSeconds(s)
},
getFileFormat(s) {
return getFileFormat(s)
}
},
props: {
isMultiSelected: {
type: Boolean,
@ -115,73 +132,42 @@ export default {
},
data() {
return {
themeItemActive: '1',
mkdirVisible: false,
orga_id: '133221333123111', // ID
themeListForm: { // list
theme_name: '',
theme_class: '',
device_direction: '',
orga_id: '',
start_time: '',
end_time: '',
folder_id: '',
page: '',
size: ''
},
page: 1,
size: 10,
total: 0,
tabItem: [], //
activeIndex: 0,
themeItemActive: '1', // / / activeIndex
themeGalleryList: [], //
movingVisible: false,
movingChecked: null,
form: {
id: null,
folderForm: { // form
fid: '',
id: '',
img_path: '',
name: '',
file: null
orga_id: ''
},
themeGalleryList: [], //
formatType: null, // 0 img 1 video 2 audio
materialImgPath: '', //
materialDuration: 0, //
materialName: '', //
fileSize: '', //
listThemeData: [
{
id: '1',
name: '人工智能',
type: 'JPG',
coverImg: require('@/assets/images//home/theme_Img_03.png'),
time: ''
},
{
id: '2',
name: '防控疫情小贴士',
type: 'vedio',
coverImg: require('@/assets/images/background.jpg'),
time: '03:00'
},
{
id: '3',
name: '人工智能',
type: 'JPG',
coverImg: require('@/assets/images//home/theme_Img_03.png'),
time: ''
},
{
id: '4',
name: '防控疫情小贴士',
type: 'vedio',
coverImg: require('@/assets/images/background.jpg'),
time: '03:00'
},
{
id: '5',
name: '人工智能',
type: 'JPG',
coverImg: require('@/assets/images//home/theme_Img_03.png'),
time: ''
},
{
id: '6',
name: '防控疫情小贴士',
type: 'vedio',
coverImg: require('@/assets/images/background.jpg'),
time: '03:00'
},
{
id: '7',
name: '人工智能',
type: 'JPG',
coverImg: require('@/assets/images//home/theme_Img_03.png'),
time: ''
}
],
materialFolders: [], // list
selectedListIds: [],
selectinFolderid: [], // ID
selectedMaterial: [], //
thisAlbumFoldId: null,
isEditFolder: false, //
mkdirVisible: false, // layer
folderChecked: -1, //
wjjList: [
{
id: '1',
@ -191,17 +177,12 @@ export default {
id: '2',
name: '文件夹2'
}
],
uploadDialogVisible: false,
uploadTitle: '上传',
uploadListVisible: false,
imgSrc: '',
videoSrc: '',
audioSrc: '',
// lsit
tabItem: [],
activeIndex: 0
]
}
},
computed: {
defaultImg() {
return 'this.src="' + require('@/assets/images/menu_bg_02.png') + '"'
}
},
watch: {
@ -213,7 +194,7 @@ export default {
},
mounted() {
this.getThemeClassList()
this.getThemeGallery()
this.getMyAlbum()
},
methods: {
// id
@ -222,99 +203,225 @@ export default {
FetchThemeClassList(orga_id).then(res => {
if (res.code == 200) {
this.tabItem = res.data
this.getThemeGallery()
}
})
},
// list
getThemeGallery() {
const params = this.queryInfo
// FetchThemeGallery(params).then(res => {
// console.log(res)
// if (res.code == 200) {
// this.themeGalleryList = res.data.content
// console.log(this.themeGalleryList)
// this.total = res.data.totalElements
// }
// })
},
// -
tabThemeClassifyClick(tab) {
this.activeIndex = tab.index
if (this.themeItemActive == 3) {
this.getMyAlbum()
} else {
this.themeGalleryList = []
this.getThemeGallery()
}
},
// tabClick
tabItemClick(tab, event) {
console.log(this.themeItemActive)
console.log(tab, event)
// / /
tabItemClick() {
if (this.themeItemActive == 3) {
this.getMyAlbum()
} else {
this.themeGalleryList = []
this.getThemeGallery()
}
},
//
// saveMaterial() {
// console.log('-----------')
// console.log(this.formatType)
// this.uploadDialogVisible = true
// this.$nextTick(() => {
// if (formatType == 0) {
// this.imgSrc = this.$refs.uploadMaterial.uploadFileUrl
// } else if (formatType == 1) {
// this.videoSrc = this.$refs.uploadMaterial.uploadFileUrl
// } else {
// this.audioSrc = this.$refs.uploadMaterial.uploadFileUrl
// }
// // console.log(this.formatType)
// const duration = this.$refs.uploadMaterial.duration
// this.fileSize = this.$refs.uploadMaterial.fileSize
// //
// this.materialName = this.$refs.uploadMaterial.fileNames
// //
// const formatType = this.$refs.uploadMaterial.formatType
// console.log(this.$refs.uploadMaterial.uploadFileUrl)
// })
// const params = {
// class_ids: this.class_ids, // id
// deposit_url: this.uploadFileUrl, //
// device_direction: this.classifyForm.direction, //
// material_id: null,
// folder_id: null, // id
// img_path: this.materialImgPath, // id
// material_type: this.formatType,
// file_size: this.fileSize, //
// orga_id: this.queryInfo.orga_id, // id
// store_type: 2// 1. 2.
// }
// },
// resetForm() {
// this.addDialogVisible = false
// this.uploadDialogVisible = false
// this.$refs.classifyForm.resetFields()
// },
//
handleMkdir() {
this.mkdirVisible = true
// list
getThemeGallery() {
this.themeListForm.orga_id = this.orga_id
this.themeListForm.theme_class = this.tabItem[this.activeIndex].id
this.themeListForm.device_direction = this.themeItemActive == 1 ? 2 : 1
this.themeListForm.page = this.page
this.themeListForm.size = this.size
FetchThemeGallery(this.themeListForm).then(res => {
if (res.code == 200) {
this.themeGalleryList = res.data.content
this.total = res.data.totalElements
} else {
this.$message.error(res.msg)
}
})
},
//
moveingTo(index) {
this.movingVisible = true
// this.movingChecked = index
// list
getMyAlbum() {
const params = {
theme_name: null,
theme_class: null,
device_direction: null,
orga_id: this.orga_id,
start_time: null,
end_time: null,
folder_id: null
}
FetchMyAlbum(params).then(res => {
if (res.code == 200) {
this.materialFolders = res.data.materialFolders
this.themeGalleryList = res.data.pageThemeVO
this.isAlbumList = res.data.pageThemeVO
this.thisAlbumFoldId = res.data.thisFoldId
} else {
this.$message.error(res.msg)
}
})
},
//
wjjSelected(index) {
this.movingChecked = index
console.log(this.movingChecked)
//
addToAlbum() {
const isRepeatItem = this.isAlbumList.filter(item => {
return this.selectedListIds.indexOf(item.material_id) != -1
})
console.log(isRepeatItem)
if (isRepeatItem.length != 0) {
this.$message.error('选中得素材,我的画册里已存在,请勿重复添加!')
return
}
const params = {
id: this.thisAlbumFoldId, // id
material_ids: this.selectedListIds, // id
orga_id: this.orga_id
}
FetchAddToMyAlbum(params).then(res => {
if (res.code == 200) {
console.log(res)
this.$message.success('已成功添加到我的画册里啦~')
} else {
this.$message.error(res.msg)
}
})
},
//
deltMyAlbumItem() {
const params = {
ids: this.selectinFolderid
}
FetchDeleteMyAlbum(params).then(res => {
if (res.code == 200) {
this.$message.success(res.msg)
this.getMyAlbum()
} else {
this.$message.error(res.msg)
}
})
},
//
selectedItem(id) {
selectedItem(item) {
const id = item.material_id
const inFolderId = item.in_folder_id
// const type = item.material_type
const arr = this.selectedListIds
// includes(),truefalseNaN
if (arr.includes(id)) {
// id,
const index = arr.indexOf(id)
if (index > -1) {
arr.splice(index, 1)
this.selectinFolderid.splice(index, 1)
this.selectedMaterial.splice(index, 1)
}
} else {
this.selectedListIds.push(id)
this.selectinFolderid.push(inFolderId)
this.selectedMaterial.push(item)
// this.formatType = type
}
},
// /
handleMkdir(mkdirType) {
this.mkdirVisible = true
this.folderForm.fid = this.thisFoldId
this.folderForm.orga_id = this.orga_id
if (mkdirType === 0) {
this.$nextTick(() => {
this.$refs.childUpload.imageUrl = ''
this.folderForm.img_path = ''
this.folderForm.name = ''
})
delete this.folderForm.id
} else {
this.$nextTick(() => {
this.$refs.childUpload.imageUrl = this.folderForm.img_path
})
}
},
//
floderDbClick(item, index) {
this.isEditMaterial = false
this.$router.replace(
{
path: '/content', query: { folderTag: 1 }
}
)
this.currentFolder = item.name
this.currentFolderId = item.id
localStorage.setItem('currentFolder', this.currentFolder)
localStorage.setItem('currentFolderId', this.currentFolderId)
this.getMaterialList()
this.selectedListId = []
this.folderChecked = -1
this.isEditFolder = false
},
//
hiddenFolderActiveClick() {
this.folderChecked = -1
this.isEditFolder = false
},
//
editFolder(item, index) {
this.isEditMaterial = false
this.selectedListId = []
//
this.$emit('changedMultiSelected')
if (index != this.folderChecked) {
this.folderChecked = index
this.isEditFolder = true
this.folderForm = {
fid: item.fid,
id: item.id,
name: item.name,
img_path: item.imgPath,
orga_id: item.orgaId
}
} else {
this.folderChecked = -1
this.isEditFolder = false
}
},
// - /
submitFolderForm(formName) {
this.folderForm.img_path = this.$refs.childUpload.imageUrl
this.$refs[formName].validate((valid) => {
if (valid) {
// FetchSaveThemeFolder(this.folderForm).then(res => {
// if (res.code === 200) {
// this.$message({
// message: '',
// duration: 2000,
// type: 'success'
// })
// this.mkdirVisible = false
// this.getMaterialList()
// } else {
// this.$message({
// message: '',
// duration: 2000,
// type: 'warning'
// })
// }
// })
} else {
console.log('error submit!!')
return false
}
})
},
//
moveingTo(index) {
this.movingVisible = true
// this.movingChecked = index
},
//
wjjSelected(index) {
this.movingChecked = index
console.log(this.movingChecked)
},
// /
publishHandle(index) {
this.$router.push(
@ -335,6 +442,7 @@ export default {
}
.theme_img {
.theme_mkdir {
position: relative;
width: 140px;
height: 250px;
margin: 0 24px 24px 0;

1
src/views/components/upload.vue

@ -217,6 +217,7 @@ export default {
_this.getVideoDuration(_this.uploadFileUrl)
setTimeout(() => {
_this.$emit('saveMaterial')
_this.$emit('uploadSubmit')
}, 200)
document.getElementById('upFile').value = ''
}

Loading…
Cancel
Save