|
|
|
|
@ -307,10 +307,13 @@ const paperTypes = {
|
|
|
|
|
B4: { width: 250, height: 352.6 },
|
|
|
|
|
B5: { width: 250, height: 175.6 }
|
|
|
|
|
}
|
|
|
|
|
const curPaper = ref({
|
|
|
|
|
const defaultPaperConfig = {
|
|
|
|
|
type: 'A4',
|
|
|
|
|
width: 210,
|
|
|
|
|
height: 296.6
|
|
|
|
|
}
|
|
|
|
|
const curPaper = ref({
|
|
|
|
|
...defaultPaperConfig
|
|
|
|
|
})
|
|
|
|
|
const paperPopVisible = ref(false)
|
|
|
|
|
const paperWidth = ref(220)
|
|
|
|
|
@ -342,6 +345,31 @@ let iconSelectEventKey = ''
|
|
|
|
|
let iconSelectHandler: ((payload: any) => void) | undefined
|
|
|
|
|
let clearSettingHandler: (() => void) | undefined
|
|
|
|
|
|
|
|
|
|
const normalizePaperConfig = (value: any) => {
|
|
|
|
|
const width = Number(value?.width)
|
|
|
|
|
const height = Number(value?.height)
|
|
|
|
|
if (width <= 0 || height <= 0 || Number.isNaN(width) || Number.isNaN(height)) {
|
|
|
|
|
return { ...defaultPaperConfig }
|
|
|
|
|
}
|
|
|
|
|
return {
|
|
|
|
|
type: typeof value?.type === 'string' && value.type ? value.type : 'other',
|
|
|
|
|
width,
|
|
|
|
|
height
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const applyPaperConfig = (value: any) => {
|
|
|
|
|
const paper = normalizePaperConfig(value)
|
|
|
|
|
curPaper.value = paper
|
|
|
|
|
paperWidth.value = paper.width
|
|
|
|
|
paperHeight.value = paper.height
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const getTemplatePaperConfig = (value: any) => {
|
|
|
|
|
const panel = Array.isArray(value?.panels) ? value.panels[0] : undefined
|
|
|
|
|
return panel
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const ensureInit = () => {
|
|
|
|
|
if (hiprintInited) {
|
|
|
|
|
return
|
|
|
|
|
@ -549,13 +577,7 @@ const handleSave = async () => {
|
|
|
|
|
const resetState = () => {
|
|
|
|
|
scaleValue.value = 1
|
|
|
|
|
setSelectedIconState(null)
|
|
|
|
|
curPaper.value = {
|
|
|
|
|
type: 'A4',
|
|
|
|
|
width: 210,
|
|
|
|
|
height: 296.6
|
|
|
|
|
}
|
|
|
|
|
paperWidth.value = 220
|
|
|
|
|
paperHeight.value = 80
|
|
|
|
|
applyPaperConfig(defaultPaperConfig)
|
|
|
|
|
paperPopVisible.value = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -564,6 +586,7 @@ const open = async (row: any) => {
|
|
|
|
|
dialogTitle.value = `${t('TemplateManagement.PrintTemplate.designTitle')}${row.templateName ? ' - ' + row.templateName : ''}`
|
|
|
|
|
currentTemplateJson.value = row.templateJson ? (typeof row.templateJson === 'string' ? JSON.parse(row.templateJson) : row.templateJson) : undefined
|
|
|
|
|
resetState()
|
|
|
|
|
applyPaperConfig(getTemplatePaperConfig(currentTemplateJson.value))
|
|
|
|
|
await loadBarcodeDictData()
|
|
|
|
|
dialogVisible.value = true
|
|
|
|
|
await nextTick()
|
|
|
|
|
|