|
|
|
|
@ -6,7 +6,7 @@ import store from '@/store'
|
|
|
|
|
* @param{string} [logContent] 审批表格html
|
|
|
|
|
* @return{void}
|
|
|
|
|
**/
|
|
|
|
|
export function print(printJs, isLog, form, logContent) {
|
|
|
|
|
export async function print(printJs, isLog, form, logContent) {
|
|
|
|
|
const staticMap = new Map([
|
|
|
|
|
['apply_name', () => `<span>${form.creator?.name}</span>`],
|
|
|
|
|
['apply_department_name', () => `<span>${form.creator_department?.name}</span>`],
|
|
|
|
|
@ -22,7 +22,8 @@ export function print(printJs, isLog, form, logContent) {
|
|
|
|
|
while ((match = regexField.exec(printJs)) !== null) {
|
|
|
|
|
fieldMaths.push(match[0]); // 提取 <field> 之间的内容
|
|
|
|
|
}
|
|
|
|
|
fieldMaths.forEach(async fieldMath => {
|
|
|
|
|
for (let i = 0;i < fieldMaths.length; i++) {
|
|
|
|
|
let fieldMath = fieldMaths[i]
|
|
|
|
|
const matchName = fieldMath.match(/name="([^"]+)"/);
|
|
|
|
|
if (matchName) {
|
|
|
|
|
const nameValue = matchName[1];
|
|
|
|
|
@ -37,6 +38,7 @@ export function print(printJs, isLog, form, logContent) {
|
|
|
|
|
})
|
|
|
|
|
let subFormBody = subForm.content.match(/<table(.*?)<\/table>/g)[0]
|
|
|
|
|
printStr = printStr.replace(fieldMath,subFormBody)
|
|
|
|
|
console.log(fieldMath, printStr)
|
|
|
|
|
} else {
|
|
|
|
|
printStr = printStr.replace(fieldMath,`<span>${value}</span>`)
|
|
|
|
|
}
|
|
|
|
|
@ -44,7 +46,7 @@ export function print(printJs, isLog, form, logContent) {
|
|
|
|
|
} else {
|
|
|
|
|
console.log('未找到name属性');
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
if(isLog) {
|
|
|
|
|
const logStyle = logContent.match(/<style>(.*?)<\/style>/g)
|
|
|
|
|
let totalLogStyle= ''
|
|
|
|
|
@ -53,8 +55,9 @@ export function print(printJs, isLog, form, logContent) {
|
|
|
|
|
})
|
|
|
|
|
printStr = printStr.replace('</style>',`</style>${totalLogStyle}<style>.vxe-table { width: 100%; } .vxe-table * { width: auto !important;white-space: initial; }.vxe-table:not(.is--print) .col--ellipsis > div { word-break: break-all;white-space: normal;overflow: initial; }.tblPrint .vxe-table td,.tblPrint .vxe-table th { font-size: 20px;padding: 0; }</style>`)
|
|
|
|
|
const logBody = logContent.match(/<table(.*?)<\/table>/g)[0]
|
|
|
|
|
printStr = printStr.replace('</table>',`</talbe>${logBody}`)
|
|
|
|
|
printStr = printStr.replace('</table>\n<style>',`</talbe>${logBody}<style>`)
|
|
|
|
|
}
|
|
|
|
|
console.log(printStr)
|
|
|
|
|
let printWindow = window.open('', '_blank');
|
|
|
|
|
printWindow.document.write(printStr);
|
|
|
|
|
printWindow.focus();
|
|
|
|
|
|