商品规格新增扩展数据
parent
30601d422b
commit
cb5faccc59
|
|
@ -140,6 +140,10 @@ class Goods extends Common
|
|||
// 品牌分类
|
||||
$this->assign('brand_list', BrandService::CategoryBrand());
|
||||
|
||||
// 规格扩展数据
|
||||
$goods_spec_extends = GoodsService::GoodsSpecificationsExtends();
|
||||
$this->assign('goods_specifications_extends', $goods_spec_extends['data']);
|
||||
|
||||
// 参数
|
||||
$this->assign('params', $params);
|
||||
|
||||
|
|
|
|||
|
|
@ -181,12 +181,13 @@
|
|||
<th>规格编码</th>
|
||||
<th>条形码</th>
|
||||
<th>原价(元)</th>
|
||||
<th class="extend-btn">扩展</th>
|
||||
<th class="operation-btn">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{if empty($specifications['value'])}}
|
||||
<tr>
|
||||
<tr class="line-0" data-line-tag=".line-0">
|
||||
<td class="value-start">
|
||||
<input type="text" name="specifications_price[]" placeholder="价格" class="am-radius" pattern="^([0-9]{1}\d{0,6})(\.\d{1,2})?$" data-validation-message="请填写有效的销售金额" required />
|
||||
</td>
|
||||
|
|
@ -203,7 +204,11 @@
|
|||
<input type="text" name="specifications_barcode[]" placeholder="条形码" class="am-radius" maxlength="80" data-validation-message="条形码最多80个字符" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="specifications_original_price[]" placeholder="原价" class="am-radius" pattern="^([0-9]{1}\d{0,6})(\.\d{1,2})?$" data-validation-message="请填写有效的销售金额" />
|
||||
<input type="text" name="specifications_original_price[]" placeholder="原价" class="am-radius" pattern="^([0-9]{1}\d{0,6})(\.\d{1,2})?$" data-validation-message="请填写有效的原价" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="hidden" name="specifications_extends[]" value="" class="line-extend-input" />
|
||||
<span class="fs-12 cr-blue c-p line-extend-btn">编辑</span>
|
||||
</td>
|
||||
<td>
|
||||
<!--operation-->
|
||||
|
|
@ -213,7 +218,7 @@
|
|||
|
||||
{{if !empty($specifications['value'])}}
|
||||
{{foreach $specifications.value as $line_k=>$line_v}}
|
||||
<tr {{if $line_k gt 0}} class="line-not-first"{{/if}}>
|
||||
<tr class="line-{{$line_k}} {{if $line_k gt 0}} line-not-first{{/if}}" data-line-tag=".line-{{$line_k}}">
|
||||
{{foreach $line_v as $v}}
|
||||
{{if isset($v['data_type'])}}
|
||||
{{switch v.data_type}}
|
||||
|
|
@ -240,7 +245,11 @@
|
|||
<input type="text" name="specifications_barcode[]" placeholder="条形码" class="am-radius" maxlength="80" data-validation-message="条形码最多80个字符" value="{{$v.data.barcode}}" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="text" name="specifications_original_price[]" placeholder="原价" class="am-radius" pattern="^([0-9]{1}\d{0,6})(\.\d{1,2})?$" data-validation-message="请填写有效的销售金额" value="{{if $v['data']['original_price'] gt 0}}{{$v.data.original_price}}{{/if}}" />
|
||||
<input type="text" name="specifications_original_price[]" placeholder="原价" class="am-radius" pattern="^([0-9]{1}\d{0,6})(\.\d{1,2})?$" data-validation-message="请填写有效的原价" value="{{if $v['data']['original_price'] gt 0}}{{$v.data.original_price}}{{/if}}" />
|
||||
</td>
|
||||
<td>
|
||||
<input type="hidden" name="specifications_extends[]" value="" class="line-extend-input" />
|
||||
<span class="fs-12 cr-blue c-p line-extend-btn">编辑</span>
|
||||
</td>
|
||||
<td>
|
||||
{{if $line_k gt 0}}
|
||||
|
|
@ -384,12 +393,146 @@
|
|||
</div>
|
||||
<!-- right content end -->
|
||||
|
||||
<!-- 规格扩展数据弹层 -->
|
||||
<div class="am-popup" id="specifications-extends-popup">
|
||||
<div class="am-popup-inner">
|
||||
<div class="am-popup-hd">
|
||||
<h4 class="am-popup-title">规格扩展数据</h4>
|
||||
<span data-am-modal-close class="am-close">×</span>
|
||||
</div>
|
||||
<div class="am-popup-bd">
|
||||
<form class="am-form form-validation-specifications-extends view-save" request-type="sync" request-value="SpecificationsExtendsBack">
|
||||
{{if !empty($goods_specifications_extends) and is_array($goods_specifications_extends)}}
|
||||
{{foreach $goods_specifications_extends as $v}}
|
||||
<div class="am-alert am-alert-secondary">
|
||||
<label class="am-text-sm">{{$v.name}}</label>
|
||||
{{if !empty($v['desc'])}}
|
||||
<span class="am-text-xs am-text-warning am-margin-left-xs">{{$v.desc}}</span>
|
||||
{{/if}}
|
||||
{{if !empty($v['element'])}}
|
||||
{{foreach $v.element as $element}}
|
||||
<div class="am-form-group">
|
||||
<label class="block">{{$element.title}}{{if !empty($element['desc'])}}<span class="am-form-group-label-tips">{{$element.desc}}</span>{{/if}}</label>
|
||||
{{switch element.element}}
|
||||
{{case input}}
|
||||
{{if in_array($element['type'], ['radio', 'checkbox']) and !empty($element['element_data']) and is_array($element['element_data'])}}
|
||||
{{foreach $element.element_data as $element_data_key=>$element_data}}
|
||||
<label class="{{if isset($element['is_block']) and $element['is_block'] eq 1}}am-{{$element.type}}{{else /}}am-{{$element.type}}-inline{{/if}}">
|
||||
<input
|
||||
type="{{$element.type}}"
|
||||
name="{{$element.name}}"
|
||||
value="{{$element_data.value}}"
|
||||
|
||||
{{if isset($data['config'][$element['name']]) and in_array($element_data['value'], explode(',', $data['config'][$element['name']]))}} checked{{/if}}
|
||||
|
||||
{{if isset($element['minchecked']) and $element['type'] eq 'checkbox'}} minchecked="{{$element.minchecked}}"{{/if}}
|
||||
|
||||
{{if isset($element['maxchecked']) and $element['type'] eq 'checkbox'}} maxchecked="{{$element.maxchecked}}"{{/if}}
|
||||
|
||||
{{if isset($element['message'])}} data-validation-message="{{$element.message}}"{{/if}}
|
||||
|
||||
{{if $element_data_key eq 0 and isset($element['is_required']) and $element['is_required'] eq 1}}required{{/if}}
|
||||
data-am-ucheck />
|
||||
{{$element_data.name}}
|
||||
</label>
|
||||
{{/foreach}}
|
||||
{{else /}}
|
||||
<input
|
||||
class="am-radius"
|
||||
type="{{$element.type}}"
|
||||
name="{{$element.name}}"
|
||||
value="{{if isset($data['config'][$element['name']])}}{{$data['config'][$element['name']]}}{{else /}}{{if isset($element['default'])}}{{$element.default}}{{/if}}{{/if}}"
|
||||
|
||||
{{if isset($element['placeholder'])}} placeholder="{{$element.placeholder}}"{{/if}}
|
||||
|
||||
{{if isset($element['message'])}} data-validation-message="{{$element.message}}"{{/if}}
|
||||
|
||||
{{if isset($element['is_required']) and $element['is_required'] eq 1}} required{{/if}}
|
||||
/>
|
||||
{{/if}}
|
||||
{{/case}}
|
||||
{{case select}}
|
||||
{{if !empty($element['element_data']) and is_array($element['element_data'])}}
|
||||
<select
|
||||
class="chosen-select am-radius"
|
||||
name="{{$element.name}}"
|
||||
|
||||
{{if isset($element['message'])}} data-validation-message="{{$element.message}}"{{/if}}
|
||||
|
||||
{{if !empty($element['placeholder'])}} data-placeholder="{{$element.placeholder}}"{{/if}}
|
||||
|
||||
{{if isset($element['is_multiple']) and $element['is_multiple'] eq 1}}
|
||||
multiple
|
||||
{{if isset($element['minchecked'])}} minchecked="{{$element.minchecked}}"{{/if}}
|
||||
{{if isset($element['maxchecked'])}} maxchecked="{{$element.maxchecked}}"{{/if}}
|
||||
{{/if}}
|
||||
|
||||
{{if isset($element['is_required']) and $element['is_required'] eq 1}}required{{/if}}
|
||||
>
|
||||
{{if !isset($element['is_multiple']) or $element['is_multiple'] neq 1}}
|
||||
{{if !empty($element['placeholder'])}}
|
||||
<option value="">{{$element.placeholder}}</option>
|
||||
{{/if}}
|
||||
{{/if}}
|
||||
{{foreach $element.element_data as $element_data_key=>$element_data}}
|
||||
<option
|
||||
value="{{$element_data.value}}"
|
||||
{{if isset($data['config'][$element['name']]) and in_array($element_data['value'], explode(',', $data['config'][$element['name']]))}}selected{{/if}}
|
||||
>{{$element_data.name}}</option>
|
||||
{{/foreach}}
|
||||
</select>
|
||||
{{/if}}
|
||||
{{/case}}
|
||||
{{case textarea}}
|
||||
<textarea
|
||||
class="am-radius"
|
||||
name="{{$element.name}}"
|
||||
|
||||
{{if isset($element['rows'])}} rows="{{$element.rows}}"{{/if}}
|
||||
|
||||
{{if isset($element['placeholder'])}} placeholder="{{$element.placeholder}}"{{/if}}
|
||||
|
||||
{{if isset($element['is_required']) and $element['is_required'] eq 1}}
|
||||
{{if isset($element['minlength'])}} minlength="{{$element.minlength}}"{{/if}}
|
||||
{{if isset($element['maxlength'])}} maxlength="{{$element.maxlength}}"{{/if}}
|
||||
required
|
||||
{{/if}}
|
||||
>{{if isset($data['config'][$element['name']])}}{{$data['config'][$element['name']]}}{{else /}}{{if isset($element['default'])}}{{$element.default}}{{/if}}{{/if}}</textarea>
|
||||
{{/case}}
|
||||
{{/switch}}
|
||||
</div>
|
||||
{{/foreach}}
|
||||
{{/if}}
|
||||
</div>
|
||||
{{/foreach}}
|
||||
|
||||
<div class="am-form-group am-form-group-refreshing">
|
||||
<input type="hidden" name="specifications-tag" value=""/>
|
||||
<button type="submit" class="am-btn am-btn-primary am-radius btn-loading-example am-btn-sm am-btn-block">确认</button>
|
||||
</div>
|
||||
{{else /}}
|
||||
<div class="table-no"><i class="am-icon-warning"></i> 没有扩展数据</div>
|
||||
{{/if}}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- footer start -->
|
||||
{{include file="public/footer" /}}
|
||||
<!-- footer end -->
|
||||
|
||||
<!-- 拖拽排序初始化 -->
|
||||
<script type="text/javascript">
|
||||
// 规格扩展返回处理
|
||||
function SpecificationsExtendsBack()
|
||||
{
|
||||
var $extends_popup = $('#specifications-extends-popup');
|
||||
var data = GetFormVal('#specifications-extends-popup', true);
|
||||
$('.specifications-table').find($extends_popup.attr('data-line-extend')).find('.line-extend-input').val(JSON.stringify(data));
|
||||
$extends_popup.modal('close');
|
||||
}
|
||||
|
||||
$(function()
|
||||
{
|
||||
{{if !empty($data['attribute'])}}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@
|
|||
<label class="am-text-sm am-text-warning">该区域为插件配置填写项,请按照插件文档填写相应的值。</label>
|
||||
{{foreach $data.element as $element}}
|
||||
<div class="am-form-group">
|
||||
<label class="block">{{$element.title}}</label>
|
||||
<label class="block">{{$element.title}}{{if !empty($element['desc'])}}<span class="am-form-group-label-tips">{{$element.desc}}</span>{{/if}}</label>
|
||||
{{switch element.element}}
|
||||
{{case input}}
|
||||
{{if in_array($element['type'], ['radio', 'checkbox']) and !empty($element['element_data']) and is_array($element['element_data'])}}
|
||||
|
|
|
|||
|
|
@ -2218,5 +2218,65 @@ class GoodsService
|
|||
$data = Db::name('GoodsCategory')->alias('gc')->join(['__GOODS_CATEGORY_JOIN__'=>'gci'], 'gc.id=gci.category_id')->where(['gci.goods_id'=>$goods_id])->column('gc.name');
|
||||
return DataReturn('获取成功', 0, $data);
|
||||
}
|
||||
|
||||
/**
|
||||
* 商品规格扩展数据
|
||||
* @author Devil
|
||||
* @blog http://gong.gg/
|
||||
* @version 1.0.0
|
||||
* @datetime 2019-07-21T16:08:34+0800
|
||||
* @param [array] $params [输入参数]
|
||||
*/
|
||||
public static function GoodsSpecificationsExtends($params = [])
|
||||
{
|
||||
// 数据
|
||||
$data = [];
|
||||
|
||||
// 规格扩展数据钩子
|
||||
$hook_name = 'plugins_service_goods_spec_extends_handle';
|
||||
Hook::listen($hook_name, [
|
||||
'hook_name' => $hook_name,
|
||||
'is_backend' => true,
|
||||
'data' => &$data,
|
||||
]);
|
||||
|
||||
// 测试配置信息
|
||||
$plugins = [
|
||||
'name' => '会员等级插件',
|
||||
'desc' => '按照会员等级设定不同金额',
|
||||
'element' =>[
|
||||
[
|
||||
'element' => 'input',
|
||||
'type' => 'text',
|
||||
'name' => 'price',
|
||||
'placeholder' => '普通会员售价',
|
||||
'title' => '普通会员售价',
|
||||
'is_required' => 0,
|
||||
'message' => '请填写应用ID',
|
||||
'desc' => '请输入会员金额',
|
||||
],
|
||||
[
|
||||
'element' => 'input',
|
||||
'type' => 'text',
|
||||
'name' => 'price2',
|
||||
'placeholder' => '高级会员售价',
|
||||
'title' => '高级会员售价',
|
||||
'is_required' => 0,
|
||||
'message' => '请填写应用公钥',
|
||||
],
|
||||
[
|
||||
'element' => 'input',
|
||||
'type' => 'text',
|
||||
'name' => 'price3',
|
||||
'placeholder' => '至尊会员售价',
|
||||
'title' => '至尊会员售价',
|
||||
'is_required' => 0,
|
||||
'message' => '请填写应用公钥',
|
||||
],
|
||||
],
|
||||
];
|
||||
$data[] = $plugins;
|
||||
return DataReturn('获取成功', 0, $data);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
@ -58,6 +58,9 @@
|
|||
.specifications-table th.operation-btn {
|
||||
width: 80px;
|
||||
}
|
||||
.specifications-table th.extend-btn {
|
||||
width: 45px;
|
||||
}
|
||||
.specifications-table > tbody > tr > td {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +1,21 @@
|
|||
// 表单初始化
|
||||
FromInit('form.form-validation-reply');
|
||||
|
||||
$(function()
|
||||
{
|
||||
// 处理
|
||||
$('.submit-reply').on('click', function()
|
||||
// 表单初始化
|
||||
FromInit('form.form-validation-reply');
|
||||
|
||||
$(function()
|
||||
{
|
||||
var json = $(this).data('json');
|
||||
var $popup = $('#my-popup-reply');
|
||||
$popup.find('input[name="id"]').val(json.id);
|
||||
$popup.find('.user-info img').attr('src', json.user.avatar || $popup.find('.user-info img').attr('src'));
|
||||
$popup.find('.user-info .user-base .username span').html(json.user.username || '<span class="cr-ddd">未填写</span>');
|
||||
$popup.find('.user-info .user-base .nickname span').html(json.user.nickname || '<span class="cr-ddd">未填写</span>');
|
||||
$popup.find('.user-info .user-base .mobile span').html(json.user.mobile || '<span class="cr-ddd">未填写</span>');
|
||||
$popup.find('.user-info .user-base .email span').html(json.user.email || '<span class="cr-ddd">未填写</span>');
|
||||
// 处理
|
||||
$('.submit-reply').on('click', function()
|
||||
{
|
||||
var json = $(this).data('json');
|
||||
var $popup = $('#my-popup-reply');
|
||||
$popup.find('input[name="id"]').val(json.id);
|
||||
$popup.find('.user-info img').attr('src', json.user.avatar || $popup.find('.user-info img').attr('src'));
|
||||
$popup.find('.user-info .user-base .username span').html(json.user.username || '<span class="cr-ddd">未填写</span>');
|
||||
$popup.find('.user-info .user-base .nickname span').html(json.user.nickname || '<span class="cr-ddd">未填写</span>');
|
||||
$popup.find('.user-info .user-base .mobile span').html(json.user.mobile || '<span class="cr-ddd">未填写</span>');
|
||||
$popup.find('.user-info .user-base .email span').html(json.user.email || '<span class="cr-ddd">未填写</span>');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
$(function()
|
||||
{
|
||||
// 表单初始化
|
||||
FromInit('form.form-validation-specifications-extends');
|
||||
|
||||
// 商品导航
|
||||
$('.goods-nav li a').on('click', function()
|
||||
{
|
||||
|
|
@ -54,13 +57,15 @@ $(function()
|
|||
return false;
|
||||
}
|
||||
|
||||
var index = parseInt(Math.random()*1000001);
|
||||
var html = $('.specifications-table').find('tbody tr:last').prop('outerHTML');
|
||||
if(html.indexOf('<!--operation-->') >= 0)
|
||||
{
|
||||
html = html.replace(/<!--operation-->/ig, '<span class="fs-12 cr-blue c-p m-r-5 line-copy">复制</span> <span class="fs-12 cr-red c-p line-remove">移除</span>');
|
||||
}
|
||||
$('.specifications-table').append(html);
|
||||
$('.specifications-table').find('tbody tr:last').addClass('line-not-first');
|
||||
$('.specifications-table').find('tbody tr:last').attr('class', 'line-'+index+' line-not-first');
|
||||
$('.specifications-table').find('tbody tr:last').attr('data-line-tag', '.line-'+index);
|
||||
|
||||
// 值赋空
|
||||
$('.specifications-table').find('tbody tr:last').find('input').each(function(k, v)
|
||||
|
|
@ -72,12 +77,15 @@ $(function()
|
|||
// 规格行复制
|
||||
$(document).on('click', '.specifications-table .line-copy', function()
|
||||
{
|
||||
var index = parseInt(Math.random()*1000001);
|
||||
var $parent = $(this).parents('tr');
|
||||
$parent.find('input').each(function(k, v)
|
||||
{
|
||||
$(this).attr('value', $(this).val());
|
||||
});
|
||||
$parent.after($parent.prop('outerHTML'));
|
||||
$('.specifications-table').find('tbody tr:last').attr('class', 'line-'+index+' line-not-first');
|
||||
$('.specifications-table').find('tbody tr:last').attr('data-line-tag', '.line-'+index);
|
||||
});
|
||||
|
||||
// 规格行移除
|
||||
|
|
@ -176,4 +184,26 @@ $(function()
|
|||
$('ul.content-app-items').dragsort({ dragSelector: 'i.drag-sort-submit', placeHolderTemplate: '<li class="drag-sort-dotted"></li>'});
|
||||
$('ul.goods-attribute-items').dragsort({ dragSelector: 'i.drag-sort-submit', placeHolderTemplate: '<li class="drag-sort-dotted"></li>'});
|
||||
|
||||
|
||||
// 规格扩展数据编辑
|
||||
var $extends_popup = $('#specifications-extends-popup');
|
||||
$(document).on('click', '.specifications-table .line-extend-btn', function()
|
||||
{
|
||||
$extends_popup.attr('data-line-extend', $(this).parents('tr').attr('data-line-tag'));
|
||||
$extends_popup.find('input,select,textarea').val('');
|
||||
var json = $(this).prev().val() || null;
|
||||
if(json != null)
|
||||
{
|
||||
FormDataFill(JSON.parse(json), '#specifications-extends-popup');
|
||||
}
|
||||
$extends_popup.modal();
|
||||
});
|
||||
|
||||
// 规格扩展数据
|
||||
$('#specifications-extends-popup button[type="button"]').on('click', function()
|
||||
{
|
||||
// var data = GetFormVal('#specifications-extends-popup', true);
|
||||
// $('.specifications-table').find($extends_popup.attr('data-line-extend')).find('.line-extend-input').val(JSON.stringify(data));
|
||||
// $extends_popup.modal('close');
|
||||
});
|
||||
});
|
||||
|
|
@ -1,8 +1,8 @@
|
|||
// 表单初始化
|
||||
FromInit('form.form-validation-reply');
|
||||
|
||||
$(function()
|
||||
{
|
||||
// 表单初始化
|
||||
FromInit('form.form-validation-reply');
|
||||
|
||||
// 处理
|
||||
$('.submit-reply').on('click', function()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,18 +1,21 @@
|
|||
/**
|
||||
* 添加
|
||||
*/
|
||||
$('.submit-add').on('click', function()
|
||||
$(function()
|
||||
{
|
||||
// 更改窗口名称
|
||||
$title = $('#data-save-win').find('.am-popup-title');
|
||||
$title.text($title.data('add-title'));
|
||||
|
||||
// 清空表单
|
||||
FormDataFill({"id":"", "name":"", "url":"", "describe":"", "sort":0, "is_enable":1});
|
||||
|
||||
// 校验成功状态增加失去焦点
|
||||
$('form.form-validation').find('.am-field-valid').each(function()
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
$('.submit-add').on('click', function()
|
||||
{
|
||||
$(this).blur();
|
||||
// 更改窗口名称
|
||||
$title = $('#data-save-win').find('.am-popup-title');
|
||||
$title.text($title.data('add-title'));
|
||||
|
||||
// 清空表单
|
||||
FormDataFill({"id":"", "name":"", "url":"", "describe":"", "sort":0, "is_enable":1});
|
||||
|
||||
// 校验成功状态增加失去焦点
|
||||
$('form.form-validation').find('.am-field-valid').each(function()
|
||||
{
|
||||
$(this).blur();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,26 +1,29 @@
|
|||
// 表单初始化
|
||||
FromInit('form.form-validation-article');
|
||||
FromInit('form.form-validation-customview');
|
||||
FromInit('form.form-validation-goods_category');
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
$('.submit-add').on('click', function()
|
||||
$(function()
|
||||
{
|
||||
// 获取标签
|
||||
var tag = $(this).data('tag');
|
||||
// 表单初始化
|
||||
FromInit('form.form-validation-article');
|
||||
FromInit('form.form-validation-customview');
|
||||
FromInit('form.form-validation-goods_category');
|
||||
|
||||
// 更改窗口名称
|
||||
$title = $('#'+tag).find('.am-popup-title');
|
||||
$title.text($title.data('add-title'));
|
||||
|
||||
// 清空表单
|
||||
FormDataFill({"id":"", "pid":0, "name":"", "url":"", "value":"", "sort":0, "is_show":1, "is_new_window_open":0}, '#'+tag);
|
||||
|
||||
// 校验成功状态增加失去焦点
|
||||
$('#'+tag).find('form').find('.am-field-valid').each(function()
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
$('.submit-add').on('click', function()
|
||||
{
|
||||
$(this).blur();
|
||||
// 获取标签
|
||||
var tag = $(this).data('tag');
|
||||
|
||||
// 更改窗口名称
|
||||
$title = $('#'+tag).find('.am-popup-title');
|
||||
$title.text($title.data('add-title'));
|
||||
|
||||
// 清空表单
|
||||
FormDataFill({"id":"", "pid":0, "name":"", "url":"", "value":"", "sort":0, "is_show":1, "is_new_window_open":0}, '#'+tag);
|
||||
|
||||
// 校验成功状态增加失去焦点
|
||||
$('#'+tag).find('form').find('.am-field-valid').each(function()
|
||||
{
|
||||
$(this).blur();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -1,9 +1,9 @@
|
|||
// 表单初始化
|
||||
FromInit('form.form-validation-audit');
|
||||
FromInit('form.form-validation-refuse');
|
||||
|
||||
$(function()
|
||||
{
|
||||
// 表单初始化
|
||||
FromInit('form.form-validation-audit');
|
||||
FromInit('form.form-validation-refuse');
|
||||
|
||||
// 弹窗数据初始化
|
||||
function PopupInit($popup, data)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,80 +1,83 @@
|
|||
/**
|
||||
* 展开/关闭
|
||||
*/
|
||||
$('.tree-list i').on('click', function()
|
||||
$(function()
|
||||
{
|
||||
if($(this).hasClass('am-icon-plus'))
|
||||
/**
|
||||
* 展开/关闭
|
||||
*/
|
||||
$('.tree-list i').on('click', function()
|
||||
{
|
||||
$(this).removeClass('am-icon-plus');
|
||||
$(this).addClass('am-icon-minus-square');
|
||||
} else {
|
||||
$(this).removeClass('am-icon-minus-square');
|
||||
$(this).addClass('am-icon-plus');
|
||||
}
|
||||
$(this).parent().next('.list-find').toggle(100);
|
||||
});
|
||||
|
||||
/**
|
||||
* 全选/取消
|
||||
*/
|
||||
|
||||
$('.node-choice').on('click', function()
|
||||
{
|
||||
var state = $(this).is(':checked');
|
||||
$(this).parents('li').next('.list-find').find('input[type="checkbox"]').each(function()
|
||||
{
|
||||
this.checked = state;
|
||||
if($(this).hasClass('am-icon-plus'))
|
||||
{
|
||||
$(this).removeClass('am-icon-plus');
|
||||
$(this).addClass('am-icon-minus-square');
|
||||
} else {
|
||||
$(this).removeClass('am-icon-minus-square');
|
||||
$(this).addClass('am-icon-plus');
|
||||
}
|
||||
$(this).parent().next('.list-find').toggle(100);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 子元素选择/取消操作
|
||||
*/
|
||||
$('.list-find input[type="checkbox"]').on('click', function()
|
||||
{
|
||||
var state = ($(this).parents('.list-find').find('input[type="checkbox"]:checked').length > 0);
|
||||
$(this).parents('ul').prev().find('label input').each(function()
|
||||
{
|
||||
this.checked = state;
|
||||
});
|
||||
});
|
||||
/**
|
||||
* 全选/取消
|
||||
*/
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
$('.submit-add').on('click', function()
|
||||
{
|
||||
// 更改窗口名称
|
||||
$title = $('#power-save-win').find('.am-popup-title');
|
||||
$title.text($title.data('add-title'));
|
||||
|
||||
// 清空表单
|
||||
FormDataFill({"id":"", "pid":0, "name":"", "control":"", "action":"", "icon":"", "sort":0, "is_show":1});
|
||||
|
||||
// 移除菜单禁止状态
|
||||
$('form select[name="pid"]').removeAttr('disabled');
|
||||
|
||||
// 校验成功状态增加失去焦点
|
||||
$('form').find('.am-field-valid').each(function()
|
||||
$('.node-choice').on('click', function()
|
||||
{
|
||||
$(this).blur();
|
||||
var state = $(this).is(':checked');
|
||||
$(this).parents('li').next('.list-find').find('input[type="checkbox"]').each(function()
|
||||
{
|
||||
this.checked = state;
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
$('.submit-edit').on('click', function()
|
||||
{
|
||||
// 更改窗口名称
|
||||
$title = $('#power-save-win').find('.am-popup-title');
|
||||
$title.text($title.data('edit-title'));
|
||||
|
||||
// 父级禁用菜单列表选择
|
||||
if($(this).data('item') == 'ok')
|
||||
/**
|
||||
* 子元素选择/取消操作
|
||||
*/
|
||||
$('.list-find input[type="checkbox"]').on('click', function()
|
||||
{
|
||||
$('form select[name="pid"]').attr('disabled', 'disabled');
|
||||
} else {
|
||||
var state = ($(this).parents('.list-find').find('input[type="checkbox"]:checked').length > 0);
|
||||
$(this).parents('ul').prev().find('label input').each(function()
|
||||
{
|
||||
this.checked = state;
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 添加
|
||||
*/
|
||||
$('.submit-add').on('click', function()
|
||||
{
|
||||
// 更改窗口名称
|
||||
$title = $('#power-save-win').find('.am-popup-title');
|
||||
$title.text($title.data('add-title'));
|
||||
|
||||
// 清空表单
|
||||
FormDataFill({"id":"", "pid":0, "name":"", "control":"", "action":"", "icon":"", "sort":0, "is_show":1});
|
||||
|
||||
// 移除菜单禁止状态
|
||||
$('form select[name="pid"]').removeAttr('disabled');
|
||||
}
|
||||
|
||||
// 校验成功状态增加失去焦点
|
||||
$('form').find('.am-field-valid').each(function()
|
||||
{
|
||||
$(this).blur();
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* 编辑
|
||||
*/
|
||||
$('.submit-edit').on('click', function()
|
||||
{
|
||||
// 更改窗口名称
|
||||
$title = $('#power-save-win').find('.am-popup-title');
|
||||
$title.text($title.data('edit-title'));
|
||||
|
||||
// 父级禁用菜单列表选择
|
||||
if($(this).data('item') == 'ok')
|
||||
{
|
||||
$('form select[name="pid"]').attr('disabled', 'disabled');
|
||||
} else {
|
||||
$('form select[name="pid"]').removeAttr('disabled');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -74,9 +74,10 @@ function ArrayTurnJson(all, object)
|
|||
* @version 0.0.1
|
||||
* @datetime 2016-12-10T14:31:19+0800
|
||||
* @param {[string]} element [元素的class或id]
|
||||
* @param {[boolean]} is_json [是否返回json对象(默认否)]
|
||||
* @return {[object]} [josn对象]
|
||||
*/
|
||||
function GetFormVal(element)
|
||||
function GetFormVal(element, is_json)
|
||||
{
|
||||
var object = new FormData();
|
||||
|
||||
|
|
@ -140,6 +141,14 @@ function GetFormVal(element)
|
|||
}
|
||||
});
|
||||
object = ArrayTurnJson(tmp_all, object);
|
||||
|
||||
// 是否需要返回json对象
|
||||
if(is_json === true)
|
||||
{
|
||||
var json = {};
|
||||
object.forEach((value, key) => json[key] = value);
|
||||
return json;
|
||||
}
|
||||
return object;
|
||||
}
|
||||
|
||||
|
|
@ -341,40 +350,58 @@ function FromInit(form_name)
|
|||
var $button = $form.find('button[type="submit"]');
|
||||
$button.button('loading');
|
||||
|
||||
// 开启进度条
|
||||
$.AMUI.progress.start();
|
||||
|
||||
// 获取表单数据
|
||||
var action = $form.attr('action');
|
||||
var method = $form.attr('method');
|
||||
var request_type = $form.attr('request-type');
|
||||
var request_value = $form.attr('request-value');
|
||||
var ajax_all = ['ajax-reload', 'ajax-url', 'ajax-fun'];
|
||||
var action = $form.attr('action') || null;
|
||||
var method = $form.attr('method') || null;
|
||||
var request_type = $form.attr('request-type') || null;
|
||||
var request_value = $form.attr('request-value') || null;
|
||||
var ajax_all = ['ajax-reload', 'ajax-url', 'ajax-fun', 'sync'];
|
||||
|
||||
// 不是form表单直接通过
|
||||
// 是form表单直接通过
|
||||
if(request_type == 'form')
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// 参数校验
|
||||
if(ajax_all.indexOf(request_type) == -1 || action == undefined || action == '' || method == undefined || method == '')
|
||||
if(ajax_all.indexOf(request_type) == -1)
|
||||
{
|
||||
$.AMUI.progress.done();
|
||||
$button.button('reset');
|
||||
Prompt('表单参数配置有误');
|
||||
Prompt('表单[类型]参数配置有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 类型不等于刷新的时候,类型值必须填写
|
||||
if(request_type != 'ajax-reload' && (request_value == undefined || request_value == ''))
|
||||
if(request_type != 'ajax-reload' && request_value == null)
|
||||
{
|
||||
$.AMUI.progress.done();
|
||||
$button.button('reset');
|
||||
Prompt('表单[类型值]参数配置有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 同步调用方法
|
||||
if(request_type == 'sync')
|
||||
{
|
||||
$button.button('reset');
|
||||
if(IsExitsFunction(request_value))
|
||||
{
|
||||
window[request_value]();
|
||||
} else {
|
||||
Prompt('['+request_value+']表单定义的方法未定义');
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
if(action == null || method == null)
|
||||
{
|
||||
$button.button('reset');
|
||||
Prompt('表单[action或method]参数配置有误');
|
||||
return false;
|
||||
}
|
||||
|
||||
// 开启进度条
|
||||
$.AMUI.progress.start();
|
||||
|
||||
// ajax请求
|
||||
$.ajax({
|
||||
url:action,
|
||||
|
|
|
|||
Loading…
Reference in New Issue