From 855b5461d8a3dd2e2038b60485a2e88c0eb3b07e Mon Sep 17 00:00:00 2001 From: liumengyi Date: Mon, 26 Jun 2023 08:26:51 +0800 Subject: [PATCH] Add tip of the dtable without data. --- lib/zin/wg/dtable/v1.php | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/lib/zin/wg/dtable/v1.php b/lib/zin/wg/dtable/v1.php index b0c351257e..3207c1169a 100644 --- a/lib/zin/wg/dtable/v1.php +++ b/lib/zin/wg/dtable/v1.php @@ -5,11 +5,14 @@ class dtable extends wg { static $defineProps = array( 'className?:string="shadow rounded"', // 表格样式。 - 'id?:string', // ID。 - 'customCols?: bool|array', // 是否支持自定义列。 - 'cols?:array', // 表格列配置 - 'data?:array', // 表格数据源 - 'module?:string', // 模块信息,主要是获取语言项 + 'id?:string', // ID。 + 'customCols?: bool|array', // 是否支持自定义列。 + 'cols?:array', // 表格列配置 + 'data?:array', // 表格数据源 + 'module?:string', // 模块信息,主要是获取语言项 + 'emptyTip?:string', // 表格数据源为空时显示的文本 + 'createLink?:array|string', // 表格数据源为空时的创建链接 + 'createTip?:string', // 表格数据源为空时显示的文本 ); static $dtableID = 0; @@ -108,6 +111,31 @@ class dtable extends wg protected function build() { + if(empty($this->prop('data'))) + { + global $lang; + $createLink = !empty($this->prop('createLink')) ? $this->getLink($this->prop('createLink')) : ''; + return div + ( + setClass('canvas text-center py-8'), + p + ( + setClass('py-8 my-8'), + span + ( + setClass('text-gray'), + !empty($this->prop('emptyTip')) ? $this->prop('emptyTip'): $lang->noData, + ), + !empty($createLink) ? a + ( + setClass('btn primary-pale bd-primary ml-0.5'), + set::href($createLink), + icon('plus'), + !empty($this->prop('createTip')) ? $this->prop('createTip') : $lang->create, + ) : '', + ) + ); + } return zui::dtable(inherit($this)); } }