<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('订单基础信息')" />
    <th:block th:include="include :: datetimepicker-css" />

</head>
<body class="gray-bg">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId" class="form-horizontal m">
                    <div class="row">

                        <div class="form-group col-sm-4 row">
                            <label class="control-label col-sm-4">订单号：</label>
                            <div class="input-group col-sm-8">
                                <input class="form-control" type="text" name="docNumber"/>
                            </div>
                        </div>
                        <div class="form-group col-sm-4">
                            <label class="control-label col-sm-4">经销商名字：</label>
                            <div class="input-group col-sm-8">
                                <input class="form-control" type="text" name="customerName"/>
                            </div>
                        </div>
                        <div class="form-group col-sm-4 row">
                            <label class="control-label col-sm-4">经销商编号：</label>
                            <div class="input-group col-sm-8">
                                <input class="form-control" type="text" name="customerCode"/>
                            </div>
                        </div>

                    </div>
                    <div class="row">
                        <!--<div class="form-group col-sm-4 row">-->
                            <!--<label class="control-label col-sm-4">销售组织：</label>-->
                            <!--<div class="input-group col-sm-8">-->
                                <!--<input class="form-control" type="text" name="salesOrgName"/>-->
                            <!--</div>-->
                        <!--</div>-->
                        <!--<div class="form-group col-sm-4">-->
                            <!--<label class="control-label col-sm-4">销售编码：</label>-->
                            <!--<div class="input-group col-sm-8">-->
                                <!--<input class="form-control" type="text" name="salesOrg"/>-->
                            <!--</div>-->
                        <!--</div>-->
                        <div class="form-group col-sm-4 row">
                            <label class="control-label col-sm-4">信用状态：</label>
                            <div class="input-group col-sm-8">
                                <select class="form-control m-b" name="creditStatus">
                                    <option value="">所有</option>
                                    <option value="信用通过">信用通过</option>
                                    <option value="信用未通过">信用未通过</option>
                                </select>
                            </div>
                        </div>


                        <div class="form-group col-sm-4 ">
                            <label class="control-label col-sm-4">期望时间：</label>
                            <div class="col-sm-4" style="padding: 0;">
                                <input type="text" class="form-control"  name="params[start_expectedTime]" placeholder="起始日期">
                            </div>
                            <div class="col-sm-4" style="padding: 0;">
                                <input type="text" class="form-control"  name="params[end_expectedTime]" placeholder="终止日期">
                            </div>
                        </div>


                        <div class="form-group col-sm-4 row">
                            <div class="form-group" style="float: right;">
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </div>
                        </div>

                    </div>


                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <!--<a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="order:orderbase:add">-->
                    <!--<i class="fa fa-plus"></i> 添加-->
                <!--</a>-->
                <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="order:orderbase:edit">-->
                    <!--<i class="fa fa-edit"></i> 修改-->
                <!--</a>-->
                <!--<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="order:orderbase:remove">-->
                    <!--<i class="fa fa-remove"></i> 删除-->
                <!--</a>-->
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="order:orderbase:export">
                    <i class="fa fa-download"></i> 导出
                </a>
                <a class="btn btn-info" onclick="$.table.importExcel()">
                    <i class="fa fa-upload"></i> 导入
                </a>
                <a class="btn btn-danger" onclick="refreshArrivalTime()" shiro:hasPermission="order:orderbase:refreshArrivalTime">
                    <i class="fa fa-refresh"></i> 批量刷新确认期望到货时间
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var orderStatusDatas = [[${@dict.getType('order_type')}]];
        var prefix = ctx + "order/orderbase";

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                exportUrl: prefix + "/export",
                importUrl: prefix + "/importData",
                modalName: "订单基础信息",
                columns: [{
                    checkbox: false
                },
                {
                    field : 'docNumber',
                    title : '订单号'
                },
                {
                    field : 'customerCode',
                    title : '经销商编号'
                },
                {
                    field : 'customerName',
                    title : '经销商名字'
                },
                {
                    field : 'createDate',
                    title : '订单创建时间'
                },
                // {
                //     field : 'SALES_ORG_NAME',
                //     title : '销售组织名字'
                // },

                // {
                //     field : 'DOC_TYPE',
                //     title : '订单类型'
                // },
                {
                    field : 'creditStatus',
                    title : '信用状态'
                },
                {
                    field : 'creditDate',
                    title : '信用通过时间'
                },
                {
                    field : 'expectedTime',
                    title : '期望到货时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs " href="javascript:void(0)" onclick="$.operate.editTitle(\'' + row.docNumber + '\')"><i class="fa fa-edit"></i>详情</a> ');
                        return actions.join('');
                    }
                }
                ]
            };
            $.table.init(options);

            //失去焦点事件
            //去除前后空格
            $("input").blur(function (event){
                var val =  $(event.target).val();
                val = val.replace(/^\s+|\s+$/g,"")
                $(event.target).val(val);
            })


            $("input[name='params[end_expectedTime]']").datetimepicker({
                format: "yyyy-mm-dd",
                minView: "month",
                autoclose: true
            });
            $("input[name='params[start_expectedTime]']").datetimepicker({
                format: "yyyy-mm-dd",
                minView: "month",
                autoclose: true
            });
        });

        function refreshArrivalTime () {
            $.modal.confirm("批量刷新确认期望到货时间吗？", function() {
                $.operate.get(prefix + "/refreshArrivalTime", function(result) {
                    if (result.code == 0) {
                        $.modal.alertSuccess(result.msg)
                    } else {
                        $.modal.alertError(result.msg);
                    }
                    $.modal.closeLoading();
                });
            });
        };
    </script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>