多媒体信息发布平台
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.

390 lines
11 KiB

3 years ago
  1. <template>
  2. <div v-if="themeItemActive==2" style="display:flex; flex-wrap: wrap">
  3. <!-- 我的画册-创建文件夹btn -->
  4. <div v-if="!isToFolder" class="theme_mkdir cont_upload" @click="handleMkdir(0)">
  5. <svg class="font-icon icon" aria-hidden="true">
  6. <use xlink:href="#icon-a-xinzeng" />
  7. </svg>
  8. <el-button class="mkdir_btn" round type="primary">创建文件夹</el-button>
  9. </div>
  10. <div v-else class="theme_mkdir cont_upload">
  11. <el-button class="cont_upload_btn" round type="primary">添加</el-button>
  12. <el-button class="return_btn" round type="primary" @click="breadcrumbToAlbum">返回</el-button>
  13. </div>
  14. <!-- 我的画册-某一文件夹 -->
  15. <div v-for="(item,index) in childMaterialFolders" :key="item.id" :class="[,'theme_mkdir', 'folder', { 'item_multi': folderChecked == index }]" @click.stop="editFolder(item,index)" @dblclick="floderDbClick(item,index)">
  16. <div class="icon_bg">
  17. <svg v-if="!item.imgPath" class="font-icon icon" aria-hidden="true">
  18. <use xlink:href="#icon-wenjianjia" />
  19. </svg>
  20. <img v-else :src="item.imgPath" />
  21. </div>
  22. <p class="file_name">{{ item.name }}</p>
  23. <span v-if="folderChecked == index" class="checked_btn"></span>
  24. </div>
  25. <!-- 创建文件夹layer / 编辑 -->
  26. <div class="publish_layer">
  27. <el-dialog title="创建文件夹" :close-on-click-modal="false" :show-close="false" :visible.sync="mkdirVisible" width="616px" height="384px">
  28. <el-form ref="folderForm" :inline="true" :model="folderForm" size="small" label-width="100px">
  29. <el-form-item
  30. label="文件夹名称"
  31. prop="name"
  32. :rules="[
  33. { required: true, message: '请输入名称', trigger: 'blur' }
  34. ]"
  35. >
  36. <el-input v-model="folderForm.name" style="width: 336px" />
  37. </el-form-item>
  38. <el-form-item label="封面" prop="file">
  39. <UploadCover ref="childUpload" />
  40. </el-form-item>
  41. </el-form>
  42. <div slot="footer" class="dialog-footer">
  43. <el-button type="primary" round @click="submitFolderForm('folderForm')"> </el-button>
  44. <el-button round @click="mkdirVisible=false"> </el-button>
  45. </div>
  46. </el-dialog>
  47. </div>
  48. <!-- 移动至layer -->
  49. <div class="wjj_layer">
  50. <!-- width="736px" -->
  51. <el-dialog title="移动至" :close-on-click-modal="false" :show-close="false" :visible.sync="movingVisible" width="576px" height="384px">
  52. <div class="wjj_list">
  53. <div v-for="(item, index) in folderList" :key="index" :class="['wjj_item', { 'wjj_item_active': folderListChecked == index }]" @click="wjjSelected(item,index)">
  54. <svg class="font-icon icon" aria-hidden="true">
  55. <use xlink:href="#icon-wenjianjia" />
  56. </svg>
  57. <p class="wjj_name">{{ item.name }}</p>
  58. </div>
  59. </div>
  60. <div slot="footer" class="dialog-footer">
  61. <el-button type="primary" round @click="moveFile">确定</el-button>
  62. <el-button round @click="movingVisible=false">取消</el-button>
  63. </div>
  64. </el-dialog>
  65. </div>
  66. </div>
  67. </template>
  68. <script>
  69. import { FetchSaveThemeFolder, FetchDeleteThemeFolder, FetchMoveMyThemeMaterial } from '@/api/theme/theme.js'
  70. import UploadCover from './upload_cover'
  71. export default {
  72. name: 'MaterialFolder',
  73. components: { UploadCover },
  74. props: {
  75. themeItemActive: {
  76. type: String,
  77. required: true
  78. },
  79. materialFolders: {
  80. type: Array,
  81. required: true
  82. },
  83. isToFolder: {
  84. type: Boolean,
  85. required: true
  86. },
  87. thisFoldId: {
  88. type: String,
  89. required: true
  90. },
  91. selectedListId: {
  92. type: Array,
  93. required: true
  94. },
  95. selectInFolderid: {
  96. type: Array,
  97. required: true
  98. }
  99. },
  100. data() {
  101. return {
  102. orga_id: '133221333123111', // 机构ID
  103. movingVisible: false,
  104. folderForm: { // form
  105. fid: '',
  106. id: '',
  107. img_path: '',
  108. name: '',
  109. orga_id: ''
  110. },
  111. childMaterialFolders: [], // 文件夹list
  112. rootFolderId: null,
  113. isEditFolder: false, // 是否编辑文件夹
  114. mkdirVisible: false, // 新建编辑layer
  115. folderChecked: -1, // 文件夹是否单击选中
  116. isEditMaterial: false, // 是否是编辑素材
  117. folderList: [], // 文件夹list
  118. folderListChecked: -1,
  119. currentFolder: '', // 当前进入的文件夹名
  120. currentFolderId: null
  121. }
  122. },
  123. computed: {
  124. defaultImg() {
  125. return 'this.src="' + require('@/assets/images/menu_bg_02.png') + '"'
  126. }
  127. },
  128. watch: {
  129. materialFolders(newName, oldName) {
  130. this.childMaterialFolders = newName
  131. },
  132. thisFoldId(newName, oldName) {
  133. this.thisChildFoldId = newName
  134. },
  135. selectedListId(newName, oldName) {
  136. this.ChildSelectedListId = newName
  137. },
  138. selectInFolderid(newName, oldName) {
  139. this.ChildSelectInFolderid = newName
  140. }
  141. },
  142. mounted() {
  143. console.log('444444444444')
  144. console.log(this.childMaterialFolders)
  145. console.log('555')
  146. // this.$emit('getMyAlbum')
  147. document.addEventListener('click', this.hiddenFolderActiveClick)
  148. },
  149. methods: {
  150. breadcrumbToAlbum() {
  151. this.$router.push('/theme')
  152. this.$emit('getMyAlbum')
  153. },
  154. // 新建 / 编辑 文件夹
  155. handleMkdir(mkdirType) {
  156. this.mkdirVisible = true
  157. this.folderForm.fid = this.thisChildFoldId
  158. this.folderForm.orga_id = this.orga_id
  159. if (mkdirType === 0) {
  160. this.$nextTick(() => {
  161. this.$refs.childUpload.imageUrl = ''
  162. this.folderForm.img_path = ''
  163. this.folderForm.name = ''
  164. })
  165. delete this.folderForm.id
  166. } else {
  167. this.$nextTick(() => {
  168. this.$refs.childUpload.imageUrl = this.folderForm.img_path
  169. })
  170. }
  171. },
  172. // 文件夹双击操作
  173. floderDbClick(item, index) {
  174. this.isEditMaterial = false
  175. this.$router.replace(
  176. {
  177. path: '/theme', query: { folderTag: 1 }
  178. }
  179. )
  180. this.currentFolder = item.name
  181. this.currentFolderId = item.id
  182. localStorage.setItem('currentFolder', this.currentFolder)
  183. localStorage.setItem('currentFolderId', this.currentFolderId)
  184. this.$emit('getMyAlbum')
  185. this.ChildSelectedListId = []
  186. this.folderChecked = -1
  187. this.isEditFolder = false
  188. },
  189. // 点击其他区域选中的文件夹 去掉选中样式
  190. hiddenFolderActiveClick() {
  191. this.folderChecked = -1
  192. this.isEditFolder = false
  193. },
  194. // 选择 编辑 文件夹
  195. editFolder(item, index) {
  196. this.isEditMaterial = false
  197. this.ChildSelectedListId = []
  198. // 有选择中的文件夹时,同时存在素材多选操作时
  199. this.$emit('changedMultiSelected')
  200. if (index != this.folderChecked) {
  201. this.folderChecked = index
  202. this.isEditFolder = true
  203. this.folderForm = {
  204. fid: item.fid,
  205. id: item.id,
  206. name: item.name,
  207. img_path: item.imgPath,
  208. orga_id: item.orgaId
  209. }
  210. } else {
  211. this.folderChecked = -1
  212. this.isEditFolder = false
  213. }
  214. },
  215. // 删除 文件夹
  216. deleteMaterialFolder() {
  217. console.log(this.folderForm.id)
  218. this.$confirm('此操作将永久删除该文件夹, 是否继续?', '提示', {
  219. confirmButtonText: '确定',
  220. cancelButtonText: '取消',
  221. type: 'warning'
  222. }).then(() => {
  223. const ids = []
  224. ids.push(this.folderForm.id)
  225. const params = {
  226. ids: ids
  227. }
  228. FetchDeleteThemeFolder(params).then(res => {
  229. if (res.code === 200) {
  230. this.$message({
  231. message: '删除文件夹成功',
  232. type: 'success'
  233. })
  234. // this.getMyAlbum()
  235. this.$emit('getMyAlbum')
  236. this.folderChecked = -1
  237. this.isEditFolder = false
  238. }
  239. })
  240. }).catch(() => {
  241. this.$message({
  242. message: '已取消删除',
  243. type: 'info'
  244. })
  245. })
  246. },
  247. // 提交表单 - 新建/编辑
  248. submitFolderForm(formName) {
  249. this.folderForm.img_path = this.$refs.childUpload.imageUrl
  250. console.log(this.folderForm)
  251. this.$refs[formName].validate((valid) => {
  252. if (valid) {
  253. FetchSaveThemeFolder(this.folderForm).then(res => {
  254. if (res.code === 200) {
  255. this.$message({
  256. message: '创建文件夹成功',
  257. duration: 2000,
  258. type: 'success'
  259. })
  260. this.mkdirVisible = false
  261. // this.getMyAlbum()
  262. this.$emit('getMyAlbum')
  263. } else {
  264. this.$message({
  265. message: '创建文件夹失败',
  266. duration: 2000,
  267. type: 'warning'
  268. })
  269. }
  270. })
  271. } else {
  272. console.log('error submit!!')
  273. return false
  274. }
  275. })
  276. },
  277. // 点击-移动btn
  278. moveingTo(index) {
  279. this.folderList = []
  280. if (this.childMaterialFolders.length > 0) {
  281. this.folderList = this.childMaterialFolders.slice(0, this.materialFolders.length)
  282. }
  283. this.rootFolderId = localStorage.getItem('rootFolderId')
  284. const returnFolder = {
  285. id: this.rootFolderId,
  286. name: '返回上一级'
  287. }
  288. this.folderList.unshift(returnFolder)
  289. this.movingVisible = true
  290. },
  291. // 文件夹list - 选中操作
  292. wjjSelected(item, index) {
  293. this.folderListChecked = index
  294. this.thisChildFoldId = item.id
  295. },
  296. // 点击确定 - 移动素材
  297. moveFile() {
  298. if (this.childMaterialFolders.length > 0) {
  299. if (this.thisChildFoldId == this.rootFolderId) {
  300. this.$message({
  301. message: '不能讲文件移动到自身目录下哦~',
  302. type: 'error'
  303. })
  304. return
  305. }
  306. } else {
  307. this.thisChildFoldId = this.rootFolderId
  308. }
  309. const params = {
  310. 'folder_id': this.thisChildFoldId,
  311. 'ids': this.ChildSelectInFolderid,
  312. 'material_ids': this.ChildSelectedListId
  313. }
  314. FetchMoveMyThemeMaterial(params).then(res => {
  315. if (res.code === 200) {
  316. this.$message({
  317. message: '移动成功',
  318. type: 'success'
  319. })
  320. this.movingVisible = false
  321. // this.getMyAlbum()
  322. this.$emit('getMyAlbum')
  323. this.ChildSelectedListId = []
  324. }
  325. })
  326. }
  327. }
  328. }
  329. </script>
  330. <style lang="scss" scoped>
  331. .el-tabs {
  332. margin-bottom: 0;
  333. }
  334. ::v-deep .el-tabs__item.is-active {
  335. color: #3a8aeb;
  336. }
  337. .theme_mkdir {
  338. position: relative;
  339. width: 140px;
  340. height: 250px;
  341. margin: 0 24px 24px 0;
  342. &.cont_upload .font-icon {
  343. width: 45px;
  344. height: 45px;
  345. margin-bottom: 20px;
  346. }
  347. &.folder .font-icon {
  348. width: 84px;
  349. height: 69px;
  350. }
  351. .icon_bg{
  352. img{
  353. display: block;
  354. width: 140px;
  355. height: 250px;
  356. }
  357. }
  358. }
  359. .theme_item {
  360. width: 140px;
  361. height: 250px;
  362. }
  363. .icon_bg {
  364. height: 220px;
  365. }
  366. .theme_item {
  367. .file_name {
  368. position: absolute;
  369. left: 0;
  370. bottom: 0;
  371. width: 100%;
  372. height: 30px;
  373. background: rgba(255, 255, 255, 0.6);
  374. line-height: 30px;
  375. }
  376. }
  377. .material_crumbs {
  378. padding: 15px 24px 0 24px;
  379. line-height: 30px;
  380. background: #fff;
  381. ::v-deep .el-breadcrumb {
  382. font-size: 12px;
  383. color: #999999;
  384. }
  385. }
  386. </style>