|
@@ -470,13 +470,13 @@
|
|
|
<div>
|
|
|
<el-form-item label="尺寸">
|
|
|
<el-radio-group v-model="formData.size">
|
|
|
- <el-radio :value="1">90:54</el-radio>
|
|
|
- <el-radio :value="2">90:50</el-radio>
|
|
|
- <el-radio :value="3">5:5</el-radio>
|
|
|
+ <el-radio :value="1">7.5 : 5.5</el-radio>
|
|
|
+ <el-radio :value="2">9 : 6</el-radio>
|
|
|
+ <el-radio :value="3">12 : 8</el-radio>
|
|
|
</el-radio-group>
|
|
|
</el-form-item>
|
|
|
<el-form :model="formData" label-width="auto" style="max-width: 750px">
|
|
|
- <el-form-item label="标题">
|
|
|
+ <el-form-item label="标题:">
|
|
|
<el-select v-model="formData.content" placeholder="请选择字段">
|
|
|
<el-option
|
|
|
v-for="item in optionsLabel"
|
|
@@ -486,6 +486,16 @@
|
|
|
/>
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
+ <el-form-item label="副标题:">
|
|
|
+ <el-select v-model="formData.content2" placeholder="请选择字段">
|
|
|
+ <el-option
|
|
|
+ v-for="item in optionsLabel"
|
|
|
+ :key="item.value"
|
|
|
+ :label="item.label"
|
|
|
+ :value="item.value"
|
|
|
+ />
|
|
|
+ </el-select>
|
|
|
+ </el-form-item>
|
|
|
|
|
|
<div v-for="(item, index) in formData.contentItems" :key="index" style="margin-top: 10px">
|
|
|
<el-form-item>
|
|
@@ -583,13 +593,14 @@ const queryParams = reactive({
|
|
|
//标签打印的表单
|
|
|
const formData = ref({
|
|
|
content: undefined,
|
|
|
+ content2:undefined,
|
|
|
selectedData: [] as SpecimenInfoVO[],
|
|
|
contentItems: [] as { label: string; value: string }[],
|
|
|
size:1,
|
|
|
sizeMap: {
|
|
|
- 1: { width: 900, height: 540 },
|
|
|
- 2: { width: 900, height: 500 },
|
|
|
- 3: { width: 500, height: 500 }
|
|
|
+ 1: { width: 750, height: 550 },
|
|
|
+ 2: { width: 900, height: 600 },
|
|
|
+ 3: { width: 1200, height: 800 }
|
|
|
}
|
|
|
})
|
|
|
const queryFormRef = ref() // 搜索的表单
|
|
@@ -693,27 +704,29 @@ const optionsLabel = [
|
|
|
label: '中文名称',
|
|
|
},
|
|
|
{
|
|
|
- value: 'specimenNumber',
|
|
|
- label: '标本编号',
|
|
|
+ value: 'englishName',
|
|
|
+ label: '英文名称',
|
|
|
},
|
|
|
{
|
|
|
- value: 'specimenType',
|
|
|
- label: '标本类型',
|
|
|
+ value: 'specimenNumber',
|
|
|
+ label: '标本编号',
|
|
|
},
|
|
|
{
|
|
|
value: 'storageLocation',
|
|
|
label: '存放位置',
|
|
|
},
|
|
|
{
|
|
|
- value: 'englishName',
|
|
|
- label: '英文名称',
|
|
|
+ value: 'provider',
|
|
|
+ label: '标本提供者',
|
|
|
+ },
|
|
|
+ {
|
|
|
+ value: 'acquisitionTime',
|
|
|
+ label: '入藏时间',
|
|
|
},
|
|
|
-
|
|
|
{
|
|
|
value: 'composition',
|
|
|
label: '成分',
|
|
|
},
|
|
|
-
|
|
|
{
|
|
|
value: 'origin',
|
|
|
label: '产地',
|
|
@@ -730,15 +743,10 @@ const optionsLabel = [
|
|
|
value: 'meteoriteType',
|
|
|
label: '陨石类型',
|
|
|
},
|
|
|
-
|
|
|
{
|
|
|
value: 'internationalName',
|
|
|
label: '国际命名',
|
|
|
},
|
|
|
- {
|
|
|
- value: 'preservationType',
|
|
|
- label: '保存类型',
|
|
|
- },
|
|
|
{
|
|
|
value: 'size',
|
|
|
label: '尺寸',
|
|
@@ -755,19 +763,12 @@ const optionsLabel = [
|
|
|
value: 'source',
|
|
|
label: '来源',
|
|
|
},
|
|
|
- {
|
|
|
- value: 'provider',
|
|
|
- label: '标本提供者',
|
|
|
- },
|
|
|
+
|
|
|
{
|
|
|
value: 'purpose',
|
|
|
label: '用途',
|
|
|
},
|
|
|
|
|
|
- {
|
|
|
- value: 'acquisitionTime',
|
|
|
- label: '入藏时间',
|
|
|
- },
|
|
|
|
|
|
]
|
|
|
|
|
@@ -844,7 +845,11 @@ const onSubmit = async () => {
|
|
|
const content = formData.value.contentItems
|
|
|
.map(contentItem => {
|
|
|
const label = optionsLabel.find(opt => opt.value === contentItem.value)?.label
|
|
|
- const value = item[contentItem.value]
|
|
|
+ let value = item[contentItem.value]
|
|
|
+ // 如果是时间字段,进行格式化
|
|
|
+ if (['acquisitionTime'].includes(contentItem.value) && value) {
|
|
|
+ value = formatDate(value as number,'YYYY年MM月DD日');
|
|
|
+ }
|
|
|
if (value !== null && value !== undefined && value !== '') {
|
|
|
return `${label}:${value}`
|
|
|
}
|
|
@@ -852,9 +857,11 @@ const onSubmit = async () => {
|
|
|
})
|
|
|
.filter(Boolean) // 过滤掉空字符串
|
|
|
.join('\n') // 每个内容项换行
|
|
|
-
|
|
|
+ console.log('content',content)
|
|
|
+ const subtitle = formData.value.content2 ? '(' + item[formData.value.content2] + ')' : ''
|
|
|
return {
|
|
|
title: item[formData.value.content],
|
|
|
+ subtitle:subtitle, // 添加副标题
|
|
|
content: content,
|
|
|
specimenNumber: item.specimenNumber
|
|
|
}
|
|
@@ -875,16 +882,30 @@ const onSubmit = async () => {
|
|
|
// 设置文本对齐方式为居中
|
|
|
ctx.textAlign = 'center'
|
|
|
// 设置字体样式
|
|
|
- ctx.font = `${(size.width+size.height) * 0.06}px Arial`
|
|
|
+ ctx.font = `${(size.width+size.height) * 0.06}px 方正黑体简`
|
|
|
// 设置文本颜色
|
|
|
ctx.fillStyle = 'black'
|
|
|
// 绘制标题
|
|
|
- ctx.fillText(label.title, canvas.width / 2, size.height * 0.3)
|
|
|
+ if (label.subtitle && label.subtitle !== '') {
|
|
|
+ ctx.fillText(label.title, canvas.width / 2, size.height * 0.2)
|
|
|
+ }else {
|
|
|
+ ctx.fillText(label.title, canvas.width / 2, size.height * 0.3)
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 添加副标题
|
|
|
+ if (label.subtitle && label.subtitle !== '') {
|
|
|
+ ctx.textAlign = 'center'
|
|
|
+ ctx.font = `${(size.width + size.height) * 0.03}px Times New Roman`
|
|
|
+ ctx.fillStyle = 'black'
|
|
|
+ ctx.fillText(label.subtitle, canvas.width / 2, size.height * 0.3)
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
// 设置文本对齐方式为左对齐
|
|
|
ctx.textAlign = 'left'
|
|
|
// 设置字体样式
|
|
|
- ctx.font = `${(size.width+size.height) * 0.03}px Arial`
|
|
|
+ ctx.font = `${(size.width+size.height) * 0.03}px 方正黑体简`
|
|
|
// 绘制内容
|
|
|
const lines = label.content.split('\n')
|
|
|
let y = size.height * 0.45
|