Commit e15e46d6 authored by wangxl's avatar wangxl

667777

parent dfeb92bf
...@@ -78,7 +78,6 @@ export default { ...@@ -78,7 +78,6 @@ export default {
item.fileName = files[0].name item.fileName = files[0].name
item.downloadUrl = data.downloadUrl item.downloadUrl = data.downloadUrl
item.downloadId = data.id item.downloadId = data.id
console.log(item, data)
} else } else
this.$message.error('上传失败') this.$message.error('上传失败')
}).catch(() => { }).catch(() => {
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
<div class="upload-layout"> <div class="upload-layout">
<div v-if="file.downloadUrl" class="file-box"> <div v-if="file.downloadUrl" class="file-box">
<div> <div>
<a-icon type="file" style="margin-right: 8px" /> <a-icon type="file" style="margin-right: 6px" />
<span class="hover-pointer" @click="downloadfile">{{file.fileName}}</span> <span class="hover-pointer" style="color:blue;text-decoration:underline;font-size: 16px;" @click="downloadfile">{{file.fileName}}</span>
</div> </div>
<a-icon type="delete" class="hover-pointer" @click="deletefile" style="margin-left: 8px" /> <a-icon type="delete" class="hover-pointer" @click="deletefile" style="margin-left: 8px" />
</div> </div>
...@@ -21,23 +21,33 @@ export default { ...@@ -21,23 +21,33 @@ export default {
name: "FileUpload", name: "FileUpload",
data () { data () {
return { return {
file: { ...File },
}; };
}, },
props: { props: {
value: { file: {
type: String, type: Object,
default: () => {
return { ...File }
}
},
isUpload: {
type: Boolean,
default () { default () {
return null return false
} }
} },
format: {
type: Array,
default () {
return []
}
},
}, },
created () { created () {
this.fileLoad(this.value) console.log(this.format)
}, },
methods: { methods: {
fileLoad (value) {
},
fileSelect () { fileSelect () {
let fileElem = this.$refs['fileElem'] let fileElem = this.$refs['fileElem']
if (fileElem) { if (fileElem) {
...@@ -51,16 +61,60 @@ export default { ...@@ -51,16 +61,60 @@ export default {
this.$message.error('未选中文件,请尝试重新选择') this.$message.error('未选中文件,请尝试重新选择')
return return
} }
this.file.fileName = files[0].name if (!this.fileCheck(files[0]))
this.file.downloadUrl = '/' + files[0].name return
this.$emit("beforeUpload", files[0]); 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 () { deletefile () {
this.file = { ...File }
this.$emit("cancel"); 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) { uploadHandle (file, fileName) {
let formData = new FormData() let formData = new FormData()
...@@ -68,11 +122,14 @@ export default { ...@@ -68,11 +122,14 @@ export default {
formData.append('fileName', fileName) formData.append('fileName', fileName)
return formData return formData
}, },
downloadfile () {
},
}, },
watch: { watch: {
value: { value: {
handler (value) { handler (value) {
this.selected = value
}, },
} }
} }
......
...@@ -447,12 +447,27 @@ ...@@ -447,12 +447,27 @@
</div> </div>
</a-col> </a-col>
</a-row> </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"> <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> </div>
</a-col> </a-col>
</a-row> </a-row>
<a-row type="flex">
<a-col :span="24">
</a-col>
</a-row>
<!-- 附件 --> <!-- 附件 -->
<file-edit :fileList.sync="formData.fileList" /> <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