多媒体信息发布平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

517 lines
17 KiB

  1. <template>
  2. <div>
  3. <!-- 我的画册-创建文件夹btn -->
  4. <div v-if="isToFolder" class="material_crumbs">
  5. <el-breadcrumb separator-class="el-icon-arrow-right">
  6. <el-breadcrumb-item><a href="/theme">主题库</a></el-breadcrumb-item>
  7. <el-breadcrumb-item><a @click="breadcrumbToAlbum">我的画册</a></el-breadcrumb-item>
  8. <el-breadcrumb-item>{{ currentFolder }}</el-breadcrumb-item>
  9. </el-breadcrumb>
  10. </div>
  11. <div style="display:flex; flex-wrap: wrap">
  12. <div v-if="!isToFolder" class="theme_mkdir cont_upload" @click="handleMkdir(0)">
  13. <svg class="font-icon icon" aria-hidden="true">
  14. <use xlink:href="#icon-a-xinzeng" />
  15. </svg>
  16. <el-button class="mkdir_btn" round type="primary">创建文件夹</el-button>
  17. </div>
  18. <div v-else class="theme_mkdir cont_upload">
  19. <el-button class="cont_upload_btn" round type="primary">添加</el-button>
  20. <el-button class="return_btn" round type="primary" @click="breadcrumbToAlbum">返回</el-button>
  21. </div>
  22. <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)">
  23. <div class="icon_bg">
  24. <svg v-if="!item.imgPath" class="font-icon icon" aria-hidden="true">
  25. <use xlink:href="#icon-wenjianjia" />
  26. </svg>
  27. <img v-else :src="item.imgPath" />
  28. </div>
  29. <p class="file_name">{{ item.name }}</p>
  30. <span v-if="folderChecked == index" class="checked_btn"></span>
  31. </div>
  32. <!-- 画册list -->
  33. <div v-for="(item, index) in themeGalleryList" :key="index" :class="['theme_item', { 'item_multi': selectInFolderid.includes(item.in_folder_id) }]">
  34. <img v-if="item.img_path || item.material_type == 1" :src="item.img_path" :onerror="defaultImg" alt />
  35. <div v-if="!item.img_path && item.material_type == 2" class="radio_img"></div>
  36. <div class="item_format">
  37. <span class="item_type">{{ item.deposit_url | getFileFormat }}</span>
  38. <span v-if="item.material_type != 0" class="item_time">{{ item.duration | getSeconds }}</span>
  39. </div>
  40. <div class="file_name">{{ item.material_name }}</div>
  41. <span v-if="isMultiSelected" class="checked_btn" @click="selectedItem(item)"></span>
  42. </div>
  43. </div>
  44. <!-- 多选操作 -->
  45. <div v-if="selectInFolderid.length !== 0 || folderChecked != -1" class="multi_handle">
  46. <div v-if="!isEditFolder && folderChecked == -1 && isMultiSelected">
  47. <el-button type="button" class="mulit_btn" @click="publishHandle(0)">即时发布</el-button>
  48. <el-button type="button" class="mulit_btn" @click="publishHandle(1)">定时发布</el-button>
  49. <el-button type="button" class="mulit_btn">下载</el-button>
  50. <el-button type="button" class="mulit_btn" @click="moveingTo">移动</el-button>
  51. <el-button type="button" class="mulit_btn mulit_delt_btn" @click="deltMyAlbumItem">删除</el-button>
  52. </div>
  53. <div v-else>
  54. <el-button type="button" class="mulit_btn" @click="handleMkdir(1)">编辑</el-button>
  55. <el-button type="button" class="mulit_btn mulit_delt_btn" @click="deleteMaterialFolder">删除</el-button>
  56. </div>
  57. </div>
  58. <!-- 创建文件夹layer / 编辑 -->
  59. <div class="publish_layer">
  60. <el-dialog title="创建文件夹" :close-on-click-modal="false" :show-close="false" :visible.sync="mkdirVisible" width="616px" height="384px">
  61. <el-form ref="folderForm" :inline="true" :model="folderForm" size="small" label-width="100px">
  62. <el-form-item
  63. label="文件夹名称"
  64. prop="name"
  65. :rules="[
  66. { required: true, message: '请输入名称', trigger: 'blur' }
  67. ]"
  68. >
  69. <el-input v-model="folderForm.name" style="width: 336px" />
  70. </el-form-item>
  71. <el-form-item label="封面" prop="file">
  72. <UploadCover ref="childUpload" />
  73. </el-form-item>
  74. </el-form>
  75. <div slot="footer" class="dialog-footer">
  76. <el-button type="primary" round @click="submitFolderForm('folderForm')"> </el-button>
  77. <el-button round @click="mkdirVisible=false"> </el-button>
  78. </div>
  79. </el-dialog>
  80. </div>
  81. <!-- 移动至layer -->
  82. <div class="wjj_layer">
  83. <!-- width="736px" -->
  84. <el-dialog title="移动至" :close-on-click-modal="false" :show-close="false" :visible.sync="movingVisible" width="576px" height="384px">
  85. <div class="wjj_list">
  86. <div v-for="(item, index) in folderList" :key="index" :class="['wjj_item', { 'wjj_item_active': folderListChecked == index }]" @click="wjjSelected(item,index)">
  87. <svg class="font-icon icon" aria-hidden="true">
  88. <use xlink:href="#icon-wenjianjia" />
  89. </svg>
  90. <p class="wjj_name">{{ item.name }}</p>
  91. </div>
  92. </div>
  93. <div slot="footer" class="dialog-footer">
  94. <el-button type="primary" round @click="moveFile">确定</el-button>
  95. <el-button round @click="movingVisible=false">取消</el-button>
  96. </div>
  97. </el-dialog>
  98. </div>
  99. </div>
  100. </template>
  101. <script>
  102. import { FetchMyAlbum, FetchDeleteMyAlbum, FetchSaveThemeFolder, FetchDeleteThemeFolder, FetchMoveMyThemeMaterial } from '@/api/theme/theme.js'
  103. import { getSeconds, getFileFormat } from '@/utils/index.js'
  104. import UploadCover from './upload_cover'
  105. export default {
  106. name: 'ThemeGalleryList',
  107. components: { UploadCover },
  108. filters: {
  109. getSeconds(s) {
  110. return getSeconds(s)
  111. },
  112. getFileFormat(s) {
  113. return getFileFormat(s)
  114. }
  115. },
  116. props: {
  117. isMultiSelected: {
  118. type: Boolean,
  119. required: true
  120. }
  121. },
  122. data() {
  123. return {
  124. orga_id: '133221333123111', // 机构ID
  125. isAlbumList: [],
  126. themeGalleryList: [], // 主题库的列表
  127. materialFolders: [], // 文件夹list
  128. selectedListId: [],
  129. selectInFolderid: [], // 关联素材得主键得ID
  130. selectedMaterial: [], // 素材选中
  131. thisFoldId: null || '',
  132. rootFolderId: null,
  133. thisAlbumFoldId: null,
  134. isEditFolder: false, // 是否编辑文件夹
  135. mkdirVisible: false, // 新建编辑layer
  136. folderChecked: -1, // 文件夹是否单击选中
  137. folderListChecked: -1,
  138. isToFolder: false, // 是否进入文件夹
  139. currentFolder: '', // 当前进入的文件夹名
  140. currentFolderId: null,
  141. folderList: [], // 文件夹list
  142. movingVisible: false,
  143. movingChecked: null,
  144. folderForm: { // form
  145. fid: '',
  146. id: '',
  147. img_path: '',
  148. name: '',
  149. orga_id: ''
  150. }
  151. }
  152. },
  153. computed: {
  154. defaultImg() {
  155. return 'this.src="' + require('@/assets/images/menu_bg_02.png') + '"'
  156. }
  157. },
  158. watch: {
  159. isMultiSelected(newName, oldName) {
  160. if (newName === false) {
  161. this.selectedListId = []
  162. this.selectInFolderid = []
  163. }
  164. }
  165. },
  166. mounted() {
  167. this.getMyAlbum()
  168. document.addEventListener('click', this.hiddenFolderActiveClick)
  169. },
  170. methods: {
  171. breadcrumbToAlbum() {
  172. this.$router.push('/theme')
  173. this.getMyAlbum()
  174. },
  175. // 获取我的画册 list
  176. getMyAlbum() {
  177. let inOrOutFolderId
  178. if (this.$route.query.folderTag) {
  179. console.log('文件夹内')
  180. this.isToFolder = true
  181. this.currentFolder = localStorage.getItem('currentFolder')
  182. this.currentFolderId = localStorage.getItem('currentFolderId')
  183. inOrOutFolderId = this.currentFolderId
  184. } else {
  185. console.log('文件夹外')
  186. this.isToFolder = false
  187. localStorage.removeItem('currentFolder')
  188. localStorage.removeItem('currentFolderId')
  189. inOrOutFolderId = null
  190. }
  191. const params = {
  192. 'theme_name': null,
  193. 'theme_class': null,
  194. 'device_direction': null,
  195. 'orga_id': this.orga_id,
  196. 'start_time': null,
  197. 'end_time': null,
  198. 'folder_id': inOrOutFolderId
  199. }
  200. // this.materialFolders = []
  201. // this.themeGalleryList = []
  202. FetchMyAlbum(params).then(res => {
  203. if (res.code == 200) {
  204. this.materialFolders = res.data.materialFolders
  205. this.themeGalleryList = res.data.pageThemeVO
  206. this.isAlbumList = res.data.pageThemeVO
  207. this.thisAlbumFoldId = res.data.thisFoldId
  208. if (!this.$route.query.folderTag) {
  209. localStorage.setItem('rootFolderId', res.data.thisFoldId)
  210. }
  211. // 创建文件夹获取data
  212. this.thisFoldId = res.data.thisFoldId
  213. } else {
  214. this.$message.error(res.msg)
  215. }
  216. })
  217. },
  218. // 删除我的画册里的素材
  219. deltMyAlbumItem() {
  220. const params = {
  221. ids: this.selectInFolderid
  222. }
  223. FetchDeleteMyAlbum(params).then(res => {
  224. if (res.code == 200) {
  225. this.$message.success(res.msg)
  226. this.getMyAlbum()
  227. } else {
  228. this.$message.error(res.msg)
  229. }
  230. })
  231. },
  232. // 多选选中
  233. selectedItem(item) {
  234. const id = item.material_id
  235. const inFolderId = item.in_folder_id
  236. // const type = item.material_type
  237. const arr = this.selectedListId
  238. const arr2 = this.selectInFolderid
  239. if (arr2.includes(inFolderId)) {
  240. const index = arr2.indexOf(inFolderId)
  241. if (index > -1) {
  242. arr2.splice(index, 1)
  243. arr.splice(index, 1)
  244. this.selectInFolderid.splice(index, 1)
  245. this.selectedMaterial.splice(index, 1)
  246. }
  247. } else {
  248. this.selectedListId.push(id)
  249. this.selectInFolderid.push(inFolderId)
  250. this.selectedMaterial.push(item)
  251. // this.formatType = type
  252. }
  253. },
  254. // 新建 / 编辑 文件夹
  255. handleMkdir(mkdirType) {
  256. this.mkdirVisible = true
  257. this.folderForm.fid = this.thisFoldId
  258. this.folderForm.orga_id = this.orga_id
  259. if (mkdirType === 0) {
  260. this.$nextTick(() => {
  261. this.$refs.childUpload.imageUrl = ''
  262. this.folderForm.img_path = ''
  263. this.folderForm.name = ''
  264. })
  265. delete this.folderForm.id
  266. } else {
  267. this.$nextTick(() => {
  268. this.$refs.childUpload.imageUrl = this.folderForm.img_path
  269. })
  270. }
  271. },
  272. // 文件夹双击操作
  273. floderDbClick(item, index) {
  274. this.$router.replace(
  275. {
  276. path: '/theme', query: { folderTag: 1 }
  277. }
  278. )
  279. this.currentFolder = item.name
  280. this.currentFolderId = item.id
  281. localStorage.setItem('currentFolder', this.currentFolder)
  282. localStorage.setItem('currentFolderId', this.currentFolderId)
  283. this.getMyAlbum()
  284. this.selectedListId = []
  285. this.folderChecked = -1
  286. this.isEditFolder = false
  287. },
  288. // 点击其他区域选中的文件夹 去掉选中样式
  289. hiddenFolderActiveClick() {
  290. this.folderChecked = -1
  291. this.isEditFolder = false
  292. },
  293. // 选择 编辑 文件夹
  294. editFolder(item, index) {
  295. this.selectedListId = []
  296. // 有选择中的文件夹时,同时存在素材多选操作时
  297. this.$emit('changedMultiSelected')
  298. if (index != this.folderChecked) {
  299. this.folderChecked = index
  300. this.isEditFolder = true
  301. this.folderForm = {
  302. fid: item.fid,
  303. id: item.id,
  304. name: item.name,
  305. img_path: item.imgPath,
  306. orga_id: item.orgaId
  307. }
  308. } else {
  309. this.folderChecked = -1
  310. this.isEditFolder = false
  311. }
  312. },
  313. // 删除 文件夹
  314. deleteMaterialFolder() {
  315. console.log(this.folderForm.id)
  316. this.$confirm('此操作将永久删除该文件夹, 是否继续?', '提示', {
  317. confirmButtonText: '确定',
  318. cancelButtonText: '取消',
  319. type: 'warning'
  320. }).then(() => {
  321. const ids = []
  322. ids.push(this.folderForm.id)
  323. const params = {
  324. ids: ids
  325. }
  326. FetchDeleteThemeFolder(params).then(res => {
  327. if (res.code === 200) {
  328. this.$message({
  329. message: '删除文件夹成功',
  330. type: 'success'
  331. })
  332. this.getMyAlbum()
  333. this.folderChecked = -1
  334. this.isEditFolder = false
  335. }
  336. })
  337. }).catch(() => {
  338. this.$message({
  339. message: '已取消删除',
  340. type: 'info'
  341. })
  342. })
  343. },
  344. // 提交表单 - 新建/编辑
  345. submitFolderForm(formName) {
  346. this.folderForm.img_path = this.$refs.childUpload.imageUrl
  347. console.log(this.folderForm)
  348. this.$refs[formName].validate((valid) => {
  349. if (valid) {
  350. FetchSaveThemeFolder(this.folderForm).then(res => {
  351. if (res.code === 200) {
  352. this.$message({
  353. message: '创建文件夹成功',
  354. duration: 2000,
  355. type: 'success'
  356. })
  357. this.mkdirVisible = false
  358. this.getMyAlbum()
  359. } else {
  360. this.$message({
  361. message: '创建文件夹失败',
  362. duration: 2000,
  363. type: 'warning'
  364. })
  365. }
  366. })
  367. } else {
  368. console.log('error submit!!')
  369. return false
  370. }
  371. })
  372. },
  373. // 点击-移动btn
  374. moveingTo(index) {
  375. this.folderList = []
  376. if (this.materialFolders.length > 0) {
  377. this.folderList = this.materialFolders.slice(0, this.materialFolders.length)
  378. }
  379. this.rootFolderId = localStorage.getItem('rootFolderId')
  380. const returnFolder = {
  381. id: this.rootFolderId,
  382. name: '返回上一级'
  383. }
  384. this.folderList.unshift(returnFolder)
  385. this.movingVisible = true
  386. },
  387. // 文件夹list - 选中操作
  388. wjjSelected(item, index) {
  389. this.folderListChecked = index
  390. this.thisFoldId = item.id
  391. },
  392. // 点击确定 - 移动素材
  393. moveFile() {
  394. if (this.materialFolders.length > 0) {
  395. if (this.thisFoldId == this.rootFolderId) {
  396. this.$message({
  397. message: '不能讲文件移动到自身目录下哦~',
  398. type: 'error'
  399. })
  400. return
  401. }
  402. } else {
  403. this.thisFoldId = this.rootFolderId
  404. }
  405. const params = {
  406. 'folder_id': this.thisFoldId,
  407. 'ids': this.selectInFolderid,
  408. 'material_ids': this.selectedListId
  409. }
  410. FetchMoveMyThemeMaterial(params).then(res => {
  411. if (res.code === 200) {
  412. this.$message({
  413. message: '移动成功',
  414. type: 'success'
  415. })
  416. this.movingVisible = false
  417. this.getMyAlbum()
  418. this.selectedListId = []
  419. this.selectInFolderid = []
  420. }
  421. })
  422. },
  423. // 即时发布/定时发布
  424. publishHandle(index) {
  425. localStorage.removeItem('selectedMaterial')
  426. localStorage.removeItem('releaseId')
  427. this.selectedMaterial = this.filterArrObj(this.selectedMaterial, 'material_id')
  428. // 判断是否选择了多个音频文件
  429. const resultAudio = []
  430. this.selectedMaterial.map(item => {
  431. if (item.material_type == 2) {
  432. resultAudio.push(item)
  433. }
  434. })
  435. if (resultAudio.length > 1) {
  436. this.$message.error('音频类型的文件只可选择1个')
  437. return
  438. }
  439. localStorage.setItem('selectedMaterial', JSON.stringify(this.selectedMaterial))
  440. this.$router.push(
  441. {
  442. path: '/release', query: { tag: index }
  443. }
  444. )
  445. },
  446. // 主题库存在重复得情况,发布前过滤
  447. filterArrObj(arr, filterField) {
  448. const newArr = arr.reduce((pre, cur) => pre.some(item => item[filterField] == cur[filterField])
  449. ? pre : [...pre, cur], [])
  450. return newArr
  451. }
  452. }
  453. }
  454. </script>
  455. <style lang="scss" scoped>
  456. .el-tabs {
  457. margin-bottom: 0;
  458. }
  459. ::v-deep .el-tabs__item.is-active {
  460. color: #3a8aeb;
  461. }
  462. .theme_img {
  463. .theme_mkdir {
  464. position: relative;
  465. width: 140px;
  466. height: 250px;
  467. margin: 0 24px 24px 0;
  468. &.cont_upload .font-icon {
  469. width: 45px;
  470. height: 45px;
  471. margin-bottom: 20px;
  472. }
  473. &.folder .font-icon {
  474. width: 84px;
  475. height: 69px;
  476. }
  477. .icon_bg{
  478. img{
  479. display: block;
  480. width: 140px;
  481. height: 250px;
  482. }
  483. }
  484. }
  485. .theme_item {
  486. width: 140px;
  487. height: 250px;
  488. }
  489. .icon_bg {
  490. height: 220px;
  491. }
  492. .theme_item {
  493. .file_name {
  494. position: absolute;
  495. left: 0;
  496. bottom: 0;
  497. width: 100%;
  498. height: 30px;
  499. background: rgba(255, 255, 255, 0.6);
  500. line-height: 30px;
  501. }
  502. }
  503. }
  504. .material_crumbs {
  505. padding: 0 0 15px 0;
  506. line-height: 30px;
  507. background: #fff;
  508. ::v-deep .el-breadcrumb {
  509. font-size: 12px;
  510. color: #999999;
  511. }
  512. }
  513. </style>