-
![]()
{
+ if (props.isView) {
+ eleData.value = props.data.options.field ? props.pageData?.[props.data.options.field] : props.data.options.default;
+ } else {
+ eleData.value = props.data.options.default || '1234567890abc';
+ }
+};
onMounted(() => {
- JsBarcode('#barcode' + props.id, props.data.options.default || '1234567890abc', {
- format: 'CODE128',
- lineColor: '#000',
- displayValue: true
+ getEleData();
+ nextTick(() => {
+ if (eleData.value) {
+ JsBarcode('#barcode' + props.id, 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)) {
- JsBarcode('#barcode' + props.id, props.data.options.default || '1234567890abc', {
- format: 'CODE128',
- lineColor: '#000',
- displayValue: true
+ getEleData();
+ nextTick(() => {
+ if (eleData.value) {
+ JsBarcode('#barcode' + props.id, eleData.value, {
+ format: 'CODE128',
+ lineColor: '#000',
+ displayValue: true
+ });
+ }
});
}
}, { deep: true });
diff --git a/src/views/print/nodes/image.vue b/src/views/print/nodes/image.vue
index 957e1ed..0d01b23 100644
--- a/src/views/print/nodes/image.vue
+++ b/src/views/print/nodes/image.vue
@@ -1,13 +1,14 @@
-
-
@@ -42,9 +43,29 @@ const props = defineProps({
pageSize: {
type: Object,
required: true
+ },
+ pageData: {
+ type: Object,
+ required: true
}
});
+const eleData = ref('');
+const getEleData = () => {
+ if (props.isView) {
+ eleData.value = props.pageData?.[props.data.options.field] || props.data.options.imageSrc;
+ } else {
+ eleData.value = props.data.options.imageSrc || image;
+ }
+};
+onMounted(() => {
+ getEleData();
+});
+watch(() => JSON.parse(JSON.stringify(props.data.options.imageSrc)), (obj1, obj2) => {
+ if (JSON.stringify(obj1) !== JSON.stringify(obj2)) {
+ getEleData();
+ }
+}, { deep: true });
+
diff --git a/src/views/print/nodes/textNode.vue b/src/views/print/nodes/textNode.vue
index 6d714c2..697862f 100644
--- a/src/views/print/nodes/textNode.vue
+++ b/src/views/print/nodes/textNode.vue
@@ -1,15 +1,16 @@
-
- {{ props.data.options.name || '文字' }}
+ {{ eleData }}
@@ -42,8 +43,28 @@ const props = defineProps({
pageSize: {
type: Object,
required: true
+ },
+ pageData: {
+ type: Object,
+ required: true
}
});
+const eleData = ref('');
+const getEleData = () => {
+ if (props.isView) {
+ eleData.value = props.data.options.field ? props.pageData?.[props.data.options.field] : props.data.options.default;
+ } else {
+ eleData.value = props.data.options.default || '文字';
+ }
+};
+onMounted(() => {
+ getEleData();
+});
+watch(() => JSON.parse(JSON.stringify(props.data.options.default)), (obj1, obj2) => {
+ if (JSON.stringify(obj1) !== JSON.stringify(obj2)) {
+ getEleData();
+ }
+}, { deep: true });