mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-27 01:32:03 +08:00
fix: close modal
This commit is contained in:
parent
91abae8898
commit
7eb0fb1655
@ -1,4 +1,5 @@
|
|||||||
<template>
|
<template>
|
||||||
|
<div>
|
||||||
<Dialog
|
<Dialog
|
||||||
v-model="dialogVisible"
|
v-model="dialogVisible"
|
||||||
:title="t('cropper.modalTitle')"
|
:title="t('cropper.modalTitle')"
|
||||||
@ -110,6 +111,7 @@
|
|||||||
<el-button type="primary" @click="handleOk">{{ t('cropper.okText') }}</el-button>
|
<el-button type="primary" @click="handleOk">{{ t('cropper.okText') }}</el-button>
|
||||||
</template>
|
</template>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useDesign } from '@/hooks/web/useDesign'
|
import { useDesign } from '@/hooks/web/useDesign'
|
||||||
@ -173,7 +175,6 @@ function handlerToolbar(event: string, arg?: number) {
|
|||||||
async function handleOk() {
|
async function handleOk() {
|
||||||
const blob = dataURLtoBlob(previewSource.value)
|
const blob = dataURLtoBlob(previewSource.value)
|
||||||
emit('uploadSuccess', { source: previewSource.value, data: blob, filename: filename })
|
emit('uploadSuccess', { source: previewSource.value, data: blob, filename: filename })
|
||||||
closeModal()
|
|
||||||
}
|
}
|
||||||
function openModal() {
|
function openModal() {
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
|
@ -4,7 +4,11 @@
|
|||||||
<el-button :class="`${prefixCls}-upload-btn`" @click="open()" v-if="showBtn">
|
<el-button :class="`${prefixCls}-upload-btn`" @click="open()" v-if="showBtn">
|
||||||
{{ btnText ? btnText : t('cropper.selectImage') }}
|
{{ btnText ? btnText : t('cropper.selectImage') }}
|
||||||
</el-button>
|
</el-button>
|
||||||
<CopperModal ref="cropperModel" @upload-success="handleUploadSuccess" :srcValue="sourceValue" />
|
<CopperModal
|
||||||
|
ref="cropperModelRef"
|
||||||
|
@upload-success="handleUploadSuccess"
|
||||||
|
:srcValue="sourceValue"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
@ -29,7 +33,7 @@ const prefixCls = getPrefixCls('cropper-avatar')
|
|||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const { t } = useI18n()
|
const { t } = useI18n()
|
||||||
|
|
||||||
const cropperModel = ref()
|
const cropperModelRef = ref()
|
||||||
|
|
||||||
watchEffect(() => {
|
watchEffect(() => {
|
||||||
sourceValue.value = props.value
|
sourceValue.value = props.value
|
||||||
@ -49,8 +53,15 @@ function handleUploadSuccess({ source, data, filename }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function open() {
|
function open() {
|
||||||
cropperModel.value.openModal()
|
cropperModelRef.value.openModal()
|
||||||
}
|
}
|
||||||
|
function close() {
|
||||||
|
cropperModelRef.value.closeModal()
|
||||||
|
}
|
||||||
|
defineExpose({
|
||||||
|
open,
|
||||||
|
close
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scoped>
|
<style lang="scss" scoped>
|
||||||
$prefix-cls: #{$namespace}--cropper-avatar;
|
$prefix-cls: #{$namespace}--cropper-avatar;
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="change-avatar">
|
<div class="change-avatar">
|
||||||
<CropperAvatar
|
<CropperAvatar
|
||||||
|
ref="cropperRef"
|
||||||
:value="avatar"
|
:value="avatar"
|
||||||
:showBtn="false"
|
:showBtn="false"
|
||||||
@change="handelUpload"
|
@change="handelUpload"
|
||||||
@ -10,7 +11,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed } from 'vue'
|
import { computed, ref } from 'vue'
|
||||||
import { propTypes } from '@/utils/propTypes'
|
import { propTypes } from '@/utils/propTypes'
|
||||||
import { CropperAvatar } from '@/components/Cropper'
|
import { CropperAvatar } from '@/components/Cropper'
|
||||||
import { uploadAvatarApi } from '@/api/system/user/profile'
|
import { uploadAvatarApi } from '@/api/system/user/profile'
|
||||||
@ -21,8 +22,10 @@ const avatar = computed(() => {
|
|||||||
return props.img
|
return props.img
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const cropperRef = ref()
|
||||||
const handelUpload = async ({ data }) => {
|
const handelUpload = async ({ data }) => {
|
||||||
await uploadAvatarApi({ avatarFile: data })
|
await uploadAvatarApi({ avatarFile: data })
|
||||||
|
cropperRef.value.close()
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user