From ef6692e84c9e01cfef5e83e1de1cb372df0f1011 Mon Sep 17 00:00:00 2001 From: zhangkang <1752553776@qq.com> Date: Mon, 17 Jul 2023 20:33:53 +0800 Subject: [PATCH 1/5] =?UTF-8?q?feat:=20=E7=9B=B4=E6=8E=A5=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E6=96=B0=E5=A2=9E=20rawItem=20=E6=A8=A1=E5=9E=8B?= =?UTF-8?q?=E5=8F=82=E6=95=B0=20&=20=E6=96=B0=E5=A2=9E=E9=9D=A2=E6=9D=BF?= =?UTF-8?q?=E7=9B=B4=E6=8E=A5=E5=86=85=E5=AE=B9=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/common/rawitem/rawitem.scss | 4 + src/common/rawitem/rawitem.tsx | 114 +++++++++++++----- .../form-detail/form-rawitem/form-rawitem.tsx | 36 +----- src/panel-component/index.ts | 3 + src/panel-component/panel-rawitem/index.ts | 15 +++ .../panel-rawitem/panel-rawitem.controller.ts | 34 ++++++ .../panel-rawitem/panel-rawitem.provider.ts | 25 ++++ .../panel-rawitem/panel-rawitem.scss | 8 ++ .../panel-rawitem/panel-rawitem.tsx | 48 ++++++++ 9 files changed, 220 insertions(+), 67 deletions(-) create mode 100644 src/common/rawitem/rawitem.scss create mode 100644 src/panel-component/panel-rawitem/index.ts create mode 100644 src/panel-component/panel-rawitem/panel-rawitem.controller.ts create mode 100644 src/panel-component/panel-rawitem/panel-rawitem.provider.ts create mode 100644 src/panel-component/panel-rawitem/panel-rawitem.scss create mode 100644 src/panel-component/panel-rawitem/panel-rawitem.tsx diff --git a/src/common/rawitem/rawitem.scss b/src/common/rawitem/rawitem.scss new file mode 100644 index 000000000..093949a90 --- /dev/null +++ b/src/common/rawitem/rawitem.scss @@ -0,0 +1,4 @@ +@include b(rawitem) { + width: 100%; + height: 100%; +} diff --git a/src/common/rawitem/rawitem.tsx b/src/common/rawitem/rawitem.tsx index 8acd3bdc6..1b4f50999 100644 --- a/src/common/rawitem/rawitem.tsx +++ b/src/common/rawitem/rawitem.tsx @@ -1,21 +1,55 @@ import { useNamespace } from '@ibiz-template/vue3-util'; -import { defineComponent, ref } from 'vue'; +import { defineComponent, PropType, ref } from 'vue'; import { createUUID } from 'qx-util'; +import { + IHtmlItem, + IPanelRawItem, + IRawItemContainer, + ITextItem, +} from '@ibiz/model-core'; +import './rawitem.scss'; export const IBizRawItem = defineComponent({ name: 'IBizRawItem', props: { type: { type: String, - required: true, + required: false, }, content: { type: [String, Object], }, + rawItem: { + type: Object as PropType, + required: false, + }, }, setup(props) { const ns = useNamespace('rawitem'); - + const { rawItem } = props.rawItem!; + const { contentType } = rawItem!; + const rawItemType = ref(props.type || contentType || ''); + const rawItemContent = ref(props.content); + let sysImage = null; + if (contentType === 'IMAGE') { + sysImage = (rawItem as IPanelRawItem).sysImage; + } + // 传入内容 + if (contentType === 'RAW' || contentType === 'HTML') { + if (contentType === 'RAW') { + rawItemType.value = 'TEXT'; + rawItemContent.value = (rawItem as ITextItem).caption!; + } else { + rawItemContent.value = (rawItem as IHtmlItem).content!; + } + } else if ( + ['VIDEO', 'DIVIDER', 'INFO', 'WARNING', 'ERROR'].includes(contentType!) + ) { + // 暂不支持 + // content = rawContent; + } else if (contentType === 'IMAGE' && sysImage) { + rawItemContent.value = sysImage; + } // 视频类型内容参数 const playerParams = ref({ id: createUUID(), @@ -54,10 +88,10 @@ export const IBizRawItem = defineComponent({ 'HEADING6', 'PARAGRAPH', 'HTML', - ].includes(props.type) + ].includes(rawItemType.value) ) { - if (props.content && typeof props.content === 'string') { - rawItemText.value = props.content; + if (rawItemContent.value && typeof rawItemContent.value === 'string') { + rawItemText.value = rawItemContent.value; rawItemText.value = rawItemText.value.replaceAll('<', '<'); rawItemText.value = rawItemText.value.replaceAll('>', '>'); rawItemText.value = rawItemText.value.replaceAll('&nbsp;', ' '); @@ -65,15 +99,19 @@ export const IBizRawItem = defineComponent({ } } - if (['VIDEO', 'DIVIDER', 'INFO', 'WARNING', 'ERROR'].includes(props.type)) { - if (props.content) { + if ( + ['VIDEO', 'DIVIDER', 'INFO', 'WARNING', 'ERROR'].includes( + rawItemType.value, + ) + ) { + if (rawItemContent.value) { let rawConfig = {}; try { - if (typeof props.content === 'string') { + if (typeof rawItemContent.value === 'string') { // eslint-disable-next-line no-new-func - const func = new Function(`return (${props.content});`); + const func = new Function(`return (${rawItemContent.value});`); rawConfig = func(); - switch (props.type) { + switch (rawItemType.value) { case 'VIDEO': Object.assign(playerParams.value, rawConfig); break; @@ -83,7 +121,7 @@ export const IBizRawItem = defineComponent({ case 'INFO': case 'WARNING': case 'ERROR': - alertParams.value.type = props.type.toLocaleLowerCase(); + alertParams.value.type = rawItemType.value.toLocaleLowerCase(); Object.assign(alertParams.value, rawConfig); break; default: @@ -91,49 +129,59 @@ export const IBizRawItem = defineComponent({ } } } catch { - ibiz.log.error(`${props.type}类型自定义参数配置错误`); + ibiz.log.error(`${rawItemType.value}类型自定义参数配置错误`); } } } - - return { ns, rawItemText, playerParams, dividerParams, alertParams }; + return { + ns, + rawItemText, + playerParams, + dividerParams, + alertParams, + rawItemType, + rawItemContent, + }; }, render() { - if (this.type === 'IMAGE') { + if (this.rawItemType === 'IMAGE') { return ( - + ); } - if (this.type === 'TEXT') { + if (this.rawItemType === 'TEXT') { return {this.rawItemText}; } - if (this.type === 'HEADING1') { + if (this.rawItemType === 'HEADING1') { return

{this.rawItemText}

; } - if (this.type === 'HEADING2') { + if (this.rawItemType === 'HEADING2') { return

{this.rawItemText}

; } - if (this.type === 'HEADING3') { + if (this.rawItemType === 'HEADING3') { return

{this.rawItemText}

; } - if (this.type === 'HEADING4') { + if (this.rawItemType === 'HEADING4') { return

{this.rawItemText}

; } - if (this.type === 'HEADING5') { + if (this.rawItemType === 'HEADING5') { return
{this.rawItemText}
; } - if (this.type === 'HEADING6') { + if (this.rawItemType === 'HEADING6') { return
{this.rawItemText}
; } - if (this.type === 'PARAGRAPH') { + if (this.rawItemType === 'PARAGRAPH') { return

{this.rawItemText}

; } - if (this.type === 'HTML') { + if (this.rawItemType === 'HTML') { return (
); } - if (this.type === 'VIDEO') { + if (this.rawItemType === 'VIDEO') { return (