update
This commit is contained in:
parent
178a6f545b
commit
27b70fed3f
|
@ -29,8 +29,17 @@ form.search-form .form-group {
|
|||
vertical-align: bottom;
|
||||
}
|
||||
|
||||
.raw
|
||||
.field-raw,.field-show
|
||||
{
|
||||
min-height: 38px;
|
||||
line-height: 38px;
|
||||
}
|
||||
|
||||
.field-required
|
||||
{
|
||||
color: red;
|
||||
}
|
||||
span.select2-container
|
||||
{
|
||||
min-width: 100%;
|
||||
}
|
|
@ -244,8 +244,16 @@ $(function () {
|
|||
ss += 1;
|
||||
}
|
||||
});
|
||||
checkall.prop('checked', ss == count);
|
||||
checkall.prop('checked', count > 0 && ss == count);
|
||||
});
|
||||
|
||||
var ss = 0;
|
||||
checkboxes.each(function (ii, ee) {
|
||||
if ($(ee).is(':checked')) {
|
||||
ss += 1;
|
||||
}
|
||||
});
|
||||
checkall.prop('checked', count > 0 && ss == count);
|
||||
});
|
||||
|
||||
$("form select").on("select2:opening", function (e) {
|
||||
|
@ -297,7 +305,7 @@ $(function () {
|
|||
// 通用绑定,
|
||||
$('.js-upload-files').each(function () {
|
||||
var $input_file = $(this).find('input'),
|
||||
$input_file_name = $input_file.attr('name');
|
||||
$input_file_name = $(this).data('name');
|
||||
|
||||
var jsOptions = window.uploadConfigs[$input_file_name];
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ use tpext\builder\common\Builder;
|
|||
|
||||
class Import extends Controller
|
||||
{
|
||||
public function index()
|
||||
public function page()
|
||||
{
|
||||
$acceptedExts = input('acceptedExts');
|
||||
$fileSize = input('fileSize');
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace tpext\builder\common;
|
||||
|
||||
use think\Model;
|
||||
use think\response\View as ViewShow;
|
||||
use tpext\builder\common\Builder;
|
||||
use tpext\builder\common\Module;
|
||||
|
@ -39,6 +40,8 @@ class Form extends Wapper implements Renderable
|
|||
|
||||
protected $validator = [];
|
||||
|
||||
protected $butonsSizeClass = '';
|
||||
|
||||
/**
|
||||
* Undocumented variable
|
||||
*
|
||||
|
@ -126,7 +129,7 @@ class Form extends Wapper implements Renderable
|
|||
*/
|
||||
public function getId()
|
||||
{
|
||||
return $this->id;
|
||||
return $this->id . ($this->search ? '-search' : '');
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -177,6 +180,18 @@ class Form extends Wapper implements Renderable
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
* btn-lg btn-sm btn-xs
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function butonsSizeClass($val)
|
||||
{
|
||||
$this->butonsSizeClass = $val;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
|
@ -297,7 +312,7 @@ class Form extends Wapper implements Renderable
|
|||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $data
|
||||
* @param array|Model $data
|
||||
* @return $this
|
||||
*/
|
||||
public function fill($data = [])
|
||||
|
@ -319,9 +334,10 @@ class Form extends Wapper implements Renderable
|
|||
{
|
||||
if ($create) {
|
||||
$this->fieldsContentEnd();
|
||||
$this->divider('', '', 12);
|
||||
$this->html('', '', 5)->showLabel(false);
|
||||
$this->divider('', '', 12)->size(0, 12)->showLabel(false);
|
||||
$this->html('', '', 4)->showLabel(false);
|
||||
$this->btnSubmit();
|
||||
$this->html('', '', 2)->showLabel(false);
|
||||
$this->btnReset();
|
||||
}
|
||||
|
||||
|
@ -336,6 +352,7 @@ class Form extends Wapper implements Renderable
|
|||
*/
|
||||
public function searchButtons()
|
||||
{
|
||||
$this->html('', '', 12)->showLabel(false);
|
||||
$this->html('', '', 5)->showLabel(false);
|
||||
$this->button('submit', '筛 选', 1)->class('btn-success btn-sm');
|
||||
$this->button('button', '重 置', 1)->class('btn-default btn-sm')->attr('onclick="location.replace(location.href)"');
|
||||
|
@ -356,7 +373,7 @@ class Form extends Wapper implements Renderable
|
|||
*/
|
||||
public function btnSubmit($label = '提 交', $size = 1, $class = 'btn-success')
|
||||
{
|
||||
$this->button('submit', $label, $size)->class($class);
|
||||
$this->button('submit', $label, $size)->class($class . ' ' . $this->butonsSizeClass);
|
||||
$this->botttomButtonsCalled = true;
|
||||
return $this;
|
||||
}
|
||||
|
@ -371,7 +388,7 @@ class Form extends Wapper implements Renderable
|
|||
*/
|
||||
public function btnReset($label = '重 置', $size = 1, $class = 'btn-warning')
|
||||
{
|
||||
$this->button('submit', $label, $size)->class($class);
|
||||
$this->button('reset', $label, $size)->class($class . ' ' . $this->butonsSizeClass);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -386,7 +403,7 @@ class Form extends Wapper implements Renderable
|
|||
*/
|
||||
public function btnBack($label = '返 回', $size = 1, $class = 'btn-default btn-go-back', $attr = 'onclick="history.go(-1);')
|
||||
{
|
||||
$this->button('button', $label, $size)->class($class)->attr($attr);
|
||||
$this->button('button', $label, $size)->class($class . ' ' . $this->butonsSizeClass)->attr($attr);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -400,7 +417,7 @@ class Form extends Wapper implements Renderable
|
|||
*/
|
||||
public function btnLayerClose($label = '返 回', $size = 1, $class = 'btn-default')
|
||||
{
|
||||
$this->button('button', $label, $size)->class($class . ' btn-close-layer');
|
||||
$this->button('button', $label, $size)->class($class . ' btn-close-layer'. ' '.$this->butonsSizeClass);
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
@ -461,8 +478,7 @@ class Form extends Wapper implements Renderable
|
|||
return;
|
||||
}
|
||||
parent.addClass('has-error');
|
||||
parent.append(error.addClass('help-block').addClass('error-label'));
|
||||
lightyear.notify('输入有误', 'warning');
|
||||
lightyear.notify(parent.find('.control-label').text() + error.text(), 'warning');
|
||||
},
|
||||
highlight: function(element) {
|
||||
var el = $(element);
|
||||
|
@ -475,7 +491,8 @@ class Form extends Wapper implements Renderable
|
|||
$(element).parents('.form-group').removeClass('has-error');
|
||||
},
|
||||
submitHandler: function(form) {
|
||||
formSubmit();
|
||||
window.forms['{$form}'].formSubmit();
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -542,9 +559,9 @@ EOT;
|
|||
'method' => strtoupper($this->method),
|
||||
'class' => $this->class,
|
||||
'attr' => $this->attr,
|
||||
'id' => $this->id,
|
||||
'id' => $this->getId(),
|
||||
'ajax' => $this->ajax || !empty($this->search) ? 1 : 0,
|
||||
'search' => $this->search
|
||||
'search' => $this->search,
|
||||
];
|
||||
|
||||
return $viewshow->assign($vars)->getContent();
|
||||
|
|
|
@ -304,7 +304,7 @@ class Table extends Wapper implements Renderable
|
|||
$cols = array_keys($data[0]);
|
||||
|
||||
foreach ($cols as $col) {
|
||||
$this->field($col, ucfirst($col));
|
||||
$this->show($col, ucfirst($col));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -452,7 +452,7 @@ class Table extends Wapper implements Renderable
|
|||
Builder::getInstance()->addCss($this->css);
|
||||
|
||||
if ($this->useToolbar) {
|
||||
$this->getToolbar()->beforRender();
|
||||
$this->getToolbar()->hasSearch(!empty($this->searchForm))->beforRender();
|
||||
}
|
||||
|
||||
if ($this->useActionbar) {
|
||||
|
@ -488,9 +488,7 @@ class Table extends Wapper implements Renderable
|
|||
if (isset($data[$pk])) {
|
||||
|
||||
$this->ids[$key] = $data[$pk];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$this->ids[$key] = $key;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace tpext\builder\common;
|
||||
|
||||
use think\response\View as ViewShow;
|
||||
use tpext\builder\toolbar\Bar;
|
||||
use tpext\builder\toolbar\Wapper;
|
||||
|
||||
class Toolbar extends Wapper implements Renderable
|
||||
|
@ -15,6 +16,8 @@ class Toolbar extends Wapper implements Renderable
|
|||
|
||||
protected $elms = [];
|
||||
|
||||
protected $__elm__;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
|
@ -63,6 +66,16 @@ class Toolbar extends Wapper implements Renderable
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @return Bar
|
||||
*/
|
||||
public function getCurrent()
|
||||
{
|
||||
return $this->__elm__;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
|
@ -101,13 +114,13 @@ class Toolbar extends Wapper implements Renderable
|
|||
|
||||
$class = static::$displayerMap[$name];
|
||||
|
||||
$elm = new $class($arguments[0], $count > 1 ? $arguments[1] : '');
|
||||
$this->__elm__ = new $class($arguments[0], $count > 1 ? $arguments[1] : '');
|
||||
|
||||
$elm->created();
|
||||
$this->__elm__->created();
|
||||
|
||||
$this->elms[] = $elm;
|
||||
$this->elms[] = $this->__elm__;
|
||||
|
||||
return $elm;
|
||||
return $this->__elm__;
|
||||
}
|
||||
|
||||
throw new \UnexpectedValueException('未知调用:' . $name);
|
||||
|
|
|
@ -12,7 +12,7 @@ class Checkbox extends Field
|
|||
|
||||
protected $inline = true;
|
||||
|
||||
protected $checkallBtn = false;
|
||||
protected $checkallBtn = '';
|
||||
|
||||
protected $default = [];
|
||||
|
||||
|
@ -45,10 +45,10 @@ class Checkbox extends Field
|
|||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @param string $val
|
||||
* @return $this
|
||||
*/
|
||||
public function checkallBtn($val = true)
|
||||
public function checkallBtn($val = '全选')
|
||||
{
|
||||
$this->checkallBtn = $val;
|
||||
return $this;
|
||||
|
@ -75,9 +75,22 @@ class Checkbox extends Field
|
|||
$this->checked = is_array($this->default) ? $this->default : explode(',', $this->default);
|
||||
}
|
||||
|
||||
$checkall = false;
|
||||
|
||||
if ($this->checkallBtn) {
|
||||
$count = 0;
|
||||
foreach ($this->options as $key => $op) {
|
||||
if (in_array($key, $this->checked)) {
|
||||
$count += 1;
|
||||
}
|
||||
}
|
||||
$checkall = $count == count($this->options);
|
||||
}
|
||||
|
||||
$vars = array_merge($vars, [
|
||||
'inline' => $this->inline ? 'checkbox-inline' : 'm-t-10',
|
||||
'checkallBtn' => $this->checkallBtn,
|
||||
'checkall' => $checkall,
|
||||
'checked' => $this->checked,
|
||||
'options' => $this->options,
|
||||
]);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
use think\Model;
|
||||
use think\response\View as ViewShow;
|
||||
use tpext\builder\common\Builder;
|
||||
use tpext\builder\common\Module;
|
||||
|
@ -136,7 +137,7 @@ class Field implements Renderable
|
|||
public function autoPost($url = '')
|
||||
{
|
||||
if (empty($url)) {
|
||||
$url = url('autopost');
|
||||
$url = url('autoPost');
|
||||
}
|
||||
$this->autoPost = $url;
|
||||
return $this;
|
||||
|
@ -150,6 +151,9 @@ class Field implements Renderable
|
|||
*/
|
||||
public function value($val)
|
||||
{
|
||||
if (is_array($val)) {
|
||||
$val = explode(',', $val);
|
||||
}
|
||||
$this->value = $val;
|
||||
return $this;
|
||||
}
|
||||
|
@ -544,12 +548,12 @@ class Field implements Renderable
|
|||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param array $data
|
||||
* @param array|Model $data
|
||||
* @return $this
|
||||
*/
|
||||
public function fill($data = [])
|
||||
{
|
||||
if (isset($data[$this->name])) {
|
||||
if (!empty($this->name) && isset($data[$this->name])) {
|
||||
$value = $data[$this->name];
|
||||
|
||||
if (is_array($value)) {
|
||||
|
@ -669,6 +673,7 @@ EOT;
|
|||
'id' => $this->getId(),
|
||||
'label' => $this->label,
|
||||
'name' => $this->getName(),
|
||||
'requiredStyle' => $this->required ? '' :'style="visibility: hidden;"',
|
||||
'tableRowKey' => $this->tableRowKey,
|
||||
'value' => $value,
|
||||
'class' => ' ' . $this->class . $mapClass,
|
||||
|
|
|
@ -19,11 +19,7 @@ class Html extends Field
|
|||
{
|
||||
parent::created();
|
||||
|
||||
$this->value = $this->name;
|
||||
|
||||
$this->content = new ViewShow($this->value);
|
||||
|
||||
$this->content->isContent(true);
|
||||
$this->value = $this->label;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -67,7 +63,9 @@ class Html extends Field
|
|||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->value = $this->content->getContent();
|
||||
if ($this->content) {
|
||||
$this->value = $this->content->getContent();
|
||||
}
|
||||
|
||||
return parent::render();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Password extends Text
|
||||
{
|
||||
protected $view = 'password';
|
||||
}
|
|
@ -6,6 +6,8 @@ class Select extends Radio
|
|||
{
|
||||
protected $view = 'select';
|
||||
|
||||
protected $class = '';
|
||||
|
||||
protected $js = [
|
||||
'/assets/tpextbuilder/js/select2/select2.min.js',
|
||||
'/assets/tpextbuilder/js/select2/i18n/zh-CN.js',
|
||||
|
@ -110,8 +112,8 @@ class Select extends Radio
|
|||
delay: {$delay},
|
||||
data: function (params) {
|
||||
return {
|
||||
q: params.term,
|
||||
page: params.page,
|
||||
q: params.term || '',
|
||||
page: params.page || 1,
|
||||
eleid : '{$selectId}'
|
||||
};
|
||||
},
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace tpext\builder\displayer;
|
||||
|
||||
class Show extends Field
|
||||
{
|
||||
protected $view = 'show';
|
||||
}
|
|
@ -34,6 +34,7 @@ namespace tpext\builder\form;
|
|||
* @method \tpext\builder\displayer\Decimal decimal($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Html html($html, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Raw raw($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Show show($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Tags tags($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\Icon icon($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
* @method \tpext\builder\displayer\MultipleImage multipleImage($name, $label = '', $cloSize = 12, $colClass = '', $colAttr = '')
|
||||
|
@ -94,6 +95,8 @@ class Wapper
|
|||
'rangeSlider' => \tpext\builder\displayer\RangeSlider::class,
|
||||
'match' => \tpext\builder\displayer\Match::class,
|
||||
'matches' => \tpext\builder\displayer\Matches::class,
|
||||
'show' => \tpext\builder\displayer\Show::class,
|
||||
'password' => \tpext\builder\displayer\Password::class,
|
||||
];
|
||||
|
||||
protected static $defaultFieldClass = [];
|
||||
|
|
|
@ -8,6 +8,10 @@ class MultipleToolbar extends Toolbar
|
|||
{
|
||||
protected $useLayer = true;
|
||||
|
||||
protected $hasSearch = false;
|
||||
|
||||
protected $btnSearch = null;
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
|
@ -21,6 +25,19 @@ class MultipleToolbar extends Toolbar
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
* @param boolean $val
|
||||
* @return $this
|
||||
*/
|
||||
public function hasSearch($val)
|
||||
{
|
||||
$this->hasSearch = $val;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Undocumented function
|
||||
*
|
||||
|
@ -32,6 +49,10 @@ class MultipleToolbar extends Toolbar
|
|||
$this->buttons();
|
||||
}
|
||||
|
||||
if ($this->hasSearch && !$this->btnSearch) {
|
||||
$this->btnToggleSearch();
|
||||
}
|
||||
|
||||
foreach ($this->elms as $elm) {
|
||||
|
||||
if (!$this->useLayer) {
|
||||
|
@ -52,7 +73,6 @@ class MultipleToolbar extends Toolbar
|
|||
$this->btnAdd();
|
||||
$this->btnDelete();
|
||||
$this->btnRefresh();
|
||||
$this->btnToggleSearch();
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -165,6 +185,8 @@ class MultipleToolbar extends Toolbar
|
|||
public function btnToggleSearch($label = '', $class = 'btn-secondary', $icon = 'mdi-magnify', $attr = 'title="搜索"')
|
||||
{
|
||||
$this->linkBtn('search', $label)->class($class)->icon($icon)->attr($attr);
|
||||
|
||||
$this->btnSearch = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]} checkbox-div" id="{$id}">
|
||||
{if condition="$checkallBtn"}
|
||||
<label class="lyear-checkbox m-t-10 m-b-10 {$class}">
|
||||
<input type="checkbox" class="checkall" id="checkall-{$name}"
|
||||
data-check="check-{$name}"><span>全选</span>
|
||||
<label class="lyear-checkbox {$inline} {$class}">
|
||||
<input type="checkbox" class="checkall" id="checkall-{$name}" {if
|
||||
condition="$checkall" }checked{/if}
|
||||
data-check="check-{$name}"><span>{$checkallBtn}</span>
|
||||
</label>
|
||||
{/if}
|
||||
{volist name="options" id="option"}
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
{if condition="$showLabel"}
|
||||
<label class="col-md-{$size[0]} {$labelClass}"{$labelAttr|raw} for="{$id}">{$label|raw}</label>
|
||||
<label class="col-md-{$size[0]} {$labelClass}" {$labelAttr|raw} for="{$id}">
|
||||
{$label|raw}
|
||||
<strong title="必填" class="field-required" {$requiredStyle|raw}> *</strong>
|
||||
</label>
|
||||
{/if}
|
|
@ -1,6 +1,6 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<div class="js-upload-files">
|
||||
<div class="js-upload-files" data-name="{$name}">
|
||||
{if condition="$canUpload"}
|
||||
<div>
|
||||
<input type="hidden" name="{$name}" class="{$class}"
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]}">
|
||||
<div class="input-group col-md-12">
|
||||
{$befor|raw}
|
||||
<input type="password" class="form-control {$class}"
|
||||
placeholder="请输入{$label}" autocomplete="new-password"
|
||||
value="{$value}" name="{$name}" id="{$id}" {$attr|raw}>
|
||||
{$after|raw}
|
||||
</div>
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -1,5 +1,5 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]} raw">
|
||||
<div class="col-md-{$size[1]} field-raw">
|
||||
{$value|raw}
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -0,0 +1,5 @@
|
|||
{include file="$labeltempl" /}
|
||||
<div class="col-md-{$size[1]} field-show">
|
||||
{$value}
|
||||
{include file="$helptempl" /}
|
||||
</div>
|
|
@ -22,108 +22,111 @@
|
|||
</form>
|
||||
|
||||
<script>
|
||||
var ajax = {$ajax};
|
||||
var search = '{$search}';
|
||||
var lastsearch = '';
|
||||
|
||||
function formSubmit()
|
||||
|
||||
if(!window.forms)
|
||||
{
|
||||
lightyear.loading('hide');
|
||||
|
||||
if(ajax)
|
||||
window.forms = [];
|
||||
}
|
||||
|
||||
window.forms['{$id}'] = {
|
||||
ajax : {$ajax},
|
||||
search : '{$search}',
|
||||
formSubmit : function ()
|
||||
{
|
||||
lightyear.loading('show');
|
||||
|
||||
var data = $('#{$id} form').serialize();
|
||||
|
||||
$.ajax({
|
||||
url: '{$action}' || location.href,
|
||||
data: data,
|
||||
type: 'POST',
|
||||
dataType: 'html',
|
||||
success: function (data) {
|
||||
setTimeout(function(){
|
||||
lightyear.loading('hide');
|
||||
},500);
|
||||
if(/^\{.+\}$/.test(data))
|
||||
{
|
||||
data = JSON.parse(data);
|
||||
if (data.status || data.code) {
|
||||
|
||||
if(data.layer_close)
|
||||
{
|
||||
closeLayer(data.msg || data.message ||'操作成功!');
|
||||
}
|
||||
else if(data.layer_close_refresh)
|
||||
{
|
||||
closeLayerRefresh(data.msg || data.message ||'操作成功!');
|
||||
}
|
||||
else if(data.url)
|
||||
{
|
||||
lightyear.notify(data.msg || data.message ||'操作成功!', 'success');
|
||||
lightyear.loading('hide');
|
||||
var search = this.search;
|
||||
|
||||
if(this.ajax)
|
||||
{
|
||||
lightyear.loading('show');
|
||||
|
||||
var data = $('#{$id} form').serialize();
|
||||
|
||||
$.ajax({
|
||||
url: '{$action}' || location.href,
|
||||
data: data,
|
||||
type: 'POST',
|
||||
dataType: 'html',
|
||||
success: function (data) {
|
||||
setTimeout(function(){
|
||||
lightyear.loading('hide');
|
||||
},500);
|
||||
if(/^\{.+\}$/.test(data))
|
||||
{
|
||||
data = JSON.parse(data);
|
||||
if (data.status || data.code) {
|
||||
|
||||
setTimeout(function(){
|
||||
location.replace(data.url);
|
||||
if(data.layer_close)
|
||||
{
|
||||
this.closeLayer(data.msg || data.message || '操作成功!');
|
||||
}
|
||||
else if(data.layer_close_refresh)
|
||||
{
|
||||
this.closeLayerRefresh(data.msg || data.message || '操作成功!');
|
||||
}
|
||||
else if(data.url)
|
||||
{
|
||||
lightyear.notify(data.msg || data.message || '操作成功!', 'success');
|
||||
|
||||
setTimeout(function(){
|
||||
location.replace(data.url);
|
||||
|
||||
}, data.wait *1000 || 2000);
|
||||
}, data.wait * 1000 || 2000);
|
||||
}
|
||||
else
|
||||
{
|
||||
lightyear.notify(data.msg || data.message || '操作成功!', 'success');
|
||||
}
|
||||
} else {
|
||||
lightyear.notify(data.msg || data.message || '操作失败', 'warning');
|
||||
}
|
||||
else
|
||||
{
|
||||
lightyear.notify(data.msg || data.message ||'操作成功!', 'success');
|
||||
}
|
||||
} else {
|
||||
lightyear.notify(data.msg || data.message || '操作失败', 'warning');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#' + search).replaceWith(data);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
lightyear.loading('hide');
|
||||
lightyear.notify('网络错误', 'danger');
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#' + search).replaceWith(data);
|
||||
}
|
||||
},
|
||||
error: function () {
|
||||
lightyear.loading('hide');
|
||||
lightyear.notify('网络错误', 'danger');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function closeLayer(msg)
|
||||
{
|
||||
parent.lightyear.notify(msg, 'success');
|
||||
|
||||
if(parent && parent.layer)
|
||||
},
|
||||
closeLayer : function (msg)
|
||||
{
|
||||
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
|
||||
parent.layer.close(index);
|
||||
}
|
||||
}
|
||||
parent.lightyear.notify(msg, 'success');
|
||||
|
||||
function closeLayerRefresh(msg)
|
||||
{
|
||||
parent.lightyear.notify(msg, 'success');
|
||||
|
||||
if(parent && parent.layer)
|
||||
if(parent && parent.layer)
|
||||
{
|
||||
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
|
||||
parent.layer.close(index);
|
||||
}
|
||||
},
|
||||
closeLayerRefresh : function (msg)
|
||||
{
|
||||
if(parent.$('#form-refresh').size())
|
||||
{
|
||||
parent.$('#form-refresh').trigger('click');
|
||||
}
|
||||
else
|
||||
{
|
||||
setTimeout(function(){
|
||||
parent.location.reload();
|
||||
},2000);
|
||||
}
|
||||
parent.lightyear.notify(msg, 'success');
|
||||
|
||||
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
|
||||
parent.layer.close(index);
|
||||
if(parent && parent.layer)
|
||||
{
|
||||
if(parent.$('#form-refresh').size())
|
||||
{
|
||||
parent.$('#form-refresh').trigger('click');
|
||||
}
|
||||
else
|
||||
{
|
||||
setTimeout(function(){
|
||||
parent.location.reload();
|
||||
},2000);
|
||||
}
|
||||
|
||||
var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
|
||||
parent.layer.close(index);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
</script>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue