bl-common-vue3 3.8.46 → 3.8.48
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bl-common-vue3",
|
|
3
|
-
"version": "3.8.
|
|
3
|
+
"version": "3.8.48",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"module": "index.js",
|
|
6
6
|
"description": "bailing vue3 common components lib",
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"tinymce": "^6.0.0",
|
|
34
34
|
"@tinymce/tinymce-vue": "^5.1.0",
|
|
35
35
|
"vuedraggable": "^4.1.0",
|
|
36
|
-
"qrcode.vue": "^3.3.3",
|
|
37
36
|
"file-saver": "^2.0.5",
|
|
38
37
|
"style-resources-loader": "^1.5.0"
|
|
39
38
|
},
|
package/src/common/utils/util.js
CHANGED
|
@@ -69,7 +69,7 @@ const utils = {
|
|
|
69
69
|
*/
|
|
70
70
|
setCommonLocal: (key, value,isUpdate=false) => {
|
|
71
71
|
if (key == 'basicConfig') {
|
|
72
|
-
utils.areaUnit = value
|
|
72
|
+
utils.areaUnit = (value && value.system_area_unit) ? value.system_area_unit : '㎡';
|
|
73
73
|
}
|
|
74
74
|
if (key == 'basicConfigI18n') {
|
|
75
75
|
utils.basicConfigI18n = value;
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
:src="urls"
|
|
20
20
|
:style="{ width: size + 'px', height: size + 'px' }"
|
|
21
21
|
/>
|
|
22
|
-
<
|
|
22
|
+
<img v-else :src="qrImgUrl" :style="{ width: size + 'px', height: size + 'px' }" />
|
|
23
23
|
<div class="qrcode-btn">
|
|
24
24
|
<Button
|
|
25
25
|
v-if="download && type == 'url'"
|
|
@@ -49,11 +49,10 @@
|
|
|
49
49
|
:src="url"
|
|
50
50
|
:style="{ width: size + 'px', height: size + 'px' }"
|
|
51
51
|
/>
|
|
52
|
-
<
|
|
52
|
+
<img
|
|
53
53
|
v-else
|
|
54
|
-
:
|
|
55
|
-
:
|
|
56
|
-
:id="'h5Qrcode_' + index"
|
|
54
|
+
:src="qrImgUrls[index]"
|
|
55
|
+
:style="{ width: size + 'px', height: size + 'px' }"
|
|
57
56
|
/>
|
|
58
57
|
<div class="qrcode-btn">
|
|
59
58
|
<Button
|
|
@@ -79,17 +78,16 @@
|
|
|
79
78
|
</template>
|
|
80
79
|
|
|
81
80
|
<script>
|
|
82
|
-
import { defineComponent, reactive, toRefs, watch, computed } from "@vue/runtime-core";
|
|
81
|
+
import { defineComponent, reactive, toRefs, watch, computed, ref } from "@vue/runtime-core";
|
|
83
82
|
import { Modal, Row, Col, Button, message } from "ant-design-vue";
|
|
84
|
-
import QrcodeVue from "qrcode.vue";
|
|
85
83
|
import {t, loadLanguageAsync} from "../../locale";
|
|
86
84
|
import utils from "../../common/utils/util";
|
|
87
85
|
import { CopyOutlined, DownloadOutlined } from '@ant-design/icons-vue';
|
|
88
86
|
|
|
89
87
|
export default defineComponent({
|
|
90
88
|
name: "QrcodeModal",
|
|
89
|
+
emits: ["cancel", "request"],
|
|
91
90
|
components: {
|
|
92
|
-
QrcodeVue,
|
|
93
91
|
Modal,
|
|
94
92
|
Row,
|
|
95
93
|
Col,
|
|
@@ -140,6 +138,9 @@ export default defineComponent({
|
|
|
140
138
|
colNum: 24,
|
|
141
139
|
});
|
|
142
140
|
|
|
141
|
+
const qrImgUrl = ref("");
|
|
142
|
+
const qrImgUrls = ref([]);
|
|
143
|
+
|
|
143
144
|
const titleProps = computed(() => {
|
|
144
145
|
return props.title || t('QrcodeModal.index.612016-1')
|
|
145
146
|
});
|
|
@@ -148,16 +149,44 @@ export default defineComponent({
|
|
|
148
149
|
emit("cancel");
|
|
149
150
|
};
|
|
150
151
|
|
|
151
|
-
const downloadCode = (index) => {
|
|
152
|
+
const downloadCode = async (index) => {
|
|
153
|
+
const imgUrl = index === -1 ? qrImgUrl.value : qrImgUrls.value[index];
|
|
154
|
+
if (!imgUrl) return;
|
|
155
|
+
const response = await fetch(imgUrl);
|
|
156
|
+
const blob = await response.blob();
|
|
157
|
+
const url = URL.createObjectURL(blob);
|
|
152
158
|
const a = document.createElement("a");
|
|
153
|
-
|
|
154
|
-
const image = document
|
|
155
|
-
.getElementById(id)
|
|
156
|
-
.toDataURL("image/png")
|
|
157
|
-
.replace("image/png", "image/octet-stream");
|
|
158
|
-
a.href = image;
|
|
159
|
+
a.href = url;
|
|
159
160
|
a.download = `${titleProps.value || "pic"}.png`;
|
|
161
|
+
document.body.appendChild(a);
|
|
160
162
|
a.click();
|
|
163
|
+
document.body.removeChild(a);
|
|
164
|
+
URL.revokeObjectURL(url);
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
const fetchQrImages = () => {
|
|
168
|
+
const urlList = typeof props.urls === 'string' ? [props.urls] : [...props.urls];
|
|
169
|
+
qrImgUrl.value = "";
|
|
170
|
+
qrImgUrls.value = [];
|
|
171
|
+
|
|
172
|
+
urlList.forEach((url, index) => {
|
|
173
|
+
emit("request", {
|
|
174
|
+
params: {
|
|
175
|
+
method: "get",
|
|
176
|
+
server: "/public",
|
|
177
|
+
url: "/qrcode",
|
|
178
|
+
extra: { qrCode: url },
|
|
179
|
+
},
|
|
180
|
+
success: (res) => {
|
|
181
|
+
if (typeof props.urls === 'string') {
|
|
182
|
+
qrImgUrl.value = res.url;
|
|
183
|
+
} else {
|
|
184
|
+
qrImgUrls.value[index] = res.url;
|
|
185
|
+
qrImgUrls.value = [...qrImgUrls.value];
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
});
|
|
189
|
+
});
|
|
161
190
|
};
|
|
162
191
|
|
|
163
192
|
const init = () => {
|
|
@@ -173,6 +202,9 @@ export default defineComponent({
|
|
|
173
202
|
(val) => {
|
|
174
203
|
if (val) {
|
|
175
204
|
init();
|
|
205
|
+
if (props.type === 'url') {
|
|
206
|
+
fetchQrImages();
|
|
207
|
+
}
|
|
176
208
|
}
|
|
177
209
|
}
|
|
178
210
|
);
|
|
@@ -198,6 +230,8 @@ export default defineComponent({
|
|
|
198
230
|
return {
|
|
199
231
|
t,
|
|
200
232
|
...toRefs(state),
|
|
233
|
+
qrImgUrl,
|
|
234
|
+
qrImgUrls,
|
|
201
235
|
titleProps,
|
|
202
236
|
handleClose,
|
|
203
237
|
downloadCode,
|