TeamBackgroundUploadQueue.vue 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <template>
  2. <div v-if="files.length" class="team-background-upload-queue">
  3. <div v-for="item in files" :key="item.id" class="queue-item">
  4. <div class="queue-item__main">
  5. <span class="queue-item__name" :title="item.name">{{ item.name }}</span>
  6. <span :class="['queue-item__status', `is-${item.status}`]">
  7. {{ statusLabels[item.status] || item.status }}
  8. </span>
  9. </div>
  10. <el-progress
  11. v-if="item.status === 'uploading'"
  12. :percentage="item.progress"
  13. :show-text="false"
  14. />
  15. <div v-if="item.error" class="queue-item__error">{{ item.error }}</div>
  16. <div class="queue-item__actions">
  17. <el-button
  18. v-if="item.status === 'failed'"
  19. type="text"
  20. size="mini"
  21. @click="$emit('retry', item)"
  22. >重试</el-button>
  23. <el-button
  24. v-if="item.status !== 'uploading'"
  25. type="text"
  26. size="mini"
  27. @click="$emit('remove', item)"
  28. >移除</el-button>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. export default {
  35. name: 'TeamBackgroundUploadQueue',
  36. props: {
  37. files: {
  38. type: Array,
  39. default: () => []
  40. }
  41. },
  42. data() {
  43. return {
  44. statusLabels: {
  45. pending: '等待上传',
  46. uploading: '上传中',
  47. success: '上传成功',
  48. failed: '上传失败'
  49. }
  50. }
  51. }
  52. }
  53. </script>
  54. <style scoped lang="scss">
  55. .team-background-upload-queue {
  56. margin: 12px 0 18px;
  57. }
  58. .queue-item {
  59. position: relative;
  60. padding: 10px 104px 10px 12px;
  61. margin-top: 8px;
  62. background: #f7f8fa;
  63. border-radius: 4px;
  64. }
  65. .queue-item__main {
  66. display: flex;
  67. min-width: 0;
  68. align-items: center;
  69. }
  70. .queue-item__name {
  71. overflow: hidden;
  72. color: #303133;
  73. text-overflow: ellipsis;
  74. white-space: nowrap;
  75. }
  76. .queue-item__status {
  77. flex: none;
  78. margin-left: 12px;
  79. color: #909399;
  80. &.is-success {
  81. color: #67c23a;
  82. }
  83. &.is-failed {
  84. color: #f56c6c;
  85. }
  86. }
  87. .queue-item__error {
  88. margin-top: 6px;
  89. color: #f56c6c;
  90. font-size: 12px;
  91. }
  92. .queue-item__actions {
  93. position: absolute;
  94. top: 4px;
  95. right: 12px;
  96. white-space: nowrap;
  97. }
  98. </style>