You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
137 lines
3.6 KiB
137 lines
3.6 KiB
<script>
|
|
import {uploadFileList} from '@/api/base/baseFunction.js';
|
|
export default {
|
|
name: "uploadFileList",
|
|
props: {
|
|
uploadDialog: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
title: {
|
|
type: String,
|
|
default: '上传文件',
|
|
},
|
|
label: {
|
|
type: String,
|
|
default: '',
|
|
},
|
|
no: {
|
|
type: [String,Number],
|
|
default: ''
|
|
},
|
|
path: {
|
|
type: String,
|
|
request: true,
|
|
},
|
|
uploadStatus: {
|
|
type: Boolean,
|
|
default: false,
|
|
},
|
|
fileList: {
|
|
type: Array,
|
|
default:() => [],
|
|
},
|
|
folder: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
orderRef3: {
|
|
type: [String,Number],
|
|
default: ''
|
|
},
|
|
orderRef4: {
|
|
type: [String,Number],
|
|
default: ''
|
|
},
|
|
},
|
|
data () {
|
|
return {
|
|
//fileRemark: '',
|
|
}
|
|
},
|
|
methods: {
|
|
closeFileUpdate () {
|
|
this.$emit('update:uploadDialog',false)
|
|
if (this.uploadStatus) {
|
|
return
|
|
}
|
|
//this.fileRemark = ''
|
|
this.$refs.uploadFile.clearFiles()
|
|
this.$emit("update:fileList",[])
|
|
},
|
|
onRemove (file,fileList) {
|
|
this.$emit("update:fileList",fileList)
|
|
},
|
|
onChange (file,fileList) {
|
|
this.$emit("update:fileList",fileList)
|
|
},
|
|
upload () {
|
|
if (this.fileList.length === 0) {
|
|
this.$message.warning("未选择需要上传的文件")
|
|
return;
|
|
}
|
|
if (this.uploadStatus) {
|
|
this.$emit('update:uploadDialog',false)
|
|
this.$message.success("操作成功")
|
|
return
|
|
}
|
|
let data = new FormData()
|
|
for (let i = 0; i < this.fileList.length; i++) {
|
|
data.append("file",this.fileList[i].raw)
|
|
}
|
|
data.append("orderRef1", this.$store.state.user.site)
|
|
data.append("orderRef2", this.no)
|
|
data.append("orderRef3", this.orderRef3)
|
|
data.append("orderRef4", this.orderRef4)
|
|
data.append("createBy", this.$store.state.user.name)
|
|
//data.append("fileRemark", this.fileRemark)
|
|
data.append("folder", this.folder)
|
|
uploadFileList(this.path, data).then(({data})=>{
|
|
if (data && data.code === 0) {
|
|
this.$emit('update:uploadDialog',false)
|
|
this.$message.success(data.msg)
|
|
} else {
|
|
this.$message.warning(data.msg)
|
|
}
|
|
}).catch((error) => {
|
|
this.$message.error(error)
|
|
})
|
|
}
|
|
}
|
|
}
|
|
</script>
|
|
|
|
<template>
|
|
<div>
|
|
<el-dialog :title="title" v-drag @close="closeFileUpdate" :visible="uploadDialog" width="400px" append-to-body>
|
|
<el-form label-position="top" label-width="80px">
|
|
<el-form-item :label="label" >
|
|
<el-input v-model="no" readonly style="width: 120px"></el-input>
|
|
</el-form-item>
|
|
<el-form-item label=" ">
|
|
<el-upload drag :file-list="fileList"
|
|
ref="uploadFile"
|
|
:on-remove="onRemove" :on-change="onChange"
|
|
multiple :auto-upload="false"
|
|
style="text-align: left;">
|
|
<i class="el-icon-upload"></i>
|
|
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
|
|
</el-upload>
|
|
</el-form-item>
|
|
<!-- <el-form-item label="备注:">-->
|
|
<!-- <el-input type="textarea" placeholder="请输入内容" v-model="fileRemark"></el-input>-->
|
|
<!-- </el-form-item>-->
|
|
</el-form>
|
|
<span slot="footer" class="dialog-footer">
|
|
<el-button type="primary" v-if="!uploadStatus" @click="upload">保存</el-button>
|
|
<el-button type="primary" @click="$emit('update:uploadDialog',false)">关闭</el-button>
|
|
</span>
|
|
</el-dialog>
|
|
</div>
|
|
</template>
|
|
|
|
<style scoped>
|
|
/deep/ .el-form-item--medium .el-form-item__content{
|
|
height: auto;
|
|
}
|
|
</style>
|