Przeglądaj źródła

修改上传组件

lex-xin 4 lat temu
rodzic
commit
4773b3dc93
1 zmienionych plików z 26 dodań i 0 usunięć
  1. 26 0
      src/components/singe-file-upload/index.vue

+ 26 - 0
src/components/singe-file-upload/index.vue

@@ -10,10 +10,20 @@
     :accept="accept">
     <el-button size="small" type="primary" plain>点击上传</el-button>
     <div slot="tip" v-if="tips" class="el-upload__tip">{{tips}}</div>
+    <div slot="file" slot-scope="{file}">
+      <div style="display: flex; align-items: center;flex: 1 auto;justify-content: space-between;">
+        <div style="display: flex; align-items: center;overflow: hidden;">
+          <i v-if="!!file.url" @click.stop="copyText(file.url)" title="复制" style="padding-right: 5px" class="el-icon-document-copy"></i>
+          <span class="upload-text" :title="file.url">{{ file.url }}</span>
+        </div>
+        <i class="el-icon-delete" @click="remove"></i>
+      </div>
+    </div>
   </el-upload>
 </template>
 
 <script>
+import copy from 'copy-to-clipboard'
 import { getToken } from '@/utils/auth'
 export default {
   name: 'singe-file-upload',
@@ -76,6 +86,22 @@ export default {
         this.$message.error(res.msg || '上传失败')
       }
     },
+    copyText(text) {
+      if (text) {
+        copy(text)
+        this.$message.success('复制成功')
+      }
+    }
   }
 }
 </script>
+
+<style lang="less" scoped>
+.upload-text {
+  display: inline-block;
+  width: 100%;
+  overflow: hidden;
+  white-space: nowrap;
+  text-overflow: ellipsis;
+}
+</style>