From f2730e356fbe7f5909edd99eb540064ad651d670 Mon Sep 17 00:00:00 2001 From: wangzemei Date: Fri, 19 Apr 2024 14:25:59 +0800 Subject: [PATCH] + zin: add thinkNode wg. --- lib/zin/func.php | 1 + lib/zin/wg/thinkcheckbox/v1.php | 2 +- lib/zin/wg/thinknode/v1.php | 73 +++++++++++++++++++++++++++++++++ lib/zin/wg/thinkradio/v1.php | 2 +- 4 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 lib/zin/wg/thinknode/v1.php diff --git a/lib/zin/func.php b/lib/zin/func.php index debb743fb6..650985eec7 100644 --- a/lib/zin/func.php +++ b/lib/zin/func.php @@ -192,6 +192,7 @@ function caseTimeInfo(): caseTimeInfo {return createWg('caseTimeInfo', func_get_ function caseRelatedList(): caseRelatedList {return createWg('caseRelatedList', func_get_args());} function flowSubTable(): flowSubTable {return createWg('flowSubTable', func_get_args());} function thumbnail(): thumbnail {return createWg('thumbnail', func_get_args());} +function thinkNode(): thinkNode {return createWg('thinkNode', func_get_args());} function thinkStep(): thinkStep {return createWg('thinkStep', func_get_args());} function thinkRadio(): thinkRadio{return createWg('thinkRadio', func_get_args());} function thinkCheckbox(): thinkCheckbox {return createWg('thinkCheckbox', func_get_args());} diff --git a/lib/zin/wg/thinkcheckbox/v1.php b/lib/zin/wg/thinkcheckbox/v1.php index a6575d45cb..712aca372b 100644 --- a/lib/zin/wg/thinkcheckbox/v1.php +++ b/lib/zin/wg/thinkcheckbox/v1.php @@ -5,7 +5,7 @@ namespace zin; require_once dirname(__DIR__) . DS . 'thinkradio' . DS . 'v1.php'; /** - * 多选题型(thinkCheckbox)部件类 + * 多选题型部件类 * The thinkCheckbox widget class */ class thinkCheckbox extends thinkRadio diff --git a/lib/zin/wg/thinknode/v1.php b/lib/zin/wg/thinknode/v1.php new file mode 100644 index 0000000000..21f72059ce --- /dev/null +++ b/lib/zin/wg/thinknode/v1.php @@ -0,0 +1,73 @@ +prop(array('item', 'status')); + + if($status == 'detail') + { + return thinkStepDetail + ( + set::type($item->type), + set::title($item->title), + set::desc($item->desc), + ); + } + else + { + $options = json_encode($item->options, true); + $itemData = get_object_vars($item); + $item = (object)array_merge($itemData, $options); + + $item->options = null; + + if($item == 'node') return thinkNode(set($this->getRestProps())); + if($type == 'transition') return thinkTransition(set($this->getRestProps())); + if($type == 'question') + { + $questionType = zget($item, 'questionType', 'radio'); + if($questionType == 'radio') return thinkRadio(set($this->getRestProps())); + if($questionType == 'checkbox') return thinkCheckbox(set($this->getRestProps())); + } + } + } + + protected function build(): wg|array + { + list($item, $status) = $this->prop(array('item', 'status')); + if(!$item) return array(); + + return array( + $status !== 'detail' ? array( + div + ( + setClass('flex items-center justify-between'), + setStyle(array('height' => '48px', 'padding' => '0 48px', 'color' => 'var(--color-gray-950)')), + div + ( + setClass('font-medium'), + data('lang.thinkwizard.step.nodeInfo'), + ), + btn + ( + set::type('primary'), + set::btnType('submit'), + data('lang.save') + ) + ), + h::hr() + ) : null, + $this->buildBody(), + $this->children() + ); + } +} diff --git a/lib/zin/wg/thinkradio/v1.php b/lib/zin/wg/thinkradio/v1.php index 4f569bfcaa..fda7a5ae90 100644 --- a/lib/zin/wg/thinkradio/v1.php +++ b/lib/zin/wg/thinkradio/v1.php @@ -5,7 +5,7 @@ namespace zin; require_once dirname(__DIR__) . DS . 'thinkstep' . DS . 'v1.php'; /** - * 单选题型(thinkRadio)部件类 + * 单选题型部件类 * The thinkRadio widget class */ class thinkRadio extends thinkStep