图片上传逻辑优化
This commit is contained in:
parent
ff182165ae
commit
1ae811604f
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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: [],
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
})
|
||||
},
|
||||
|
|
|
|||
|
|
@ -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
|
||||
})
|
||||
},
|
||||
// 上传之前
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
})
|
||||
},
|
||||
// 上传之前
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue