fixd:头像上传新增名称
This commit is contained in:
@ -56,7 +56,7 @@
|
|||||||
</el-col>
|
</el-col>
|
||||||
<el-col :lg="{ span: 2, offset: 6 }" :md="2">
|
<el-col :lg="{ span: 2, offset: 6 }" :md="2">
|
||||||
<el-button type="primary" :loading="loading" @click="confirmUpload">
|
<el-button type="primary" :loading="loading" @click="confirmUpload">
|
||||||
提 交
|
提 交 yyds
|
||||||
</el-button>
|
</el-button>
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@ -74,10 +74,10 @@ const props = withDefaults(defineProps<{
|
|||||||
fileId?: number | string
|
fileId?: number | string
|
||||||
fileUrl?: string
|
fileUrl?: string
|
||||||
/**
|
/**
|
||||||
* 图片大小(单位MB)
|
* 图片大小(单位MB)
|
||||||
*
|
*
|
||||||
* @default 2
|
* @default 2
|
||||||
*/
|
*/
|
||||||
fileSize?: number
|
fileSize?: number
|
||||||
/** 默认生成截图框宽度 */
|
/** 默认生成截图框宽度 */
|
||||||
autoCropHeight?: number
|
autoCropHeight?: number
|
||||||
@ -175,10 +175,13 @@ function realTime(data: PreviewData) {
|
|||||||
options.previews = data
|
options.previews = data
|
||||||
}
|
}
|
||||||
const file = shallowRef()
|
const file = shallowRef()
|
||||||
|
const fileName = shallowRef()
|
||||||
const cropperURL = useObjectUrl(file)
|
const cropperURL = useObjectUrl(file)
|
||||||
|
|
||||||
onChange((param) => {
|
onChange((param) => {
|
||||||
file.value = param?.item(0)
|
file.value = param?.item(0)
|
||||||
|
const flName = param?.item(0).name
|
||||||
|
fileName.value = flName.substring(0, flName.lastIndexOf('.'))
|
||||||
})
|
})
|
||||||
|
|
||||||
function selectImage() {
|
function selectImage() {
|
||||||
@ -203,6 +206,7 @@ async function uploadImg(blob: Blob) {
|
|||||||
loading = true
|
loading = true
|
||||||
const formData = new FormData()
|
const formData = new FormData()
|
||||||
formData.append('file', blob)
|
formData.append('file', blob)
|
||||||
|
formData.append('name', fileName.value)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const res = await props.uploadFunction(formData)
|
const res = await props.uploadFunction(formData)
|
||||||
@ -241,7 +245,7 @@ tryOnMounted(init)
|
|||||||
watch(() => props.fileId, init)
|
watch(() => props.fileId, init)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
@import url('vue-cropper/dist/index.css');
|
@import url('vue-cropper/dist/index.css');
|
||||||
@import url('element-plus/theme-chalk/el-upload.css');
|
@import url('element-plus/theme-chalk/el-upload.css');
|
||||||
</style>
|
</style>
|
||||||
|
Reference in New Issue
Block a user