@page
@model Waste.Web.Entry.Pages.SZPlt.AddressModel
@{
}
<div class="layui-card">
    <div class="layui-form layui-card-header layuiadmin-card-header-auto">
        <div class="layui-form-item">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" name="Name" id="Name" placeholder="请输入名称" />
                </div>
            </div>
            <div class="layui-inline">
                <button class="btn btn-primary btn-lg  js-search" type="button">查询</button>
                <button class="btn btn-primary btn-lg  js-add" type="button">添加</button>
            </div>
        </div>
    </div>
    <div class="layui-card-body">
        <table class="layui-table" id="list" lay-filter="list">
        </table>
    </div>
</div>
<script type="text/html" id="optpl">
    <a href="#" class="js-edit" title="编辑" data-id="{{d.id}}">编辑</a>&nbsp;
    <a href="#" class="js-delete" title="删除" data-id="{{d.id}}">删除</a>
</script>
@section Scripts
{
    <script type="text/javascript">
        layui.use(['common'], function () {
            var common = layui.common;
            common.initTable({
                url: '/api/szplt/getaddresslist'
                , method: 'post'
                , cols: [[
                    {
                        field: 'name', title: '名称'
                    }
                    ,
                    {
                        field: 'code', title: '编号'
                    }
                    ,
                    {
                        field: 'addr', title: '地址'
                    }
                    ,
                    {
                        field: 'city', title: '城市编码'
                    }
                    ,
                    {
                        field: 'area', title: '区域编码'
                    }
                    ,
                    {
                        field: 'street', title: '街道编码'
                    }
                    ,
                    {
                        field: 'createtime', title: '添加时间'
                    },
                    {
                        title: '操作', templet: "#optpl"
                    }
                ]]
            });
            $(".js-search").on("click", function () {
                common.reloadtable("list", {
                    where: {
                        queryParam: [{
                            "Name": 'name',
                            "Type": QueryCond.Like,
                            "Value": $("#Name").val()
                        }]
                    }
                });
            });
            $(".js-add").on("click", function () {
                common.dialog({
                    title: '添加区域',
                    content: '/szplt/EditAddress'
                });
            });
            $("body").on("click", ".js-edit", function () {
                var id = $(this).data('id');
                common.dialog({
                    title: '编辑区域',
                    content: '/szplt/EditAddress?id=' + id
                });
            });
            $("body").on("click", ".js-delete", function () {
                var id = $(this).data('id');
                common.confirm("确定删除?", function(){
                    common.ajax({
                        url: "/api/szplt/deleteaddress?id=" + id
                    });
                });
            });
        });
    </script>
}