@xilonglab/vue-main 1.3.9 → 1.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
defineOptions({ name: "XlSignatureInput" })
|
|
3
|
+
|
|
4
|
+
import { ref, computed } from 'vue'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
const emits = defineEmits(['change', 'update:modelValue'])
|
|
8
|
+
|
|
9
|
+
const props = defineProps({
|
|
10
|
+
modelValue: {
|
|
11
|
+
default: "",
|
|
12
|
+
},
|
|
13
|
+
api: {
|
|
14
|
+
type: Function,
|
|
15
|
+
default: () => { },
|
|
16
|
+
},
|
|
17
|
+
headers: {
|
|
18
|
+
type: Object,
|
|
19
|
+
default: () => ({})
|
|
20
|
+
},
|
|
21
|
+
params: {
|
|
22
|
+
type: Object,
|
|
23
|
+
default: () => ({})
|
|
24
|
+
},
|
|
25
|
+
disabled: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: false,
|
|
28
|
+
},
|
|
29
|
+
accept: {
|
|
30
|
+
type: String,
|
|
31
|
+
default: ''
|
|
32
|
+
},
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
const value = computed({
|
|
37
|
+
get() {
|
|
38
|
+
return props.modelValue;
|
|
39
|
+
},
|
|
40
|
+
set(data) {
|
|
41
|
+
emits('change', data)
|
|
42
|
+
emits('update:modelValue', data)
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
const loading = ref(false)
|
|
48
|
+
|
|
49
|
+
function beforeUpload() {
|
|
50
|
+
loading.value = true
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function onSuccess(data, file, filelist) {
|
|
54
|
+
loading.value = false;
|
|
55
|
+
emits('update:modelValue', data)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function upload(option) {
|
|
59
|
+
let formData = new FormData();
|
|
60
|
+
const { api, params } = props
|
|
61
|
+
const { file } = option
|
|
62
|
+
formData.append("file", file);
|
|
63
|
+
formData.append("filename", file.name);
|
|
64
|
+
for (let key in params) {
|
|
65
|
+
formData.append(key, params[key]);
|
|
66
|
+
}
|
|
67
|
+
return api(formData);
|
|
68
|
+
}
|
|
69
|
+
</script>
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<el-upload class="xl-signature-input" action="" :headers="headers" :http-request="upload" :before-upload="beforeUpload"
|
|
74
|
+
:on-success="onSuccess" :show-file-list="false" :disabled="disabled" :accept="props.accept">
|
|
75
|
+
<div class="image-container" v-if="value">
|
|
76
|
+
<img class="image" :src="`/storage/${value.uri}`"
|
|
77
|
+
:style="{
|
|
78
|
+
width: value.width ? `${value.width}px` : 'auto',
|
|
79
|
+
height: value.height ? `${value.height}px` : 'auto'
|
|
80
|
+
}" />
|
|
81
|
+
</div>
|
|
82
|
+
<el-icon class="icon" v-else>
|
|
83
|
+
<Plus />
|
|
84
|
+
</el-icon>
|
|
85
|
+
</el-upload>
|
|
86
|
+
</template>
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
<style lang="less">
|
|
90
|
+
.xl-signature-input {
|
|
91
|
+
|
|
92
|
+
.el-upload {
|
|
93
|
+
border: 1px dashed var(--el-border-color);
|
|
94
|
+
border-radius: 6px;
|
|
95
|
+
cursor: pointer;
|
|
96
|
+
position: relative;
|
|
97
|
+
overflow: hidden;
|
|
98
|
+
transition: var(--el-transition-duration-fast);
|
|
99
|
+
|
|
100
|
+
&:hover {
|
|
101
|
+
border-color: var(--el-color-primary);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.image-container {
|
|
106
|
+
width: 356px;
|
|
107
|
+
height: 67px;
|
|
108
|
+
display: flex;
|
|
109
|
+
align-items: center;
|
|
110
|
+
justify-content: center;
|
|
111
|
+
overflow: hidden;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
.image {
|
|
115
|
+
max-width: 100%;
|
|
116
|
+
max-height: 100%;
|
|
117
|
+
display: block;
|
|
118
|
+
object-fit: contain;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.el-icon.icon {
|
|
122
|
+
font-size: 28px;
|
|
123
|
+
color: #8c939d;
|
|
124
|
+
width: 356px;
|
|
125
|
+
height: 67px;
|
|
126
|
+
text-align: center;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
</style>
|