wwf
22 小时以前 737179a0ce34147269cccf288fecd0e7bb4c309b
src/views/main/components/UploadBtn.vue
@@ -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}类型文件`