!821 feat: 添加radio、checkbox、select打印显示

Merge pull request !821 from Lesan/feature/bpm-打印
dev
芋道源码 2025-09-10 00:37:10 +00:00 committed by Gitee
commit 8e6a8d9124
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F
1 changed files with 41 additions and 22 deletions

View File

@ -30,23 +30,37 @@ const open = async (id: string) => {
defineExpose({ open })
const parseFormFields = () => {
// TODO @lesanform field form-create api = =
// TODO @form-create
const formFieldsObj = decodeFields(printData.value.processInstance.processDefinition.formFields)
const processVariables = printData.value.processInstance.formVariables
let res: any = []
for (const item of formFieldsObj) {
const id = item['field']
const name = item['title']
let html = '暂不支持此类型的表单展示'
// TODO
// TODO @lesan UploadImgUploadFile else processVariables[item['field']]
// TODO @selectlabel...
// TODO @lesan form-create api
if (item['type'] === 'input') {
html = processVariables[item['field']]
} else if (item['type'] === 'UploadImg') {
html = `<img src="${processVariables[item['field']]}" style="max-width: 600px" />`
const variable = processVariables[item['field']]
let html = variable
switch (item['type']) {
case 'UploadImg': {
let imgEl = document.createElement('img')
imgEl.setAttribute('src', variable)
imgEl.setAttribute('style', 'max-width: 600px;')
html = imgEl.outerHTML
break
}
case 'radio':
case 'checkbox':
case 'select': {
const options = item['options'] || []
const temp: any = []
if (Array.isArray(variable)) {
const labels = options.filter((o) => variable.includes(o.value)).map((o) => o.label)
temp.push(...labels)
} else {
const opt = options.find((o) => o.value === variable)
temp.push(opt.label)
}
html = temp.join(',')
}
// TODO
}
printDataMap.value[item['field']] = html
res.push({ id, name, html })
@ -128,7 +142,7 @@ const printObj = ref({
<template>
<el-dialog v-loading="loading" v-model="visible" :show-close="false">
<div id="printDivTag">
<div id="printDivTag" style="word-break: break-all">
<div v-if="printData.printTemplateEnable" v-html="getPrintTemplateHTML()"></div>
<div v-else>
<h2 class="text-center">{{ printData.processInstance.name }}</h2>
@ -163,16 +177,6 @@ const printObj = ref({
<h4>表单内容</h4>
</td>
</tr>
<!-- <tr>-->
<!-- <td class="p-5px w-100% text-center" colspan="4">-->
<!-- <form-create-->
<!-- v-model="detailForm.value"-->
<!-- v-model:api="fApi"-->
<!-- :option="detailForm.option"-->
<!-- :rule="detailForm.rule"-->
<!-- />-->
<!-- </td>-->
<!-- </tr>-->
<tr v-for="item in formFields" :key="item.id">
<td class="p-5px w-20%">
{{ item.name }}
@ -209,3 +213,18 @@ const printObj = ref({
</template>
</el-dialog>
</template>
<style>
/* 修复打印只显示一页 */
@media print {
@page {
size: auto;
}
body,
html,
div {
height: auto !important;
}
}
</style>