|
@@ -21,6 +21,7 @@ import { computed, defineProps, nextTick, ref } from 'vue'
|
|
|
import { VueCropper } from 'vue-cropper'
|
|
|
import confirm from '@kankan-components/components/basic/dialog/src/confirm.vue'
|
|
|
import 'vue-cropper/dist/index.css'
|
|
|
+import { cropperProps } from './cropper'
|
|
|
// import { useI18n } from '@/i18n'
|
|
|
// const { t } = useI18n({ useScope: 'global' })
|
|
|
const sizeType = ref(1)
|
|
@@ -29,44 +30,44 @@ const layerWidth = 500
|
|
|
defineOptions({
|
|
|
name: 'UICropper',
|
|
|
})
|
|
|
-
|
|
|
-const props = defineProps({
|
|
|
- fixedNumber: {
|
|
|
- type: Array,
|
|
|
- default: () => [1, 1],
|
|
|
- },
|
|
|
- img: { type: String },
|
|
|
- cb: {
|
|
|
- type: Function,
|
|
|
- },
|
|
|
- showSize: {
|
|
|
- type: Boolean,
|
|
|
- default: false,
|
|
|
- },
|
|
|
- noText: {
|
|
|
- type: String,
|
|
|
- default: '取消',
|
|
|
- },
|
|
|
- okText: {
|
|
|
- type: String,
|
|
|
- default: '确认',
|
|
|
- },
|
|
|
- title: {
|
|
|
- type: String,
|
|
|
- default: '裁剪',
|
|
|
- },
|
|
|
- longSize: {
|
|
|
- type: String,
|
|
|
- default: '长型',
|
|
|
- },
|
|
|
- squareSize: {
|
|
|
- type: String,
|
|
|
- default: '方型',
|
|
|
- },
|
|
|
-})
|
|
|
+const props = defineProps(cropperProps)
|
|
|
+// const props = defineProps({
|
|
|
+// fixedNumber: {
|
|
|
+// type: Array,
|
|
|
+// default: () => [1, 1],
|
|
|
+// },
|
|
|
+// img: { type: String },
|
|
|
+// cb: {
|
|
|
+// type: Function,
|
|
|
+// },
|
|
|
+// showSize: {
|
|
|
+// type: Boolean,
|
|
|
+// default: false,
|
|
|
+// },
|
|
|
+// noText: {
|
|
|
+// type: String,
|
|
|
+// default: '取消',
|
|
|
+// },
|
|
|
+// okText: {
|
|
|
+// type: String,
|
|
|
+// default: '确认',
|
|
|
+// },
|
|
|
+// title: {
|
|
|
+// type: String,
|
|
|
+// default: '裁剪',
|
|
|
+// },
|
|
|
+// longSize: {
|
|
|
+// type: String,
|
|
|
+// default: '长型',
|
|
|
+// },
|
|
|
+// squareSize: {
|
|
|
+// type: String,
|
|
|
+// default: '方型',
|
|
|
+// },
|
|
|
+// })
|
|
|
const show = ref(true)
|
|
|
// const fixedNumber = props.fixedNumber
|
|
|
-const getHeight = width => (fixedNumber[1] / fixedNumber[0]) * width
|
|
|
+const getHeight = (width: number) => (props.fixedNumber[1] / props.fixedNumber[0]) * width
|
|
|
|
|
|
const option = {
|
|
|
outputSize: 1,
|
|
@@ -88,7 +89,7 @@ const option = {
|
|
|
maxImgSize: 400,
|
|
|
// ...props,
|
|
|
}
|
|
|
-const changSize = type => {
|
|
|
+const changSize = (type: number) => {
|
|
|
if (sizeType.value != type) {
|
|
|
sizeType.value = type
|
|
|
show.value = false
|
|
@@ -117,7 +118,7 @@ const on = {
|
|
|
},
|
|
|
}
|
|
|
|
|
|
-const clickHandler = async status => {
|
|
|
+const clickHandler = async (status: string) => {
|
|
|
if (status === 'ok') {
|
|
|
const data = await Promise.all([new Promise(resolve => vmRef.value.getCropBlob(resolve)), new Promise(resolve => vmRef.value.getCropData(resolve))])
|
|
|
if (props.showSize) {
|