index.vue 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <template>
  2. <el-drawer title="媒体库" :visible.sync="drawer">
  3. <div style="display:flex;justify-content:space-around;flex-wrap:wrap;padding-top:40px">
  4. <el-image
  5. class="header-img-box-list"
  6. :src="(item.url && item.url.slice(0, 4) !== 'http')?path+item.url:item.url"
  7. v-for="(item,key) in picList"
  8. :key="key"
  9. @click.native="chooseImg(item.url,target,targetKey)"
  10. >
  11. <div slot="error" class="header-img-box-list">
  12. <i class="el-icon-picture-outline"></i>
  13. </div>
  14. </el-image>
  15. </div>
  16. </el-drawer>
  17. </template>
  18. <script>
  19. const path = process.env.VUE_APP_BASE_API
  20. import { getFileList } from "@/api/fileUploadAndDownload";
  21. export default {
  22. props: {
  23. target: [Object],
  24. targetKey: [String]
  25. },
  26. data() {
  27. return {
  28. drawer: false,
  29. picList: [],
  30. path:path
  31. };
  32. },
  33. methods: {
  34. chooseImg(url, target, targetKey) {
  35. if(target&&targetKey){
  36. target[targetKey] = url;
  37. }
  38. this.$emit("enter-img", url);
  39. this.drawer = false;
  40. },
  41. async open() {
  42. const res = await getFileList({ page: 1, pageSize: 9999 });
  43. this.picList = res.data.list;
  44. this.drawer = true;
  45. }
  46. }
  47. };
  48. </script>
  49. <style lang="scss">
  50. .header-img-box-list {
  51. width: 180px;
  52. height: 180px;
  53. border: 1px dashed #ccc;
  54. border-radius: 20px;
  55. text-align: center;
  56. line-height: 180px;
  57. cursor: pointer;
  58. }
  59. </style>