<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>进度分配</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=order-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../layuiadmin/style/admin.css" media="all">
    <style type="text/css">
        .seach_items {
            float: right;
            margin-left: 10px;
        }
    </style>
    <style type="text/css">
        .LAY-btns .layui-nav {
            padding-left: 0;
            padding-right: 10px;
            top: -4px;
            margin: 0 10px;
            border: 0;
            background-color: #009688;
        }

        .LAY-btns .layui-nav .layui-nav-item {
            line-height: 40px;
        }

        .LAY-btns .layui-nav .layui-nav-child {
            top: 34px;
        }

        .LAY-btns .layui-nav .layui-nav-bar {
            display: none;
        }

        .LAY-btns .layui-nav .layui-nav-child dd.layui-this a {
            color: #333;
            background-color: #fff;
        }

        .LAY-btns .layui-nav .layui-nav-child dd.layui-this a:hover {
            background-color: #f2f2f2;
            color: #000;
        }

        .tableContent{
            width: 100%;
            display: flex;
            justify-content: space-between;
            flex-direction: row;
        }
    </style>

</head>
<body>

<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body" pad15>
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="LAY-btns" style="margin-bottom: 10px;">
                        <form class="layui-form" lay-filter="query-form-element">
                            <div class="seach_items">
                                <button class="layui-btn" lay-submit lay-filter="query-form-element"><i
                                        class="layui-icon layui-icon-search"></i>查询
                                </button>
                            </div>
                            <div class="seach_items">
                                <input type="text" name="no" autocomplete="off" class="layui-input"
                                       placeholder="单号"/>
                            </div>
                            <div class="seach_items">
                                <input type="text" name="name" autocomplete="off" class="layui-input"
                                       placeholder="客户名称"/>
                            </div>
                            <div class="seach_items">
                                <input type="text" name="tel" autocomplete="off" class="layui-input"
                                       placeholder="客户电话"/>
                            </div>
                        </form>
                        <div style="clear: both;"></div>
                    </div>

                    <table class="layui-hide" id="dispatch_process_datagrid" lay-filter="order-operate"></table>


                    <script type="text/html" id="order-operate-bar">
                        <div class="layui-btn-group">
                            <a class="layui-btn layui-btn-xs" lay-event="order_search"
                            >查看</a>
                        </div>
                        <div class="layui-btn-group">
                            <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="order_update"
                            >分配</a>
                        </div>
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../../layuiadmin/layui/layui.js?t=1"></script>
<script>
    layui.config({
        base: '../../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'form',], function () {
        var $ = layui.$;
        var table = layui.table
            , form = layui.form
            , admin = layui.admin;

        table.render({
            elem: '#dispatch_process_datagrid'
            , url: '/order/?status=3'
            , cols: [[
                {field: 'no', title: '单号', width: 180}
                , {field: 'name', title: '客户名称', width: 110}
                , {field: 'tel', title: '客户电话', width: 120}
                , {field: 'address', title: '地址', width: 200}
                , {field: 'village', title: '小区', width: 200}
                , {field: 'project_text', title: '项目', width: 120}
                , {field: 'stage_progress_text', title: "申请进度", width: 150}
                , {field: 'service_user_text', title: '当前服务人', width: 150}
                , {width: 200, align: 'center', fixed: 'right', toolbar: '#order-operate-bar'}
            ]]
            , page: true
            , height: 'full-108'
        });
        //导出列表
        form.on('submit(query-form-element)', function (data) {
            table.reload('dispatch_process_datagrid', {
                where: data.field
                , page: {curr: 1}
            });
            layer.closeAll();
            return false
        });
        //监听工具条
        table.on('tool(order-operate)', function (obj) {
            var data = obj.data;
            if (obj.event === 'order_search') {
               table.editdata = data;
               layer.open({
                type: 2,
                title: '查看详情',
                area: ['55%', '80%'],
                btn: ['关闭'],
                btn1: function (index, layero) {
                    layer.close(index);//关闭当前按钮
                },
                content: 'detail.html?order_id=' + data.id
            });
            }else if(obj.event === "order_update"){
                // 更新进度
                layer.open({
                    type: 2,
                    title: '分配',
                    area: ['40%', '60%'],
                    btn: ['保存','取消'],
                    yes: function (index, dom) {
                        layui.onSubmitChild = function (res) {
                            // 刷新父级页面的菜单数量
                            parent.layui.getTipsData();
                            layer.close(index);
                            table.reload('dispatch_process_datagrid', {});
                        };
                        layui.submitChild();
                    },
                    btn2: function (index, layero) {
                        layer.close(index);//关闭当前按钮
                    },
                    content: 'dispatch_process_edit.html?customer_id=' + data.customer +'&order_id=' + data.id
                });
            }
        });
    });

</script>
</body>
</html>
