|
@@ -1,33 +1,11 @@
|
|
|
<template>
|
|
|
<div class="upload">
|
|
|
- <el-upload
|
|
|
- v-if="isBtn()"
|
|
|
- :platformId="platformId"
|
|
|
- :action="action"
|
|
|
- :headers="headers"
|
|
|
- :multiple="multiple"
|
|
|
- :data="data"
|
|
|
- :name="name"
|
|
|
- :show-file-list="showFileList"
|
|
|
- :drag="drag"
|
|
|
- :accept="accept"
|
|
|
- :listType="listType"
|
|
|
- :autoUpload="autoUpload"
|
|
|
- :disabled="disabled"
|
|
|
- :before-upload="beforeUpload"
|
|
|
- :on-progress="onProgress"
|
|
|
- :on-success="onSuccess"
|
|
|
- :on-error="onError"
|
|
|
- :width="width"
|
|
|
- :height="height"
|
|
|
- >
|
|
|
+ <el-upload v-if="isBtn()" :platformId="platformId" :action="action" :headers="headers" :multiple="multiple"
|
|
|
+ :data="data" :name="name" :show-file-list="showFileList" :drag="drag" :accept="accept" :listType="listType"
|
|
|
+ :autoUpload="autoUpload" :disabled="disabled" :before-upload="beforeUpload" :on-progress="onProgress"
|
|
|
+ :on-success="onSuccess" :on-error="onError" :width="width" :height="height">
|
|
|
<!-- <el-button v-if="listType !== 'picture-card'" :type="type" ref="upload"> -->
|
|
|
- <el-button
|
|
|
- v-if="listType !== 'picture-card'"
|
|
|
- type="primary"
|
|
|
- size="mini"
|
|
|
- ref="upload"
|
|
|
- >
|
|
|
+ <el-button v-if="listType !== 'picture-card'" type="primary" size="mini" ref="upload">
|
|
|
<slot v-if="percentage <= 0 && !form.file">点击上传</slot>
|
|
|
<span v-if="percentage > 0 && !form.file">{{ title }}</span>
|
|
|
<span v-if="form.file">上传成功</span>
|
|
@@ -36,14 +14,8 @@
|
|
|
<i class="el-icon-plus" />
|
|
|
</div>
|
|
|
</el-upload>
|
|
|
- <el-progress
|
|
|
- v-if="isPercentage()"
|
|
|
- type="circle"
|
|
|
- :percentage="percentage"
|
|
|
- :status="status"
|
|
|
- @click.native="handleUpload"
|
|
|
- :width="146"
|
|
|
- />
|
|
|
+ <el-progress v-if="isPercentage()" type="circle" :percentage="percentage" :status="status"
|
|
|
+ @click.native="handleUpload" :width="146" />
|
|
|
<div class="img" v-if="isImg()">
|
|
|
<i class="el-icon-delete" v-if="!disabled" @click="onDelete" />
|
|
|
<el-image :src="form.file" />
|
|
@@ -106,11 +78,11 @@ export default {
|
|
|
},
|
|
|
// 图片尺寸
|
|
|
width: {
|
|
|
- type: String,
|
|
|
+ type: Number,
|
|
|
default: null,
|
|
|
},
|
|
|
height: {
|
|
|
- type: String,
|
|
|
+ type: Number,
|
|
|
default: null,
|
|
|
},
|
|
|
// 文件大小
|
|
@@ -181,10 +153,14 @@ export default {
|
|
|
var platformId = this.$props.platformId;
|
|
|
this.form.platformId = platformId;
|
|
|
this.data.platformId = platformId;
|
|
|
-
|
|
|
+ // console.log("beforeUpload:", this.width, this.height)
|
|
|
if (this.width && this.height) {
|
|
|
- var w = Number(this.width);
|
|
|
- var h = Number(this.height);
|
|
|
+ // var w = Number(this.width);
|
|
|
+ // var h = Number(this.height);
|
|
|
+ // 检查并转换 width 和 height 为数字
|
|
|
+ const w = typeof this.width === 'String' ? Number(this.width) : this.width;
|
|
|
+ const h = typeof this.height === 'String' ? Number(this.height) : this.height;
|
|
|
+ // console.log("传入的:", w, h, "666", typeof this.height === 'string')
|
|
|
const data = await this.readerImg(file);
|
|
|
let _width =
|
|
|
data.width % w === 0 || w % data.width === 0 ? true : false;
|