From 24a36eaf7f9ed816ec378945e23438af7d3d612c Mon Sep 17 00:00:00 2001 From: zhf <1204297681@qq.com> Date: Fri, 1 Sep 2023 15:17:39 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20span=E7=BC=96=E8=BE=91=E5=99=A8?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=97=B6=E9=97=B4=E7=B1=BB=E5=9E=8B=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E7=9A=84=E5=80=BC=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + src/editor/span/span/span.tsx | 20 +++++++++++-------- .../panel-field/panel-field.controller.ts | 4 ++++ 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 172ac107b..5a3234a2e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - 支持表格的固定列配置,操作列默认固定 - 支持代码表文本样式 - 支持placeholder占位控件 +- span编辑器支持时间类型数据的值格式化 ### Fixed diff --git a/src/editor/span/span/span.tsx b/src/editor/span/span/span.tsx index 8c21f05ee..9655b9943 100644 --- a/src/editor/span/span/span.tsx +++ b/src/editor/span/span/span.tsx @@ -7,6 +7,8 @@ import { import './span.scss'; import { CodeListItem } from '@ibiz-template/runtime'; import { isNil } from 'ramda'; +import { DataTypes } from '@ibiz-template/core'; +import dayjs from 'dayjs'; import { SpanEditorController } from '../span-editor.controller'; export const IBizSpan = defineComponent({ @@ -29,21 +31,23 @@ export const IBizSpan = defineComponent({ text.value = ''; return; } - if (c.parent.valueFormat) { + const { valueFormat, dataType, unitName } = c.parent; + if (valueFormat) { try { - text.value = ibiz.util.text.format( - `${newVal}`, - c.parent.valueFormat, - ); + if (dataType != null && DataTypes.isDate(dataType)) { + text.value = dayjs(newVal).format(valueFormat); + } else { + text.value = ibiz.util.text.format(`${newVal}`, valueFormat); + } } catch (error) { text.value = `${newVal}`; ibiz.log.error(`${newVal} 值格式化错误`); } } else { - text.value = newVal ? `${newVal}` : ''; + text.value = `${newVal}`; } - if (c.parent.unitName) { - text.value += c.parent.unitName; + if (unitName) { + text.value += unitName; } } }, diff --git a/src/panel-component/panel-field/panel-field.controller.ts b/src/panel-component/panel-field/panel-field.controller.ts index eb35478bf..8ed3dde86 100644 --- a/src/panel-component/panel-field/panel-field.controller.ts +++ b/src/panel-component/panel-field/panel-field.controller.ts @@ -35,6 +35,10 @@ export class PanelFieldController return this.model.valueFormat; } + get dataType(): number | undefined { + return undefined; + } + get context(): IContext { return this.panel.context; } -- Gitee