修改打印模版配置

master
suixy 3 weeks ago
parent 11b1649d12
commit 92f408fb06

@ -153,7 +153,7 @@ const handleClose = (done) => {
};
const drawer = ref(false);
const loading = ref(false);
const drawerRef = ref()
const drawerRef = ref();
const printTemplateList = ref([]);
const route = useRoute();
const printType = ref(0);
@ -188,8 +188,20 @@ const messageFun = (event) => {
// let data = JSON.parse(event.data);
let data = event.data;
if (data.type === 'print') {
window.chrome?.webview?.postMessage(JSON.stringify({ value: pageDatas.value, type: 'print' }));
printFun();
let zoomEl = zoom.value
zoom.value = 5
nextTick(() => {
setTimeout(()=>{
printFun()
setTimeout(()=>{
zoom.value = zoomEl
},200)
},500)
})
// printFun();
}
if (data.type === 'return') {
window.chrome?.webview?.postMessage(JSON.stringify({ value: pageDatas.value, type: 'return' }));
}
if (data.type === 'JSONDATA') {
if (typeof data.message === 'object' && data.message !== null && !Array.isArray(data.message)) {
@ -202,6 +214,23 @@ const messageFun = (event) => {
// window.chrome?.webview?.postMessage('setDataFail');
}
}
if (data.type === 'updateData') {
let data = [];
if (typeof data.message === 'object' && data.message !== null && !Array.isArray(data.message)) {
data = [data.message];
// window.chrome?.webview?.postMessage('setDataFinally');
} else if (Array.isArray(data.message)) {
data = data.message;
// window.chrome?.webview?.postMessage('setDataFinally');
} else {
// window.chrome?.webview?.postMessage('setDataFail');
}
data.forEach((item, index) => {
Object.keys(item).forEach(key => {
pageDatas.value[index][key] = item[key];
});
});
}
// }
};
const setNodes = (data) => {
@ -232,7 +261,7 @@ const setNodes = (data) => {
nextTick(() => {
zoom.value = ((printRef.value.offsetWidth) / 793);
});
drawer.value = false
drawer.value = false;
loading.value = false;
});
});
@ -240,7 +269,49 @@ const setNodes = (data) => {
const setValue = (value, field, index) => {
pageDatas.value[index][field] = value;
};
const test = () =>{
let json1 = {
'PlanCode': '20260112100528PL0001',
'CardRecordCode': '20260112NC001010001',
'ClassesName': '\u65E9',
'TeamName': '\u7532\u73ED',
'MaterialSpec': 'NL821/832/833/840/841/844/848/849/106',
'MachineName': '\u5185\u5B58\u5C421#',
'UserList': ['\u674E\u5185\u886C\u5C42', '\u738B\u5185\u886C\u5C42', '\u5F20\u5185\u886C\u5C42'],
'UserListSel': null,
'ResultList': ['\u5408\u683C', '\u4E0D\u5408\u683C'],
'ResultListSel': null,
'ValidDate': '30',
'ToolingCode': '',
'Width': '1000',
'RealBeginTime': '2026-01-12 10:54:35',
'RealEndTime': '2026-01-12 14:34:12',
'CompleteAmount': '0',
'UnitList': ['\u7C73'],
'UnitListSel': null,
'Batch': '0',
'ContinueTime': '0',
'Remark': '',
'StationList': ['\u5185\u5B58\u5C421#\u4EA7\u51FA\u5DE5\u4F4D1', '\u5185\u5B58\u5C421#\u4EA7\u51FA\u5DE5\u4F4D2'],
'StationListSel': '\u5185\u5B58\u5C421#',
'BarCode': null
};
pageDatas.value = [json1];
setTimeout(() => {
console.log(123);
let data = [{ Batch: '123' }];
data.forEach((item, index) => {
Object.keys(item).forEach(key => {
pageDatas.value[index][key] = item[key];
});
});
}, 1000 * 5);
}
onMounted(() => {
// test()
window.addEventListener('afterprint', () => {
isPrint.value = false;
});
window.chrome?.webview?.addEventListener('message', messageFun);
window.chrome?.webview?.postMessage('onMounted');
const param = route.query.data;
@ -305,6 +376,7 @@ const printFun = (e) => {
);
});
Promise.all(pros).then((values) => {
window.print();
// window.chrome?.webview?.postMessage('completed');
isPrint.value = false;
@ -348,10 +420,11 @@ defineExpose({
});
</script>
<style scoped>
.content {
position: relative;
width: 100%;
overflow: hidden;
//overflow: hidden;
background-repeat: no-repeat;
background-size: 100% 100%;
border-top: 1px solid #ccc;
@ -397,6 +470,7 @@ defineExpose({
right: 0;
top: 0;
}
.printTemplateList {
width: 150px;
display: inline-block;

@ -1190,7 +1190,10 @@ onMounted(() => {
listPrintTemplateInfo({ templateListId: router.query.id }).then(e => {
let data = e.rows[0];
console.log(data);
if (!data) return;
if (!data) {
loading.value = false;
return;
}
pageType.value = (data.paperType || 'A4') === '自定义' ? 'zdy' : data.paperType;
pageId.value = data.templateInfoId;
pageWidth.value = data.width || 21;

@ -104,6 +104,21 @@ onMounted(() => {
}
});
});
watch(() => JSON.parse(JSON.stringify(props.pageData || '')), (obj1, obj2) => {
if (JSON.stringify(obj1) !== JSON.stringify(obj2)) {
getEleData();
nextTick(() => {
if (eleData.value) {
JsBarcode('#barcode' + props.id + props.index, eleData.value, {
format: 'CODE128',
lineColor: '#000',
displayValue: true
});
}
});
}
})
watch(() => JSON.parse(JSON.stringify(props.data.options.default)), (obj1, obj2) => {
if (JSON.stringify(obj1) !== JSON.stringify(obj2)) {
getEleData();

@ -6,7 +6,7 @@
v-if="!props.isView && !props.isHideHandle && props.selected" />
<div class="custom-node"
:style="{...border(),textAlign:props.data.options.align,width:props.dimensions.width+'px',lineHeight:props.dimensions.height+'px',height:props.dimensions.height+'px',pointerEvents:props.isView?'auto': 'none'}">
<el-input class="inputEl" v-model="text" style="width: 100%;height: 100%" @change="spanChange"
<el-input class="inputEl" v-model="text" style="width: 100%;height: 100%" @input="spanChange"
v-if="!props.isPrint" />
<div class="printDiv" :style="{justifyContent: props.data.options.verticalAlign || 'center'}"
v-if="props.isPrint">
@ -58,6 +58,7 @@ const props = defineProps({
const text = ref('');
const options = ref([]);
const spanChange = (val) => {
console.log(123123);
emit('update', val)
};
watch(() => JSON.parse(JSON.stringify(props.data.options.default)), (obj1, obj2) => {
@ -73,6 +74,11 @@ const getEleData = () => {
text.value = props.data.options.default;
}
};
watch(() => JSON.parse(JSON.stringify(props.pageData||'')), (obj1, obj2) => {
if (JSON.stringify(obj1) !== JSON.stringify(obj2)) {
getEleData();
}
}, { deep: true, immediate: true });
onMounted(() => {
getEleData();
});

@ -6,6 +6,7 @@
v-if="!props.isView && !props.isHideHandle && props.selected" />
<div class="custom-node"
:style="{...border(),textAlign:props.data.options.align,width:props.dimensions.width+'px',lineHeight:props.dimensions.height+'px',height:props.dimensions.height+'px',pointerEvents:props.isView?'auto': 'none'}">
<el-dropdown @command="spanChange" style="width: 100%;height: 100%" v-if="!props.isPrint">
<div class="dropDiv" :style="{justifyContent: props.data.options.verticalAlign || 'center'}">
<span class="span" :style="{textAlign: props.data.options.horizontalAlign || 'center'}">
@ -91,7 +92,7 @@ const getEleData = async () => {
const data = await addFunction(request)();
options.value = data;
} else if (props.data.options.selectField) {
options.value = options.value = props.pageData?.[props.data.options.selectField] || [];
options.value = props.pageData?.[props.data.options.selectField] || [];
} else if (props.data.options.dic) {
getDic(props.data.options.dic);
} else {
@ -120,7 +121,16 @@ watch(() => [JSON.parse(JSON.stringify(props.data.options.selectOptions)), JSON.
watch(() => JSON.parse(JSON.stringify(props.data.options.default)), (obj1, obj2) => {
if (JSON.stringify(obj1) !== JSON.stringify(obj2)) {
if (props.data.options.field) {
text.value = options.value = props.pageData?.[props.data.options.field] || '';
text.value = props.pageData?.[props.data.options.field] || '';
} else {
text.value = props.data.options.default;
}
}
}, { deep: true, immediate: true });
watch(() => JSON.parse(JSON.stringify(props.pageData||'')), (obj1, obj2) => {
if (JSON.stringify(obj1) !== JSON.stringify(obj2)) {
if (props.data.options.field) {
text.value = props.pageData?.[props.data.options.field] || '';
} else {
text.value = props.data.options.default;
}

@ -66,6 +66,11 @@ watch(() => JSON.parse(JSON.stringify(props.data.options.default)), (obj1, obj2)
getEleData();
}
}, { deep: true });
watch(() => JSON.parse(JSON.stringify(props.pageData||'')), (obj1, obj2) => {
if (JSON.stringify(obj1) !== JSON.stringify(obj2)) {
getEleData();
}
}, { deep: true, immediate: true });
const border = () => {
let res = {};
if (props.data.options.border) {

Loading…
Cancel
Save