wwf
16 小时以前 4e6f18dfa08e2f2f4f02aaa1b8e8e51852b7a9a1
src/views/main/components/UploadBtn.vue
@@ -38,7 +38,7 @@
      <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"
        >
@@ -77,12 +77,14 @@
</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() {
@@ -101,7 +103,7 @@
    accept: {
      type: Array,
      default: () => {
        return ['pdf', 'xls', 'doc', 'image', 'jpg', 'png']
        return ['pdf', 'xls', 'doc', 'image', 'jpg', 'png', 'zip']
      }
    },
    limitFileCount: {
@@ -123,19 +125,26 @@
    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() {
@@ -145,7 +154,8 @@
        doc: 'WORD',
        image: '图片',
        jpg: 'JPEG/JPG',
        png: 'PNG'
        png: 'PNG',
        zip: 'ZIP'
      }
      let tip = this.accept.map(ele => obj[ele]).join('、')
      return `支持${tip}类型文件` 
@@ -167,7 +177,7 @@
        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)