|
|
@ -648,6 +648,14 @@ |
|
|
import comShowLabelSerialInfo from "../com_show_label_serial_info"; |
|
|
import comShowLabelSerialInfo from "../com_show_label_serial_info"; |
|
|
import { availableFont,getParentLabelInfo ,getParentSerialElements} from '@/api/labelSetting/label_setting.js' |
|
|
import { availableFont,getParentLabelInfo ,getParentSerialElements} from '@/api/labelSetting/label_setting.js' |
|
|
|
|
|
|
|
|
|
|
|
const DEFAULT_FONT_OPTION = { |
|
|
|
|
|
name: '默认字体', |
|
|
|
|
|
value: 'default', |
|
|
|
|
|
category: 'system', |
|
|
|
|
|
description: 'ARIAL UNICODE MS.TTF', |
|
|
|
|
|
supported: true |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
export default { |
|
|
export default { |
|
|
name: 'PropertyForm', |
|
|
name: 'PropertyForm', |
|
|
props: { |
|
|
props: { |
|
|
@ -659,7 +667,8 @@ export default { |
|
|
emits: ['data-source', 'image-upload', 'element-combination'], |
|
|
emits: ['data-source', 'image-upload', 'element-combination'], |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
availableFonts: [], |
|
|
|
|
|
|
|
|
// 下拉框必须始终可选default,避免后端字体列表不含default时出现空白/不可回退 |
|
|
|
|
|
availableFonts: [{ ...DEFAULT_FONT_OPTION }], |
|
|
fontLoading: false, |
|
|
fontLoading: false, |
|
|
fontsLoaded: false, |
|
|
fontsLoaded: false, |
|
|
parentSerialElements: [] // 父标签的流水号元素列表 |
|
|
parentSerialElements: [] // 父标签的流水号元素列表 |
|
|
@ -667,11 +676,12 @@ export default { |
|
|
}, |
|
|
}, |
|
|
computed: { |
|
|
computed: { |
|
|
groupedFonts() { |
|
|
groupedFonts() { |
|
|
if (!this.availableFonts.length) { |
|
|
|
|
|
|
|
|
const normalizedFonts = this.ensureDefaultFontOption(this.availableFonts) |
|
|
|
|
|
if (!normalizedFonts.length) { |
|
|
return [] |
|
|
return [] |
|
|
} |
|
|
} |
|
|
const groups = {} |
|
|
const groups = {} |
|
|
this.availableFonts.forEach(font => { |
|
|
|
|
|
|
|
|
normalizedFonts.forEach(font => { |
|
|
const category = font.category || 'other' |
|
|
const category = font.category || 'other' |
|
|
if (!groups[category]) { |
|
|
if (!groups[category]) { |
|
|
groups[category] = { |
|
|
groups[category] = { |
|
|
@ -1093,7 +1103,7 @@ export default { |
|
|
try { |
|
|
try { |
|
|
const response = await availableFont({}) |
|
|
const response = await availableFont({}) |
|
|
if (response.data.success) { |
|
|
if (response.data.success) { |
|
|
this.availableFonts = response.data.data || [] |
|
|
|
|
|
|
|
|
this.availableFonts = this.ensureDefaultFontOption(response.data.data || []) |
|
|
this.fontsLoaded = true |
|
|
this.fontsLoaded = true |
|
|
console.log('加载字体列表成功,共', this.availableFonts.length, '个字体') |
|
|
console.log('加载字体列表成功,共', this.availableFonts.length, '个字体') |
|
|
} else { |
|
|
} else { |
|
|
@ -1126,7 +1136,7 @@ export default { |
|
|
// 获取默认字体列表(备用方案) |
|
|
// 获取默认字体列表(备用方案) |
|
|
getDefaultFonts() { |
|
|
getDefaultFonts() { |
|
|
return [ |
|
|
return [ |
|
|
{ name: '默认字体', value: 'default', category: 'system', description: '系统默认', supported: true }, |
|
|
|
|
|
|
|
|
{ ...DEFAULT_FONT_OPTION }, |
|
|
{ name: '微软雅黑', value: 'Microsoft YaHei', category: 'chinese', description: '中文字体', supported: true }, |
|
|
{ name: '微软雅黑', value: 'Microsoft YaHei', category: 'chinese', description: '中文字体', supported: true }, |
|
|
{ name: '宋体', value: 'SimSun', category: 'chinese', description: '中文字体', supported: true }, |
|
|
{ name: '宋体', value: 'SimSun', category: 'chinese', description: '中文字体', supported: true }, |
|
|
{ name: '黑体', value: 'SimHei', category: 'chinese', description: '中文字体', supported: true }, |
|
|
{ name: '黑体', value: 'SimHei', category: 'chinese', description: '中文字体', supported: true }, |
|
|
@ -1136,6 +1146,27 @@ export default { |
|
|
] |
|
|
] |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
ensureDefaultFontOption(fonts) { |
|
|
|
|
|
const safeFonts = Array.isArray(fonts) ? fonts.filter(item => item && item.value) : [] |
|
|
|
|
|
const hasDefault = safeFonts.some(font => String(font.value).toLowerCase() === 'default') |
|
|
|
|
|
const normalizedFonts = safeFonts.map(font => { |
|
|
|
|
|
if (String(font.value).toLowerCase() !== 'default') { |
|
|
|
|
|
return font |
|
|
|
|
|
} |
|
|
|
|
|
return { |
|
|
|
|
|
...font, |
|
|
|
|
|
value: 'default', |
|
|
|
|
|
category: font.category || DEFAULT_FONT_OPTION.category, |
|
|
|
|
|
description: font.description || DEFAULT_FONT_OPTION.description, |
|
|
|
|
|
supported: true |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
|
|
|
if (hasDefault) { |
|
|
|
|
|
return normalizedFonts |
|
|
|
|
|
} |
|
|
|
|
|
return [{ ...DEFAULT_FONT_OPTION }, ...normalizedFonts] |
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
// 字体族变化处理 |
|
|
// 字体族变化处理 |
|
|
onFontFamilyChange(value) { |
|
|
onFontFamilyChange(value) { |
|
|
console.log('字体族变化:', value) |
|
|
console.log('字体族变化:', value) |
|
|
|