删除无引用的上传组件
This commit is contained in:
@@ -1,368 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="app-container">
|
|
||||||
<div class="listconadd">
|
|
||||||
<el-form ref="dataForm" :model="formobj" class="formaddcopy02">
|
|
||||||
<!-- <div class="headtitle"><span>系列:{{ formobj.productLineValue }}<span style="margin-left: 20px">驱动:{{ formobj.driveFormValue }}<span style="margin-left: 20px">功能:{{ formobj.vehicleTypeValue }}<span style="margin-left: 20px">马力:{{ formobj.powerValue }}</span></span></span></span></div>-->
|
|
||||||
<div class="headtitle_con">
|
|
||||||
<div class="headtitle">
|
|
||||||
{{ formobj.vehicleAlias }}
|
|
||||||
<div class="headtitle_jia">销售指导价:<span>{{ guidedPrice }} 万元</span></div>
|
|
||||||
<div class="icon_sty" @click="changeDown(false)" v-show="isDown">
|
|
||||||
<i class="el-icon-arrow-down"/>
|
|
||||||
<span>展开</span>
|
|
||||||
</div>
|
|
||||||
<div class="icon_sty" @click="changeUp(true)" v-show="!isDown">
|
|
||||||
<i class="el-icon-arrow-up"/>
|
|
||||||
<span>收起</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>品牌</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.brandName }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>功能</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.vehicleTypeValue }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>系列</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.productLineValue }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>驱动</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.driveFormValue }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4">
|
|
||||||
<div class="span-sty"><span>马力</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.powerValue }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>版本</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.vehicleVersionValue }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>燃料</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.fuelTypeValue }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="14">
|
|
||||||
<div class="span-sty"><span>变速箱</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.gearboxTypeValue }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</div>
|
|
||||||
<div class="more_content" v-show="!isDown">
|
|
||||||
<div class="headline">车型信息</div>
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>排放标准</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo addinputwTwo">{{ formobj.emissionStandardValue }}</span>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>发动机型号</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo addinputwTwo">{{ formobj.engineTypeValue }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>细分市场</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo addinputwTwo">{{ formobj.marketSegmentsValue }}</span>
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>规格型号</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo addinputwTwo">{{ formobj.specifications }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4">
|
|
||||||
<div class="span-sty"><span>系别</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo addinputwTwo">{{ formobj.departmentValue }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<div class="headline">常用配置</div>
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>后桥</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.rearAxleValue }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>速比</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.rearAxleRatio }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>轴距</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.wheelbase }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>悬架</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.suspension }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4">
|
|
||||||
<div class="span-sty"><span>鞍座</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.saddle }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>颜色</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.carColor }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>驾驶室</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.specification }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>保险杠</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.bumper }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>燃料箱</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.fuelTank }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4">
|
|
||||||
<div class="span-sty"><span>导流罩</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.baffleModel }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>独立热源</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.independentSources }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>缓速器</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.slowMachine }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>护轮罩</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.tireCover }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>后视镜</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.rearViewMirror }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4">
|
|
||||||
<div class="span-sty"><span>轮胎</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.tireSize }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<el-row>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>轮毂材质</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.hubMaterial }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>空调</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.airConditioner }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>座椅</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.seat }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="5">
|
|
||||||
<div class="span-sty"><span>多媒体</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.multimedia }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
<el-col :span="4">
|
|
||||||
<div class="span-sty"><span>配置包</span></div>
|
|
||||||
<el-form-item><span class="addinputInfo">{{ formobj.configuringBao }}</span></el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
<div class="headline">
|
|
||||||
更多配置
|
|
||||||
<div class="icon_sty" @click="changeDownOtherConfig(false)" v-show="isDownOther">
|
|
||||||
<i class="el-icon-arrow-down"/>
|
|
||||||
<span>展开</span>
|
|
||||||
</div>
|
|
||||||
<div class="icon_sty" @click="changeUpOtherConfig(true)" v-show="!isDownOther">
|
|
||||||
<i class="el-icon-arrow-up"/>
|
|
||||||
<span>收起</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<el-row v-show="!isDownOther">
|
|
||||||
<el-col :span="24">
|
|
||||||
<el-form-item>{{ formobj.otherConfig }}</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</div>
|
|
||||||
</el-form>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { selectExiCarConfig } from '@/api/vehicleModel/vehicleconfiguration.js'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
name: 'chexingpeizhibiaozhun',
|
|
||||||
props: {
|
|
||||||
params: {
|
|
||||||
type: Object
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
FormLoading: false,
|
|
||||||
priceValidity: '',
|
|
||||||
guidedPrice: '',
|
|
||||||
formobj: {},
|
|
||||||
isDown: true,
|
|
||||||
isDownOther: true,
|
|
||||||
sid_list: {
|
|
||||||
modelSid: '',
|
|
||||||
configSid: '',
|
|
||||||
vehModelConfigSid: '',
|
|
||||||
userSid: window.sessionStorage.getItem('userSid')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
params: {
|
|
||||||
deep: true,
|
|
||||||
immediate: false,
|
|
||||||
handler(newVal, oldVal) {
|
|
||||||
if (newVal.configSid !== '' && newVal.modelSid !== '') {
|
|
||||||
this.guidedPrice = newVal.guidedPrice
|
|
||||||
selectExiCarConfig({
|
|
||||||
modelSid: newVal.modelSid,
|
|
||||||
configSid: newVal.configSid,
|
|
||||||
vehModelConfigSid: newVal.vehModelConfigSid
|
|
||||||
}).then((response) => {
|
|
||||||
this.FormLoading = false
|
|
||||||
if (response.success) {
|
|
||||||
this.formobj = response.data
|
|
||||||
} else {
|
|
||||||
this.$message({
|
|
||||||
showClose: true,
|
|
||||||
message: '查看失败!',
|
|
||||||
type: 'error'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
this.formobj = {}
|
|
||||||
this.guidedPrice = ''
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 控制标题展开和收起
|
|
||||||
changeDown(val) {
|
|
||||||
this.isDown = val
|
|
||||||
},
|
|
||||||
changeUp(val) {
|
|
||||||
this.isDown = val
|
|
||||||
},
|
|
||||||
// 控制更多配置展开和收起
|
|
||||||
changeDownOtherConfig(val) {
|
|
||||||
this.isDownOther = val
|
|
||||||
},
|
|
||||||
changeUpOtherConfig(val) {
|
|
||||||
this.isDownOther = val
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
<style scoped>
|
|
||||||
/* 标题头部的样式 */
|
|
||||||
.headtitle {
|
|
||||||
padding: 9px;
|
|
||||||
/*font-weight: bold;*/
|
|
||||||
font-size: 20px;
|
|
||||||
background-color: #0294d7;
|
|
||||||
text-align: left;
|
|
||||||
color: #ffffff;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 内容头部的样式 */
|
|
||||||
.headline {
|
|
||||||
padding: 9px;
|
|
||||||
/*font-weight: bold;*/
|
|
||||||
font-size: 16px;
|
|
||||||
background-color: #0294d7;
|
|
||||||
text-align: left;
|
|
||||||
color: #ffffff;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 标题中内容的样式 */
|
|
||||||
.formaddcopy02 .headtitle_con .span-sty {
|
|
||||||
font-size: 16px;
|
|
||||||
width: 88px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.formaddcopy02 .headtitle_con .addinputInfo {
|
|
||||||
font-size: 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.formaddcopy02 .headtitle_con /deep/ .el-form-item__content {
|
|
||||||
font-size: 16px;
|
|
||||||
line-height: 15px !important;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: flex-start;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 内容部分中内容的样式 */
|
|
||||||
.formaddcopy02 .more_content .span-sty {
|
|
||||||
font-size: 16px;
|
|
||||||
width: 88px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.formaddcopy02 .more_content /deep/ .el-form-item__content {
|
|
||||||
font-size: 16px;
|
|
||||||
line-height: 15px !important;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: flex-start;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.formaddcopy02 .headtitle_con .headtitle .icon_sty .el-icon-arrow-down, .el-icon-arrow-up {
|
|
||||||
font-size: 14px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 标题部分的展开与收起按钮*/
|
|
||||||
.formaddcopy02 .headtitle_con .headtitle .icon_sty {
|
|
||||||
display: inline-block;
|
|
||||||
position: absolute;
|
|
||||||
font-size: 14px;
|
|
||||||
top: 14px;
|
|
||||||
right: 10px;
|
|
||||||
text-align: center;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 销售指导价的样式 */
|
|
||||||
.formaddcopy02 .headtitle_con .headtitle .headtitle_jia {
|
|
||||||
display: inline-block;
|
|
||||||
position: absolute;
|
|
||||||
right: 70px;
|
|
||||||
/*color: #d00000;*/
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 内容部分的展开与收起按钮 */
|
|
||||||
.formaddcopy02 .headline .icon_sty {
|
|
||||||
display: inline-block;
|
|
||||||
position: absolute;
|
|
||||||
font-size: 14px;
|
|
||||||
font-weight: bolder;
|
|
||||||
right: 10px;
|
|
||||||
text-align: center;
|
|
||||||
cursor: pointer;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 更多配置一行的内边距 */
|
|
||||||
.formaddcopy02 .more_content /deep/ .el-col-24 {
|
|
||||||
padding: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 更多配置一行的行高 */
|
|
||||||
.formaddcopy02 .more_content .el-col-24 /deep/ .el-form-item__content {
|
|
||||||
line-height: 28px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,166 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-upload ref="imgUpload" v-loading="loadding" class="avatar-uploader" :headers="accessToken"
|
|
||||||
:action="uploadFile" accept=".jpg,.jpeg,.png,.bmp,.pdf,.JPG,.JPEG,.BMP" list-type="picture-card"
|
|
||||||
:file-list="files" :on-remove="removeImage" :on-preview="handlePictureCardPreview"
|
|
||||||
:on-error="uploadError" :on-success="uploadImgSuccess_FuJian">
|
|
||||||
<i class="el-icon-plus avatar-uploader-icon"/>
|
|
||||||
</el-upload>
|
|
||||||
<el-dialog :visible.sync="dialogVisible" :append-to-body="true" title="查看图片">
|
|
||||||
<img width="100%" :src="dialogImageUrl" alt="">
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { uploadFile, deleteFilesOss } from '@/api/portal/Upload'
|
|
||||||
import { getStorage } from '@/utils/auth.js'
|
|
||||||
export default {
|
|
||||||
model: {
|
|
||||||
prop: 'name',
|
|
||||||
event: 'change'
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
bucket: {
|
|
||||||
type: String,
|
|
||||||
default: 'abc'
|
|
||||||
},
|
|
||||||
// 长度
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '270px'
|
|
||||||
},
|
|
||||||
limit: {
|
|
||||||
type: Number,
|
|
||||||
default: 1
|
|
||||||
},
|
|
||||||
accept: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
// 文件名称
|
|
||||||
name: {
|
|
||||||
type: Array,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
uploadData: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dialogImageUrl: '',
|
|
||||||
dialogVisible: false,
|
|
||||||
accessToken: null,
|
|
||||||
uploadFile: uploadFile,
|
|
||||||
fileList_FuJian: [],
|
|
||||||
enclosure: '',
|
|
||||||
file_add: '',
|
|
||||||
file_catch: '',
|
|
||||||
files: [],
|
|
||||||
files_list: [],
|
|
||||||
filedUrl: '',
|
|
||||||
isview: false,
|
|
||||||
nameArr: '',
|
|
||||||
loadding: false,
|
|
||||||
stateName: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
name: {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
handler(newVal, oldVal) {
|
|
||||||
console.log('aaaa1', newVal)
|
|
||||||
console.log('aaaa2', oldVal)
|
|
||||||
this.files = newVal
|
|
||||||
if (this.stateName === 'xunidingjinAdd') {
|
|
||||||
if (this.files.length > 1) {
|
|
||||||
this.files.splice(0, 1)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
console.log('aaaa2', this.files)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.Init()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.uploadFile = uploadFile // 接口
|
|
||||||
this.accessToken = {
|
|
||||||
token: getStorage()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
showImg(imgList) {
|
|
||||||
this.stateName = 'xunidingjinAdd'
|
|
||||||
this.files = imgList
|
|
||||||
console.log('回显图片', this.files)
|
|
||||||
},
|
|
||||||
view() {
|
|
||||||
// window.open(this.filedUrl)
|
|
||||||
},
|
|
||||||
// 页面第一次加载
|
|
||||||
Init() {
|
|
||||||
if (this.name !== undefined) {
|
|
||||||
this.files = []
|
|
||||||
for (var i = 0; i < this.name.length; i++) {
|
|
||||||
this.files.push({
|
|
||||||
name: this.name[i],
|
|
||||||
url: this.name[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 上传方案--成功后执行
|
|
||||||
uploadImgSuccess_FuJian(response, file, fileList) {
|
|
||||||
console.log('您选择的file:', file)
|
|
||||||
if (file.response.code === '200') {
|
|
||||||
this.loadding = false
|
|
||||||
// 返显图片
|
|
||||||
this.filedUrl = this.fileUrl + file.response.data
|
|
||||||
// var uid = file.response.data
|
|
||||||
this.files.push({
|
|
||||||
name: file.response.data.sourceFileName,
|
|
||||||
url: file.response.data.fullUrl,
|
|
||||||
size: file.response.data.size,
|
|
||||||
})
|
|
||||||
this.$emit('change', this.files)
|
|
||||||
this.$emit('eett', this.files)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
removeImage(file, ImageFileList) {
|
|
||||||
deleteFilesOss(file.url).then((res) => {
|
|
||||||
if (res.success) {
|
|
||||||
this.files.splice(this.files.indexOf(file), 1)
|
|
||||||
const imgFiles = []
|
|
||||||
|
|
||||||
this.files.forEach((o) => {
|
|
||||||
imgFiles.push(o.url)
|
|
||||||
})
|
|
||||||
this.$emit('fileChange', this.files)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
handlePictureCardPreview(file) {
|
|
||||||
this.dialogVisible = true
|
|
||||||
this.dialogImageUrl = file.url
|
|
||||||
},
|
|
||||||
// 上传失败
|
|
||||||
uploadError() {
|
|
||||||
this.loadding = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-upload class="upload-demo" :data="datas" :accept="accept" :on-success="uploadImgSuccess"
|
|
||||||
:on-change="handleChange" :on-remove="handleRemove" :file-list="fileList_FuJian"
|
|
||||||
:http-request="uploadSectionFile">
|
|
||||||
<el-button size="small" type="primary">点击上传</el-button>
|
|
||||||
<div slot="tip" class="el-upload__tip">单个文件大小不允许超过100M,支持上传文件类型:{{ accept }}</div>
|
|
||||||
</el-upload>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import {
|
|
||||||
uploadFile
|
|
||||||
} from '@/api/business/beiAn'
|
|
||||||
import {
|
|
||||||
mapGetters
|
|
||||||
} from 'vuex'
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
// 长度
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '270px',
|
|
||||||
},
|
|
||||||
accept: {
|
|
||||||
type: String,
|
|
||||||
default: '.jpg,.jpeg,.png,.bmp,.pdf,.JPG,.JPEG,.BMP,.PDF,.xls,.docx,.xlsx,.ppt,.pptx',
|
|
||||||
},
|
|
||||||
// 文件列表
|
|
||||||
files: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
// 文件名称
|
|
||||||
name: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
datas: null,
|
|
||||||
name:null,
|
|
||||||
accessToken: {},
|
|
||||||
fileList_FuJian: [],
|
|
||||||
enclosure: '',
|
|
||||||
file_add: '',
|
|
||||||
idsz: '',
|
|
||||||
file_catch: '',
|
|
||||||
files_list: [],
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapGetters([
|
|
||||||
'id',
|
|
||||||
'departmentCode',
|
|
||||||
'departmentLevel',
|
|
||||||
'departmentType',
|
|
||||||
'token',
|
|
||||||
]),
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
files: {
|
|
||||||
deep: true,
|
|
||||||
handler(val) {
|
|
||||||
this.pageLoad(val, '')
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
creatd() {
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
// this.Init()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 页面第一次加载
|
|
||||||
Init() {
|
|
||||||
// 1. 文件上传用token
|
|
||||||
// this.accessToken = {
|
|
||||||
// token: this.token,
|
|
||||||
// }
|
|
||||||
this.pageLoad(this.files)
|
|
||||||
},
|
|
||||||
handleChange(file, fileList) {},
|
|
||||||
// 传入数据并绑定
|
|
||||||
pageLoad(files) {
|
|
||||||
// console.log('传入:' + files)
|
|
||||||
if (files !== null && files !== '') {
|
|
||||||
this.files_list = JSON.parse(files)
|
|
||||||
var ids = ''
|
|
||||||
this.fileList_FuJian = []
|
|
||||||
// 1. 回显页面
|
|
||||||
for (var i = 0; i < this.files_list.length; i++) {
|
|
||||||
var body = {
|
|
||||||
name: this.files_list[i].name,
|
|
||||||
url: '',
|
|
||||||
status: 'finished',
|
|
||||||
}
|
|
||||||
this.fileList_FuJian.push(body)
|
|
||||||
ids = ids + this.files_list[i].id + ','
|
|
||||||
}
|
|
||||||
// 2. 回存文件id
|
|
||||||
if (ids !== '') {
|
|
||||||
ids = ids.substring(0, ids.length - 1)
|
|
||||||
}
|
|
||||||
this.enclosure = ids
|
|
||||||
this.file_catch = ids
|
|
||||||
} else {
|
|
||||||
this.file_add = ''
|
|
||||||
this.file_catch = ''
|
|
||||||
this.enclosure = ''
|
|
||||||
this.files_list = []
|
|
||||||
this.fileList_FuJian = []
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 上传方案--成功后执行
|
|
||||||
uploadImgSuccess(response, file, fileList) {
|
|
||||||
this.$emit('change', this.enclosure)
|
|
||||||
},
|
|
||||||
handleRemove(file, fileList) {
|
|
||||||
if (this.idsz != '') {
|
|
||||||
this.$emit('handleRemove', this.idsz)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 上传文件 FrontPhoto
|
|
||||||
uploadSectionFile(params) {
|
|
||||||
const file = params.file
|
|
||||||
// 根据后台需求数据格式
|
|
||||||
const form = new FormData()
|
|
||||||
// console.log('77777777777777',form)
|
|
||||||
// 文件对象
|
|
||||||
form.append('file', file)
|
|
||||||
// 项目封装的请求方法,下面做简单介绍
|
|
||||||
uploadFile(form).then((res) => {
|
|
||||||
// 自行处理各种情况
|
|
||||||
if (res.code === '200') {
|
|
||||||
let a = ''
|
|
||||||
a = res.data.filePath
|
|
||||||
this.idsz = a
|
|
||||||
this.$emit('handleSuccess', res)
|
|
||||||
}
|
|
||||||
if (res.msg == '操作成功') {
|
|
||||||
this.$message({
|
|
||||||
message: '上传成功!',
|
|
||||||
type: 'success',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(err)
|
|
||||||
// 如果等于备案,就调备案图片上传接口
|
|
||||||
})
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
|
||||||
@@ -1,131 +0,0 @@
|
|||||||
<template>
|
|
||||||
|
|
||||||
<el-upload ref="upload" class="avatar-uploader" action="imageUrl" :show-file-list="true" list-type="picture-card" :data="datas" :on-change="uploadchangeFile" :http-request="uploadSectionFile" :on-remove="onRemove">
|
|
||||||
<i class="el-icon-plus" />
|
|
||||||
<img v-if="FrontPhoto" :src="FrontPhoto" class="avatar">
|
|
||||||
<i v-else class="el-icon-plus avatar-uploader-icon" />
|
|
||||||
<div slot="tip" class="el-upload__tip">{{ tip }}</div>
|
|
||||||
</el-upload>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { imgUploadz } from '@/api/jichuxinxi/baseaffiliatcompany'
|
|
||||||
export default {
|
|
||||||
model: {
|
|
||||||
prop: 'types',
|
|
||||||
event: 'change'
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
tip: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
types: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
files: {
|
|
||||||
type: String,
|
|
||||||
required: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
FrontPhoto: '',
|
|
||||||
datas: null,
|
|
||||||
imgId: '',
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.datas = { type: this.types }
|
|
||||||
console.log(this.datas, 111111111111)
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 上传文件 FrontPhoto
|
|
||||||
uploadSectionFile(params) {
|
|
||||||
// console.log(params, 111111111111)
|
|
||||||
const file = params.file
|
|
||||||
const fileType = file.type
|
|
||||||
const isImage = fileType.indexOf('image') != -1
|
|
||||||
const isLt2M = file.size / 1024 / 1024 < 2
|
|
||||||
// console.log(params)
|
|
||||||
// 这里常规检验,看项目需求而定
|
|
||||||
if (!isImage) {
|
|
||||||
this.$message.error('只能上传图片格式png、jpg、gif、jpeg!')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!isLt2M) {
|
|
||||||
this.$message.error('只能上传图片大小小于2M')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 根据后台需求数据格式
|
|
||||||
const form = new FormData()
|
|
||||||
// console.log(form)
|
|
||||||
// 文件对象
|
|
||||||
form.append('file', file)
|
|
||||||
imgUploadz(form).then((res) => {
|
|
||||||
// 自行处理各种情况
|
|
||||||
if (res.code === '200') {
|
|
||||||
this.imgId = ''
|
|
||||||
res.data.attachType = this.types
|
|
||||||
this.imgId = res.data.filePath
|
|
||||||
this.$emit('imgdata', res)
|
|
||||||
}
|
|
||||||
// this.FrontPhoto = res.fullUrl
|
|
||||||
if (res.msg == '操作成功') {
|
|
||||||
this.$message({
|
|
||||||
message: '上传成功!',
|
|
||||||
type: 'success',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(err)
|
|
||||||
})
|
|
||||||
// 如果等于备案,就调备案图片上传接口
|
|
||||||
},
|
|
||||||
onRemove() {
|
|
||||||
if (this.imgId != '') {
|
|
||||||
this.$emit('removeIds', this.imgId)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
uploadchangeFile(file) {
|
|
||||||
this.FrontPhoto = URL.createObjectURL(file.raw)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.avatar-uploader .el-upload {
|
|
||||||
border: 1px dashed #d9d9d9;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-uploader .el-upload:hover {
|
|
||||||
border-color: #409eff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-uploader-icon {
|
|
||||||
font-size: 28px;
|
|
||||||
color: #8c939d;
|
|
||||||
width: 200px;
|
|
||||||
height: 178px;
|
|
||||||
line-height: 178px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar {
|
|
||||||
width: 178px;
|
|
||||||
height: 178px;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.el-upload__tip {
|
|
||||||
line-height: 25px;
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,159 +0,0 @@
|
|||||||
<template>
|
|
||||||
|
|
||||||
<el-upload ref="upload" class="avatar-uploader" action="imageUrl" :show-file-list="true" list-type="picture-card" :data="datas" :on-change="uploadchangeFile" :http-request="uploadSectionFile" :on-remove="onRemove">
|
|
||||||
<i class="el-icon-plus" />
|
|
||||||
<img v-if="FrontPhoto" :src="FrontPhoto" class="avatar">
|
|
||||||
<i v-else class="el-icon-plus avatar-uploader-icon" />
|
|
||||||
<div slot="tip" class="el-upload__tip">{{ tip }}</div>
|
|
||||||
</el-upload>
|
|
||||||
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { imageUpload } from '@/api/portal/Upload.js'
|
|
||||||
import { imgUploadz } from '@/api/jichuxinxi/baseaffiliatcompany' // 这个没用着
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
tip: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
types: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
linkChange: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
FrontPhoto: '',
|
|
||||||
imageUrl: imgUploadz,
|
|
||||||
datas: null,
|
|
||||||
imgId: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.datas = { type: this.types }
|
|
||||||
console.log(this.linkChange, 111111111111)
|
|
||||||
|
|
||||||
// console.log(this.datas, 11)
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 上传文件 FrontPhoto
|
|
||||||
uploadSectionFile(params) {
|
|
||||||
// console.log(params, 111111111111)
|
|
||||||
const file = params.file
|
|
||||||
const fileType = file.type
|
|
||||||
const isImage = fileType.indexOf('image') != -1
|
|
||||||
const isLt2M = file.size / 1024 / 1024 < 2
|
|
||||||
// console.log(params)
|
|
||||||
// 这里常规检验,看项目需求而定
|
|
||||||
if (!isImage) {
|
|
||||||
this.$message.error('只能上传图片格式png、jpg、gif、jpeg!')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!isLt2M) {
|
|
||||||
this.$message.error('只能上传图片大小小于2M')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 根据后台需求数据格式
|
|
||||||
const form = new FormData()
|
|
||||||
// console.log(form)
|
|
||||||
// 文件对象
|
|
||||||
form.append('file', file)
|
|
||||||
|
|
||||||
// 如果等于'', 就调挂靠公司图片上传的接口
|
|
||||||
// 项目封装的请求方法,下面做简单介绍
|
|
||||||
if (this.linkChange == '') {
|
|
||||||
imageUpload(form)
|
|
||||||
.then((res) => {
|
|
||||||
// 自行处理各种情况
|
|
||||||
if (res.code === '200') {
|
|
||||||
this.imgId = ''
|
|
||||||
res.data.attachType = this.types
|
|
||||||
this.imgId = res.data.filePath
|
|
||||||
this.$emit('imgdata', res)
|
|
||||||
}
|
|
||||||
// this.FrontPhoto = res.fullUrl
|
|
||||||
if (res.msg == '操作成功') {
|
|
||||||
this.$message({
|
|
||||||
message: '上传成功!',
|
|
||||||
type: 'success'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(err)
|
|
||||||
})
|
|
||||||
// 如果等于备案,就调备案图片上传接口
|
|
||||||
}
|
|
||||||
// else if (this.linkChange == 'keepOnRecord') {
|
|
||||||
// imageUpload(form)
|
|
||||||
// .then((res) => {
|
|
||||||
// // 自行处理各种情况
|
|
||||||
// if (res.code === '200') {
|
|
||||||
// this.imgId = ''
|
|
||||||
// res.data.attachType = this.types
|
|
||||||
// this.imgId = res.data.filePath
|
|
||||||
// this.$emit('imgdata', res)
|
|
||||||
// }
|
|
||||||
// // this.FrontPhoto = res.fullUrl
|
|
||||||
// if (res.msg == '操作成功') {
|
|
||||||
// this.$message({
|
|
||||||
// message: '上传成功!',
|
|
||||||
// type: 'success',
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
// .catch((err) => {
|
|
||||||
// console.log(err)
|
|
||||||
// })
|
|
||||||
// }
|
|
||||||
},
|
|
||||||
onRemove() {
|
|
||||||
if (this.imgId != '') {
|
|
||||||
this.$emit('removeIds', this.imgId)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
uploadchangeFile(file) {
|
|
||||||
this.FrontPhoto = URL.createObjectURL(file.raw)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.avatar-uploader .el-upload {
|
|
||||||
border: 1px dashed #d9d9d9;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-uploader .el-upload:hover {
|
|
||||||
border-color: #409eff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-uploader-icon {
|
|
||||||
font-size: 28px;
|
|
||||||
color: #8c939d;
|
|
||||||
width: 200px;
|
|
||||||
height: 178px;
|
|
||||||
line-height: 178px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar {
|
|
||||||
width: 178px;
|
|
||||||
height: 178px;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.el-upload__tip {
|
|
||||||
line-height: 25px;
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,214 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<div>
|
|
||||||
<el-upload ref="imgUpload" v-loading="loadding" class="avatar-uploader" :headers="accessToken"
|
|
||||||
:action="uploadFile" accept=".jpg,.jpeg,.png,.bmp,.pdf,.JPG,.JPEG,.BMP" list-type="picture-card"
|
|
||||||
:file-list="files" :on-remove="removeImage" :on-preview="handlePictureCardPreview" :on-progress="uploadProgrees"
|
|
||||||
:on-error="uploadError" :on-success="uploadImgSuccess_FuJian">
|
|
||||||
<i class="el-icon-plus avatar-uploader-icon" />
|
|
||||||
</el-upload>
|
|
||||||
<!-- <button @click="test()">test</button> -->
|
|
||||||
</div>
|
|
||||||
<el-dialog :visible.sync="showpicture" :append-to-body="true" title="查看图片">
|
|
||||||
<img width="100%" :src="dialogImageUrl" alt="">
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import {
|
|
||||||
uploadFile
|
|
||||||
} from '@/api/portal/Upload.js'
|
|
||||||
import {
|
|
||||||
getStorage
|
|
||||||
} from '@/utils/auth.js'
|
|
||||||
import {
|
|
||||||
mapGetters
|
|
||||||
} from 'vuex'
|
|
||||||
export default {
|
|
||||||
model: {
|
|
||||||
prop: 'imageFileList',
|
|
||||||
event: 'fileListChange'
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
// 长度
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '270px'
|
|
||||||
},
|
|
||||||
// 图片路径--全路径
|
|
||||||
imageFileList: {
|
|
||||||
type: Array,
|
|
||||||
required: []
|
|
||||||
},
|
|
||||||
num: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dialogImageUrl: '',
|
|
||||||
accessToken: null,
|
|
||||||
uploadFile: uploadFile,
|
|
||||||
files: [],
|
|
||||||
showpicture: false,
|
|
||||||
loadding: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapGetters([
|
|
||||||
'id',
|
|
||||||
'departmentCode',
|
|
||||||
'departmentLevel',
|
|
||||||
'departmentType',
|
|
||||||
'token'
|
|
||||||
])
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
imageFileList: {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
handler(newVal, oldVal) {
|
|
||||||
// debugger
|
|
||||||
console.log('aaaa1', newVal)
|
|
||||||
this.files = []
|
|
||||||
this.$nextTick(() => {
|
|
||||||
for (var i = 0; i < newVal.length; i++) {
|
|
||||||
// debugger
|
|
||||||
this.files.push({
|
|
||||||
name: newVal[i],
|
|
||||||
url: newVal[i],
|
|
||||||
// fullUrl: newVal[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.Init()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.uploadFile = uploadFile // 接口
|
|
||||||
this.accessToken = {
|
|
||||||
'token': getStorage()
|
|
||||||
}
|
|
||||||
console.log('token', this.accessToken)
|
|
||||||
// console.log('imageFileList', this.imageFileList)
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 页面第一次加载
|
|
||||||
Init() {
|
|
||||||
// 1. 文件上传用token
|
|
||||||
// this.accessToken = {
|
|
||||||
// token: this.token
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
console.log('aaaa2', this.imageFileList)
|
|
||||||
if (this.imageFileList !== undefined) {
|
|
||||||
this.files = []
|
|
||||||
for (var i = 0; i < this.imageFileList.length; i++) {
|
|
||||||
// console.log('aaaa', i)
|
|
||||||
this.files.push({
|
|
||||||
name: this.imageFileList[i],
|
|
||||||
url: this.imageFileList[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, // 上传方案--成功后执行
|
|
||||||
uploadImgSuccess_FuJian(response, file, ImageFileList) {
|
|
||||||
console.log('上传成功!')
|
|
||||||
// debugger
|
|
||||||
this.loadding = false
|
|
||||||
if (file.response.code === '200') {
|
|
||||||
// debugger
|
|
||||||
// 返显图片
|
|
||||||
this.dialogImageUrl = file.response.data.fullUrl
|
|
||||||
var uid = file.response.data
|
|
||||||
this.files.push({
|
|
||||||
name: file.response.data.sourceFileName,
|
|
||||||
url: file.response.data.fullUrl,
|
|
||||||
// url: file.response.data.fullUrl,
|
|
||||||
// fullUrl: file.response.data.fullUrl,
|
|
||||||
// size: file.response.data.size,
|
|
||||||
// sourceFileName: file.response.data.sourceFileName
|
|
||||||
})
|
|
||||||
const imgFiles = []
|
|
||||||
this.files.forEach(o => {
|
|
||||||
imgFiles.push(o.url)
|
|
||||||
})
|
|
||||||
this.$emit('fileListChange', imgFiles)
|
|
||||||
console.log('上传成功:' + JSON.stringify(this.files))
|
|
||||||
// this.$emit('fileChange', this.files)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
removeImage(file, ImageFileList) {
|
|
||||||
console.log('删除照片',file)
|
|
||||||
this.files.splice(this.files.indexOf(file), 1)
|
|
||||||
console.log('删除照片',this.files)
|
|
||||||
const imgFiles = []
|
|
||||||
this.files.forEach(o => {
|
|
||||||
imgFiles.push(o.url)
|
|
||||||
})
|
|
||||||
this.$emit('fileChange', this.files,imgFiles)
|
|
||||||
},
|
|
||||||
handlePictureCardPreview(file) {
|
|
||||||
// this.dialogImageUrl = file.url
|
|
||||||
// this.dialogImageUrl = file.fullUrl
|
|
||||||
this.dialogImageUrl = file.url
|
|
||||||
this.showpicture = true
|
|
||||||
},
|
|
||||||
// 上传失败
|
|
||||||
uploadError() {
|
|
||||||
this.loadding = false
|
|
||||||
},
|
|
||||||
uploadProgrees(event, file, fileList) {
|
|
||||||
if (Number(event.percent) > 0) {
|
|
||||||
this.loadding = true
|
|
||||||
}
|
|
||||||
// console.log('event:', event)
|
|
||||||
},
|
|
||||||
test() {
|
|
||||||
console.log('aaa', this.files)
|
|
||||||
this.$set(this.files, this.files)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
.avatar-uploader .el-upload {
|
|
||||||
border: 1px dashed #d9d9d9;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-uploader .el-upload:hover {
|
|
||||||
border-color: #409eff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-uploader-icon {
|
|
||||||
font-size: 28px;
|
|
||||||
color: #8c939d;
|
|
||||||
width: 100px;
|
|
||||||
height: 250px;
|
|
||||||
line-height: 100px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar {
|
|
||||||
width: 200px;
|
|
||||||
height: 200px;
|
|
||||||
display: block;
|
|
||||||
// float: left;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,116 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-upload class="avatar-uploader" ref="upload" :action="fakeaction" :show-file-list="false" :on-change="uploadchangeFile" :http-request="uploadSectionFile">
|
|
||||||
<!-- <el-button size="small" type="primary">点击上传</el-button> -->
|
|
||||||
<img v-if="Photo" :src="Photo" class="avatar">
|
|
||||||
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
|
||||||
<div slot="tip" class="el-upload__tip">{{tip}}</div>
|
|
||||||
</el-upload>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { imageUpload } from '@/api/Common/Upload.js'
|
|
||||||
export default {
|
|
||||||
props: {
|
|
||||||
tip: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
FrontPhoto: {
|
|
||||||
type: String,
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
Photo: this.FrontPhoto,
|
|
||||||
loading: null,
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
openFullScreen2() {
|
|
||||||
this.loading = this.$loading({
|
|
||||||
lock: true,
|
|
||||||
text: 'Loading',
|
|
||||||
spinner: 'el-icon-loading',
|
|
||||||
background: 'rgba(0, 0, 0, 0.7)',
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// 上传文件 FrontPhoto
|
|
||||||
uploadSectionFile(params) {
|
|
||||||
const file = params.file,
|
|
||||||
fileType = file.type,
|
|
||||||
isImage = fileType.indexOf('image') != -1,
|
|
||||||
isLt2M = file.size / 1024 / 1024 < 10
|
|
||||||
this.openFullScreen2()
|
|
||||||
console.log(params)
|
|
||||||
// 这里常规检验,看项目需求而定
|
|
||||||
if (!isImage) {
|
|
||||||
this.$message.error('只能上传图片格式png、jpg、gif!')
|
|
||||||
this.loading.close()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (!isLt2M) {
|
|
||||||
this.$message.error('只能上传图片大小小于10M')
|
|
||||||
this.loading.close()
|
|
||||||
return
|
|
||||||
}
|
|
||||||
// 根据后台需求数据格式
|
|
||||||
const form = new FormData()
|
|
||||||
console.log(form)
|
|
||||||
// 文件对象
|
|
||||||
form.append('file', file)
|
|
||||||
|
|
||||||
// 项目封装的请求方法,下面做简单介绍
|
|
||||||
imageUpload(form)
|
|
||||||
.then((res) => {
|
|
||||||
//自行处理各种情况
|
|
||||||
console.log(res)
|
|
||||||
this.$emit('imgUrl', res.data)
|
|
||||||
this.Photo = res.data.fullUrl
|
|
||||||
if (res.code == 200) {
|
|
||||||
this.loading.close()
|
|
||||||
this.$message({
|
|
||||||
message: '上传成功!',
|
|
||||||
type: 'success',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(err)
|
|
||||||
})
|
|
||||||
},
|
|
||||||
uploadchangeFile(file) {
|
|
||||||
// this.Photo = URL.createObjectURL(file.raw)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.avatar-uploader .el-upload {
|
|
||||||
border: 1px dashed #d9d9d9;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-uploader .el-upload:hover {
|
|
||||||
border-color: #409eff;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-uploader-icon {
|
|
||||||
font-size: 28px;
|
|
||||||
color: #8c939d;
|
|
||||||
width: 200px;
|
|
||||||
height: 178px;
|
|
||||||
line-height: 178px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar {
|
|
||||||
width: 178px;
|
|
||||||
height: 178px;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,252 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<!-- <el-upload class="upload-demo" :data="datas" :accept="accept" :on-success="uploadImgSuccess"-->
|
|
||||||
<!-- :on-change="handleChange" :on-remove="handleRemove" :file-list="fileList_FuJian"-->
|
|
||||||
<!-- :http-request="uploadSectionFile">-->
|
|
||||||
<!-- <el-button size="small" type="primary">点击上传</el-button>-->
|
|
||||||
<!-- <div slot="tip" class="el-upload__tip">单个文件大小不允许超过100M,支持上传文件类型:{{ accept }}</div>-->
|
|
||||||
<!-- </el-upload>-->
|
|
||||||
<!-- <el-upload list-type="picture-card" :on-preview="handlePictureCardPreview" :on-remove="handleRemove">-->
|
|
||||||
<!-- <i class="el-icon-plus"></i>-->
|
|
||||||
<!-- </el-upload>-->
|
|
||||||
<el-dialog :visible.sync="dialogVisible">
|
|
||||||
<img width="100%" :src="dialogImageUrl" alt="">
|
|
||||||
</el-dialog>
|
|
||||||
<el-upload class="upload-demo" :headers="accessToken" :action="uploadFile" :accept="accept" :data="uploadData"
|
|
||||||
:on-success="uploadImgSuccess_FuJian" :on-remove="handleRemove" :file-list="fileList_FuJian"
|
|
||||||
:on-preview="handlePictureCardPreview">
|
|
||||||
<el-button size="small" type="primary">点击上传</el-button>
|
|
||||||
<!-- <el-button v-show="isview" size="small" type="primary" @click="view()">查看</el-button> -->
|
|
||||||
<!-- <div slot="tip" class="el-upload__tip">单个文件大小不允许超过100M,支持上传文件类型:{{ accept }}</div> -->
|
|
||||||
</el-upload>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { uploadFile } from '@/api/portal/Upload.js'
|
|
||||||
import { getStorage } from '@/utils/auth.js' //token
|
|
||||||
import { mapGetters } from 'vuex'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
model: {
|
|
||||||
prop: 'name',
|
|
||||||
event: 'change'
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
bucket: {
|
|
||||||
type: String,
|
|
||||||
default: 'abc'
|
|
||||||
},
|
|
||||||
// 长度
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '270px'
|
|
||||||
},
|
|
||||||
limit: {
|
|
||||||
type: Number,
|
|
||||||
default: 1
|
|
||||||
},
|
|
||||||
accept: {
|
|
||||||
type: String,
|
|
||||||
default:
|
|
||||||
'.jpg,.jpeg,.png,.bmp,.pdf,.JPG,.JPEG,.BMP,.PDF,.xls,.docx,.xlsx,.ppt,.pptx'
|
|
||||||
},
|
|
||||||
// 文件名称
|
|
||||||
name: {
|
|
||||||
type: Array,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
uploadData: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dialogImageUrl: '',
|
|
||||||
dialogVisible: false,
|
|
||||||
accessToken: null,
|
|
||||||
uploadFile: uploadFile,
|
|
||||||
fileList_FuJian: [],
|
|
||||||
enclosure: '',
|
|
||||||
file_add: '',
|
|
||||||
file_catch: '',
|
|
||||||
files: [],
|
|
||||||
files_list: [],
|
|
||||||
filedUrl: '',
|
|
||||||
// fileUrl: fileUrl,
|
|
||||||
// showpicture:false,
|
|
||||||
isview: false,
|
|
||||||
nameArr: '',
|
|
||||||
loadding: false,
|
|
||||||
stateName: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapGetters([
|
|
||||||
'id',
|
|
||||||
'departmentCode',
|
|
||||||
'departmentLevel',
|
|
||||||
'departmentType',
|
|
||||||
'token'
|
|
||||||
])
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
name: {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
handler(newVal, oldVal) {
|
|
||||||
console.log('aaaa1', newVal)
|
|
||||||
this.files = newVal
|
|
||||||
// if (this.stateName = 'xunidingjinAdd') {
|
|
||||||
// if (this.files.length > 1) {
|
|
||||||
// this.files.splice(0, 1)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
console.log('aaaa2', this.files)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.Init()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.uploadFile = uploadFile // 接口
|
|
||||||
this.accessToken = {
|
|
||||||
token: getStorage()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
showImg(imgList) {
|
|
||||||
this.stateName = 'xunidingjinAdd'
|
|
||||||
this.files = imgList
|
|
||||||
console.log('回显图片', this.files)
|
|
||||||
},
|
|
||||||
view() {
|
|
||||||
// window.open(this.filedUrl)
|
|
||||||
},
|
|
||||||
// 页面第一次加载
|
|
||||||
Init() {
|
|
||||||
if (this.name !== undefined) {
|
|
||||||
this.files = []
|
|
||||||
for (var i = 0; i < this.name.length; i++) {
|
|
||||||
this.files.push({
|
|
||||||
name: this.name[i],
|
|
||||||
url: this.name[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 上传方案--成功后执行
|
|
||||||
uploadImgSuccess_FuJian(response, file, fileList) {
|
|
||||||
console.log('您选择的file:', file)
|
|
||||||
if (file.response.code === '200') {
|
|
||||||
this.loadding = false
|
|
||||||
// 返显图片
|
|
||||||
this.filedUrl = this.fileUrl + file.response.data
|
|
||||||
// var uid = file.response.data
|
|
||||||
this.files.push({
|
|
||||||
name: file.response.data.sourceFileName,
|
|
||||||
url: file.response.data.fullUrl,
|
|
||||||
size: file.response.data.size
|
|
||||||
})
|
|
||||||
this.$emit('change', this.files)
|
|
||||||
this.$emit('eett', this.files)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
removeImage(file, ImageFileList) {
|
|
||||||
this.files.splice(this.files.indexOf(file), 1)
|
|
||||||
const imgFiles = []
|
|
||||||
|
|
||||||
this.files.forEach((o) => {
|
|
||||||
imgFiles.push(o.url)
|
|
||||||
})
|
|
||||||
this.$emit('fileChange', this.files)
|
|
||||||
},
|
|
||||||
handleRemove(file, fileList) {
|
|
||||||
console.log('file:' + JSON.stringify(file))
|
|
||||||
console.log('fileList:' + JSON.stringify(fileList))
|
|
||||||
this.enclosure = ''
|
|
||||||
// 1. 保存新增文件id(this.file_add)
|
|
||||||
this.getNewFileId(fileList)
|
|
||||||
// 2. 保存数据库读取的已有文件id(this.file_catch)
|
|
||||||
this.getCatchFileId(file)
|
|
||||||
// 3. 保存并拼接id
|
|
||||||
this.getFileId()
|
|
||||||
// 4. 返回拼接id
|
|
||||||
this.$emit('change', this.enclosure)
|
|
||||||
},
|
|
||||||
// 返回this.file_add(新上传文件的id拼接集合)
|
|
||||||
getNewFileId(fileList) {
|
|
||||||
// debugger
|
|
||||||
this.file_add = ''
|
|
||||||
for (var i = 0; i < fileList.length; i++) {
|
|
||||||
if (fileList[i].response && fileList[i].response.code === '200') {
|
|
||||||
this.file_add = this.file_add + fileList[i].response.data + ','
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.file_add = this.file_add.substring(0, this.file_add.length - 1)
|
|
||||||
}
|
|
||||||
// console.log('1. this.file_add: ' + this.file_add)
|
|
||||||
},
|
|
||||||
// 返回this.file_catch(数库一寸照的文件的id的拼接集合)
|
|
||||||
getCatchFileId(file) {
|
|
||||||
for (var i = 0; i < this.files_list.length; i++) {
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
// 1. 检查当前删除的文件是否是修改文件列表里面的,如果是,将修改列表里去除此id
|
|
||||||
if (this.files_list[i].name === file.name) {
|
|
||||||
// 2. 拆开file_catch到fils_arry
|
|
||||||
var fils_arry = this.file_catch.split(',')
|
|
||||||
// 3. 从fils_arry去除 this.files_list[i].id
|
|
||||||
var arry = []
|
|
||||||
fils_arry.forEach((element) => {
|
|
||||||
// 不加载文件里面的
|
|
||||||
if (element !== this.files_list[i].id) {
|
|
||||||
arry.push(element)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 4. 重新拼接成file_catch
|
|
||||||
this.file_catch = arry.join(',')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// console.log('2. this.file_catch:' + this.file_catch)
|
|
||||||
},
|
|
||||||
// 保存并拼接id
|
|
||||||
getFileId() {
|
|
||||||
// console.log('3. this.file_catch:' + this.file_catch + ',this.file_add:' + this.file_add)
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.enclosure = this.file_catch + ',' + this.file_add
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_catch
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_add
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handlePictureCardPreview(file) {
|
|
||||||
this.dialogImageUrl = file.url
|
|
||||||
},
|
|
||||||
// 上传失败
|
|
||||||
uploadError() {
|
|
||||||
this.loadding = false
|
|
||||||
},
|
|
||||||
uploadProgrees(event, file, fileList) {
|
|
||||||
if (Number(event.percent) > 0) {
|
|
||||||
this.loadding = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
|
||||||
@@ -1,245 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-upload ref="imgUpload" v-loading="loadding" class="avatar-uploader" :headers="accessToken"
|
|
||||||
:action="uploadFile" accept=".jpg,.jpeg,.png,.bmp,.pdf,.JPG,.JPEG,.BMP" list-type="picture-card"
|
|
||||||
:file-list="files" :on-remove="removeImage" :on-preview="handlePictureCardPreview"
|
|
||||||
:on-progress="uploadProgrees"
|
|
||||||
:on-error="uploadError" :on-success="uploadImgSuccess_FuJian">
|
|
||||||
<i class="el-icon-plus avatar-uploader-icon"/>
|
|
||||||
</el-upload>
|
|
||||||
<el-dialog :visible.sync="dialogVisible" :append-to-body="true" title="查看图片">
|
|
||||||
<img width="100%" :src="dialogImageUrl" alt="">
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { uploadFile } from '@/api/portal/Upload.js'
|
|
||||||
import { getStorage } from '@/utils/auth.js' //token
|
|
||||||
import { mapGetters } from 'vuex'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
model: {
|
|
||||||
prop: 'name',
|
|
||||||
event: 'change'
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
bucket: {
|
|
||||||
type: String,
|
|
||||||
default: 'abc'
|
|
||||||
},
|
|
||||||
// 长度
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '270px'
|
|
||||||
},
|
|
||||||
limit: {
|
|
||||||
type: Number,
|
|
||||||
default: 1
|
|
||||||
},
|
|
||||||
accept: {
|
|
||||||
type: String,
|
|
||||||
default:
|
|
||||||
'.jpg,.jpeg,.png,.bmp,.pdf,.JPG,.JPEG,.BMP,.PDF,.xls,.docx,.xlsx,.ppt,.pptx'
|
|
||||||
},
|
|
||||||
// 文件名称
|
|
||||||
name: {
|
|
||||||
type: Array,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
uploadData: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dialogImageUrl: '',
|
|
||||||
dialogVisible: false,
|
|
||||||
accessToken: null,
|
|
||||||
uploadFile: uploadFile,
|
|
||||||
fileList_FuJian: [],
|
|
||||||
enclosure: '',
|
|
||||||
file_add: '',
|
|
||||||
file_catch: '',
|
|
||||||
files: [],
|
|
||||||
files_list: [],
|
|
||||||
filedUrl: '',
|
|
||||||
// fileUrl: fileUrl,
|
|
||||||
// showpicture:false,
|
|
||||||
isview: false,
|
|
||||||
nameArr: '',
|
|
||||||
loadding: false,
|
|
||||||
stateName: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapGetters([
|
|
||||||
'id',
|
|
||||||
'departmentCode',
|
|
||||||
'departmentLevel',
|
|
||||||
'departmentType',
|
|
||||||
'token'
|
|
||||||
])
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
name: {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
handler(newVal, oldVal) {
|
|
||||||
console.log('aaaa1', newVal)
|
|
||||||
this.files = newVal
|
|
||||||
// if (this.stateName = 'xunidingjinAdd') {
|
|
||||||
// if (this.files.length > 1) {
|
|
||||||
// this.files.splice(0, 1)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
console.log('aaaa2', this.files)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.Init()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.uploadFile = uploadFile // 接口
|
|
||||||
this.accessToken = {
|
|
||||||
token: getStorage()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
showImg(imgList) {
|
|
||||||
this.stateName = 'xunidingjinAdd'
|
|
||||||
this.files = imgList
|
|
||||||
console.log('回显图片', this.files)
|
|
||||||
},
|
|
||||||
view() {
|
|
||||||
// window.open(this.filedUrl)
|
|
||||||
},
|
|
||||||
// 页面第一次加载
|
|
||||||
Init() {
|
|
||||||
if (this.name !== undefined) {
|
|
||||||
this.files = []
|
|
||||||
for (var i = 0; i < this.name.length; i++) {
|
|
||||||
this.files.push({
|
|
||||||
name: this.name[i],
|
|
||||||
url: this.name[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 上传方案--成功后执行
|
|
||||||
uploadImgSuccess_FuJian(response, file, fileList) {
|
|
||||||
console.log('您选择的file:', file)
|
|
||||||
if (file.response.code === '200') {
|
|
||||||
this.loadding = false
|
|
||||||
// 返显图片
|
|
||||||
this.filedUrl = this.fileUrl + file.response.data
|
|
||||||
// var uid = file.response.data
|
|
||||||
this.files.push({
|
|
||||||
name: file.response.data.sourceFileName,
|
|
||||||
url: file.response.data.fullUrl,
|
|
||||||
size: file.response.data.size
|
|
||||||
})
|
|
||||||
this.$emit('change', this.files)
|
|
||||||
this.$emit('eett', this.files)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
removeImage(file, ImageFileList) {
|
|
||||||
this.files.splice(this.files.indexOf(file), 1)
|
|
||||||
const imgFiles = []
|
|
||||||
|
|
||||||
this.files.forEach((o) => {
|
|
||||||
imgFiles.push(o.url)
|
|
||||||
})
|
|
||||||
this.$emit('fileChange', this.files)
|
|
||||||
this.$emit('change', this.files)
|
|
||||||
},
|
|
||||||
handleRemove(file, fileList) {
|
|
||||||
console.log('file:' + JSON.stringify(file))
|
|
||||||
console.log('fileList:' + JSON.stringify(fileList))
|
|
||||||
this.enclosure = ''
|
|
||||||
// 1. 保存新增文件id(this.file_add)
|
|
||||||
this.getNewFileId(fileList)
|
|
||||||
// 2. 保存数据库读取的已有文件id(this.file_catch)
|
|
||||||
this.getCatchFileId(file)
|
|
||||||
// 3. 保存并拼接id
|
|
||||||
this.getFileId()
|
|
||||||
// 4. 返回拼接id
|
|
||||||
this.$emit('change', this.enclosure)
|
|
||||||
},
|
|
||||||
// 返回this.file_add(新上传文件的id拼接集合)
|
|
||||||
getNewFileId(fileList) {
|
|
||||||
// debugger
|
|
||||||
this.file_add = ''
|
|
||||||
for (var i = 0; i < fileList.length; i++) {
|
|
||||||
if (fileList[i].response && fileList[i].response.code === '200') {
|
|
||||||
this.file_add = this.file_add + fileList[i].response.data + ','
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.file_add = this.file_add.substring(0, this.file_add.length - 1)
|
|
||||||
}
|
|
||||||
// console.log('1. this.file_add: ' + this.file_add)
|
|
||||||
},
|
|
||||||
// 返回this.file_catch(数库一寸照的文件的id的拼接集合)
|
|
||||||
getCatchFileId(file) {
|
|
||||||
for (var i = 0; i < this.files_list.length; i++) {
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
// 1. 检查当前删除的文件是否是修改文件列表里面的,如果是,将修改列表里去除此id
|
|
||||||
if (this.files_list[i].name === file.name) {
|
|
||||||
// 2. 拆开file_catch到fils_arry
|
|
||||||
var fils_arry = this.file_catch.split(',')
|
|
||||||
// 3. 从fils_arry去除 this.files_list[i].id
|
|
||||||
var arry = []
|
|
||||||
fils_arry.forEach((element) => {
|
|
||||||
// 不加载文件里面的
|
|
||||||
if (element !== this.files_list[i].id) {
|
|
||||||
arry.push(element)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 4. 重新拼接成file_catch
|
|
||||||
this.file_catch = arry.join(',')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// console.log('2. this.file_catch:' + this.file_catch)
|
|
||||||
},
|
|
||||||
// 保存并拼接id
|
|
||||||
getFileId() {
|
|
||||||
// console.log('3. this.file_catch:' + this.file_catch + ',this.file_add:' + this.file_add)
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.enclosure = this.file_catch + ',' + this.file_add
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_catch
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_add
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handlePictureCardPreview(file) {
|
|
||||||
this.dialogImageUrl = file.url
|
|
||||||
this.dialogVisible = true
|
|
||||||
},
|
|
||||||
// 上传失败
|
|
||||||
uploadError() {
|
|
||||||
this.loadding = false
|
|
||||||
},
|
|
||||||
uploadProgrees(event, file, fileList) {
|
|
||||||
if (Number(event.percent) > 0) {
|
|
||||||
this.loadding = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
|
||||||
@@ -1,229 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-upload class="upload-demo" :headers="accessToken" :action="uploadFile" :accept="accept" :data="uploadData"
|
|
||||||
:on-success="uploadImgSuccess_FuJian" :on-remove="handleRemove" :file-list="fileList_FuJian"
|
|
||||||
:on-preview="handlePictureCardPreview" :show-file-list="false" :multiple="true">
|
|
||||||
<el-button size="mini" type="primary">点击上传</el-button>
|
|
||||||
</el-upload>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { uploadimg_tuiku } from '@/api/Common/Upload'
|
|
||||||
import { getStorage } from '@/utils/auth.js'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
model: {
|
|
||||||
prop: 'name',
|
|
||||||
event: 'change'
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
bucket: {
|
|
||||||
type: String,
|
|
||||||
default: 'abc'
|
|
||||||
},
|
|
||||||
// 长度
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '270px'
|
|
||||||
},
|
|
||||||
limit: {
|
|
||||||
type: Number,
|
|
||||||
default: 1
|
|
||||||
},
|
|
||||||
accept: {
|
|
||||||
type: String,
|
|
||||||
default:
|
|
||||||
'.jpg,.jpeg,.png,.JPG,.JPEG'
|
|
||||||
},
|
|
||||||
// 文件名称
|
|
||||||
name: {
|
|
||||||
type: Array,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
uploadData: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dialogImageUrl: '',
|
|
||||||
dialogVisible: false,
|
|
||||||
accessToken: null,
|
|
||||||
uploadFile: uploadimg_tuiku,
|
|
||||||
fileList_FuJian: [],
|
|
||||||
enclosure: '',
|
|
||||||
file_add: '',
|
|
||||||
file_catch: '',
|
|
||||||
files: [],
|
|
||||||
files_list: [],
|
|
||||||
filedUrl: '',
|
|
||||||
// fileUrl: fileUrl,
|
|
||||||
// showpicture:false,
|
|
||||||
isview: false,
|
|
||||||
nameArr: '',
|
|
||||||
loadding: false,
|
|
||||||
stateName: '',
|
|
||||||
/* uploadData: { modelSid: '' },*/
|
|
||||||
sid: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
name: {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
handler(newVal, oldVal) {
|
|
||||||
console.log('aaaa1', newVal)
|
|
||||||
this.files = newVal
|
|
||||||
console.log('aaaa2', this.files)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.Init()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.uploadFile = uploadimg_tuiku // 接口
|
|
||||||
this.accessToken = {
|
|
||||||
token: getStorage()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
view() {
|
|
||||||
// window.open(this.filedUrl)
|
|
||||||
},
|
|
||||||
showImg(sid) {
|
|
||||||
// this.uploadData.sid = sid
|
|
||||||
},
|
|
||||||
|
|
||||||
// 页面第一次加载
|
|
||||||
Init() {
|
|
||||||
if (this.name !== undefined) {
|
|
||||||
this.files = []
|
|
||||||
for (var i = 0; i < this.name.length; i++) {
|
|
||||||
this.files.push({
|
|
||||||
name: this.name[i],
|
|
||||||
url: this.name[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 上传方案--成功后执行
|
|
||||||
uploadImgSuccess_FuJian(response, file, fileList) {
|
|
||||||
let _this = this
|
|
||||||
console.log('您选择的file:', file)
|
|
||||||
// console.log('您传递的data:', _this.uploadData)
|
|
||||||
if (file.response.code === '200') {
|
|
||||||
this.loadding = false
|
|
||||||
// 返显图片
|
|
||||||
this.filedUrl = this.fileUrl + file.response.data
|
|
||||||
// var uid = file.response.data
|
|
||||||
this.files.push({
|
|
||||||
name: file.response.data.sourceFileName,
|
|
||||||
url: file.response.data.fullUrl,
|
|
||||||
size: file.response.data.size
|
|
||||||
})
|
|
||||||
this.$emit('change', this.files)
|
|
||||||
this.$emit('eett', this.files)
|
|
||||||
// this.getUrl()
|
|
||||||
// SaveList(this.tempInfo).then(response => {
|
|
||||||
// if (response.success) {
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
},
|
|
||||||
removeImage(file, ImageFileList) {
|
|
||||||
this.files.splice(this.files.indexOf(file), 1)
|
|
||||||
const imgFiles = []
|
|
||||||
this.files.forEach((o) => {
|
|
||||||
imgFiles.push(o.url)
|
|
||||||
})
|
|
||||||
this.$emit('fileChange', this.files)
|
|
||||||
},
|
|
||||||
handleRemove(file, fileList) {
|
|
||||||
console.log('file:' + JSON.stringify(file))
|
|
||||||
console.log('fileList:' + JSON.stringify(fileList))
|
|
||||||
this.enclosure = ''
|
|
||||||
// 1. 保存新增文件id(this.file_add)
|
|
||||||
this.getNewFileId(fileList)
|
|
||||||
// 2. 保存数据库读取的已有文件id(this.file_catch)
|
|
||||||
this.getCatchFileId(file)
|
|
||||||
// 3. 保存并拼接id
|
|
||||||
this.getFileId()
|
|
||||||
// 4. 返回拼接id
|
|
||||||
this.$emit('change', this.enclosure)
|
|
||||||
},
|
|
||||||
// 返回this.file_add(新上传文件的id拼接集合)
|
|
||||||
getNewFileId(fileList) {
|
|
||||||
// debugger
|
|
||||||
this.file_add = ''
|
|
||||||
for (var i = 0; i < fileList.length; i++) {
|
|
||||||
if (fileList[i].response && fileList[i].response.code === '200') {
|
|
||||||
this.file_add = this.file_add + fileList[i].response.data + ','
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.file_add = this.file_add.substring(0, this.file_add.length - 1)
|
|
||||||
}
|
|
||||||
// console.log('1. this.file_add: ' + this.file_add)
|
|
||||||
},
|
|
||||||
// 返回this.file_catch(数库一寸照的文件的id的拼接集合)
|
|
||||||
getCatchFileId(file) {
|
|
||||||
for (var i = 0; i < this.files_list.length; i++) {
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
// 1. 检查当前删除的文件是否是修改文件列表里面的,如果是,将修改列表里去除此id
|
|
||||||
if (this.files_list[i].name === file.name) {
|
|
||||||
// 2. 拆开file_catch到fils_arry
|
|
||||||
var fils_arry = this.file_catch.split(',')
|
|
||||||
// 3. 从fils_arry去除 this.files_list[i].id
|
|
||||||
var arry = []
|
|
||||||
fils_arry.forEach((element) => {
|
|
||||||
// 不加载文件里面的
|
|
||||||
if (element !== this.files_list[i].id) {
|
|
||||||
arry.push(element)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 4. 重新拼接成file_catch
|
|
||||||
this.file_catch = arry.join(',')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// console.log('2. this.file_catch:' + this.file_catch)
|
|
||||||
},
|
|
||||||
// 保存并拼接id
|
|
||||||
getFileId() {
|
|
||||||
// console.log('3. this.file_catch:' + this.file_catch + ',this.file_add:' + this.file_add)
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.enclosure = this.file_catch + ',' + this.file_add
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_catch
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_add
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handlePictureCardPreview(file) {
|
|
||||||
this.dialogImageUrl = file.url
|
|
||||||
},
|
|
||||||
// 上传失败
|
|
||||||
uploadError() {
|
|
||||||
this.loadding = false
|
|
||||||
},
|
|
||||||
uploadProgrees(event, file, fileList) {
|
|
||||||
if (Number(event.percent) > 0) {
|
|
||||||
this.loadding = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,242 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div><!---->
|
|
||||||
<el-upload class="upload-demo" :headers="accessToken" :action="uploadFile" :accept="accept" :data="uploadData"
|
|
||||||
:on-success="uploadImgSuccess_FuJian" :on-remove="handleRemove" :file-list="fileList_FuJian"
|
|
||||||
:on-preview="handlePictureCardPreview" :show-file-list="false">
|
|
||||||
<el-button size="mini" type="primary">点击上传</el-button>
|
|
||||||
</el-upload>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { uploadFile } from '@/api/portal/Upload_chexing.js'
|
|
||||||
import { getStorage } from '@/utils/auth.js' //token
|
|
||||||
import {
|
|
||||||
SaveList
|
|
||||||
} from '@/api/cheliang/basevehiclemodel'
|
|
||||||
import { mapGetters } from 'vuex'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
model: {
|
|
||||||
prop: 'name',
|
|
||||||
event: 'change'
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
bucket: {
|
|
||||||
type: String,
|
|
||||||
default: 'abc'
|
|
||||||
},
|
|
||||||
// 长度
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '270px'
|
|
||||||
},
|
|
||||||
limit: {
|
|
||||||
type: Number,
|
|
||||||
default: 1
|
|
||||||
},
|
|
||||||
accept: {
|
|
||||||
type: String,
|
|
||||||
default:
|
|
||||||
'.jpg,.jpeg,.png,.bmp,.pdf,.JPG,.JPEG,.BMP,.PDF,.xls,.docx,.xlsx,.ppt,.pptx'
|
|
||||||
},
|
|
||||||
// 文件名称
|
|
||||||
name: {
|
|
||||||
type: Array,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
uploadData: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dialogImageUrl: '',
|
|
||||||
dialogVisible: false,
|
|
||||||
accessToken: null,
|
|
||||||
uploadFile: uploadFile,
|
|
||||||
fileList_FuJian: [],
|
|
||||||
enclosure: '',
|
|
||||||
file_add: '',
|
|
||||||
file_catch: '',
|
|
||||||
files: [],
|
|
||||||
files_list: [],
|
|
||||||
filedUrl: '',
|
|
||||||
// fileUrl: fileUrl,
|
|
||||||
// showpicture:false,
|
|
||||||
isview: false,
|
|
||||||
nameArr: '',
|
|
||||||
loadding: false,
|
|
||||||
stateName: '',
|
|
||||||
/* uploadData: { modelSid: '' },*/
|
|
||||||
sid: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapGetters([
|
|
||||||
'id',
|
|
||||||
'departmentCode',
|
|
||||||
'departmentLevel',
|
|
||||||
'departmentType',
|
|
||||||
'token'
|
|
||||||
])
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
name: {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
handler(newVal, oldVal) {
|
|
||||||
console.log('aaaa1', newVal)
|
|
||||||
this.files = newVal
|
|
||||||
console.log('aaaa2', this.files)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.Init()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.uploadFile = uploadFile // 接口
|
|
||||||
this.accessToken = {
|
|
||||||
token: getStorage()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
view() {
|
|
||||||
// window.open(this.filedUrl)
|
|
||||||
},
|
|
||||||
showImg(sid) {
|
|
||||||
// this.uploadData.sid = sid
|
|
||||||
},
|
|
||||||
|
|
||||||
// 页面第一次加载
|
|
||||||
Init() {
|
|
||||||
if (this.name !== undefined) {
|
|
||||||
this.files = []
|
|
||||||
for (var i = 0; i < this.name.length; i++) {
|
|
||||||
this.files.push({
|
|
||||||
name: this.name[i],
|
|
||||||
url: this.name[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 上传方案--成功后执行
|
|
||||||
uploadImgSuccess_FuJian(response, file, fileList) {
|
|
||||||
let _this = this
|
|
||||||
console.log('您选择的file:', file)
|
|
||||||
// console.log('您传递的data:', _this.uploadData)
|
|
||||||
if (file.response.code === '200') {
|
|
||||||
this.loadding = false
|
|
||||||
// 返显图片
|
|
||||||
this.filedUrl = this.fileUrl + file.response.data
|
|
||||||
// var uid = file.response.data
|
|
||||||
this.files.push({
|
|
||||||
name: file.response.data.sourceFileName,
|
|
||||||
url: file.response.data.fullUrl,
|
|
||||||
size: file.response.data.size
|
|
||||||
})
|
|
||||||
this.$emit('eett', this.files)
|
|
||||||
this.$emit('change', this.files)
|
|
||||||
// this.getUrl()
|
|
||||||
// SaveList(this.tempInfo).then(response => {
|
|
||||||
// if (response.success) {
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
},
|
|
||||||
removeImage(file, ImageFileList) {
|
|
||||||
this.files.splice(this.files.indexOf(file), 1)
|
|
||||||
const imgFiles = []
|
|
||||||
this.files.forEach((o) => {
|
|
||||||
imgFiles.push(o.url)
|
|
||||||
})
|
|
||||||
this.$emit('fileChange', this.files)
|
|
||||||
},
|
|
||||||
handleRemove(file, fileList) {
|
|
||||||
console.log('file:' + JSON.stringify(file))
|
|
||||||
console.log('fileList:' + JSON.stringify(fileList))
|
|
||||||
this.enclosure = ''
|
|
||||||
// 1. 保存新增文件id(this.file_add)
|
|
||||||
this.getNewFileId(fileList)
|
|
||||||
// 2. 保存数据库读取的已有文件id(this.file_catch)
|
|
||||||
this.getCatchFileId(file)
|
|
||||||
// 3. 保存并拼接id
|
|
||||||
this.getFileId()
|
|
||||||
// 4. 返回拼接id
|
|
||||||
this.$emit('change', this.enclosure)
|
|
||||||
},
|
|
||||||
// 返回this.file_add(新上传文件的id拼接集合)
|
|
||||||
getNewFileId(fileList) {
|
|
||||||
// debugger
|
|
||||||
this.file_add = ''
|
|
||||||
for (var i = 0; i < fileList.length; i++) {
|
|
||||||
if (fileList[i].response && fileList[i].response.code === '200') {
|
|
||||||
this.file_add = this.file_add + fileList[i].response.data + ','
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.file_add = this.file_add.substring(0, this.file_add.length - 1)
|
|
||||||
}
|
|
||||||
// console.log('1. this.file_add: ' + this.file_add)
|
|
||||||
},
|
|
||||||
// 返回this.file_catch(数库一寸照的文件的id的拼接集合)
|
|
||||||
getCatchFileId(file) {
|
|
||||||
for (var i = 0; i < this.files_list.length; i++) {
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
// 1. 检查当前删除的文件是否是修改文件列表里面的,如果是,将修改列表里去除此id
|
|
||||||
if (this.files_list[i].name === file.name) {
|
|
||||||
// 2. 拆开file_catch到fils_arry
|
|
||||||
var fils_arry = this.file_catch.split(',')
|
|
||||||
// 3. 从fils_arry去除 this.files_list[i].id
|
|
||||||
var arry = []
|
|
||||||
fils_arry.forEach((element) => {
|
|
||||||
// 不加载文件里面的
|
|
||||||
if (element !== this.files_list[i].id) {
|
|
||||||
arry.push(element)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 4. 重新拼接成file_catch
|
|
||||||
this.file_catch = arry.join(',')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// console.log('2. this.file_catch:' + this.file_catch)
|
|
||||||
},
|
|
||||||
// 保存并拼接id
|
|
||||||
getFileId() {
|
|
||||||
// console.log('3. this.file_catch:' + this.file_catch + ',this.file_add:' + this.file_add)
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.enclosure = this.file_catch + ',' + this.file_add
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_catch
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_add
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handlePictureCardPreview(file) {
|
|
||||||
this.dialogImageUrl = file.url
|
|
||||||
},
|
|
||||||
// 上传失败
|
|
||||||
uploadError() {
|
|
||||||
this.loadding = false
|
|
||||||
},
|
|
||||||
uploadProgrees(event, file, fileList) {
|
|
||||||
if (Number(event.percent) > 0) {
|
|
||||||
this.loadding = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
|
||||||
@@ -1,234 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div><!---->
|
|
||||||
<el-upload class="avatar-uploader" :headers="accessToken" :action="uploadFile" :accept="accept" :data="uploadData"
|
|
||||||
:on-success="uploadImgSuccess_FuJian" :on-remove="handleRemove" :file-list="fileList_FuJian" list-type="picture-card"
|
|
||||||
:on-preview="handlePictureCardPreview" :multiple="true">
|
|
||||||
<i class="el-icon-plus avatar-uploader-icon"/>
|
|
||||||
</el-upload>
|
|
||||||
<el-dialog :visible.sync="dialogVisible" :append-to-body="true" title="查看图片">
|
|
||||||
<img width="100%" :src="dialogImageUrl" alt="">
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { uploadFile_yanchejiancha } from '@/api/portal/Upload.js'
|
|
||||||
import { getStorage } from '@/utils/auth.js' // token
|
|
||||||
|
|
||||||
export default {
|
|
||||||
model: {
|
|
||||||
prop: 'name',
|
|
||||||
event: 'change'
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
bucket: {
|
|
||||||
type: String,
|
|
||||||
default: 'abc'
|
|
||||||
},
|
|
||||||
// 长度
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '270px'
|
|
||||||
},
|
|
||||||
limit: {
|
|
||||||
type: Number,
|
|
||||||
default: 1
|
|
||||||
},
|
|
||||||
accept: {
|
|
||||||
type: String,
|
|
||||||
default:
|
|
||||||
'.jpg,.jpeg,.png,.JPG,.JPEG,'
|
|
||||||
},
|
|
||||||
// 文件名称
|
|
||||||
name: {
|
|
||||||
type: Array,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
uploadData: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dialogImageUrl: '',
|
|
||||||
dialogVisible: false,
|
|
||||||
accessToken: null,
|
|
||||||
uploadFile: uploadFile_yanchejiancha,
|
|
||||||
fileList_FuJian: [],
|
|
||||||
enclosure: '',
|
|
||||||
file_add: '',
|
|
||||||
file_catch: '',
|
|
||||||
files: [],
|
|
||||||
files_list: [],
|
|
||||||
filedUrl: '',
|
|
||||||
// fileUrl: fileUrl,
|
|
||||||
// showpicture:false,
|
|
||||||
isview: false,
|
|
||||||
nameArr: '',
|
|
||||||
loadding: false,
|
|
||||||
stateName: '',
|
|
||||||
/* uploadData: { modelSid: '' },*/
|
|
||||||
sid: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
name: {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
handler(newVal, oldVal) {
|
|
||||||
console.log('aaaa1', newVal)
|
|
||||||
this.files = newVal
|
|
||||||
console.log('aaaa2', this.files)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.Init()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.uploadFile = uploadFile_yanchejiancha // 接口
|
|
||||||
this.accessToken = {
|
|
||||||
token: getStorage()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
view() {
|
|
||||||
// window.open(this.filedUrl)
|
|
||||||
},
|
|
||||||
showImg(sid) {
|
|
||||||
// this.uploadData.sid = sid
|
|
||||||
},
|
|
||||||
|
|
||||||
// 页面第一次加载
|
|
||||||
Init() {
|
|
||||||
if (this.name !== undefined) {
|
|
||||||
this.files = []
|
|
||||||
for (var i = 0; i < this.name.length; i++) {
|
|
||||||
this.files.push({
|
|
||||||
name: this.name[i],
|
|
||||||
url: this.name[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 上传方案--成功后执行
|
|
||||||
uploadImgSuccess_FuJian(response, file, fileList) {
|
|
||||||
let _this = this
|
|
||||||
console.log('您选择的file:', file)
|
|
||||||
// console.log('您传递的data:', _this.uploadData)
|
|
||||||
if (file.response.code === '200') {
|
|
||||||
this.loadding = false
|
|
||||||
// 返显图片
|
|
||||||
this.filedUrl = this.fileUrl + file.response.data
|
|
||||||
// var uid = file.response.data
|
|
||||||
const files = []
|
|
||||||
files.push({
|
|
||||||
name: file.response.data.sourceFileName,
|
|
||||||
url: file.response.data.fullUrl,
|
|
||||||
size: file.response.data.size
|
|
||||||
})
|
|
||||||
this.$emit('change', files)
|
|
||||||
this.$emit('eett', files)
|
|
||||||
// this.getUrl()
|
|
||||||
// SaveList(this.tempInfo).then(response => {
|
|
||||||
// if (response.success) {
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
},
|
|
||||||
removeImage(file, ImageFileList) {
|
|
||||||
this.files.splice(this.files.indexOf(file), 1)
|
|
||||||
const imgFiles = []
|
|
||||||
this.files.forEach((o) => {
|
|
||||||
imgFiles.push(o.url)
|
|
||||||
})
|
|
||||||
this.$emit('fileChange', this.files)
|
|
||||||
},
|
|
||||||
handleRemove(file, fileList) {
|
|
||||||
console.log('file:' + JSON.stringify(file))
|
|
||||||
console.log('fileList:' + JSON.stringify(fileList))
|
|
||||||
this.enclosure = ''
|
|
||||||
// 1. 保存新增文件id(this.file_add)
|
|
||||||
this.getNewFileId(fileList)
|
|
||||||
// 2. 保存数据库读取的已有文件id(this.file_catch)
|
|
||||||
this.getCatchFileId(file)
|
|
||||||
// 3. 保存并拼接id
|
|
||||||
this.getFileId()
|
|
||||||
// 4. 返回拼接id
|
|
||||||
this.$emit('change', this.enclosure)
|
|
||||||
},
|
|
||||||
// 返回this.file_add(新上传文件的id拼接集合)
|
|
||||||
getNewFileId(fileList) {
|
|
||||||
// debugger
|
|
||||||
this.file_add = ''
|
|
||||||
for (var i = 0; i < fileList.length; i++) {
|
|
||||||
if (fileList[i].response && fileList[i].response.code === '200') {
|
|
||||||
this.file_add = this.file_add + fileList[i].response.data + ','
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.file_add = this.file_add.substring(0, this.file_add.length - 1)
|
|
||||||
}
|
|
||||||
// console.log('1. this.file_add: ' + this.file_add)
|
|
||||||
},
|
|
||||||
// 返回this.file_catch(数库一寸照的文件的id的拼接集合)
|
|
||||||
getCatchFileId(file) {
|
|
||||||
for (var i = 0; i < this.files_list.length; i++) {
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
// 1. 检查当前删除的文件是否是修改文件列表里面的,如果是,将修改列表里去除此id
|
|
||||||
if (this.files_list[i].name === file.name) {
|
|
||||||
// 2. 拆开file_catch到fils_arry
|
|
||||||
var fils_arry = this.file_catch.split(',')
|
|
||||||
// 3. 从fils_arry去除 this.files_list[i].id
|
|
||||||
var arry = []
|
|
||||||
fils_arry.forEach((element) => {
|
|
||||||
// 不加载文件里面的
|
|
||||||
if (element !== this.files_list[i].id) {
|
|
||||||
arry.push(element)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 4. 重新拼接成file_catch
|
|
||||||
this.file_catch = arry.join(',')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// console.log('2. this.file_catch:' + this.file_catch)
|
|
||||||
},
|
|
||||||
// 保存并拼接id
|
|
||||||
getFileId() {
|
|
||||||
// console.log('3. this.file_catch:' + this.file_catch + ',this.file_add:' + this.file_add)
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.enclosure = this.file_catch + ',' + this.file_add
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_catch
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_add
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handlePictureCardPreview(file) {
|
|
||||||
this.dialogVisible = true
|
|
||||||
this.dialogImageUrl = file.url
|
|
||||||
},
|
|
||||||
// 上传失败
|
|
||||||
uploadError() {
|
|
||||||
this.loadding = false
|
|
||||||
},
|
|
||||||
uploadProgrees(event, file, fileList) {
|
|
||||||
if (Number(event.percent) > 0) {
|
|
||||||
this.loadding = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
|
||||||
@@ -1,242 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div><!---->
|
|
||||||
<el-upload class="upload-demo" :headers="accessToken" :action="uploadFile" :accept="accept" :data="uploadData"
|
|
||||||
:on-success="uploadImgSuccess_FuJian" :on-remove="handleRemove" :file-list="fileList_FuJian"
|
|
||||||
:on-preview="handlePictureCardPreview" :show-file-list="false">
|
|
||||||
<el-button size="mini" type="primary">点击上传</el-button>
|
|
||||||
</el-upload>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { uploadImgFileList } from '@/api/portal/Upload_chexing.js'
|
|
||||||
import { getStorage } from '@/utils/auth.js' //token
|
|
||||||
import {
|
|
||||||
SaveList
|
|
||||||
} from '@/api/cheliang/basevehiclemodel'
|
|
||||||
import { mapGetters } from 'vuex'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
model: {
|
|
||||||
prop: 'name',
|
|
||||||
event: 'change'
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
bucket: {
|
|
||||||
type: String,
|
|
||||||
default: 'abc'
|
|
||||||
},
|
|
||||||
// 长度
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '270px'
|
|
||||||
},
|
|
||||||
limit: {
|
|
||||||
type: Number,
|
|
||||||
default: 1
|
|
||||||
},
|
|
||||||
accept: {
|
|
||||||
type: String,
|
|
||||||
default:
|
|
||||||
'.jpg,.jpeg,.png,.bmp,.pdf,.JPG,.JPEG,.BMP,.PDF,.xls,.docx,.xlsx,.ppt,.pptx'
|
|
||||||
},
|
|
||||||
// 文件名称
|
|
||||||
name: {
|
|
||||||
type: Array,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
uploadData: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dialogImageUrl: '',
|
|
||||||
dialogVisible: false,
|
|
||||||
accessToken: null,
|
|
||||||
uploadFile: uploadImgFileList,
|
|
||||||
fileList_FuJian: [],
|
|
||||||
enclosure: '',
|
|
||||||
file_add: '',
|
|
||||||
file_catch: '',
|
|
||||||
files: [],
|
|
||||||
files_list: [],
|
|
||||||
filedUrl: '',
|
|
||||||
// fileUrl: fileUrl,
|
|
||||||
// showpicture:false,
|
|
||||||
isview: false,
|
|
||||||
nameArr: '',
|
|
||||||
loadding: false,
|
|
||||||
stateName: '',
|
|
||||||
/* uploadData: { modelSid: '' },*/
|
|
||||||
sid: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapGetters([
|
|
||||||
'id',
|
|
||||||
'departmentCode',
|
|
||||||
'departmentLevel',
|
|
||||||
'departmentType',
|
|
||||||
'token'
|
|
||||||
])
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
name: {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
handler(newVal, oldVal) {
|
|
||||||
console.log('aaaa1', newVal)
|
|
||||||
this.files = newVal
|
|
||||||
console.log('aaaa2', this.files)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.Init()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.uploadFile = uploadImgFileList // 接口
|
|
||||||
this.accessToken = {
|
|
||||||
token: getStorage()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
view() {
|
|
||||||
// window.open(this.filedUrl)
|
|
||||||
},
|
|
||||||
showImg(sid) {
|
|
||||||
// this.uploadData.sid = sid
|
|
||||||
},
|
|
||||||
|
|
||||||
// 页面第一次加载
|
|
||||||
Init() {
|
|
||||||
if (this.name !== undefined) {
|
|
||||||
this.files = []
|
|
||||||
for (var i = 0; i < this.name.length; i++) {
|
|
||||||
this.files.push({
|
|
||||||
name: this.name[i],
|
|
||||||
url: this.name[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 上传方案--成功后执行
|
|
||||||
uploadImgSuccess_FuJian(response, file, fileList) {
|
|
||||||
let _this = this
|
|
||||||
console.log('您选择的file:', file)
|
|
||||||
// console.log('您传递的data:', _this.uploadData)
|
|
||||||
if (file.response.code === '200') {
|
|
||||||
this.loadding = false
|
|
||||||
// 返显图片
|
|
||||||
this.filedUrl = this.fileUrl + file.response.data
|
|
||||||
// var uid = file.response.data
|
|
||||||
this.files.push({
|
|
||||||
name: file.response.data.sourceFileName,
|
|
||||||
url: file.response.data.fullUrl,
|
|
||||||
size: file.response.data.size
|
|
||||||
})
|
|
||||||
this.$emit('change', this.files)
|
|
||||||
this.$emit('eett', this.files)
|
|
||||||
// this.getUrl()
|
|
||||||
// SaveList(this.tempInfo).then(response => {
|
|
||||||
// if (response.success) {
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
},
|
|
||||||
removeImage(file, ImageFileList) {
|
|
||||||
this.files.splice(this.files.indexOf(file), 1)
|
|
||||||
const imgFiles = []
|
|
||||||
this.files.forEach((o) => {
|
|
||||||
imgFiles.push(o.url)
|
|
||||||
})
|
|
||||||
this.$emit('fileChange', this.files)
|
|
||||||
},
|
|
||||||
handleRemove(file, fileList) {
|
|
||||||
console.log('file:' + JSON.stringify(file))
|
|
||||||
console.log('fileList:' + JSON.stringify(fileList))
|
|
||||||
this.enclosure = ''
|
|
||||||
// 1. 保存新增文件id(this.file_add)
|
|
||||||
this.getNewFileId(fileList)
|
|
||||||
// 2. 保存数据库读取的已有文件id(this.file_catch)
|
|
||||||
this.getCatchFileId(file)
|
|
||||||
// 3. 保存并拼接id
|
|
||||||
this.getFileId()
|
|
||||||
// 4. 返回拼接id
|
|
||||||
this.$emit('change', this.enclosure)
|
|
||||||
},
|
|
||||||
// 返回this.file_add(新上传文件的id拼接集合)
|
|
||||||
getNewFileId(fileList) {
|
|
||||||
// debugger
|
|
||||||
this.file_add = ''
|
|
||||||
for (var i = 0; i < fileList.length; i++) {
|
|
||||||
if (fileList[i].response && fileList[i].response.code === '200') {
|
|
||||||
this.file_add = this.file_add + fileList[i].response.data + ','
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.file_add = this.file_add.substring(0, this.file_add.length - 1)
|
|
||||||
}
|
|
||||||
// console.log('1. this.file_add: ' + this.file_add)
|
|
||||||
},
|
|
||||||
// 返回this.file_catch(数库一寸照的文件的id的拼接集合)
|
|
||||||
getCatchFileId(file) {
|
|
||||||
for (var i = 0; i < this.files_list.length; i++) {
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
// 1. 检查当前删除的文件是否是修改文件列表里面的,如果是,将修改列表里去除此id
|
|
||||||
if (this.files_list[i].name === file.name) {
|
|
||||||
// 2. 拆开file_catch到fils_arry
|
|
||||||
var fils_arry = this.file_catch.split(',')
|
|
||||||
// 3. 从fils_arry去除 this.files_list[i].id
|
|
||||||
var arry = []
|
|
||||||
fils_arry.forEach((element) => {
|
|
||||||
// 不加载文件里面的
|
|
||||||
if (element !== this.files_list[i].id) {
|
|
||||||
arry.push(element)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 4. 重新拼接成file_catch
|
|
||||||
this.file_catch = arry.join(',')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// console.log('2. this.file_catch:' + this.file_catch)
|
|
||||||
},
|
|
||||||
// 保存并拼接id
|
|
||||||
getFileId() {
|
|
||||||
// console.log('3. this.file_catch:' + this.file_catch + ',this.file_add:' + this.file_add)
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.enclosure = this.file_catch + ',' + this.file_add
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_catch
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_add
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handlePictureCardPreview(file) {
|
|
||||||
this.dialogImageUrl = file.url
|
|
||||||
},
|
|
||||||
// 上传失败
|
|
||||||
uploadError() {
|
|
||||||
this.loadding = false
|
|
||||||
},
|
|
||||||
uploadProgrees(event, file, fileList) {
|
|
||||||
if (Number(event.percent) > 0) {
|
|
||||||
this.loadding = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
|
||||||
@@ -1,237 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-dialog :visible.sync="dialogVisible">
|
|
||||||
<img width="100%" :src="dialogImageUrl" alt="">
|
|
||||||
</el-dialog>
|
|
||||||
<el-upload class="upload-demo" :headers="accessToken" :action="uploadFile" :accept="accept" :data="uploadData"
|
|
||||||
:on-success="uploadImgSuccess_FuJian" :on-remove="handleRemove" :file-list="fileList_FuJian"
|
|
||||||
:on-preview="handlePictureCardPreview" :show-file-list="false">
|
|
||||||
<el-button size="small" type="primary">点击上传</el-button>
|
|
||||||
</el-upload>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { uploadFile } from '@/api/portal/Upload.js'
|
|
||||||
import { getStorage } from '@/utils/auth.js' //token
|
|
||||||
import { mapGetters } from 'vuex'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
model: {
|
|
||||||
prop: 'name',
|
|
||||||
event: 'change'
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
bucket: {
|
|
||||||
type: String,
|
|
||||||
default: 'abc'
|
|
||||||
},
|
|
||||||
// 长度
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '270px'
|
|
||||||
},
|
|
||||||
limit: {
|
|
||||||
type: Number,
|
|
||||||
default: 1
|
|
||||||
},
|
|
||||||
accept: {
|
|
||||||
type: String,
|
|
||||||
default:
|
|
||||||
'.jpg,.jpeg,.png,.bmp,.pdf,.JPG,.JPEG,.BMP,'
|
|
||||||
},
|
|
||||||
// 文件名称
|
|
||||||
name: {
|
|
||||||
type: Array,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
uploadData: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dialogImageUrl: '',
|
|
||||||
dialogVisible: false,
|
|
||||||
accessToken: null,
|
|
||||||
uploadFile: uploadFile,
|
|
||||||
fileList_FuJian: [],
|
|
||||||
enclosure: '',
|
|
||||||
file_add: '',
|
|
||||||
file_catch: '',
|
|
||||||
files: [],
|
|
||||||
files_list: [],
|
|
||||||
filedUrl: '',
|
|
||||||
// fileUrl: fileUrl,
|
|
||||||
// showpicture:false,
|
|
||||||
isview: false,
|
|
||||||
nameArr: '',
|
|
||||||
loadding: false,
|
|
||||||
stateName: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapGetters([
|
|
||||||
'id',
|
|
||||||
'departmentCode',
|
|
||||||
'departmentLevel',
|
|
||||||
'departmentType',
|
|
||||||
'token'
|
|
||||||
])
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
name: {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
handler(newVal, oldVal) {
|
|
||||||
console.log('aaaa1', newVal)
|
|
||||||
this.files = newVal
|
|
||||||
// if (this.stateName = 'xunidingjinAdd') {
|
|
||||||
// if (this.files.length > 1) {
|
|
||||||
// this.files.splice(0, 1)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
console.log('aaaa2', this.files)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.Init()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.uploadFile = uploadFile // 接口
|
|
||||||
this.accessToken = {
|
|
||||||
token: getStorage()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
showImg(imgList) {
|
|
||||||
this.stateName = 'xunidingjinAdd'
|
|
||||||
this.files = imgList
|
|
||||||
console.log('回显图片', this.files)
|
|
||||||
},
|
|
||||||
view() {
|
|
||||||
// window.open(this.filedUrl)
|
|
||||||
},
|
|
||||||
// 页面第一次加载
|
|
||||||
Init() {
|
|
||||||
if (this.name !== undefined) {
|
|
||||||
this.files = []
|
|
||||||
for (var i = 0; i < this.name.length; i++) {
|
|
||||||
this.files.push({
|
|
||||||
name: this.name[i],
|
|
||||||
url: this.name[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 上传方案--成功后执行
|
|
||||||
uploadImgSuccess_FuJian(response, file, fileList) {
|
|
||||||
console.log('您选择的file:', file)
|
|
||||||
if (file.response.code === '200') {
|
|
||||||
this.loadding = false
|
|
||||||
// 返显图片
|
|
||||||
this.filedUrl = this.fileUrl + file.response.data
|
|
||||||
// var uid = file.response.data
|
|
||||||
this.files.push(file.response.data.fullUrl)
|
|
||||||
this.$emit('change', this.files)
|
|
||||||
this.$emit('eett', this.files)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
removeImage(file, ImageFileList) {
|
|
||||||
this.files.splice(this.files.indexOf(file), 1)
|
|
||||||
const imgFiles = []
|
|
||||||
|
|
||||||
this.files.forEach((o) => {
|
|
||||||
imgFiles.push(o.url)
|
|
||||||
})
|
|
||||||
this.$emit('fileChange', this.files)
|
|
||||||
},
|
|
||||||
handleRemove(file, fileList) {
|
|
||||||
console.log('file:' + JSON.stringify(file))
|
|
||||||
console.log('fileList:' + JSON.stringify(fileList))
|
|
||||||
this.enclosure = ''
|
|
||||||
// 1. 保存新增文件id(this.file_add)
|
|
||||||
this.getNewFileId(fileList)
|
|
||||||
// 2. 保存数据库读取的已有文件id(this.file_catch)
|
|
||||||
this.getCatchFileId(file)
|
|
||||||
// 3. 保存并拼接id
|
|
||||||
this.getFileId()
|
|
||||||
// 4. 返回拼接id
|
|
||||||
this.$emit('change', this.enclosure)
|
|
||||||
},
|
|
||||||
// 返回this.file_add(新上传文件的id拼接集合)
|
|
||||||
getNewFileId(fileList) {
|
|
||||||
// debugger
|
|
||||||
this.file_add = ''
|
|
||||||
for (var i = 0; i < fileList.length; i++) {
|
|
||||||
if (fileList[i].response && fileList[i].response.code === '200') {
|
|
||||||
this.file_add = this.file_add + fileList[i].response.data + ','
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.file_add = this.file_add.substring(0, this.file_add.length - 1)
|
|
||||||
}
|
|
||||||
// console.log('1. this.file_add: ' + this.file_add)
|
|
||||||
},
|
|
||||||
// 返回this.file_catch(数库一寸照的文件的id的拼接集合)
|
|
||||||
getCatchFileId(file) {
|
|
||||||
for (var i = 0; i < this.files_list.length; i++) {
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
// 1. 检查当前删除的文件是否是修改文件列表里面的,如果是,将修改列表里去除此id
|
|
||||||
if (this.files_list[i].name === file.name) {
|
|
||||||
// 2. 拆开file_catch到fils_arry
|
|
||||||
var fils_arry = this.file_catch.split(',')
|
|
||||||
// 3. 从fils_arry去除 this.files_list[i].id
|
|
||||||
var arry = []
|
|
||||||
fils_arry.forEach((element) => {
|
|
||||||
// 不加载文件里面的
|
|
||||||
if (element !== this.files_list[i].id) {
|
|
||||||
arry.push(element)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 4. 重新拼接成file_catch
|
|
||||||
this.file_catch = arry.join(',')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// console.log('2. this.file_catch:' + this.file_catch)
|
|
||||||
},
|
|
||||||
// 保存并拼接id
|
|
||||||
getFileId() {
|
|
||||||
// console.log('3. this.file_catch:' + this.file_catch + ',this.file_add:' + this.file_add)
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.enclosure = this.file_catch + ',' + this.file_add
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_catch
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_add
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handlePictureCardPreview(file) {
|
|
||||||
this.dialogImageUrl = file.url
|
|
||||||
},
|
|
||||||
// 上传失败
|
|
||||||
uploadError() {
|
|
||||||
this.loadding = false
|
|
||||||
},
|
|
||||||
uploadProgrees(event, file, fileList) {
|
|
||||||
if (Number(event.percent) > 0) {
|
|
||||||
this.loadding = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
|
||||||
@@ -1,243 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-upload ref="imgUpload" v-loading="loadding" class="avatar-uploader" :headers="accessToken"
|
|
||||||
:action="uploadFile" accept=".jpg,.jpeg,.png,.bmp,.pdf,.JPG,.JPEG,.BMP" list-type="picture-card"
|
|
||||||
:file-list="files" :on-remove="removeImage" :on-preview="handlePictureCardPreview"
|
|
||||||
:on-progress="uploadProgrees"
|
|
||||||
:on-error="uploadError" :on-success="uploadImgSuccess_FuJian">
|
|
||||||
<i class="el-icon-plus avatar-uploader-icon"/>
|
|
||||||
</el-upload>
|
|
||||||
<el-dialog :visible.sync="dialogVisible" :append-to-body="true" title="查看图片">
|
|
||||||
<img width="100%" :src="dialogImageUrl" alt="">
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { uploadFile } from '@/api/portal/Upload.js'
|
|
||||||
import { getStorage } from '@/utils/auth.js' //token
|
|
||||||
import { mapGetters } from 'vuex'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
model: {
|
|
||||||
prop: 'name',
|
|
||||||
event: 'change'
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
bucket: {
|
|
||||||
type: String,
|
|
||||||
default: 'abc'
|
|
||||||
},
|
|
||||||
// 长度
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '270px'
|
|
||||||
},
|
|
||||||
limit: {
|
|
||||||
type: Number,
|
|
||||||
default: 1
|
|
||||||
},
|
|
||||||
accept: {
|
|
||||||
type: String,
|
|
||||||
default:
|
|
||||||
'.jpg,.jpeg,.png,.bmp,.pdf,.JPG,.JPEG,.BMP,.PDF,.xls,.docx,.xlsx,.ppt,.pptx'
|
|
||||||
},
|
|
||||||
// 文件名称
|
|
||||||
name: {
|
|
||||||
type: Array,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
uploadData: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dialogImageUrl: '',
|
|
||||||
dialogVisible: false,
|
|
||||||
accessToken: null,
|
|
||||||
uploadFile: uploadFile,
|
|
||||||
fileList_FuJian: [],
|
|
||||||
enclosure: '',
|
|
||||||
file_add: '',
|
|
||||||
file_catch: '',
|
|
||||||
files: [],
|
|
||||||
files_list: [],
|
|
||||||
filedUrl: '',
|
|
||||||
// fileUrl: fileUrl,
|
|
||||||
// showpicture:false,
|
|
||||||
isview: false,
|
|
||||||
nameArr: '',
|
|
||||||
loadding: false,
|
|
||||||
stateName: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapGetters([
|
|
||||||
'id',
|
|
||||||
'departmentCode',
|
|
||||||
'departmentLevel',
|
|
||||||
'departmentType',
|
|
||||||
'token'
|
|
||||||
])
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
name: {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
handler(newVal, oldVal) {
|
|
||||||
console.log('aaaa1', newVal)
|
|
||||||
this.files = newVal
|
|
||||||
if (this.files.length > 1) {
|
|
||||||
this.files.splice(0, 1)
|
|
||||||
}
|
|
||||||
console.log('aaaa2', this.files)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.Init()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.uploadFile = uploadFile // 接口
|
|
||||||
this.accessToken = {
|
|
||||||
token: getStorage()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
showImg(imgList) {
|
|
||||||
this.stateName = 'xunidingjinAdd'
|
|
||||||
this.files = imgList
|
|
||||||
console.log('回显图片', this.files)
|
|
||||||
},
|
|
||||||
view() {
|
|
||||||
// window.open(this.filedUrl)
|
|
||||||
},
|
|
||||||
// 页面第一次加载
|
|
||||||
Init() {
|
|
||||||
if (this.name !== undefined) {
|
|
||||||
this.files = []
|
|
||||||
for (var i = 0; i < this.name.length; i++) {
|
|
||||||
this.files.push({
|
|
||||||
name: this.name[i],
|
|
||||||
url: this.name[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 上传方案--成功后执行
|
|
||||||
uploadImgSuccess_FuJian(response, file, fileList) {
|
|
||||||
console.log('您选择的file:', file)
|
|
||||||
if (file.response.code === '200') {
|
|
||||||
this.loadding = false
|
|
||||||
// 返显图片
|
|
||||||
this.filedUrl = this.fileUrl + file.response.data
|
|
||||||
// var uid = file.response.data
|
|
||||||
this.files.push({
|
|
||||||
name: file.response.data.sourceFileName,
|
|
||||||
url: file.response.data.fullUrl,
|
|
||||||
size: file.response.data.size
|
|
||||||
})
|
|
||||||
|
|
||||||
this.$emit('change', this.files)
|
|
||||||
this.$emit('eett', this.files)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
removeImage(file, ImageFileList) {
|
|
||||||
this.files.splice(this.files.indexOf(file), 1)
|
|
||||||
const imgFiles = []
|
|
||||||
|
|
||||||
this.files.forEach((o) => {
|
|
||||||
imgFiles.push(o.url)
|
|
||||||
})
|
|
||||||
this.$emit('fileChange', this.files)
|
|
||||||
},
|
|
||||||
handleRemove(file, fileList) {
|
|
||||||
console.log('file:' + JSON.stringify(file))
|
|
||||||
console.log('fileList:' + JSON.stringify(fileList))
|
|
||||||
this.enclosure = ''
|
|
||||||
// 1. 保存新增文件id(this.file_add)
|
|
||||||
this.getNewFileId(fileList)
|
|
||||||
// 2. 保存数据库读取的已有文件id(this.file_catch)
|
|
||||||
this.getCatchFileId(file)
|
|
||||||
// 3. 保存并拼接id
|
|
||||||
this.getFileId()
|
|
||||||
// 4. 返回拼接id
|
|
||||||
this.$emit('change', this.enclosure)
|
|
||||||
},
|
|
||||||
// 返回this.file_add(新上传文件的id拼接集合)
|
|
||||||
getNewFileId(fileList) {
|
|
||||||
// debugger
|
|
||||||
this.file_add = ''
|
|
||||||
for (var i = 0; i < fileList.length; i++) {
|
|
||||||
if (fileList[i].response && fileList[i].response.code === '200') {
|
|
||||||
this.file_add = this.file_add + fileList[i].response.data + ','
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.file_add = this.file_add.substring(0, this.file_add.length - 1)
|
|
||||||
}
|
|
||||||
// console.log('1. this.file_add: ' + this.file_add)
|
|
||||||
},
|
|
||||||
// 返回this.file_catch(数库一寸照的文件的id的拼接集合)
|
|
||||||
getCatchFileId(file) {
|
|
||||||
for (var i = 0; i < this.files_list.length; i++) {
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
// 1. 检查当前删除的文件是否是修改文件列表里面的,如果是,将修改列表里去除此id
|
|
||||||
if (this.files_list[i].name === file.name) {
|
|
||||||
// 2. 拆开file_catch到fils_arry
|
|
||||||
var fils_arry = this.file_catch.split(',')
|
|
||||||
// 3. 从fils_arry去除 this.files_list[i].id
|
|
||||||
var arry = []
|
|
||||||
fils_arry.forEach((element) => {
|
|
||||||
// 不加载文件里面的
|
|
||||||
if (element !== this.files_list[i].id) {
|
|
||||||
arry.push(element)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 4. 重新拼接成file_catch
|
|
||||||
this.file_catch = arry.join(',')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// console.log('2. this.file_catch:' + this.file_catch)
|
|
||||||
},
|
|
||||||
// 保存并拼接id
|
|
||||||
getFileId() {
|
|
||||||
// console.log('3. this.file_catch:' + this.file_catch + ',this.file_add:' + this.file_add)
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.enclosure = this.file_catch + ',' + this.file_add
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_catch
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_add
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handlePictureCardPreview(file) {
|
|
||||||
this.dialogImageUrl = file.url
|
|
||||||
this.dialogVisible = true
|
|
||||||
},
|
|
||||||
// 上传失败
|
|
||||||
uploadError() {
|
|
||||||
this.loadding = false
|
|
||||||
},
|
|
||||||
uploadProgrees(event, file, fileList) {
|
|
||||||
if (Number(event.percent) > 0) {
|
|
||||||
this.loadding = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
|
||||||
@@ -1,165 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-upload ref="imgUpload" v-loading="loadding" class="avatar-uploader" :headers="accessToken" :action="uploadFile" :accept="accept" :limit="limit" list-type="picture-card" :file-list="files" :on-remove="removeImage" :on-preview="handlePictureCardPreview" :on-progress="uploadProgrees" :on-error="uploadError" :on-success="uploadImgSuccess_FuJian" :multiple="multiple">
|
|
||||||
<i class="el-icon-plus avatar-uploader-icon"/>
|
|
||||||
</el-upload>
|
|
||||||
<el-dialog :visible.sync="dialogVisible" title="查看图片">
|
|
||||||
<img width="100%" :src="dialogImageUrl" alt="">
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { uploadFile_yanchejiancha } from '@/api/portal/Upload.js'
|
|
||||||
import { getStorage } from '@/utils/auth.js'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
model: {
|
|
||||||
prop: 'name',
|
|
||||||
event: 'change'
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
bucket: {
|
|
||||||
type: String,
|
|
||||||
default: 'abc'
|
|
||||||
},
|
|
||||||
// 长度
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '270px'
|
|
||||||
},
|
|
||||||
limit: {
|
|
||||||
type: Number,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
multiple: {
|
|
||||||
type: Boolean,
|
|
||||||
default: true
|
|
||||||
},
|
|
||||||
accept: {
|
|
||||||
type: String,
|
|
||||||
default: '.jpg,.jpeg,.png,.JPG,.JPEG,'
|
|
||||||
},
|
|
||||||
// 文件名称
|
|
||||||
name: {
|
|
||||||
type: Array,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
uploadData: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dialogImageUrl: '',
|
|
||||||
dialogVisible: false,
|
|
||||||
accessToken: null,
|
|
||||||
uploadFile: uploadFile_yanchejiancha,
|
|
||||||
fileList_FuJian: [],
|
|
||||||
enclosure: '',
|
|
||||||
file_add: '',
|
|
||||||
file_catch: '',
|
|
||||||
files: [],
|
|
||||||
files_list: [],
|
|
||||||
filedUrl: '',
|
|
||||||
// fileUrl: fileUrl,
|
|
||||||
// showpicture:false,
|
|
||||||
isview: false,
|
|
||||||
nameArr: '',
|
|
||||||
loadding: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
name: {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
handler(newVal, oldVal) {
|
|
||||||
console.log('aaaa1', newVal)
|
|
||||||
this.files = newVal
|
|
||||||
console.log('aaaa2', this.files)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.Init()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.uploadFile = uploadFile_yanchejiancha // 接口
|
|
||||||
this.accessToken = {
|
|
||||||
token: getStorage()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
showImg(imgList) {
|
|
||||||
this.files = imgList
|
|
||||||
console.log('123123123', this.files)
|
|
||||||
},
|
|
||||||
view() {
|
|
||||||
// window.open(this.filedUrl)
|
|
||||||
},
|
|
||||||
// 页面第一次加载
|
|
||||||
Init() {
|
|
||||||
console.log(this.name, 78788)
|
|
||||||
if (this.name !== undefined) {
|
|
||||||
this.files = []
|
|
||||||
for (var i = 0; i < this.name.length; i++) {
|
|
||||||
this.files.push({
|
|
||||||
name: this.name[i],
|
|
||||||
url: this.name[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handlePictureCardPreview(file) {
|
|
||||||
console.log(this.file)
|
|
||||||
this.dialogVisible = true
|
|
||||||
this.dialogImageUrl = file.url
|
|
||||||
},
|
|
||||||
// 上传方案--成功后执行
|
|
||||||
uploadImgSuccess_FuJian(response, file) {
|
|
||||||
console.log('您选择的file:', file)
|
|
||||||
if (file.response.code === '200') {
|
|
||||||
this.loadding = false
|
|
||||||
// 返显图片
|
|
||||||
this.filedUrl = this.fileUrl + file.response.data
|
|
||||||
// var uid = file.response.data
|
|
||||||
this.files.push({
|
|
||||||
name: file.response.data.sourceFileName,
|
|
||||||
url: file.response.data.fullUrl,
|
|
||||||
size: file.response.data.size
|
|
||||||
})
|
|
||||||
this.$emit('change', this.files)
|
|
||||||
this.$emit('eett', this.files)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
removeImage(file, ImageFileList) {
|
|
||||||
this.files.splice(this.files.indexOf(file), 1)
|
|
||||||
const imgFiles = []
|
|
||||||
this.files.forEach((o) => {
|
|
||||||
imgFiles.push(o.url)
|
|
||||||
})
|
|
||||||
this.$emit('fileChange', this.files)
|
|
||||||
},
|
|
||||||
// 上传失败
|
|
||||||
uploadError() {
|
|
||||||
this.loadding = false
|
|
||||||
},
|
|
||||||
uploadProgrees(event, file, fileList) {
|
|
||||||
if (Number(event.percent) > 0) {
|
|
||||||
this.loadding = true
|
|
||||||
}
|
|
||||||
// console.log('event:', event)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,245 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-upload ref="imgUpload" v-loading="loadding" class="avatar-uploader" :headers="accessToken"
|
|
||||||
:action="uploadFile" accept=".jpg,.jpeg,.png,.bmp,.pdf,.JPG,.JPEG,.BMP" list-type="picture-card"
|
|
||||||
:file-list="files" :on-remove="removeImage" :on-preview="handlePictureCardPreview"
|
|
||||||
:on-progress="uploadProgrees"
|
|
||||||
:on-error="uploadError" :on-success="uploadImgSuccess_FuJian">
|
|
||||||
<i class="el-icon-plus avatar-uploader-icon"/>
|
|
||||||
</el-upload>
|
|
||||||
<el-dialog :visible.sync="dialogVisible" :append-to-body="true" title="查看图片">
|
|
||||||
<img width="100%" :src="dialogImageUrl" alt="">
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { uploadFile } from '@/api/portal/Upload.js'
|
|
||||||
import { getStorage } from '@/utils/auth.js' //token
|
|
||||||
import { mapGetters } from 'vuex'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
model: {
|
|
||||||
prop: 'name',
|
|
||||||
event: 'change'
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
bucket: {
|
|
||||||
type: String,
|
|
||||||
default: 'abc'
|
|
||||||
},
|
|
||||||
// 长度
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '270px'
|
|
||||||
},
|
|
||||||
limit: {
|
|
||||||
type: Number,
|
|
||||||
default: 1
|
|
||||||
},
|
|
||||||
accept: {
|
|
||||||
type: String,
|
|
||||||
default:
|
|
||||||
'.jpg,.jpeg,.png,.JPG,.JPEG'
|
|
||||||
},
|
|
||||||
// 文件名称
|
|
||||||
name: {
|
|
||||||
type: Array,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
uploadData: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dialogImageUrl: '',
|
|
||||||
dialogVisible: false,
|
|
||||||
accessToken: null,
|
|
||||||
uploadFile: uploadFile,
|
|
||||||
fileList_FuJian: [],
|
|
||||||
enclosure: '',
|
|
||||||
file_add: '',
|
|
||||||
file_catch: '',
|
|
||||||
files: [],
|
|
||||||
files_list: [],
|
|
||||||
filedUrl: '',
|
|
||||||
// fileUrl: fileUrl,
|
|
||||||
// showpicture:false,
|
|
||||||
isview: false,
|
|
||||||
nameArr: '',
|
|
||||||
loadding: false,
|
|
||||||
stateName: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapGetters([
|
|
||||||
'id',
|
|
||||||
'departmentCode',
|
|
||||||
'departmentLevel',
|
|
||||||
'departmentType',
|
|
||||||
'token'
|
|
||||||
])
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
name: {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
handler(newVal, oldVal) {
|
|
||||||
console.log('aaaa1', newVal)
|
|
||||||
this.files = newVal
|
|
||||||
// if (this.stateName = 'xunidingjinAdd') {
|
|
||||||
// if (this.files.length > 1) {
|
|
||||||
// this.files.splice(0, 1)
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
console.log('aaaa2', this.files)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.Init()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.uploadFile = uploadFile // 接口
|
|
||||||
this.accessToken = {
|
|
||||||
token: getStorage()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
showImg(imgList) {
|
|
||||||
this.stateName = 'xunidingjinAdd'
|
|
||||||
this.files = imgList
|
|
||||||
console.log('回显图片', this.files)
|
|
||||||
},
|
|
||||||
view() {
|
|
||||||
// window.open(this.filedUrl)
|
|
||||||
},
|
|
||||||
// 页面第一次加载
|
|
||||||
Init() {
|
|
||||||
if (this.name !== undefined) {
|
|
||||||
this.files = []
|
|
||||||
for (var i = 0; i < this.name.length; i++) {
|
|
||||||
this.files.push({
|
|
||||||
name: this.name[i],
|
|
||||||
url: this.name[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 上传方案--成功后执行
|
|
||||||
uploadImgSuccess_FuJian(response, file, fileList) {
|
|
||||||
console.log('您选择的file:', file)
|
|
||||||
if (file.response.code === '200') {
|
|
||||||
this.loadding = false
|
|
||||||
// 返显图片
|
|
||||||
this.filedUrl = this.fileUrl + file.response.data
|
|
||||||
// var uid = file.response.data
|
|
||||||
this.files.push({
|
|
||||||
name: file.response.data.sourceFileName,
|
|
||||||
url: file.response.data.fullUrl,
|
|
||||||
filePath: file.response.data.filePath,
|
|
||||||
size: file.response.data.size
|
|
||||||
})
|
|
||||||
this.$emit('change', this.files)
|
|
||||||
this.$emit('eett', this.files)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
removeImage(file, ImageFileList) {
|
|
||||||
this.files.splice(this.files.indexOf(file), 1)
|
|
||||||
const imgFiles = []
|
|
||||||
|
|
||||||
this.files.forEach((o) => {
|
|
||||||
imgFiles.push(o.url)
|
|
||||||
})
|
|
||||||
this.$emit('fileChange', this.files)
|
|
||||||
},
|
|
||||||
handleRemove(file, fileList) {
|
|
||||||
console.log('file:' + JSON.stringify(file))
|
|
||||||
console.log('fileList:' + JSON.stringify(fileList))
|
|
||||||
this.enclosure = ''
|
|
||||||
// 1. 保存新增文件id(this.file_add)
|
|
||||||
this.getNewFileId(fileList)
|
|
||||||
// 2. 保存数据库读取的已有文件id(this.file_catch)
|
|
||||||
this.getCatchFileId(file)
|
|
||||||
// 3. 保存并拼接id
|
|
||||||
this.getFileId()
|
|
||||||
// 4. 返回拼接id
|
|
||||||
this.$emit('change', this.enclosure)
|
|
||||||
},
|
|
||||||
// 返回this.file_add(新上传文件的id拼接集合)
|
|
||||||
getNewFileId(fileList) {
|
|
||||||
// debugger
|
|
||||||
this.file_add = ''
|
|
||||||
for (var i = 0; i < fileList.length; i++) {
|
|
||||||
if (fileList[i].response && fileList[i].response.code === '200') {
|
|
||||||
this.file_add = this.file_add + fileList[i].response.data + ','
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.file_add = this.file_add.substring(0, this.file_add.length - 1)
|
|
||||||
}
|
|
||||||
// console.log('1. this.file_add: ' + this.file_add)
|
|
||||||
},
|
|
||||||
// 返回this.file_catch(数库一寸照的文件的id的拼接集合)
|
|
||||||
getCatchFileId(file) {
|
|
||||||
for (var i = 0; i < this.files_list.length; i++) {
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
// 1. 检查当前删除的文件是否是修改文件列表里面的,如果是,将修改列表里去除此id
|
|
||||||
if (this.files_list[i].name === file.name) {
|
|
||||||
// 2. 拆开file_catch到fils_arry
|
|
||||||
var fils_arry = this.file_catch.split(',')
|
|
||||||
// 3. 从fils_arry去除 this.files_list[i].id
|
|
||||||
var arry = []
|
|
||||||
fils_arry.forEach((element) => {
|
|
||||||
// 不加载文件里面的
|
|
||||||
if (element !== this.files_list[i].id) {
|
|
||||||
arry.push(element)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 4. 重新拼接成file_catch
|
|
||||||
this.file_catch = arry.join(',')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// console.log('2. this.file_catch:' + this.file_catch)
|
|
||||||
},
|
|
||||||
// 保存并拼接id
|
|
||||||
getFileId() {
|
|
||||||
// console.log('3. this.file_catch:' + this.file_catch + ',this.file_add:' + this.file_add)
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.enclosure = this.file_catch + ',' + this.file_add
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_catch
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_add
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handlePictureCardPreview(file) {
|
|
||||||
this.dialogImageUrl = file.url
|
|
||||||
this.dialogVisible = true
|
|
||||||
},
|
|
||||||
// 上传失败
|
|
||||||
uploadError() {
|
|
||||||
this.loadding = false
|
|
||||||
},
|
|
||||||
uploadProgrees(event, file, fileList) {
|
|
||||||
if (Number(event.percent) > 0) {
|
|
||||||
this.loadding = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,230 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-upload class="upload-demo" :headers="accessToken" :action="uploadFile" :accept="accept" :data="uploadData"
|
|
||||||
:on-success="uploadImgSuccess_FuJian" :on-remove="handleRemove" :file-list="fileList_FuJian"
|
|
||||||
:on-preview="handlePictureCardPreview" :show-file-list="false" :multiple="true">
|
|
||||||
<el-button size="mini" type="primary">点击上传</el-button>
|
|
||||||
</el-upload>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { uploadFile_yanchejiancha } from '@/api/portal/Upload'
|
|
||||||
import { getStorage } from '@/utils/auth.js'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
model: {
|
|
||||||
prop: 'name',
|
|
||||||
event: 'change'
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
bucket: {
|
|
||||||
type: String,
|
|
||||||
default: 'abc'
|
|
||||||
},
|
|
||||||
// 长度
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '270px'
|
|
||||||
},
|
|
||||||
limit: {
|
|
||||||
type: Number,
|
|
||||||
default: 1
|
|
||||||
},
|
|
||||||
accept: {
|
|
||||||
type: String,
|
|
||||||
default:
|
|
||||||
'.jpg,.jpeg,.png,.JPG,.JPEG'
|
|
||||||
},
|
|
||||||
// 文件名称
|
|
||||||
name: {
|
|
||||||
type: Array,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
uploadData: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dialogImageUrl: '',
|
|
||||||
dialogVisible: false,
|
|
||||||
accessToken: null,
|
|
||||||
uploadFile: uploadFile_yanchejiancha,
|
|
||||||
fileList_FuJian: [],
|
|
||||||
enclosure: '',
|
|
||||||
file_add: '',
|
|
||||||
file_catch: '',
|
|
||||||
files: [],
|
|
||||||
files_list: [],
|
|
||||||
filedUrl: '',
|
|
||||||
// fileUrl: fileUrl,
|
|
||||||
// showpicture:false,
|
|
||||||
isview: false,
|
|
||||||
nameArr: '',
|
|
||||||
loadding: false,
|
|
||||||
stateName: '',
|
|
||||||
/* uploadData: { modelSid: '' },*/
|
|
||||||
sid: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
name: {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
handler(newVal, oldVal) {
|
|
||||||
console.log('aaaa1', newVal)
|
|
||||||
this.files = newVal
|
|
||||||
console.log('aaaa2', this.files)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.Init()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.uploadFile = uploadFile_yanchejiancha // 接口
|
|
||||||
this.accessToken = {
|
|
||||||
token: getStorage()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
view() {
|
|
||||||
// window.open(this.filedUrl)
|
|
||||||
},
|
|
||||||
showImg(sid) {
|
|
||||||
// this.uploadData.sid = sid
|
|
||||||
},
|
|
||||||
|
|
||||||
// 页面第一次加载
|
|
||||||
Init() {
|
|
||||||
if (this.name !== undefined) {
|
|
||||||
this.files = []
|
|
||||||
for (var i = 0; i < this.name.length; i++) {
|
|
||||||
this.files.push({
|
|
||||||
name: this.name[i],
|
|
||||||
url: this.name[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 上传方案--成功后执行
|
|
||||||
uploadImgSuccess_FuJian(response, file, fileList) {
|
|
||||||
let _this = this
|
|
||||||
console.log('您选择的file:', file)
|
|
||||||
// console.log('您传递的data:', _this.uploadData)
|
|
||||||
if (file.response.code === '200') {
|
|
||||||
this.loadding = false
|
|
||||||
// 返显图片
|
|
||||||
this.filedUrl = this.fileUrl + file.response.data
|
|
||||||
// var uid = file.response.data
|
|
||||||
const files = []
|
|
||||||
files.push({
|
|
||||||
name: file.response.data.sourceFileName,
|
|
||||||
url: file.response.data.fullUrl,
|
|
||||||
size: file.response.data.size
|
|
||||||
})
|
|
||||||
this.$emit('change', files)
|
|
||||||
this.$emit('eett', files)
|
|
||||||
// this.getUrl()
|
|
||||||
// SaveList(this.tempInfo).then(response => {
|
|
||||||
// if (response.success) {
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
},
|
|
||||||
removeImage(file, ImageFileList) {
|
|
||||||
this.files.splice(this.files.indexOf(file), 1)
|
|
||||||
const imgFiles = []
|
|
||||||
this.files.forEach((o) => {
|
|
||||||
imgFiles.push(o.url)
|
|
||||||
})
|
|
||||||
this.$emit('fileChange', this.files)
|
|
||||||
},
|
|
||||||
handleRemove(file, fileList) {
|
|
||||||
console.log('file:' + JSON.stringify(file))
|
|
||||||
console.log('fileList:' + JSON.stringify(fileList))
|
|
||||||
this.enclosure = ''
|
|
||||||
// 1. 保存新增文件id(this.file_add)
|
|
||||||
this.getNewFileId(fileList)
|
|
||||||
// 2. 保存数据库读取的已有文件id(this.file_catch)
|
|
||||||
this.getCatchFileId(file)
|
|
||||||
// 3. 保存并拼接id
|
|
||||||
this.getFileId()
|
|
||||||
// 4. 返回拼接id
|
|
||||||
this.$emit('change', this.enclosure)
|
|
||||||
},
|
|
||||||
// 返回this.file_add(新上传文件的id拼接集合)
|
|
||||||
getNewFileId(fileList) {
|
|
||||||
// debugger
|
|
||||||
this.file_add = ''
|
|
||||||
for (var i = 0; i < fileList.length; i++) {
|
|
||||||
if (fileList[i].response && fileList[i].response.code === '200') {
|
|
||||||
this.file_add = this.file_add + fileList[i].response.data + ','
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.file_add = this.file_add.substring(0, this.file_add.length - 1)
|
|
||||||
}
|
|
||||||
// console.log('1. this.file_add: ' + this.file_add)
|
|
||||||
},
|
|
||||||
// 返回this.file_catch(数库一寸照的文件的id的拼接集合)
|
|
||||||
getCatchFileId(file) {
|
|
||||||
for (var i = 0; i < this.files_list.length; i++) {
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
// 1. 检查当前删除的文件是否是修改文件列表里面的,如果是,将修改列表里去除此id
|
|
||||||
if (this.files_list[i].name === file.name) {
|
|
||||||
// 2. 拆开file_catch到fils_arry
|
|
||||||
var fils_arry = this.file_catch.split(',')
|
|
||||||
// 3. 从fils_arry去除 this.files_list[i].id
|
|
||||||
var arry = []
|
|
||||||
fils_arry.forEach((element) => {
|
|
||||||
// 不加载文件里面的
|
|
||||||
if (element !== this.files_list[i].id) {
|
|
||||||
arry.push(element)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 4. 重新拼接成file_catch
|
|
||||||
this.file_catch = arry.join(',')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// console.log('2. this.file_catch:' + this.file_catch)
|
|
||||||
},
|
|
||||||
// 保存并拼接id
|
|
||||||
getFileId() {
|
|
||||||
// console.log('3. this.file_catch:' + this.file_catch + ',this.file_add:' + this.file_add)
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.enclosure = this.file_catch + ',' + this.file_add
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_catch
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_add
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handlePictureCardPreview(file) {
|
|
||||||
this.dialogImageUrl = file.url
|
|
||||||
},
|
|
||||||
// 上传失败
|
|
||||||
uploadError() {
|
|
||||||
this.loadding = false
|
|
||||||
},
|
|
||||||
uploadProgrees(event, file, fileList) {
|
|
||||||
if (Number(event.percent) > 0) {
|
|
||||||
this.loadding = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,227 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div>
|
|
||||||
<el-upload ref="imgUpload" v-loading="loadding" class="avatar-uploader" :limit="limit" :headers="accessToken" :action="uploadFile"
|
|
||||||
:accept="accept" list-type="picture-card" :file-list="files" :on-remove="removeImage"
|
|
||||||
:on-preview="handlePictureCardPreview" :on-progress="uploadProgrees"
|
|
||||||
:on-error="uploadError" :on-success="uploadImgSuccess_FuJian">
|
|
||||||
<i class="el-icon-plus avatar-uploader-icon" />
|
|
||||||
</el-upload>
|
|
||||||
<el-dialog :visible.sync="dialogVisible" title="查看图片">
|
|
||||||
<img width="100%" :src="dialogImageUrl" alt="">
|
|
||||||
</el-dialog>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import {
|
|
||||||
uploadFile
|
|
||||||
} from '@/api/portal/Upload'
|
|
||||||
import {
|
|
||||||
getStorage
|
|
||||||
} from '@/utils/auth.js'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
model: {
|
|
||||||
prop: 'name',
|
|
||||||
event: 'change'
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
bucket: {
|
|
||||||
type: String,
|
|
||||||
default: 'abc'
|
|
||||||
},
|
|
||||||
// 长度
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '270px'
|
|
||||||
},
|
|
||||||
limit: {
|
|
||||||
type: Number,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
accept: {
|
|
||||||
type: String,
|
|
||||||
default: '.jpg,.jpeg,.png,.JPG,.JPEG,'
|
|
||||||
},
|
|
||||||
// 文件名称
|
|
||||||
name: {
|
|
||||||
type: Array,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
uploadData: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dialogImageUrl: '',
|
|
||||||
dialogVisible: false,
|
|
||||||
accessToken: null,
|
|
||||||
uploadFile: uploadFile,
|
|
||||||
fileList_FuJian: [],
|
|
||||||
enclosure: '',
|
|
||||||
file_add: '',
|
|
||||||
file_catch: '',
|
|
||||||
files: [],
|
|
||||||
files_list: [],
|
|
||||||
filedUrl: '',
|
|
||||||
// fileUrl: fileUrl,
|
|
||||||
// showpicture:false,
|
|
||||||
isview: false,
|
|
||||||
nameArr: '',
|
|
||||||
loadding: false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
name: {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
handler(newVal, oldVal) {
|
|
||||||
this.files = newVal
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.Init()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.uploadFile = uploadFile // 接口
|
|
||||||
this.accessToken = {
|
|
||||||
token: getStorage()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
showImg(imgList) {
|
|
||||||
this.files = imgList
|
|
||||||
},
|
|
||||||
view() {
|
|
||||||
// window.open(this.filedUrl)
|
|
||||||
},
|
|
||||||
// 页面第一次加载
|
|
||||||
Init() {
|
|
||||||
if (this.name !== undefined) {
|
|
||||||
this.files = []
|
|
||||||
for (var i = 0; i < this.name.length; i++) {
|
|
||||||
this.files.push({
|
|
||||||
name: this.name[i],
|
|
||||||
url: this.name[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handlePictureCardPreview(file) {
|
|
||||||
this.dialogVisible = true
|
|
||||||
this.dialogImageUrl = file.url
|
|
||||||
},
|
|
||||||
// 上传方案--成功后执行
|
|
||||||
uploadImgSuccess_FuJian(response, file, fileList) {
|
|
||||||
console.log('您选择的file:', file)
|
|
||||||
if (file.response.code === '200') {
|
|
||||||
this.loadding = false
|
|
||||||
// 返显图片
|
|
||||||
this.filedUrl = this.fileUrl + file.response.data
|
|
||||||
// var uid = file.response.data
|
|
||||||
this.files.push({
|
|
||||||
name: file.response.data.sourceFileName,
|
|
||||||
url: file.response.data.fullUrl,
|
|
||||||
size: file.response.data.size
|
|
||||||
})
|
|
||||||
this.$emit('change', this.files)
|
|
||||||
this.$emit('eett', this.files)
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
removeImage(file, ImageFileList) {
|
|
||||||
this.files.splice(this.files.indexOf(file), 1)
|
|
||||||
const imgFiles = []
|
|
||||||
this.files.forEach((o) => {
|
|
||||||
imgFiles.push(o.url)
|
|
||||||
})
|
|
||||||
this.$emit('fileChange', this.files)
|
|
||||||
this.$emit('change', this.files)
|
|
||||||
},
|
|
||||||
handleRemove(file, fileList) {
|
|
||||||
console.log('file:' + JSON.stringify(file))
|
|
||||||
console.log('fileList:' + JSON.stringify(fileList))
|
|
||||||
this.enclosure = ''
|
|
||||||
// 1. 保存新增文件id(this.file_add)
|
|
||||||
this.getNewFileId(fileList)
|
|
||||||
// 2. 保存数据库读取的已有文件id(this.file_catch)
|
|
||||||
this.getCatchFileId(file)
|
|
||||||
// 3. 保存并拼接id
|
|
||||||
this.getFileId()
|
|
||||||
// 4. 返回拼接id
|
|
||||||
this.$emit('change', this.enclosure)
|
|
||||||
},
|
|
||||||
// 返回this.file_add(新上传文件的id拼接集合)
|
|
||||||
getNewFileId(fileList) {
|
|
||||||
// debugger
|
|
||||||
this.file_add = ''
|
|
||||||
for (var i = 0; i < fileList.length; i++) {
|
|
||||||
if (fileList[i].response && fileList[i].response.code === '200') {
|
|
||||||
this.file_add = this.file_add + fileList[i].response.data + ','
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.file_add = this.file_add.substring(0, this.file_add.length - 1)
|
|
||||||
}
|
|
||||||
// console.log('1. this.file_add: ' + this.file_add)
|
|
||||||
},
|
|
||||||
// 返回this.file_catch(数库一寸照的文件的id的拼接集合)
|
|
||||||
getCatchFileId(file) {
|
|
||||||
for (var i = 0; i < this.files_list.length; i++) {
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
// 1. 检查当前删除的文件是否是修改文件列表里面的,如果是,将修改列表里去除此id
|
|
||||||
if (this.files_list[i].name === file.name) {
|
|
||||||
// 2. 拆开file_catch到fils_arry
|
|
||||||
var fils_arry = this.file_catch.split(',')
|
|
||||||
// 3. 从fils_arry去除 this.files_list[i].id
|
|
||||||
var arry = []
|
|
||||||
fils_arry.forEach((element) => {
|
|
||||||
// 不加载文件里面的
|
|
||||||
if (element !== this.files_list[i].id) {
|
|
||||||
arry.push(element)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 4. 重新拼接成file_catch
|
|
||||||
this.file_catch = arry.join(',')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// console.log('2. this.file_catch:' + this.file_catch)
|
|
||||||
},
|
|
||||||
// 保存并拼接id
|
|
||||||
getFileId() {
|
|
||||||
// console.log('3. this.file_catch:' + this.file_catch + ',this.file_add:' + this.file_add)
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.enclosure = this.file_catch + ',' + this.file_add
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_catch
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_add
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 上传失败
|
|
||||||
uploadError() {
|
|
||||||
this.loadding = false
|
|
||||||
},
|
|
||||||
uploadProgrees(event, file, fileList) {
|
|
||||||
if (Number(event.percent) > 0) {
|
|
||||||
this.loadding = true
|
|
||||||
}
|
|
||||||
// console.log('event:', event)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped></style>
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-upload class="avatar-uploader" ref="upload" action="fakeaction"
|
|
||||||
:show-file-list="false"
|
|
||||||
:on-change="uploadchangeFile"
|
|
||||||
:http-request="uploadSectionFile">
|
|
||||||
<img v-if="FrontPhoto" :src="FrontPhoto" class="avatar">
|
|
||||||
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
|
|
||||||
<div slot="tip" class="el-upload__tip">{{tip}}</div>
|
|
||||||
</el-upload>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { imageUpload } from '@/api/Upload.js'
|
|
||||||
export default {
|
|
||||||
props:{
|
|
||||||
tip:{
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
FrontPhoto: '',
|
|
||||||
};
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
// 上传文件 FrontPhoto
|
|
||||||
uploadSectionFile(params) {
|
|
||||||
const file = params.file,
|
|
||||||
fileType = file.type,
|
|
||||||
isImage = fileType.indexOf("image") != -1,
|
|
||||||
isLt2M = file.size / 1024 / 1024 < 2;
|
|
||||||
console.log(params)
|
|
||||||
// 这里常规检验,看项目需求而定
|
|
||||||
if (!isImage) {
|
|
||||||
this.$message.error("只能上传图片格式png、jpg、gif!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (!isLt2M) {
|
|
||||||
this.$message.error("只能上传图片大小小于2M");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 根据后台需求数据格式
|
|
||||||
const form = new FormData();
|
|
||||||
console.log(form)
|
|
||||||
// 文件对象
|
|
||||||
form.append("file", file);
|
|
||||||
|
|
||||||
// 项目封装的请求方法,下面做简单介绍
|
|
||||||
imageUpload(form).then(res => {
|
|
||||||
//自行处理各种情况
|
|
||||||
console.log(res)
|
|
||||||
this.$emit('imgUrl',res.filePath)
|
|
||||||
// this.FrontPhoto = res.fullUrl
|
|
||||||
if(res.msg == '操作成功'){
|
|
||||||
this.$message({
|
|
||||||
message: '上传成功!',
|
|
||||||
type: 'success'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.catch((err) => {
|
|
||||||
console.log(err)
|
|
||||||
});
|
|
||||||
},
|
|
||||||
uploadchangeFile(file){
|
|
||||||
this.FrontPhoto = URL.createObjectURL(file.raw)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.avatar-uploader .el-upload {
|
|
||||||
border: 1px dashed #d9d9d9;
|
|
||||||
border-radius: 6px;
|
|
||||||
cursor: pointer;
|
|
||||||
position: relative;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-uploader .el-upload:hover {
|
|
||||||
border-color: #409EFF;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar-uploader-icon {
|
|
||||||
font-size: 28px;
|
|
||||||
color: #8c939d;
|
|
||||||
width: 200px;
|
|
||||||
height: 178px;
|
|
||||||
line-height: 178px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar {
|
|
||||||
width: 178px;
|
|
||||||
height: 178px;
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.el-upload__tip{
|
|
||||||
line-height: 25px;
|
|
||||||
margin-top: 0;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -1,242 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div><!---->
|
|
||||||
<el-upload class="upload-demo" :headers="accessToken" :action="uploadFile" :accept="accept" :data="uploadData"
|
|
||||||
:on-success="uploadImgSuccess_FuJian" :on-remove="handleRemove" :file-list="fileList_FuJian"
|
|
||||||
:on-preview="handlePictureCardPreview" :show-file-list="false">
|
|
||||||
<el-button size="mini" type="primary">上传</el-button>
|
|
||||||
</el-upload>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { uploadFile } from '@/api/Common/Upload'
|
|
||||||
import { getStorage } from '@/utils/auth.js' //token
|
|
||||||
import {
|
|
||||||
SaveList
|
|
||||||
} from '@/api/cheliang/basevehiclemodel'
|
|
||||||
import { mapGetters } from 'vuex'
|
|
||||||
|
|
||||||
export default {
|
|
||||||
model: {
|
|
||||||
prop: 'name',
|
|
||||||
event: 'change'
|
|
||||||
},
|
|
||||||
props: {
|
|
||||||
placeholder: {
|
|
||||||
type: String,
|
|
||||||
default: ''
|
|
||||||
},
|
|
||||||
bucket: {
|
|
||||||
type: String,
|
|
||||||
default: 'abc'
|
|
||||||
},
|
|
||||||
// 长度
|
|
||||||
width: {
|
|
||||||
type: String,
|
|
||||||
default: '270px'
|
|
||||||
},
|
|
||||||
limit: {
|
|
||||||
type: Number,
|
|
||||||
default: 1
|
|
||||||
},
|
|
||||||
accept: {
|
|
||||||
type: String,
|
|
||||||
default:
|
|
||||||
'.jpg,.jpeg,.png,.bmp,.pdf,.JPG,.JPEG,.BMP,.PDF,.xls,.docx,.xlsx,.ppt,.pptx'
|
|
||||||
},
|
|
||||||
// 文件名称
|
|
||||||
name: {
|
|
||||||
type: Array,
|
|
||||||
required: true
|
|
||||||
},
|
|
||||||
uploadData: {
|
|
||||||
type: Object,
|
|
||||||
default: {}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
dialogImageUrl: '',
|
|
||||||
dialogVisible: false,
|
|
||||||
accessToken: null,
|
|
||||||
uploadFile: uploadFile,
|
|
||||||
fileList_FuJian: [],
|
|
||||||
enclosure: '',
|
|
||||||
file_add: '',
|
|
||||||
file_catch: '',
|
|
||||||
files: [],
|
|
||||||
files_list: [],
|
|
||||||
filedUrl: '',
|
|
||||||
// fileUrl: fileUrl,
|
|
||||||
// showpicture:false,
|
|
||||||
isview: false,
|
|
||||||
nameArr: '',
|
|
||||||
loadding: false,
|
|
||||||
stateName: '',
|
|
||||||
/* uploadData: { modelSid: '' },*/
|
|
||||||
sid: ''
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
|
||||||
...mapGetters([
|
|
||||||
'id',
|
|
||||||
'departmentCode',
|
|
||||||
'departmentLevel',
|
|
||||||
'departmentType',
|
|
||||||
'token'
|
|
||||||
])
|
|
||||||
},
|
|
||||||
watch: {
|
|
||||||
name: {
|
|
||||||
deep: true,
|
|
||||||
immediate: true,
|
|
||||||
handler(newVal, oldVal) {
|
|
||||||
console.log('aaaa1', newVal)
|
|
||||||
this.files = newVal
|
|
||||||
console.log('aaaa2', this.files)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
mounted() {
|
|
||||||
this.$nextTick(() => {
|
|
||||||
this.Init()
|
|
||||||
})
|
|
||||||
},
|
|
||||||
created() {
|
|
||||||
this.uploadFile = uploadFile // 接口
|
|
||||||
this.accessToken = {
|
|
||||||
token: getStorage()
|
|
||||||
}
|
|
||||||
},
|
|
||||||
methods: {
|
|
||||||
view() {
|
|
||||||
// window.open(this.filedUrl)
|
|
||||||
},
|
|
||||||
showImg(sid) {
|
|
||||||
// this.uploadData.sid = sid
|
|
||||||
},
|
|
||||||
|
|
||||||
// 页面第一次加载
|
|
||||||
Init() {
|
|
||||||
if (this.name !== undefined) {
|
|
||||||
this.files = []
|
|
||||||
for (var i = 0; i < this.name.length; i++) {
|
|
||||||
this.files.push({
|
|
||||||
name: this.name[i],
|
|
||||||
url: this.name[i]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// 上传方案--成功后执行
|
|
||||||
uploadImgSuccess_FuJian(response, file, fileList) {
|
|
||||||
let _this = this
|
|
||||||
console.log('您选择的file:', file)
|
|
||||||
// console.log('您传递的data:', _this.uploadData)
|
|
||||||
if (file.response.code === '200') {
|
|
||||||
this.loadding = false
|
|
||||||
// 返显图片
|
|
||||||
this.filedUrl = this.fileUrl + file.response.data
|
|
||||||
// var uid = file.response.data
|
|
||||||
this.files.push({
|
|
||||||
name: file.response.data.sourceFileName,
|
|
||||||
url: file.response.data.fullUrl,
|
|
||||||
size: file.response.data.size
|
|
||||||
})
|
|
||||||
this.$emit('change', this.files)
|
|
||||||
this.$emit('eett', this.files)
|
|
||||||
// this.getUrl()
|
|
||||||
// SaveList(this.tempInfo).then(response => {
|
|
||||||
// if (response.success) {
|
|
||||||
// }
|
|
||||||
// })
|
|
||||||
}
|
|
||||||
},
|
|
||||||
removeImage(file, ImageFileList) {
|
|
||||||
this.files.splice(this.files.indexOf(file), 1)
|
|
||||||
const imgFiles = []
|
|
||||||
this.files.forEach((o) => {
|
|
||||||
imgFiles.push(o.url)
|
|
||||||
})
|
|
||||||
this.$emit('fileChange', this.files)
|
|
||||||
},
|
|
||||||
handleRemove(file, fileList) {
|
|
||||||
console.log('file:' + JSON.stringify(file))
|
|
||||||
console.log('fileList:' + JSON.stringify(fileList))
|
|
||||||
this.enclosure = ''
|
|
||||||
// 1. 保存新增文件id(this.file_add)
|
|
||||||
this.getNewFileId(fileList)
|
|
||||||
// 2. 保存数据库读取的已有文件id(this.file_catch)
|
|
||||||
this.getCatchFileId(file)
|
|
||||||
// 3. 保存并拼接id
|
|
||||||
this.getFileId()
|
|
||||||
// 4. 返回拼接id
|
|
||||||
this.$emit('change', this.enclosure)
|
|
||||||
},
|
|
||||||
// 返回this.file_add(新上传文件的id拼接集合)
|
|
||||||
getNewFileId(fileList) {
|
|
||||||
// debugger
|
|
||||||
this.file_add = ''
|
|
||||||
for (var i = 0; i < fileList.length; i++) {
|
|
||||||
if (fileList[i].response && fileList[i].response.code === '200') {
|
|
||||||
this.file_add = this.file_add + fileList[i].response.data + ','
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.file_add = this.file_add.substring(0, this.file_add.length - 1)
|
|
||||||
}
|
|
||||||
// console.log('1. this.file_add: ' + this.file_add)
|
|
||||||
},
|
|
||||||
// 返回this.file_catch(数库一寸照的文件的id的拼接集合)
|
|
||||||
getCatchFileId(file) {
|
|
||||||
for (var i = 0; i < this.files_list.length; i++) {
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
// 1. 检查当前删除的文件是否是修改文件列表里面的,如果是,将修改列表里去除此id
|
|
||||||
if (this.files_list[i].name === file.name) {
|
|
||||||
// 2. 拆开file_catch到fils_arry
|
|
||||||
var fils_arry = this.file_catch.split(',')
|
|
||||||
// 3. 从fils_arry去除 this.files_list[i].id
|
|
||||||
var arry = []
|
|
||||||
fils_arry.forEach((element) => {
|
|
||||||
// 不加载文件里面的
|
|
||||||
if (element !== this.files_list[i].id) {
|
|
||||||
arry.push(element)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
// 4. 重新拼接成file_catch
|
|
||||||
this.file_catch = arry.join(',')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// console.log('2. this.file_catch:' + this.file_catch)
|
|
||||||
},
|
|
||||||
// 保存并拼接id
|
|
||||||
getFileId() {
|
|
||||||
// console.log('3. this.file_catch:' + this.file_catch + ',this.file_add:' + this.file_add)
|
|
||||||
if (this.file_catch !== '') {
|
|
||||||
if (this.file_add !== '') {
|
|
||||||
this.enclosure = this.file_catch + ',' + this.file_add
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_catch
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.enclosure = this.file_add
|
|
||||||
}
|
|
||||||
},
|
|
||||||
handlePictureCardPreview(file) {
|
|
||||||
this.dialogImageUrl = file.url
|
|
||||||
},
|
|
||||||
// 上传失败
|
|
||||||
uploadError() {
|
|
||||||
this.loadding = false
|
|
||||||
},
|
|
||||||
uploadProgrees(event, file, fileList) {
|
|
||||||
if (Number(event.percent) > 0) {
|
|
||||||
this.loadding = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style lang="scss" scoped></style>
|
|
||||||
Reference in New Issue
Block a user