<!DOCTYPE html>
<!--[if IE 8]>
<html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]>
<html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html>
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
    <base href="#springUrl('/assets/adminlte/')"/>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>工作台</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <!-- Bootstrap 3.3.5 -->
    <link rel="stylesheet" href="bootstrap/css/bootstrap.min.css">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="plugins/font-awesome/css/font-awesome.min.css">
    <!-- Ionicons -->
    <link rel="stylesheet" href="plugins/ionicons/css/ionicons.min.css">

    <!-- DataTables -->
    <link rel="stylesheet" href="plugins/datatables/dataTables.bootstrap.css">

    <!-- Theme style -->
    <link rel="stylesheet" href="dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="dist/css/skins/_all-skins.min.css">
    <!-- iCheck -->
    <link rel="stylesheet" href="plugins/iCheck/flat/blue.css">
    <!-- Date Picker -->
    <link rel="stylesheet" href="plugins/datepicker/datepicker3.css">
    <!-- Daterange picker -->
    <link rel="stylesheet" href="plugins/daterangepicker/daterangepicker-bs3.css">
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" href="plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css">
    <!--validate css-->
    <link rel="stylesheet" href="plugins/jquery-validation/css/validate.css">
    <!--fileinput css-->
    <link rel="stylesheet" href="plugins/bootstrap-fileinput/bootstrap-fileinput.css">
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<!-- END HEAD -->
<body class="hold-transition skin-blue sidebar-mini">

<div class="wrapper">
    <div class="content-wrapper" style="margin-left:0;">

        <div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <h4 class="modal-title" id="exampleModalLabel" style="font-weight: 700;">咨询单拒绝原由</h4>
                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>
                    </div>
                    <div class="modal-body">
                        <form>
                            <!--<div class="form-group">-->
                                <!--<label for="recipient-name" class="col-form-label">Recipient:</label>-->
                                <!--<input type="text" class="form-control" id="recipient-name">-->
                            <!--</div>-->
                            <div class="form-group">
                                <label for="message-text" class="col-form-label">请输入拒绝原由:</label>
                                <textarea class="form-control" rows="3" id="message-text"></textarea>
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                        <button type="button" class="btn btn-primary" onclick="review()">提交</button>
                    </div>
                </div>
            </div>
        </div>


        <section class="content-header">
            <h1>
                咨询单管理
                <small>咨询单</small>
            </h1>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i>首页</a></li>
                <li><a class="active">咨询单</a></li>
            </ol>
        </section>


        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-xs-12">
                    <!-- general form elements disabled -->
                    <div class="box box-primary">
                        <form role="form" id="myForm">
                            <input id="id" name="id" value="$!{data.id}" hidden="true"/>

                            <div class="box-body">

                                <div class="panel panel-primary">
                                    <div class="panel-heading">基础信息</div>

                                    <div class="panel-body">
                                        <div class="form-group form-md-line-input col-xs-5">
                                            <label>咨询单编码<font style="color: red"></font></label>
                                            <input type="text"
                                                   class="form-control" name="consultId"
                                                   id="consultId" readonly="readonly"
                                                   maxlength="50" placeholder="用药人姓名"
                                                   value="$!{data.consultId}"
                                            >
                                        </div>
                                        <!--                                    <div-->
                                        <!--                                           class="form-control" name="consultId"-->
                                        <!--                                           id="consultId"-->
                                        <!--                                           style="height: 68px;background: #EEEEEE"-->
                                        <!--                                    >$!{data.consultId}</div>-->
                                        <div class="form-group form-md-line-input col-xs-5">
                                            <label>用药人姓名</label>
                                            <input type="text"
                                                   class="form-control" name="userName"
                                                   id="userName" readonly="readonly"
                                                   maxlength="50" placeholder="用药人姓名"
                                                   value="$!{data.userName}"
                                            >
                                        </div>
                                        <!--                                    <label>身份证号<font style="color: red"></font></label>-->
                                        <!--                                    <input type="text"-->
                                        <!--                                           class="form-control" name="numberId"-->
                                        <!--                                           id="numberId" readonly="readonly"-->
                                        <!--                                           maxlength="50" placeholder="身份证号"-->
                                        <!--                                           value="$!{data.numberId}"-->
                                        <!--                                    >-->
                                        <div class="form-group form-md-line-input col-xs-5">
                                            <label>性别<font style="color: red"></font></label>
                                            <input type="text"
                                                   class="form-control" name="sex"
                                                   id="sex" readonly="readonly"
                                                   maxlength="50" placeholder=""
                                                   value="$!{data.sex}"
                                            >
                                        </div>

                                        <div class="form-group form-md-line-input col-xs-5">
                                            <label>联系方式<font style="color: red"></font></label>
                                            <input type="text"
                                                   class="form-control" name="iPhone"
                                                   id="iPhone" readonly="readonly"
                                                   maxlength="50" placeholder="联系方式"
                                                   value="$!{data.phone}"
                                            >
                                        </div>

                                    </div>
                                </div>

                                <div class="panel panel-primary">
                                    <div class="panel-heading">订单信息</div>

                                    <div class="panel-body">
                                        <div class="form-group form-md-line-input col-xs-10">
                                            <label>审核状态<font style="color: red"></font></label>
                                            <input type="text"
                                                   class="form-control" name="status"
                                                   id="status" readonly="readonly"
                                                   maxlength="50" placeholder="status"
                                                   value="$!{data.status}"
                                            >
                                        </div>

                                        <div class="form-group form-md-line-input col-xs-5">
                                            <label>处方单<font style="color: red"></font></label>
                                            <br/>
                                            <div class="form-group " id="imageurl"
                                                 style=" width: 130px; height: 120px;margin-left: 5px; padding :10px ;background-color :#f4f4f4; border:  1px solid #CCCCCC">
                                                <img style="cursor:zoom-in; width: 108px;height: 100% "
                                                     src="$!{data.prescription}" onclick="imgcli(this)">
                                            </div>
                                        </div>

                                        <div class="form-group form-md-line-input col-xs-5">
                                            <label>审核未通过原因<font style="color: red"></font></label>
                                            <div
                                                    class="form-control" name="description"
                                                    id="description"
                                                    maxlength="50"
                                                    style="height: 68px;background: #EEEEEE"
                                            >$!{data.description}
                                            </div>
                                        </div>

                                        <div class="form-group form-md-line-input col-xs-5">
                                            <label>疾病史<font style="color: red"></font></label>
                                            <div
                                                    class="form-control" name="pastRecords"
                                                    id="pastRecords"
                                                    maxlength="50"
                                                    style="height: 68px;background: #EEEEEE"
                                            >$!{data.pastRecords}
                                            </div>
                                        </div>

                                        <div class="form-group form-md-line-input col-xs-5">
                                            <label>过敏史<font style="color: red"></font></label>
                                            <div
                                                    class="form-control" name="allergy"
                                                    id="allergy"
                                                    maxlength="50"
                                                    style="height: 68px;background: #EEEEEE"
                                            >$!{data.allergy}
                                            </div>
                                        </div>

                                        <div class="form-group form-md-line-input col-xs-5">
                                            <label>病情描述<font style="color: red"></font></label>
                                            <div
                                                    class="form-control" name="illness"
                                                    id="illness"
                                                    maxlength="50"
                                                    style="height: 68px;background: #EEEEEE"
                                            >$!{data.illness}
                                            </div>
                                        </div>

                                        <div class="form-group form-md-line-input col-xs-5">
                                            <label>药师姓名<font style="color: red"></font></label>
                                            <input type="text"
                                                   class="form-control" name="doctorName"
                                                   id="doctorName" readonly="readonly"
                                                   maxlength="50" placeholder="药师姓名"
                                                   value="$!{data.pharmaName}"
                                            >
                                        </div>

                                        <div class="form-group form-md-line-input col-xs-5">
                                            <label>客服姓名<font style="color: red"></font></label>
                                            <input type="text"
                                                   class="form-control" name="customerName"
                                                   id="customerName" readonly="readonly"
                                                   maxlength="50" placeholder="客服姓名"
                                                   value="$!{data.customerName}"
                                            >
                                        </div>

                                    </div>
                                </div>


                                <div class="box-footer">
                                    #if($shiro.hasPermission("qy:consultSheet:edit"))
                                    <input class="btn btn-info" id="save" value="通过" type="submit">
                                    #end
                                    <a id="reject" class="btn btn-danger" data-toggle="modal" data-target="#exampleModal">拒绝</a>

                                    <a href="#springUrl('/a/consultSheet/list')" class="btn btn-default">返回</a>
                                </div>
                            </div>
                        </form>
                        <!-- /.box-body -->
                    </div><!-- /.box -->


                </div><!-- /.col -->
            </div><!-- /.row -->
        </section><!-- /.content -->
    </div><!-- /.content-wrapper -->


    <!-- Add the sidebar's background. This div must be placed
         immediately after the control sidebar -->
    <div class="control-sidebar-bg"></div>
</div><!-- ./wrapper -->
<div id="divimg"
     style="cursor:zoom-out;background: rgba(0,0,0,.6);width:100%;position: absolute;z-index: 9999;left: 0;top: 0;display: none"
     onclick="hide()">
    <img style="width: 50%;margin-left: 25%; ">
</div>
<script src="plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- Bootstrap 3.3.5 -->
<script src="bootstrap/js/bootstrap.min.js"></script>
<!-- DataTables -->
<script src="plugins/datatables/jquery.dataTables.min.js"></script>
<script src="plugins/datatables/extensions/i18n/lanauage_ch.js"></script>
<script src="plugins/datatables/dataTables.bootstrap.min.js"></script>
<!-- SlimScroll -->
<script src="plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="plugins/fastclick/fastclick.min.js"></script>
<!--fileinput js-->
<script src="plugins/bootstrap-fileinput/bootstrap-fileinput.js"></script>
<!-- AdminLTE App -->
<script src="dist/js/app.min.js"></script>
<script src="plugins/bootstrap-maxlength/bootstrap-maxlength.min.js" type="text/javascript"></script>
<script src="plugins/security/sha256.js" type="text/javascript"></script>
<script src="plugins/jquery-validation/js/jquery.validate.min.js"></script>
<script src="js/jquery.form.min.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="plugins/ueditor-min-1.4.3/lang/zh-cn/zh-cn.js"></script>
<script src="common/js/cfapp.js"></script>
<!-- END PAGE LEVEL PLUGINS -->
<script>

    var consultid;


    // href="#springUrl('/a/consultSheet/list')"
    $().ready(function () {
        consultid = $("#consultId").val();

        var value = $("#sex").val();
        if (value == 0) {
            $("#sex").val("女");
        } else {
            $("#sex").val("男");
        }
        var status = $("#status").val();
        console.log("status:", status)
        if (status == 0) {
            $("#status").val("未审核");
        } else if (status == 1) {
            $("#status").val("已通过");
        } else if (status == 2) {
            $("#status").val("已拒绝");
        }
        if (status == 1 || status == 2) {
            $("#reject").hide();
            $("#save").hide();
        }


        Cfapp.init();
        recdTypeAdd.init();
    });


    $('#divimg').click(function () {
        $(this).fadeOut(200)
    })
    function imgcli(obj) {
        $('#divimg').height($('.content-wrapper').height())
        $('#divimg').fadeIn(200);
        $('#divimg img').attr('src', $(obj).attr("src"));
        $('#divimg img').css("margin-top", "10%")
        $('#divimg img').css("height", "55%")

    }
    function hide() {
        $("#hide").hide();
    }
    function review() {
        var url = "#springUrl('/a/consultSheet/updateData')";

        var descriptionAdd = $("#message-text").text();
        var aadata = {
            consultId: consultid,
            status: "2",
            description: descriptionAdd
        };
        $.ajax({
            url: url,
            data: aadata,
            type: "GET",
            success: function (data) {
                if (data.errorNo == 0) {
                    Cfapp.alert({
                        message: "拒绝成功",
                        btntext: "确定",
                        success: function () {
                            location.href = "#springUrl('/a/consultSheet/list')"
                        }
                    });
                } else {
                    Cfapp.alert({
                        message: "审批失败",
                        btntext: "确定",
                        success: function () {
                            location.href = "#springUrl('/a/consultSheet/list')"
                        }
                    });
                }
            }
        });
    }

    var recdTypeAdd = function () {
        var initForm = function () {
            var initFormCtrl = function () {
                bindEvent();
            };
            var bindEvent = function () {
                $("#myForm").validate({
                    rules: {},
                    messages: {},
                    submitHandler: function (form) {
                        // $("#save").attr("disabled", true);
                        // var dataJSON =  $("#myForm").serialize();

                        Cfapp.confirm({
                            message: "确定审核通过吗",
                            btnoktext: "确定",
                            btncanceltext: "取消",
                            success: function () {
                                var dataJSON = {
                                    "consultId": $("#consultId").val(),
                                    "status": "1"
                                };
                                $.getJSON("#springUrl('/a/consultSheet/updateStatus')", dataJSON, function (returnobj) {
                                    // $("#save").attr("disabled", false);
                                    if (returnobj.errorNo == 0) {  //保存成功
                                        Cfapp.alert({
                                            message: "审核成功",
                                            btntext: "确定",
                                            success: function () {
                                                location.href = "#springUrl('/a/consultSheet/list')";
                                            }
                                        });
                                    } else if (returnobj.errorNo == 1) {  //修改成功
                                        Cfapp.alert({
                                            message: "审核失败",
                                            btntext: "确定",
                                            success: function () {
                                                location.href = "#springUrl('/a/consultSheet/list')";
                                            }
                                        });
                                    }
                                });
                            },
                            cancel: function () {
                                return;
                            }
                        });

                    }
                })
            }
            initFormCtrl();
        }
        return {

            //main function to initiate the module
            init: function () {
                initForm();
            }

        };
    }();
</script>
</body>

<!-- END BODY -->
</html>