From 6418ff75135a01d1497ea9737d5c1128f04ed280 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8E=E8=82=96=E7=A3=8A?= <18851179580@163.com> Date: Mon, 9 Dec 2024 13:58:51 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E8=87=AA=E5=AE=9A=E4=B9=89?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9A=84=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../custom-module/data-rendering/index.vue | 29 ++-- .../common/custom-module/model-icon/index.vue | 8 +- .../custom-module/model-image/index.vue | 21 ++- .../common/custom-module/model-text/index.vue | 17 +- .../model-custom/components/index.vue | 15 +- src/components/model-custom/index.vue | 12 +- .../model-custom/model-custom-content.vue | 151 ++++++++++-------- .../components/custom/index.vue | 4 +- .../model-data-magic-content.vue | 5 +- src/config/const/custom.ts | 7 +- src/views/layout/index.vue | 8 +- 11 files changed, 149 insertions(+), 128 deletions(-) diff --git a/src/components/common/custom-module/data-rendering/index.vue b/src/components/common/custom-module/data-rendering/index.vue index 4a34b2d3..e02baec0 100644 --- a/src/components/common/custom-module/data-rendering/index.vue +++ b/src/components/common/custom-module/data-rendering/index.vue @@ -2,19 +2,19 @@
@@ -47,10 +47,6 @@ const props = defineProps({ return {}; } }, - sourceType: { - type: String, - default: '' - }, dataHeight: { type: Number, default: 0, @@ -58,6 +54,21 @@ const props = defineProps({ scale: { type: Number, default: 1, + }, + isCustom: { + type: Boolean, + default: false + }, + showData: { + type: Object as PropType<{ + data_key: string; + data_name: string; + data_logo?: string; + }>, + default: () => ({ + data_key: 'id', + data_name: 'name', + }) } }); diff --git a/src/components/common/custom-module/model-icon/index.vue b/src/components/common/custom-module/model-icon/index.vue index 8ff9f267..0e524da0 100644 --- a/src/components/common/custom-module/model-icon/index.vue +++ b/src/components/common/custom-module/model-icon/index.vue @@ -33,9 +33,9 @@ const props = defineProps({ type: Number, default: 1 }, - sourceType: { - type: String, - default: '' + isCustom: { + type: Boolean, + default: false } }); // 用于页面判断显示 @@ -49,7 +49,7 @@ const icon_class = computed(() => { // 不输入商品, 文章和品牌时,从外层处理数据 let icon = props.sourceList[form.value.data_source_id]; // 如果是商品,品牌,文章的图片, 其他的切换为从data中取数据 - if (['goods', 'article', 'brand'].includes(props.sourceType) && !isEmpty(props.sourceList.data)) { + if (!isEmpty(props.sourceList.data) && props.isCustom) { icon = props.sourceList.data[form.value.data_source_id]; } return icon; diff --git a/src/components/common/custom-module/model-image/index.vue b/src/components/common/custom-module/model-image/index.vue index 397e221f..5035cc76 100644 --- a/src/components/common/custom-module/model-image/index.vue +++ b/src/components/common/custom-module/model-image/index.vue @@ -28,18 +28,15 @@ const props = defineProps({ type: Number, default: 1 }, - sourceType: { + isCustom: { + type: Boolean, + default: false + }, + imgParams: { type: String, - default: '', + default: '' } }); - -const keyMap: { [key: string]: string } = { - goods: 'images', - article: 'cover', - brand: 'logo' -}; - // 用于页面判断显示 const form = computed(() => props.value); @@ -51,9 +48,9 @@ const img = computed(() => { // 不输入商品, 文章和品牌时,从外层处理数据 let image_url = props.sourceList[form.value.data_source_id]; // 如果是商品,品牌,文章的图片, 其他的切换为从data中取数据 - if (['goods', 'article', 'brand'].includes(props.sourceType) && !isEmpty(props.sourceList.data)) { - if (form.value.data_source_id == keyMap[props.sourceType]) { - image_url = !isEmpty(props.sourceList.new_cover)? props.sourceList.new_cover[0]?.url || '' : props.sourceList.data[keyMap[props.sourceType]]; + if (!isEmpty(props.sourceList.data) && props.isCustom) { + if (form.value.data_source_id == props.imgParams) { + image_url = !isEmpty(props.sourceList.new_cover)? props.sourceList.new_cover[0]?.url || '' : props.sourceList.data[props.imgParams]; } else { image_url = props.sourceList.data[form.value.data_source_id]; } diff --git a/src/components/common/custom-module/model-text/index.vue b/src/components/common/custom-module/model-text/index.vue index be897eaf..4136a4c5 100644 --- a/src/components/common/custom-module/model-text/index.vue +++ b/src/components/common/custom-module/model-text/index.vue @@ -35,16 +35,15 @@ const props = defineProps({ type: Number, default: 1 }, - sourceType: { + isCustom: { + type: Boolean, + default: false + }, + titleParams: { type: String, default: '' } }); -const keyMap: { [key: string]: string } = { - goods: 'title', - article: 'title', - brand: 'name' -}; // 用于页面判断显示 const form = computed(() => props.value); @@ -52,10 +51,10 @@ const text_title = computed(() => { let text = ''; let text_title = props.sourceList[form.value.data_source_id]; // 如果是商品的标题或者是品牌的名称,需要判断是否有新的标题,没有的话就取原来的标题 - if (['goods', 'article', 'brand'].includes(props.sourceType) && !isEmpty(props.sourceList.data)) { + if (!isEmpty(props.sourceList.data) && props.isCustom) { // 其他的切换为从data中取数据 - if (form.value.data_source_id == keyMap[props.sourceType]) { - text_title = !isEmpty(props.sourceList.new_title) ? props.sourceList.new_title : props.sourceList.data[keyMap[props.sourceType]]; + if (form.value.data_source_id == props.titleParams) { + text_title = !isEmpty(props.sourceList.new_title) ? props.sourceList.new_title : props.sourceList.data[props.titleParams]; } else { text_title = props.sourceList.data[form.value.data_source_id]; } diff --git a/src/components/model-custom/components/index.vue b/src/components/model-custom/components/index.vue index 824b5f63..49a7bcc3 100644 --- a/src/components/model-custom/components/index.vue +++ b/src/components/model-custom/components/index.vue @@ -70,19 +70,19 @@
@@ -107,7 +107,7 @@