|
@@ -105,11 +105,11 @@ class SelectTable extends Field
|
|
|
protected function addScript()
|
|
protected function addScript()
|
|
|
{
|
|
{
|
|
|
$this->script .= <<<JS
|
|
$this->script .= <<<JS
|
|
|
-Dcat.grid.SelectTable({
|
|
|
|
|
- modal: replaceNestedFormIndex('#{$this->modal->getId()}'),
|
|
|
|
|
- container: '{$this->getElementClassSelector()}',
|
|
|
|
|
- input: replaceNestedFormIndex('#hidden-{$this->id}'),
|
|
|
|
|
- button: replaceNestedFormIndex('#{$this->getButtonId()}'),
|
|
|
|
|
|
|
+Dcat.grid.SelectTable({
|
|
|
|
|
+ modal: replaceNestedFormIndex('#{$this->modal->id()}'),
|
|
|
|
|
+ container: replaceNestedFormIndex('#{$this->getAttribute('id')}'),
|
|
|
|
|
+ input: replaceNestedFormIndex('#hidden-{$this->id}'),
|
|
|
|
|
+ button: replaceNestedFormIndex('#{$this->getButtonId()}'),
|
|
|
values: {$this->options},
|
|
values: {$this->options},
|
|
|
});
|
|
});
|
|
|
JS;
|
|
JS;
|
|
@@ -117,8 +117,10 @@ JS;
|
|
|
|
|
|
|
|
protected function setUpModal()
|
|
protected function setUpModal()
|
|
|
{
|
|
{
|
|
|
- $this->modal
|
|
|
|
|
- ->getTable()
|
|
|
|
|
|
|
+ $table = $this->modal->getTable();
|
|
|
|
|
+
|
|
|
|
|
+ $table
|
|
|
|
|
+ ->id('table-card-'.$this->getElementId())
|
|
|
->getRenderable()
|
|
->getRenderable()
|
|
|
->with('key', $this->form->getKey());
|
|
->with('key', $this->form->getKey());
|
|
|
|
|
|
|
@@ -127,6 +129,16 @@ JS;
|
|
|
->id($this->getElementId())
|
|
->id($this->getElementId())
|
|
|
->runScript(false)
|
|
->runScript(false)
|
|
|
->footer($this->renderFooter());
|
|
->footer($this->renderFooter());
|
|
|
|
|
+
|
|
|
|
|
+ // 显示弹窗的时候异步加载表格
|
|
|
|
|
+ $this->modal->getModal()->onShow(
|
|
|
|
|
+ <<<JS
|
|
|
|
|
+if (! modal.table) {
|
|
|
|
|
+ modal.table = $(replaceNestedFormIndex('{$table->getElementSelector()}'));
|
|
|
|
|
+}
|
|
|
|
|
+modal.table.trigger('table:load');
|
|
|
|
|
+JS
|
|
|
|
|
+ );
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public function render()
|
|
public function render()
|
|
@@ -139,7 +151,8 @@ JS;
|
|
|
$this->prepend('<i class="feather icon-arrow-up"></i>')
|
|
$this->prepend('<i class="feather icon-arrow-up"></i>')
|
|
|
->defaultAttribute('class', 'form-control '.$this->getElementClassString())
|
|
->defaultAttribute('class', 'form-control '.$this->getElementClassString())
|
|
|
->defaultAttribute('type', 'text')
|
|
->defaultAttribute('type', 'text')
|
|
|
- ->defaultAttribute('name', $name);
|
|
|
|
|
|
|
+ ->defaultAttribute('name', $name)
|
|
|
|
|
+ ->defaultAttribute('id', 'container-'.$this->getElementId());
|
|
|
|
|
|
|
|
$this->addVariables([
|
|
$this->addVariables([
|
|
|
'prepend' => $this->prepend,
|
|
'prepend' => $this->prepend,
|
|
@@ -152,7 +165,7 @@ JS;
|
|
|
$this->script = $this->modal->getScript();
|
|
$this->script = $this->modal->getScript();
|
|
|
|
|
|
|
|
$this->addScript();
|
|
$this->addScript();
|
|
|
-
|
|
|
|
|
|
|
+// dd($this->script);
|
|
|
return parent::render();
|
|
return parent::render();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -167,7 +180,7 @@ JS;
|
|
|
$cancel = trans('admin.cancel');
|
|
$cancel = trans('admin.cancel');
|
|
|
|
|
|
|
|
return <<<HTML
|
|
return <<<HTML
|
|
|
-<a id="{$this->getButtonId()}" class="btn btn-primary" style="color: #fff"> {$submit} </a>
|
|
|
|
|
|
|
+<a id="{$this->getButtonId()}" class="btn btn-primary" style="color: #fff"> {$submit} </a>
|
|
|
<a onclick="$(this).parents('.modal').modal('toggle')" class="btn btn-white"> {$cancel} </a>
|
|
<a onclick="$(this).parents('.modal').modal('toggle')" class="btn btn-white"> {$cancel} </a>
|
|
|
HTML;
|
|
HTML;
|
|
|
}
|
|
}
|
|
@@ -177,7 +190,7 @@ HTML;
|
|
|
*
|
|
*
|
|
|
* @return string
|
|
* @return string
|
|
|
*/
|
|
*/
|
|
|
- protected function getButtonId()
|
|
|
|
|
|
|
+ public function getButtonId()
|
|
|
{
|
|
{
|
|
|
return 'submit-'.$this->id;
|
|
return 'submit-'.$this->id;
|
|
|
}
|
|
}
|