|
@@ -215,13 +215,13 @@
|
|
|
<div class="flex tag">
|
|
|
<div class="flex column flex-1 fit-size tag-info">
|
|
|
<div class="tag-logo"><img src="@/assets/imgs/logo.png" width="100%" height="100%" /></div>
|
|
|
- <div class="flex column valign-center tag-materiel-info">
|
|
|
+ <div class="flex column valign-center tag-materiel-info" :style="{ fontSize: goodsNameFontSize + 'px' }">
|
|
|
<template v-if="qrData">
|
|
|
<div>{{ qrData.goodsName }},</div>
|
|
|
<div>({{ qrData.packageNumber }})</div>
|
|
|
</template>
|
|
|
</div>
|
|
|
- <div class="flex center tag-provider-name">{{ qrData ? qrData.providerName : '' }}</div>
|
|
|
+ <div class="flex center tag-provider-name" :style="{ fontSize: providerNameFontSize + 'px' }">{{ qrData ? qrData.providerName : '' }}</div>
|
|
|
</div>
|
|
|
<div class="tag-qr">
|
|
|
<qr-code-view v-if="qrData" :code="qrData.qrCode"></qr-code-view>
|
|
@@ -244,6 +244,14 @@ export default {
|
|
|
data: () => ({
|
|
|
qrData: null
|
|
|
}),
|
|
|
+ computed: {
|
|
|
+ goodsNameFontSize () {
|
|
|
+ return this.qrData && this.qrData.goodsName ? this.calculateFontSize(this.qrData.goodsName) : 20
|
|
|
+ },
|
|
|
+ providerNameFontSize () {
|
|
|
+ return this.qrData && this.qrData.providerName ? this.calculateFontSize(this.qrData.providerName) : 20
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
onOpenDetailEditorBtnClick (data) {
|
|
|
this.$$request(TagCode.$$api.getDetail, data, this)
|
|
@@ -323,6 +331,23 @@ export default {
|
|
|
},
|
|
|
tagSelectAble (row) {
|
|
|
return row.tagApplyStateId === '2' || row.tagApplyStateId === '3'
|
|
|
+ },
|
|
|
+ calculateFontSize (text) {
|
|
|
+ const chineseCharRegex = /[\u4e00-\u9fa5]/g
|
|
|
+ const chineseChars = text.match(chineseCharRegex) || []
|
|
|
+ const otherChars = text.length - chineseChars.length
|
|
|
+
|
|
|
+ const length = chineseChars.length + otherChars * 0.5
|
|
|
+
|
|
|
+ if (length <= 20) {
|
|
|
+ return 20
|
|
|
+ } else if (length > 20 && length <= 36) {
|
|
|
+ return 16
|
|
|
+ } else if (length > 36 && length <= 80) {
|
|
|
+ return 14
|
|
|
+ } else {
|
|
|
+ return 12
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|