| | |
| | | <template v-if="listType=='picture-card'"> |
| | | <el-image |
| | | ref="previewImg" |
| | | :src="file.url" |
| | | :src="file.url.includes('http') ? file.url : $qxueyou.qxyRes + file.url" |
| | | :initial-index="initialPreviewImgIndex" |
| | | :preview-src-list="filterPreviewImgList" |
| | | > |
| | |
| | | </template> |
| | | |
| | | <script> |
| | | import { getFileUrlName } from '@/utils/tool.js' |
| | | const pdf = 'application/pdf' |
| | | const xls = 'application/vnd.ms-excel,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' |
| | | const doc = 'application/msword,application/vnd.openxmlformats-officedocument.wordprocessingml.document' |
| | | const image = 'image/*' |
| | | const jpg = 'image/jpeg' |
| | | const png = 'image/png' |
| | | const zip = 'application/zip,application/x-zip-compressed' |
| | | import { genFileId } from 'element-plus' |
| | | export default { |
| | | data() { |
| | |
| | | accept: { |
| | | type: Array, |
| | | default: () => { |
| | | return ['pdf', 'xls', 'doc', 'image', 'jpg', 'png'] |
| | | return ['pdf', 'xls', 'doc', 'image', 'jpg', 'png', 'zip'] |
| | | } |
| | | }, |
| | | limitFileCount: { |
| | |
| | | modelValue: { |
| | | handler: function() { |
| | | this.list = this.modelValue |
| | | this.list.forEach(ele => { |
| | | if (!ele.name) { |
| | | ele.name = getFileUrlName(ele.url) |
| | | } |
| | | }) |
| | | }, |
| | | immediate: true, |
| | | deep: true |
| | | }, |
| | | list: { |
| | | handler: function(val) { |
| | | this.$emit('update:modelValue', val) |
| | | }, |
| | | immediate: true, |
| | | deep: true |
| | | } |
| | | }, |
| | | computed: { |
| | | acceptType() { |
| | | let obj = { pdf, xls, doc, image, jpg, png } |
| | | let obj = { pdf, xls, doc, image, jpg, png, zip } |
| | | return this.accept.map(ele => obj[ele]).join(',') |
| | | }, |
| | | tip() { |
| | |
| | | doc: 'WORD', |
| | | image: '图片', |
| | | jpg: 'JPEG/JPG', |
| | | png: 'PNG' |
| | | png: 'PNG', |
| | | zip: 'ZIP' |
| | | } |
| | | let tip = this.accept.map(ele => obj[ele]).join('、') |
| | | return `支持${tip}类型文件` |
| | |
| | | file: UploadRequestOptions.file, |
| | | directory: '' |
| | | } |
| | | this.$axios.post('/infra/file/upload', data, { |
| | | this.$axios.post('/infra/file/exam/upload', data, { |
| | | headers: { 'Content-Type': "multipart/form-data" } |
| | | }).then(res => { |
| | | let index = this.list.findIndex(ele => ele.uid == data.file.uid) |