Commit e15e46d6 authored by wangxl's avatar wangxl

667777

parent dfeb92bf
......@@ -78,7 +78,6 @@ export default {
item.fileName = files[0].name
item.downloadUrl = data.downloadUrl
item.downloadId = data.id
console.log(item, data)
} else
this.$message.error('上传失败')
}).catch(() => {
......
......@@ -2,8 +2,8 @@
<div class="upload-layout">
<div v-if="file.downloadUrl" class="file-box">
<div>
<a-icon type="file" style="margin-right: 8px" />
<span class="hover-pointer" @click="downloadfile">{{file.fileName}}</span>
<a-icon type="file" style="margin-right: 6px" />
<span class="hover-pointer" style="color:blue;text-decoration:underline;font-size: 16px;" @click="downloadfile">{{file.fileName}}</span>
</div>
<a-icon type="delete" class="hover-pointer" @click="deletefile" style="margin-left: 8px" />
</div>
......@@ -21,23 +21,33 @@ export default {
name: "FileUpload",
data () {
return {
file: { ...File },
};
},
props: {
value: {
type: String,
file: {
type: Object,
default: () => {
return { ...File }
}
},
isUpload: {
type: Boolean,
default () {
return null
return false
}
},
format: {
type: Array,
default () {
return []
}
},
},
created () {
this.fileLoad(this.value)
console.log(this.format)
},
methods: {
fileLoad (value) {
},
fileSelect () {
let fileElem = this.$refs['fileElem']
if (fileElem) {
......@@ -51,16 +61,60 @@ export default {
this.$message.error('未选中文件,请尝试重新选择')
return
}
if (!this.fileCheck(files[0]))
return
if (this.isUpload) {
this.$api.base.asyncUpload(this.uploadHandle(files[0], files[0].name)).then(({ data = {} }) => {
if (data) {
this.file.fileName = files[0].name
this.file.downloadId = data.id
this.file.downloadUrl = data.downloadUrl
} else
this.$message.error('上传失败')
}).catch(() => {
this.$message.error('上传失败')
})
} else {
this.file.fileName = files[0].name
this.file.downloadUrl = '/' + files[0].name
this.$emit("beforeUpload", files[0]);
}
},
downloadfile () {
fileCheck (file) {
//判断是否小于1M
let isLtSize = file.size < 1024 * 1024 * 15;
if (!isLtSize) {
this.$message.error('文件大小不能超过15M!');
return false
}
var fileNames = file.name.split('.')
var fileType = fileNames[fileNames.length - 1].toLocaleLowerCase()
if (!!this.format && this.format.length > 0) {
var extList = this.format
if (!extList.find((item) => item == fileType)) {
this.$message.error('文件格式错误!')
return false
}
}
return true
},
deletefile () {
this.file = { ...File }
this.$emit("cancel");
if (this.isUpload) {
this.$api.base.deletefile({ id: this.file.downloadId }).then(({ data = {} }) => {
if (data) {
this.file.fileName = null
this.file.downloadUrl = null
this.file.downloadId = null
}
}).catch(() => {
this.$message.error('删除失败')
})
} else {
this.file.fileName = null
this.file.downloadUrl = null
this.file.downloadId = null
}
},
uploadHandle (file, fileName) {
let formData = new FormData()
......@@ -68,11 +122,14 @@ export default {
formData.append('fileName', fileName)
return formData
},
downloadfile () {
},
},
watch: {
value: {
handler (value) {
this.selected = value
},
}
}
......
......@@ -447,12 +447,27 @@
</div>
</a-col>
</a-row>
<a-row>
<a-row type="flex">
<a-col :span="24" class="bg-gray">
<div class="special-middle" style="font-weight: bold;text-align: center;">
<span style="color: red;margin-left: 42px;">注:正文部分需要下载模版,填写完成后上传到系统中,格式 .doc,.docx。</span>
</div>
</a-col>
</a-row>
<a-row type="flex">
<a-col :span="24">
<div>
<div style="height:42px;line-height: 42px;text-align: center;">
<a :href="'/downloadFile/textTemplate.docx'" download="申请书正文.docx">
<a-icon type="download"></a-icon>&nbsp;<span style="color:green;text-decoration:underline;font-size: 16px;">正文模板下载</span>
</a>
<up-load :isUpload="true" :file.sync="formData" :format="['doc', 'docx']"/>
</div>
</a-col>
</a-row>
<a-row type="flex">
<a-col :span="24">
</a-col>
</a-row>
<!-- 附件 -->
<file-edit :fileList.sync="formData.fileList" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment