+ zin: add thinkNode wg.

This commit is contained in:
wangzemei
2024-04-19 14:26:07 +08:00
parent 9d75d6ba07
commit f2730e356f
4 changed files with 76 additions and 2 deletions
+1
View File
@@ -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());}
+1 -1
View File
@@ -5,7 +5,7 @@ namespace zin;
require_once dirname(__DIR__) . DS . 'thinkradio' . DS . 'v1.php';
/**
* 多选题型(thinkCheckbox)部件类
* 多选题型部件类
* The thinkCheckbox widget class
*/
class thinkCheckbox extends thinkRadio
+73
View File
@@ -0,0 +1,73 @@
<?php
declare(strict_types=1);
namespace zin;
class thinkNode extends wg
{
protected static array $defineProps = array(
'item: object',
'status?: string="detail"',
);
protected function buildBody(): wg|array
{
list($item, $status) = $this->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()
);
}
}
+1 -1
View File
@@ -5,7 +5,7 @@ namespace zin;
require_once dirname(__DIR__) . DS . 'thinkstep' . DS . 'v1.php';
/**
* 单选题型(thinkRadio)部件类
* 单选题型部件类
* The thinkRadio widget class
*/
class thinkRadio extends thinkStep