|
@@ -4,6 +4,8 @@
|
|
|
<div class="myDemo">
|
|
|
<el-upload
|
|
|
class="upload-demo"
|
|
|
+ action="#"
|
|
|
+ :auto-upload="false"
|
|
|
:drag="drag"
|
|
|
:multiple="multiple"
|
|
|
:data="data"
|
|
@@ -23,7 +25,10 @@
|
|
|
style="width: 100%"
|
|
|
>
|
|
|
<i class="el-icon-upload"></i>
|
|
|
- <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
|
+ <div class="el-upload__text">
|
|
|
+ <div>将文件拖到此处,或<em>点击上传</em></div>
|
|
|
+ <div v-if="accept"><span>只能上传{{ accept }}文件</span></div>
|
|
|
+ </div>
|
|
|
</el-upload>
|
|
|
</div>
|
|
|
<div class="line" v-if="fileList.length > 0"></div>
|
|
@@ -44,6 +49,69 @@
|
|
|
</ul>
|
|
|
</div>
|
|
|
</div>
|
|
|
+ <el-dialog
|
|
|
+ custom-class="myUpload_dialog"
|
|
|
+ :visible.sync="dialogVisible"
|
|
|
+ width="500px"
|
|
|
+ :before-close="handleClose"
|
|
|
+ :append-to-body="true">
|
|
|
+ <div slot="title">提示信息<span class="title" ><i class="el-icon-warning"></i></span></div>
|
|
|
+ <div>
|
|
|
+ <div v-if="discontent.length>0">
|
|
|
+ <div class="content">
|
|
|
+ <div>
|
|
|
+ <i class="el-icon-error red"></i>
|
|
|
+ </div>
|
|
|
+ <div @click="showDiscontent = !showDiscontent">
|
|
|
+ <i class="el-icon-caret-right" v-if="!showDiscontent"></i>
|
|
|
+ <i class="el-icon-caret-bottom" v-else></i>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ 上传文件格式不正确
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-if="showDiscontent" class="list showList">
|
|
|
+ <!-- {{ discontent.map((item) => { return item.name;}).join(',') }} -->
|
|
|
+ <div v-for="(item,index) in discontent" :key="item.name">{{ item.name }}<span v-if="index != discontent.length-1">,</span></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-if="exist.length>0">
|
|
|
+ <div class="content">
|
|
|
+ <div>
|
|
|
+ <i class="el-icon-error red"></i>
|
|
|
+ </div>
|
|
|
+ <div @click="showExist = !showExist">
|
|
|
+ <i class="el-icon-caret-right" v-if="!showExist"></i>
|
|
|
+ <i class="el-icon-caret-bottom" v-else></i>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ 上传文件名称重复
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div v-if="showExist" class="showList">
|
|
|
+ <div class="list">{{ exist.map((item) => { return item.name;}).join(',') }}</div>
|
|
|
+ <div class="menu">
|
|
|
+ <div @click="choose(1)">
|
|
|
+ <i class="el-icon-check"></i>
|
|
|
+ <span>替换目标中的文件</span>
|
|
|
+ </div>
|
|
|
+ <div @click="choose(2)">
|
|
|
+ <i class="iconfont icon--skip"></i>
|
|
|
+ <span>跳过这些文件</span>
|
|
|
+ </div>
|
|
|
+ <!-- <div @click="choose(3)">
|
|
|
+ <i class="iconfont icon-wenbentihuan"></i>
|
|
|
+ <span>让我决定每个文件</span>
|
|
|
+ </div> -->
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+
|
|
|
+ </div>
|
|
|
+ <div slot="footer">
|
|
|
+ <el-button type="primary" size="small" @click="handleClose" >我知道了</el-button>
|
|
|
+ </div>
|
|
|
+ </el-dialog>
|
|
|
</div>
|
|
|
</template>
|
|
|
|
|
@@ -103,6 +171,11 @@ export default {
|
|
|
data() {
|
|
|
return {
|
|
|
discontent: [],
|
|
|
+ showDiscontent:false,
|
|
|
+ exist:[],
|
|
|
+ exist2:[],
|
|
|
+ showExist:false,
|
|
|
+ dialogVisible:false,
|
|
|
};
|
|
|
},
|
|
|
watch: {},
|
|
@@ -126,6 +199,11 @@ export default {
|
|
|
this.$emit("on-progress", event, file, fileList);
|
|
|
},
|
|
|
onChange(file, fileList) {
|
|
|
+ this.$nextTick(() => {
|
|
|
+ if(this.discontent.length>0 || this.exist.length>0){
|
|
|
+ this.open()
|
|
|
+ }
|
|
|
+ });
|
|
|
if (this.accept) {
|
|
|
var arr = this.accept.split(/,|,/g);
|
|
|
var fileType = file.name.substring(file.name.lastIndexOf("."));
|
|
@@ -136,31 +214,83 @@ export default {
|
|
|
this.discontent.push(file);
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- this.$emit("on-change", file);
|
|
|
- this.$nextTick(() => {
|
|
|
- if (this.discontent.length > 0) {
|
|
|
- var arr = this.discontent.map((item) => {
|
|
|
- return item.name;
|
|
|
- });
|
|
|
- this.$alert(`您上传的<span style='color:red'>${arr.join(",")}</span>等文件格式不正确,请上传<span style='color:blue'>${this.accept.replace(/,|,/g,",")}</span>等格式文件`,"提示",
|
|
|
- {
|
|
|
- dangerouslyUseHTMLString: true,
|
|
|
- confirmButtonText: "确定",
|
|
|
- type: "warning",
|
|
|
- callback: (action) => {
|
|
|
- this.discontent = [];
|
|
|
- },
|
|
|
- }
|
|
|
- );
|
|
|
+ if(this.fileList.length>0){
|
|
|
+ var index = this.fileList.findIndex(item =>{
|
|
|
+ return item.name == file.name || item.originalName == file.name
|
|
|
+ })
|
|
|
+ if(index != -1){
|
|
|
+ this.exist.push(file)
|
|
|
+ this.exist2.push(this.fileList[index])
|
|
|
+ return false
|
|
|
+ }else{
|
|
|
+ if(this.autoUpload){
|
|
|
+ this.uploadFile(file)
|
|
|
+ return false
|
|
|
+ }
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+ this.$emit("on-change", file);
|
|
|
+
|
|
|
},
|
|
|
onExceed(file, fileList) {
|
|
|
this.$emit("on-exceed", file, fileList);
|
|
|
},
|
|
|
- //查看图片
|
|
|
- checkFiles(file) {},
|
|
|
+ //查看文件
|
|
|
+ checkFiles(file) {
|
|
|
+ if(file.guid){
|
|
|
+
|
|
|
+ }else{
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //上传附件
|
|
|
+ uploadFile(file){
|
|
|
+ let formData = new FormData()
|
|
|
+ formData.append('sourceId',this.$constants.sourceId)
|
|
|
+ formData.append('files',file.raw)
|
|
|
+ this.$api.uploadFile(formData).then(response=>{
|
|
|
+ if(response.code == 200){
|
|
|
+ file.guid = response.data
|
|
|
+ file.raw.guid = response.data
|
|
|
+ this.$emit("on-change", file)
|
|
|
+ }
|
|
|
+
|
|
|
+ })
|
|
|
+ },
|
|
|
+ //打开提示弹窗
|
|
|
+ open(){
|
|
|
+ this.dialogVisible = true
|
|
|
+ },
|
|
|
+ //关闭弹窗
|
|
|
+ handleClose(){
|
|
|
+ this.dialogVisible = false
|
|
|
+ this.discontent = []
|
|
|
+ this.exist = []
|
|
|
+ this.exist2=[]
|
|
|
+ this.showDiscontent=false
|
|
|
+ this.showExist = false
|
|
|
+ },
|
|
|
+ //操作
|
|
|
+ choose(type){
|
|
|
+ switch(type){
|
|
|
+ case 1:
|
|
|
+ this.exist2.forEach((item,index)=>{
|
|
|
+ this.onRemove(item,this.fileList)
|
|
|
+ this.$emit("on-change", this.exist[index]);
|
|
|
+ this.uploadFile(this.exist[index])
|
|
|
+ })
|
|
|
+ this.handleClose()
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ this.handleClose()
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
},
|
|
|
};
|
|
|
</script>
|
|
@@ -183,6 +313,82 @@ export default {
|
|
|
display: none;
|
|
|
}
|
|
|
}
|
|
|
+.myUpload_dialog{
|
|
|
+ border: 2px solid var(--bg);
|
|
|
+ box-shadow: none;
|
|
|
+ --fs:15px;
|
|
|
+ i{
|
|
|
+ cursor: pointer;
|
|
|
+ }
|
|
|
+ .el-dialog__close{
|
|
|
+ color: black;
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+ .el-dialog__headerbtn{
|
|
|
+ top: 14px;
|
|
|
+ }
|
|
|
+ .el-dialog__header{
|
|
|
+ border-bottom: 2px solid var(--bg) !important;
|
|
|
+ color: red;
|
|
|
+ padding: 10px;
|
|
|
+ }
|
|
|
+ .el-dialog__body{
|
|
|
+ padding: 20px 10px;
|
|
|
+ }
|
|
|
+ .el-dialog__footer{
|
|
|
+ border-top:none !important;
|
|
|
+ }
|
|
|
+ .title{
|
|
|
+ margin-left: 10px;
|
|
|
+ }
|
|
|
+ .content{
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ padding: 5px 0px;
|
|
|
+ color: var(--bg);
|
|
|
+ font-size: var(--fs);
|
|
|
+ font-family: var(--fm);
|
|
|
+ font-weight: bold;
|
|
|
+ }
|
|
|
+ .red{
|
|
|
+ color: red;
|
|
|
+ }
|
|
|
+ .showList{
|
|
|
+ padding-left:var(--fs) ;
|
|
|
+ }
|
|
|
+ .list{
|
|
|
+ padding-top: 5px;
|
|
|
+ padding-bottom: 5px;
|
|
|
+ font-size: 14px;
|
|
|
+ display: flex;
|
|
|
+ flex-wrap: wrap;
|
|
|
+ // overflow: hidden;
|
|
|
+ // white-space: nowrap;
|
|
|
+ // text-overflow:ellipsis;
|
|
|
+ }
|
|
|
+ .menu{
|
|
|
+ font-size: 14px;
|
|
|
+ i{
|
|
|
+ font-size: 14px;
|
|
|
+ }
|
|
|
+ div{
|
|
|
+ font-family: var(--fm);
|
|
|
+ padding: 5px 0;
|
|
|
+ cursor: pointer;
|
|
|
+ color: var(--bg);
|
|
|
+ i{
|
|
|
+ color: blue;
|
|
|
+ }
|
|
|
+ span{
|
|
|
+ margin-left:10px
|
|
|
+ }
|
|
|
+ }
|
|
|
+ div:hover{
|
|
|
+ background: #85afd9;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
</style>
|
|
|
<style lang="scss" scoped>
|
|
|
.myUpload {
|