<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="keywords" content="">
    <meta name="description" content="">
    <title text="资格申请"></title>
    <link rel="stylesheet" href="../../../component/pear/css/pear.css" />
    <link rel="stylesheet" href="../../../admin/css/other/user.css" />
</head>
<body class="pear-container">
<div class="layui-card">
    <div class="layui-card-body">
        <form class="layui-form">
            <div class="layui-form-item">
                <label class="layui-form-label">姓名</label>
                <div class="layui-input-inline">
                    <input type="text" name="name" placeholder="" class="layui-input">
                </div>
                <label class="layui-form-label">业务状态</label>
                <div class="layui-input-inline">
                    <select name="businessState">
                        <option value="">请选择</option>
                        <option value="1">申请中</option>
                        <option value="2">审核中</option>
                        <option value="3">已完成</option>
                        <option value="4">已驳回</option>
                    </select>
                </div>
                <button class="pear-btn pear-btn-md-0 pear-btn-primary" lay-submit lay-filter="query">
                    <i class="layui-icon layui-icon-search"></i> 查询
                </button>
                <button type="reset" class="pear-btn pear-btn-md-0">
                    <i class="layui-icon layui-icon-refresh"></i> 重置
                </button>
            </div>
        </form>
    </div>
</div>
<div class="layui-card">
    <div class="layui-card-body">
        <table id="table" lay-filter="table"></table>
    </div>
</div>
</body>
<script type="text/html" id="toolbar">
</script>
<script type="text/html" id="bar">
    <a class="cool-line-btn cool-bg-blue" lay-event="detail">详情</a>
</script>
<script type="text/html" id="businessState">
    {{#if (d.businessState == 1) { }}
    <span class="layui-badge-dot warning"></span>申请中
    {{# } else if (d.businessState == 2) { }}
    <span class="layui-badge-dot warning"></span>审核中
    {{# } else if (d.businessState == 3) { }}
    <span class="layui-badge-dot success"></span>已完成
    {{# } else if (d.businessState == 4) { }}
    <span class="layui-badge-dot failure"></span>已驳回
    {{# } }}
</script>
<script type="text/html" id="createTimeTpl">
    {{layui.util.toDateString(d.createTime, 'yyyy-MM-dd HH:mm:ss')}}
</script>
<script src="../../../component/layui/layui.js"></script>
<script src="../../../component/pear/pear.js"></script>
<script>
    layui.use(['request', 'table', 'form', 'popup', 'common'], function () {
        var request = layui.request,
            table = layui.table,
            form = layui.form,
            popup = layui.popup,
            common = layui.common;

        var MODULE_PATH = "/business/qualification/v1/";

        request.tableRender({
            url: MODULE_PATH,
            cols: [
                [
                    {type: 'checkbox'},
                    {title: '业务编号', field: 'businessNumber', align: 'center'},
                    {title: '姓名', field: 'name', align: 'center'},
                    {title: '手机号', field: 'phone', align: 'center'},
                    {title: '流程号', field: 'flowNumber', align: 'center'},
                    {title: '流程节点名称', field: 'flowNodeName', align: 'center'},
                    {title: '业务状态', field: 'businessState', align: 'center', templet: '#businessState'},
                    {title: '其他说明', field: 'remark', align: 'center'},
                    {title: '操作', toolbar: '#bar', align: 'center', width: 130}
                ]
            ]
        });

        table.on('tool(table)', function (obj) {
            if (obj.event === 'detail') {
                window.location.href = 'view.html?id=' + obj.data.id;
            }
        });

        table.on('toolbar(table)', function (obj) {
            if (obj.event === 'add') {
                add();
            }
            else if (obj.event === 'removeBatch') {
                remove(common.checkField(obj,'id'));
            }
        });

        form.on('submit(query)', function (data) {
            refresh(data.field);
            return false;
        });

        window.add = function() {
            layer.open({
                type: 2,
                title: '新增',
                shade: 0.1,
                area: ['480px', '500px'],
                content: ['add.html', 'no']
            });
        };

        window.edit=  function(obj) {
            layer.open({
                type: 2,
                title: '编辑',
                shade: 0.1,
                area: ['480px', '500px'],
                content: ['add.html?id=' + obj.data.id, 'no']
            });
        };

        window.remove=  function(ids) {
            if (ids === '' || ids === undefined) {
                layer.alert('请先选择删除数据！');
                return false;
            }
            layer.confirm("是否确认删除这些项？", function () {
                request.http({
                    type: "delete",
                    url: MODULE_PATH + ids,
                    loading: true,
                    success: function (result) {
                        refresh();
                        if (result.success) {
                            popup.success(result.msg);
                        } else {
                            popup.failure(result.msg);
                        }
                    }
                })
            });
        };

        window.refresh = function (param) {
            table.reload('table', {where: param});
        };
    })
</script>
</html>
