图片上传逻辑优化

This commit is contained in:
zzyuan 2025-06-24 14:41:38 +08:00
parent ff182165ae
commit 1ae811604f
9 changed files with 43 additions and 13 deletions

View File

@ -191,7 +191,7 @@
</el-tabs>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button type="primary" @click="submitForm" :disabled="isUpload"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
@ -279,6 +279,7 @@
}
]
},
isUpload:false,
fileList: [],//
checkUrlList: [],//
checkUrlNameList: [],//
@ -391,7 +392,6 @@
if (valid) {
this.baseForm.bizStartTime=this.rangeTime[0]
this.baseForm.bizEndTime=this.rangeTime[1]
// this.$set(this.baseForm,"imgUrl",this.checkUrlList[0])
if (this.canteenId != "") {
updateCanteenApi(this.baseForm).then(response => {
this.$modal.msgSuccess("修改成功");
@ -422,8 +422,8 @@
},
//
imgUpLoad(param, name, index) {
// console.log(param,'image')
param.type = 'canteen'
param.type = 'canteen';
this.isUpload=true
imgUpLoadTwo(param).then((res) => {
if (res.code == 200) {
this.checkUrlList.push(res.data.url)
@ -433,14 +433,16 @@
this.$modal.msgError(res.msg)
this.$set(this.baseForm,"imgUrl","")
}
this.isUpload=false
})
.catch((error) => {
this.$modal.msgError(error)
this.isUpload=false
})
},
//
handleBeforeUpload(file) {
const isLt = file.size / 1024 / 1024 < 10
const isLt = file.size / 1024 / 1024 < 5
if (!isLt) {
this.$modal.msgError(`图片大小不能超过 5 MB`)
return false

View File

@ -307,7 +307,7 @@
</el-tab-pane>
</el-tabs>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button type="primary" @click="submitForm" :disabled="isUpload"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
@ -453,6 +453,7 @@ export default {
checkUrlNameList: [],//
dialogVisible:false,//
dialogImageUrl:"",//
isUpload:false
};
},
created() {
@ -705,6 +706,7 @@ export default {
imgUpLoad(param, name, index) {
// console.log(param,'image')
param.type = 'stall'
this.isUpload=true
imgUpLoadTwo(param).then((res) => {
if (res.code == 200) {
this.checkUrlList.push(res.data.url)
@ -714,9 +716,11 @@ export default {
this.$modal.msgError(res.msg)
this.$set(this.baseForm,"imgUrl","")
}
this.isUpload=false
})
.catch((error) => {
this.$modal.msgError(error)
this.isUpload=false
})
},
handleAvatarSuccess(res, file) {

View File

@ -147,7 +147,7 @@
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button type="primary" @click="submitForm" :disabled="isUpload"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
@ -207,6 +207,7 @@ export default {
checkUrlNameList: [],//
dialogVisible:false,//
dialogImageUrl:"",//
isUpload:false
};
},
created() {
@ -327,9 +328,9 @@ export default {
}).catch(() => {});
},
//
imgUpLoad(param, name, index) {
// console.log(param,'image')
imgUpLoad(param, name, index) {
param.type = 'canteen'
this.isUpload=true
imgUpLoadTwo(param).then((res) => {
if (res.code == 200) {
this.checkUrlList.push(res.data.url)
@ -339,9 +340,11 @@ export default {
this.$modal.msgError(res.msg)
this.$set(this.form,"imgUrl","")
}
this.isUpload=false
})
.catch((error) => {
this.$modal.msgError(error)
this.isUpload=false
})
},
checkImageSize(file, fileType) {

View File

@ -113,7 +113,6 @@
<script>
import { getSettingListApi,addSettingApi,updateSettingApi,removeSettingApi } from "@/api/base/mobile.js";
import { imgUpLoadTwo } from '@/api/system/upload'
export default {
name: "",
dicts: [],

View File

@ -1397,6 +1397,7 @@
//
imgUpLoad(param, name, index) {
param.type = 'dishes'
this.btnLoading=true;
imgUpLoadTwo(param).then((res) => {
if (res.code == 200) {
this.checkUrlList.push(res.data.url)
@ -1409,10 +1410,12 @@
this.$set(this.baseForm,"imageUrl",'')
this.$modal.msgError(res.msg)
}
this.btnLoading=false;
}).catch((error) => {
this.fileList=[]
this.checkUrlList=[]
this.checkUrlNameList=[]
this.btnLoading=false;
this.$modal.msgError(error)
})
},

View File

@ -403,6 +403,7 @@ export default {
imgUpLoad(param, name, index) {
// console.log(param,'image')
param.type = 'stall'
this.loading=true
imgUpLoadTwo(param).then((res) => {
if (res.code == 200) {
this.checkUrlList.push(res.data.url)
@ -412,9 +413,11 @@ export default {
this.$modal.msgError(res.msg)
this.$set(this.form,"imgUrl","")
}
this.loading=false
})
.catch((error) => {
this.$modal.msgError(error)
this.loading=false
})
},
//

View File

@ -1074,6 +1074,7 @@
imgUpLoad(param, name, index) {
// console.log(param,'image')
param.type = 'canteen'
this.loadingBtn=true
imgUpLoadTwo(param).then((res) => {
if (res.code == 200) {
this.checkUrlList.push(res.data.url)
@ -1081,9 +1082,11 @@
} else {
this.$modal.msgError(res.msg)
}
this.loadingBtn=false
})
.catch((error) => {
this.$modal.msgError(error)
this.loadingBtn=false
})
},
handleAvatarSuccess(res, file) {

View File

@ -325,7 +325,7 @@
</el-form>
</div>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button type="primary" @click="submitForm" :disabled="loadingBtn"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
@ -482,6 +482,7 @@ export default {
checkUrlList2: [],//
dialogVisible:false,//
dialogImageUrl:"",//
loadingBtn:false
};
},
created() {
@ -718,6 +719,7 @@ export default {
//
imgUpLoad0(param, name, index) {
param.type = 'canteen'
this.loadingBtn=true
imgUpLoadTwo(param).then((res) => {
if (res.code == 200) {
this.checkUrlList0.push(res.data.url)
@ -725,13 +727,16 @@ export default {
} else {
this.$modal.msgError(res.msg)
}
this.loadingBtn=false
})
.catch((error) => {
this.$modal.msgError(error)
this.loadingBtn=false
})
},
imgUpLoad1(param, name, index) {
param.type = 'canteen'
this.loadingBtn=true
imgUpLoadTwo(param).then((res) => {
if (res.code == 200) {
this.checkUrlList1.push(res.data.url)
@ -739,13 +744,16 @@ export default {
} else {
this.$modal.msgError(res.msg)
}
this.loadingBtn=false
})
.catch((error) => {
this.$modal.msgError(error)
this.loadingBtn=false
})
},
imgUpLoad2(param, name, index) {
param.type = 'canteen'
this.loadingBtn=true
imgUpLoadTwo(param).then((res) => {
if (res.code == 200) {
this.checkUrlList2.push(res.data.url)
@ -753,9 +761,11 @@ export default {
} else {
this.$modal.msgError(res.msg)
}
this.loadingBtn=false
})
.catch((error) => {
this.$modal.msgError(error)
this.loadingBtn=false
})
},
//

View File

@ -646,7 +646,7 @@
</el-row>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button type="primary" @click="submitForm" :disabled="loadingBtn"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
@ -932,6 +932,7 @@ export default {
checkUrlNameList: [],//
dialogVisible:false,//
dialogImageUrl:"",//
loadingBtn:false,
// cropper
visible: false,
options: {
@ -1407,7 +1408,7 @@ export default {
imgUpLoad(param, name, index) {
// console.log(param,'image')
param.type = 'face'
console.log(param.file)
this.loadingBtn=true
imgUpLoadTwo(param).then((res) => {
if (res.code == 200) {
this.checkUrlList.push(res.data.url)
@ -1415,9 +1416,11 @@ export default {
} else {
this.$modal.msgError(res.msg)
}
this.loadingBtn=false
})
.catch((error) => {
this.$modal.msgError(error)
this.loadingBtn=false
})
},
handleAvatarSuccess(res, file) {