From d9259a91412150bff1f8c0e121f958a9de146311 Mon Sep 17 00:00:00 2001 From: zhipenglin Date: Thu, 17 Oct 2024 09:46:09 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E4=BA=86=E4=B8=80=E4=BA=9B?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package.json | 2 +- src/TableView/index.js | 35 ++++++++++++++++++++++++++++++++--- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 8807dc9..c42c5d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@kne/info-page", - "version": "0.1.4", + "version": "0.1.5", "description": "一般用在复杂的详情展示页面,InfoPage提供了一个标准的展示信息的格式", "syntax": { "esmodules": true diff --git a/src/TableView/index.js b/src/TableView/index.js index 76810e9..9f6d6be 100644 --- a/src/TableView/index.js +++ b/src/TableView/index.js @@ -16,6 +16,20 @@ const defaultFormat = { const template = args[0] || 'YYYY-MM-DD HH:mm:ss'; return dayjs(value).format(template); }, + dateRange: (value, { args }) => { + const template = args[0] || 'YYYY-MM-DD', + allowNull = args[1]; + if (!isEmpty(value[0]) && !isEmpty(value[1])) { + return `${dayjs(value[0]).format(template)}~${dayjs(value[1]).format(template)}`; + } + if (allowNull === 'allow' && !isEmpty(value[0])) { + return `${dayjs(value[0]).format(template)}以后`; + } + if (allowNull === 'allow' && !isEmpty(value[1])) { + return `${dayjs(value[1]).format(template)}以前`; + } + return ''; + }, boolean: value => { if (value) { return '是'; @@ -105,11 +119,11 @@ const TableView = props => { return ( - {renderColumns.map(item => { + {renderColumns.map((item, index) => { return ( { > {item.title} - {item.isEmpty ? item.placeholder || placeholder : typeof item.render === 'function' ? item.render(item.value) : item.value} + + {item.isEmpty + ? typeof item.renderPlaceholder === 'function' + ? item.renderPlaceholder({ + column: item, + dataSource, + placeholder + }) + : item.placeholder || placeholder + : typeof item.render === 'function' + ? item.render(item.value, { + column: item, + dataSource + }) + : item.value} + );