This commit is contained in:
ichynul 2020-02-25 00:58:58 +08:00
parent 626bccab78
commit d591d82d0c
7 changed files with 55 additions and 12 deletions

View File

@ -11,16 +11,21 @@
});
var val = values.join(',');
name = name.split('-')[0];
var dataid = $(this).parents('tr.table-row-id').data('id');
tpextbuilder.autoSendData({
id: dataid,
name: name,
value: val
}, url, 0);
});
$('body').on('change', 'td.' + classname + ' :radio', function () {
var name = $(this).attr('name');
var val = $('td.' + classname + " input[name='" + name + "']:checked").val();
name = name.split('-')[0];
var dataid = $(this).parents('tr.table-row-id').data('id');
tpextbuilder.autoSendData({
id: dataid,
name: name,
value: val
}, url, 0);
@ -30,7 +35,9 @@
var name = $(this).attr('name');
var val = $(this).val();
name = name.split('-')[0];
var dataid = $(this).parents('tr.table-row-id').data('id');
tpextbuilder.autoSendData({
id: dataid,
name: name,
value: val
}, url, 0);
@ -40,7 +47,9 @@
var name = $(this).attr('name');
var val = $(this).val();
name = name.split('-')[0];
var dataid = $(this).parents('tr.table-row-id').data('id');
tpextbuilder.autoSendData({
id: dataid,
name: name,
value: val
}, url, 0);
@ -50,7 +59,9 @@
var name = $(this).attr('name');
var val = $(this).val();
name = name.split('-')[0];
var dataid = $(this).parents('tr.table-row-id').data('id');
tpextbuilder.autoSendData({
id: dataid,
name: name,
value: val
}, url, 0);

View File

@ -52,7 +52,7 @@ class Table extends Wapper implements Renderable
protected $rowCheckbox = true;
protected $emptyText = "暂未数据~";
protected $emptyText = "<p class='text-center'><span>暂无数据~</span></p>";
protected $toolbar = null;
@ -489,6 +489,10 @@ class Table extends Wapper implements Renderable
$this->ids[$key] = $data[$pk];
}
else
{
$this->ids[$key] = $key;
}
foreach ($cols as $col) {
@ -552,7 +556,7 @@ class Table extends Wapper implements Renderable
'emptyText' => $this->emptyText,
'headTextAlign' => $this->headTextAlign,
'ids' => $this->ids,
'rowCheckbox' => $this->rowCheckbox && !empty($this->ids),
'rowCheckbox' => $this->rowCheckbox && $this->useToolbar,
'name' => time() . mt_rand(1000, 9999),
'verticalAlign' => $this->verticalAlign,
'textAlign' => $this->textAlign,

View File

@ -68,6 +68,8 @@ class Field implements Renderable
protected static $labeltempl;
protected $mapClassWhen = [];
public function __construct($name, $label = '')
{
if (empty($label)) {
@ -533,6 +535,22 @@ class Field implements Renderable
return $this;
}
/**
* Undocumented function
*
* @param array|string $value acses
* @param string $class
* @return $this
*/
public function mapClassWhen($values, $class)
{
if (!is_array($values)) {
$values = [$values];
}
$this->mapClassWhen = [$values, $class];
return $this;
}
/**
* Undocumented function
*
@ -610,13 +628,23 @@ EOT;
$this->default = implode(',', $this->default);
}
$value = !($this->value === '' || $this->value === null) ? $this->value : $this->default;
$mapClass = '';
if (!empty($this->mapClassWhen)) {
if (in_array($value, $this->mapClassWhen[0])) {
$mapClass = ' ' . $this->mapClassWhen[1];
}
}
$vars = [
'id' => $this->getId(),
'label' => $this->label,
'name' => $this->getName(),
'tableRowKey' => $this->tableRowKey,
'value' => !($this->value === '' || $this->value === null) ? $this->value : $this->default,
'class' => ' ' . $this->class,
'value' => $value,
'class' => ' ' . $this->class . $mapClass,
'attr' => $this->attr . ($this->disabled ? ' disabled' : '') . ($this->readonly ? ' readonly onclick="return false;"' : '') . (empty($this->style) ? '' : ' style="' . $this->style . '"'),
'error' => $this->error,
'size' => $this->size,

View File

@ -30,8 +30,6 @@ class Match extends Raw
$this->value = $vars['value'] = $this->options[$vars['value']];
} else if (isset($this->options['__default__'])) {
$this->value = $vars['value'] = $this->options['__default__'];
} else {
echo $this->name, ':', $this->value, '|', $vars['value'], '<br>';
}
$viewshow = $this->getViewInstance();

View File

@ -266,11 +266,12 @@ class Actionbar extends Toolbar
* @param string $label
* @param string $class
* @param string $icon
* @param boolean $confirm
* @param string $attr
* @param boolean $confirm
* @return $this
*
*/
public function btnPostRowid($name = '', $postUrl, $label = '', $class = 'btn-secondary', $icon = 'mdi-checkbox-marked-outline', $confirm = true, $attr = '')
public function btnPostRowid($name = '', $postUrl, $label = '', $class = 'btn-secondary', $icon = 'mdi-checkbox-marked-outline', $attr = '', $confirm = true)
{
if (!$name) {
$name = preg_replace('/.+?\/(\w+)\.?\w+$/', '$1', $postUrl, -1, $count);

View File

@ -196,11 +196,12 @@ class MultipleToolbar extends Toolbar
* @param string $label
* @param string $class
* @param string $icon
* @param boolean $confirm
* @param string $attr
* @param boolean $confirm
* @return $this
*
*/
public function btnPostChecked($url, $label = '', $class = 'btn-secondary', $icon = 'mdi-checkbox-marked-outline', $confirm = true, $attr = '')
public function btnPostChecked($url, $label = '', $class = 'btn-secondary', $icon = 'mdi-checkbox-marked-outline', $attr = '', $confirm = true)
{
$action = preg_replace('/.+?\/(\w+)\.?\w+$/', '$1', $url, -1, $count);

View File

@ -29,7 +29,7 @@
{/notempty}
<tbody>
{volist name="list" id="row"}
<tr>
<tr class="table-row-id" data-id="{$ids[$key]}">
{if condition="$rowCheckbox"}
<td class="{$verticalAlign} {$textAlign}">
<label class="lyear-checkbox checkbox-primary">
@ -54,7 +54,7 @@
{/volist}
{empty name="$data"}
<tr>
<td>{$emptyText}</td>
<td colspan="{$cols|count}">{$emptyText|raw}</td>
</tr>
{/empty}
</tbody>