76 lines
2.5 KiB
HTML

{extend name="admin@main"}
{block name="content"}
<form onsubmit="return false;" data-auto="true" action="{:url('save')}" method="post" class='layui-form layui-card' autocomplete="off">
<div class="layui-card-body think-box-shadow padding-bottom-20 padding-left-40">
<div data-item-container>
{foreach $list as $index=>$item}
{assign name='is_default' value='0'}
{assign name='index' value='$index+1'}
{assign name='group_title' value='邮费规则分组'}
{include file='express_template/index_item'}
{/foreach}
</div>
<div class="margin-bottom-20"><a onclick="addRuleItem()" class="layui-btn layui-btn-warm">添加邮费规则分组</a></div>
{assign name='index' value='0'}
{assign name='is_default' value='1'}
{assign name='group_title' value='默认邮费规则'}
{assign name="item" value="$default"}
{include file='express_template/index_item'}
<div class="hr-line-dashed"></div>
<div class="layui-form-item text-center">
<button class="layui-btn" type='submit'>保存数据</button>
</div>
</div>
</form>
<script>
form.render();
checkRuleItem();
function delRuleItem(that) {
$.msg.confirm('确定要移除这个邮费规则吗?', function (index) {
$(that).parent('fieldset').remove(), $.msg.close(index);
checkRuleItem();
})
}
function addRuleItem() {
this.itemIndex = $('[data-item-container] fieldset:last').attr('data-max-index') || 0;
this.html = $('#template').html().replace(/\[index\]/gi, parseInt(this.itemIndex) + 1);
$('[data-item-container]').append(this.html);
}
function checkRuleItem() {
if ($('[data-item-container] fieldset').length < 1) {
// addRuleItem();
}
}
(function (opt) {
opt.selecter = 'input[type=checkbox][data-province-input]';
$('body').off('change', opt.selecter).on('change', opt.selecter, function () {
if (this.checked) $(opt.selecter + '[value="' + this.value + '"]').not(this).map(function () {
if (this.checked) $(this).trigger('click');
});
});
})({});
</script>
{assign name='is_default' value='0'}
{assign name='index' value='[index]'}
{assign name='group_title' value='邮费规则分组'}
{php}$item=[];{/php}
<div class="layui-hide" id="template">
{include file='express_template/index_item'}
</div>
{/block}