<title>物流公司表</title>
<!--当前位置开始-->
<div class="layui-card layadmin-header">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <script type="text/html" template lay-done="layui.data.updateMainBreadcrumb();">
        </script>
    </div>
</div>
<!--当前位置结束-->
<style>
    /* 重写样式 */
</style>
<script type="text/html" template lay-type="Post" lay-url="{{ layui.setter.apiUrl }}Api/CoreCmsLogistics/GetIndex" lay-done="layui.data.done(d);">
    <div class="layui-form coreshop-search-form">
        <div class="layui-form-item">
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" name="logiName" id="logiName" placeholder="请输入物流公司名称" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <input type="text" name="logiCode" id="logiCode" placeholder="请输入物流公司编码" class="layui-input">
                </div>
            </div>
            <div class="layui-inline">
                <div class="layui-input-inline">
                    <select name="isDelete" id="isDelete">
                        <option value="">请选择是否删除</option>
                        <option value="True">是</option>
                        <option value="False">否</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="LAY-app-CoreCmsLogistics-search"><i class="layui-icon layui-icon-search"></i>筛选</button>
            </div>
        </div>
    </div>
</script>
<div class="table-body">
    <table id="LAY-app-CoreCmsLogistics-tableBox" lay-filter="LAY-app-CoreCmsLogistics-tableBox"></table>
</div>

<script type="text/html" id="LAY-app-CoreCmsLogistics-toolbar">
    <div class="layui-btn-container">
        <button class="layui-btn layui-btn-sm" lay-event="updateCompany"><i class="layui-icon layui-icon-refresh-1"></i>刷新接口</button>
    </div>
</script>

<script>
    var indexData;
    var debug = layui.setter.debug;
    layui.data.done = function (d) {
        //开启调试情况下获取接口赋值数据
        if (debug) { console.log(d); }

        indexData = d.data;
        layui.use(['index', 'table', 'laydate', 'util', 'coreHelper'],
            function () {
                var $ = layui.$
                    , admin = layui.admin
                    , table = layui.table
                    , form = layui.form
                    , laydate = layui.laydate
                    , setter = layui.setter
                    , coreHelper = layui.coreHelper
                    , util = layui.util
                    , view = layui.view;

                //重载form
                form.render();
                var searchwhere;
                //监听搜索
                form.on('submit(LAY-app-CoreCmsLogistics-search)',
                    function (data) {
                        var field = data.field;
                        searchwhere = field;
                        //执行重载
                        table.reload('LAY-app-CoreCmsLogistics-tableBox', { where: field });
                    });
                //数据绑定
                table.render({
                    elem: '#LAY-app-CoreCmsLogistics-tableBox',
                    url: layui.setter.apiUrl + 'Api/CoreCmsLogistics/GetPageList',
                    method: 'POST',
                    toolbar: '#LAY-app-CoreCmsLogistics-toolbar',
                    defaultToolbar: ['filter', 'print', 'exports'],
                    height: 'full-189',//无面包屑127,搜索框189,1行62
                    page: true,
                    limit: 30,
                    limits: [10, 15, 20, 25, 30, 50, 100, 200],
                    text: { none: '暂无相关数据' },
                    cols: [
                        [
                            //{ type: "checkbox", fixed: "left" },
                            { field: 'id', title: '序列', width: 60, sort: false },
                            { field: 'logiName', title: '物流公司名称', sort: false },
                            { field: 'logiCode', title: '物流公司编码', sort: false },
                            { field: 'sort', title: '排序', sort: false, width: 105 },
                            { field: 'isDelete', title: '是否删除', width: 95, templet: '#switch_isDelete', sort: false, unresize: true },
                            //{ width: 122, align: 'center', title: '操作', fixed: 'right', toolbar: '#LAY-app-CoreCmsLogistics-tableBox-bar' }
                        ]
                    ]
                });
                //监听排序事件
                table.on('sort(LAY-app-CoreCmsLogistics-tableBox)', function (obj) {
                    table.reload('LAY-app-CoreCmsLogistics-tableBox', {
                        initSort: obj, //记录初始排序，如果不设的话，将无法标记表头的排序状态。
                        where: { //请求参数（注意：这里面的参数可任意定义，并非下面固定的格式）
                            orderField: obj.field, //排序字段
                            orderDirection: obj.type //排序方式
                        }
                    });
                });
                //头工具栏事件
                table.on('toolbar(LAY-app-CoreCmsLogistics-tableBox)', function (obj) {
                    var checkStatus = table.checkStatus(obj.config.id);
                    switch (obj.event) {
                        case 'updateCompany':
                            updateCompany();
                            break;
                    };
                });

                //刷新数据
                function updateCompany(obj) {
                    layer.confirm('确定刷新吗？刷新后将删除老数据。', function (index) {
                        coreHelper.Post("Api/CoreCmsLogistics/DoUpdateCompany", null, function (e) {
                            if (debug) { console.log(e); } //开启调试返回数据
                            table.reload('LAY-app-CoreCmsLogistics-tableBox');
                            layer.msg(e.msg);
                        });
                    });
                }

                //监听 表格复选框操作
                layui.form.on('switch(switch_isDelete)', function (obj) {
                    coreHelper.Post("Api/CoreCmsLogistics/DoSetisDelete", { id: this.value, data: obj.elem.checked }, function (e) {
                        if (debug) { console.log(e); } //开启调试返回数据
                        //table.reload('LAY-app-CoreCmsLogistics-tableBox');
                        layer.msg(e.msg);
                    });
                });

            });
    };
</script>

<!--设置是否删除-->
<script type="text/html" id="switch_isDelete">
    <input type="checkbox" name="switch_isDelete" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="switch_isDelete" {{ d.isDelete ? 'checked' : '' }}>
</script>