index.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. <template>
  2. <el-row>
  3. <el-col :span="17">
  4. <list ref="list" @onNameChange="onNameChange" @folderChecked="folderChecked" @toFolderDetail="toFolderDetail">
  5. <template v-if="!showBtnGroup">
  6. <h-upload v-if="tool.checkAuth($route.name,'upload')" :folderid="folderid" slot="upload" @onSuccess="onSuccess" :hidemediastock="true"></h-upload>
  7. <add v-if="tool.checkAuth($route.name,'insert')" slot="add" ref="add" style="margin-left:10px" @addClick="addClick" @onSuccess="onSuccess"></add>
  8. </template>
  9. <template v-else>
  10. <el-button-group slot="btngroup">
  11. <download v-if="tool.checkAuth($route.name,'download')" :checklist="checklist"></download>
  12. <delete-file v-if="tool.checkAuth($route.name,'delete')" :checklist="checklist" @onSuccess="onSuccess"></delete-file>
  13. <more-operation v-if="tool.checkAuth($route.name,'update')" ref="edit" :checklist="checklist" @restName="restName" @onSuccess="onSuccess"></more-operation>
  14. </el-button-group>
  15. </template>
  16. </list>
  17. </el-col>
  18. <el-col :span="7">
  19. <fileInfo ref="filelist" :filelist="checklist"></fileInfo>
  20. </el-col>
  21. </el-row>
  22. </template>
  23. <script>
  24. import hUpload from '../../components/upload/hw_obs_upload.vue'
  25. import list from './modules/list.vue'
  26. import add from './modules/add.vue'
  27. import download from './modules/download.vue'
  28. import deleteFile from './modules/delete.vue'
  29. import moreOperation from './modules/moreOperation.vue'
  30. import fileInfo from './modules/fileInfo.vue'
  31. export default {
  32. components:{
  33. hUpload,
  34. list,
  35. add,
  36. download,
  37. deleteFile,
  38. moreOperation,
  39. fileInfo
  40. },
  41. data () {
  42. return {
  43. showBtnGroup:false,
  44. folderid:'',
  45. checklist:[]
  46. }
  47. },
  48. methods:{
  49. // 监听新建按钮
  50. addClick () {
  51. this.$refs['add'].createFolderComplete({
  52. document:'新建文件夹',
  53. postfix:'FOLDER'
  54. })
  55. },
  56. // 监听修改文件夹名称,失去焦点执行
  57. onNameChange (folder) {
  58. folder.attachmentid ? this.$refs.edit.confirmRestName(folder) : this.$refs.add.createFolderComplete(folder)
  59. },
  60. // 监听创建成功
  61. onSuccess () {
  62. let id = this.$route.query.id?this.$route.query.id:0
  63. this.$refs.list.queryAttachment(id)
  64. this.$refs.list.restChecked()
  65. this.folderChecked([])
  66. },
  67. // 监听文件选择
  68. folderChecked (arr) {
  69. this.checklist = arr
  70. if (arr.length > 0) {
  71. this.showBtnGroup = true
  72. } else {
  73. this.showBtnGroup = false
  74. }
  75. this.$refs['filelist'].setFileInfo(arr)
  76. },
  77. // 监听打开文件夹
  78. toFolderDetail (id) {
  79. this.folderid = id
  80. },
  81. // 监听重命名
  82. restName () {
  83. this.checklist[0].newfolder = true
  84. let obj = this.checklist[0]
  85. this.$refs.list.list.forEach((e,index) => {
  86. if (e.attachmentid === this.checklist[0].attachmentid) {
  87. this.$set(this.$refs.list.list, index, obj);
  88. }
  89. })
  90. },
  91. }
  92. }
  93. </script>
  94. <style>
  95. </style>