<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('处方登记信息详情')" />
    <th:block th:include="include :: bootstrap-fileinput-css" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="gray-bg">
<input type="hidden" id="id" name="id" th:value="${id}">
<div class="col-sm-12 search-collapse">
    <h4 class="query-condition-title">患者信息</h4>
    <form id="dtp-form-newcfxxx" class="customize-search-form">
        <div class="customize-form-group-container">
            <div class="patient-info">
                <div class="info-item">
                    <span class="label">患者姓名:</span>
                    <span class="value" id="patientName"></span>
                </div>
                <!--<div class="info-item">
                    <span class="label">手机号码:</span>
                    <span class="value" id="phoneNumber"></span>
                </div>-->
                <div class="info-item">
                    <span class="label">性别:</span>
                    <span class="value" id="gender"></span>
                </div>
                <div class="info-item">
                    <span class="label">年龄:</span>
                    <span class="value" id="age"></span>
                </div>
            </div>
        </div>
    </form>
</div>
<div class="col-sm-12 search-collapse">
    <form id="dtp-form-newcfxx" class="customize-search-form">
        <div class="customize-form-group-container">
            <div class="patient-info">
                <div class="customize-form-group">
                    <label>医院:</label>
                    <input name="hospital" placeholder="医院" id="hospital" class="styled-input" readonly  type="text">
                </div>
                <div class="customize-form-group">
                    <label>处方医生:</label>
                    <input name="prescribingDoctor" id="prescribingDoctor" placeholder="处方医生"  readonly  class="styled-input" type="text">
                </div>
                <div class="customize-form-group">
                    <label>科室:</label>
                    <input name="department" id="department" placeholder="科室"   class="styled-input" readonly  type="text">
                </div>
                <div class="customize-form-group">
                    <label >处方诊断：:</label>
                    <input name="prescriptionDiagnosis" id="prescriptionDiagnosis" placeholder="处方诊断" readonly  class="styled-input" type="text">
                </div>
                <div class="customize-form-group">
                    <label >主管医生:</label>
                    <input name="attendingDoctor" id="attendingDoctor" placeholder="主管医生" readonly  class="styled-input" type="text">
                </div>
<!--                <div class="customize-form-group">-->
<!--                    <label >临床诊断:</label>-->
<!--                    <input name="clinicalDiagnosis" id="clinicalDiagnosis" placeholder="临床诊断" readonly  class="styled-input" type="text">-->
<!--                </div>-->
                <div class="customize-form-group">
                    <label>临床诊断：</label>
                    <select id="category-select"  disabled="true" class="styled-input" >

                    </select>
                </div>
                <!--<div class="customize-form-group">
                    <label>处方图片:</label>
                    <input name="prescriptionImageUrl" id="prescriptionImageUrl" placeholder="处方图片"  class="styled-input" type="text">
                </div>-->
                <div class="customize-form-group  select-time">
                    <label>处方开具日期:</label>
                    <input name="prescriptionIssueDate" id="prescriptionIssueDate" placeholder="处方开具日期" readonly  class="styled-input" type="text" >
                </div>
                <div class="customize-form-group">
                    <label>发票编码:</label>
                    <input name="invoiceCode" id="invoiceCode" placeholder="发票编码" readonly  class="styled-input" type="text">
                </div>
                <!--<div class="customize-form-group">
                    <label>发票图片:</label>
                    <input name="invoiceImageUrl" id="invoiceImageUrl" placeholder="发票图片"  class="styled-input" type="text">
                </div>-->
                <div class="customize-form-group">
                    <label >登记药师姓名:</label>
                    <input name="registerPharmacistName" id="registerPharmacistName" placeholder="登记药师姓名" readonly  class="styled-input" type="text">
                </div>
                <div class="customize-form-group">
                    <label >登记人:</label>
                    <input name="registrant" id="registrant" placeholder="登记人" readonly  class="styled-input" type="text">
                </div>
                <div class="customize-form-group">
                    <label>审核药师姓名:</label>
                    <input name="reviewingName" id="reviewingName" placeholder="审核药师姓名" readonly  class="styled-input" type="text">
                </div>
            </div>
        </div>
    </form>
</div>
    <div class="col-sm-12 search-collapse">
    <h4 class="query-condition-title">新建处方登记</h4>
        <!-- 假设这是你的 HTML 结构class="table table-bordered" -->
        <div class="ibox" id="data-ibox" style="overflow: auto;">
            <div class="ibox-title" style="width: 100%;">药品登记列表</div>
            <table id="bootstrap-table" class="fixed-layout-table"></table>
        </div>
    </div>

    <div class="main-content">
        <div class="col-sm-offset-6 col-sm-10">
            <!--<button type="button" class="btn btn-sm btn-primary" onclick="submitHandler()"><i class="fa fa-check"></i>提 交</button>&nbsp;-->
            <button type="button" class="btn btn-sm btn-danger" onclick="closeT()"><i class="fa fa-reply-all"></i>关 闭 </button>
        </div>
    </div>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: bootstrap-fileinput-js" />
<th:block th:include="include :: bootstrap-table-fixed-columns-js" />
<th:block th:include="include :: layout-latest-js" />
<th:block th:include="include :: select2-js" />


<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('dtp:RecipeRegister:edit')}]];
    var removeFlag = [[${@permission.hasPermi('dtp:RecipeRegister:remove')}]];
    var prefix_recipe = ctx + "dtp/recipe";
    var prefix_yppz= ctx + "yppz/drugConfig";
    var prefix_pmService = ctx + "dtp/pmService";
    var hzparam =[];
    var data;
    var shangcigyList=[];
    var dataList=[];
    /*<![CDATA[*/
    var dl = /*[[${dl}]]*/ '';
    /*]]>*/
    $(document).ready(function() {
        var id = $('#id').val().trim();
        console.log("id----->"+id)
        var datas=[];
        var data = {
            "id":id,
        };
        $.ajax({
            cache : true,
            type : "POST",
            url : prefix_recipe + "/getLastRecipeInfo",
            data : data,
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                var  shangciObj={};
                shangcigyList=data.data.recipeList;
                if(data.data.recipeList !=null || data.data.recipeList != undefined){
                    initTabShow(datas=data.data.recipeList)
                }
                if(data.data.recipe!=null){
                    shangciObj=data.data.recipe;
                    // 动态填充表单字段
                    $.each(shangciObj, function(key, value) {
                        $('#' + key).val(value);
                        // if (key=='prescriptionImageUrl'){
                        //     document.getElementById('prescriptionImageUrl').src == value;
                        // }
                        if (key=="patientName" || key=="patientPhone" || key=="gender" || key=="age"){
                            if (key=="gender"){
                                if (value==0){
                                    value="男";
                                }else {
                                    value="女";
                                }
                            }
                            $('#' + key).text(value);
                        }
                    });
                   /* $('#hospital').val(shangciObj.hospital);
                    $('#prescribingDoctor').val(shangciObj.prescribingDoctor);
                    $('#department').val(shangciObj.department);
                    $('#attendingDoctor').val(shangciObj.attendingDoctor);*/
                }else {
                    shangciObj={};
                    $('#hospital').val('');
                    $('#prescribingDoctor').val('');
                    $('#department').val('');
                    $('#attendingDoctor').val('');
                }

            }
        });

        // 直接使用 dl 数据预填充下拉列表
        var dlParsed = JSON.parse(dl);
        if (Array.isArray(dlParsed)) {
            var dlIds = dlParsed.map(function (item) {
                return item.id;
            }); // 转换为 ID 数组

            // 添加 dl 中的选项到下拉列表
            $.each(dlParsed, function (index, item) {
                $('<option>', {
                    value: item.id,
                    text: item.name
                }).appendTo($('#category-select'));
            });

            // 设置默认选中的 dl 选项
            $('#category-select').val(dlIds).trigger('change');
        }
    });

function initTabShow(datas){
    var tableId = 'bootstrap-table';
    var tableElement = $('#' + tableId);
    tableElement.bootstrapTable({
        data: datas,
        columns : [
            {field: 'saleDate', title: '销售日期' , width:'250px'},
            { field: 'salesOrderNumber', title: '销售订单编号' },
            {field: 'prescriptionNumber', title: '处方编号' },
            { field: 'prescriptionDate', title: '处方日期', width:'250px' },
            { field: 'genericName', title: '药品通用名' },
            { field: 'productName', title: '商品名' },
            { field: 'medicationRoute', title: '用药途径' },
            { field: 'dosageFrequency', title: '用药频次' },
            { field: 'singleDoseUnit', title: '单次剂量' },
            { field: 'pharmacyName', title: '购药门店名称' }
        ]
    });
}
function closeT() {
    $.modal.close();
}
</script>
<style>
    .patient-info {
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
    }

    .info-item {
        display: flex;
        align-items: center;
        background-color: #f5f5f5;
        border-radius: 4px;
        padding: 8px;
        box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    }

    .label {
        font-weight: bold;
        margin-right: 20px;
        color: #e7eaec;
        font-size: 15px;
        background-color: #337ab7;
    }

    .value {
        flex-grow: 1;
        color: #307cc2;
    }
    .ibox {
        width: auto;
        height: 400px;
        overflow: auto; /* 当内容超过指定尺寸时显示滚动条 */
    }

    .fixed-layout-table {
        width: 100%;
        border-collapse: collapse; /* 减少单元格间距 */
    }

    .fixed-layout-table thead th {
        position: sticky;
        top: 0;
        background-color: #f8f9fa; /* 表头背景颜色 */
        z-index: 1;
    }

    /* 隐藏列的样式 */
    .hidden-column {
        display: none;
    }


    .hidden {
        display: none;
    }
    /*.ibox {*/
    /*    width: 700px;*/
    /*    margin-bottom: 20px;*/
    /*    border: 1px solid #e7eaec;*/
    /*    border-radius: 4px;*/
    /*}*/
    .ibox-title {
        background-color: #f3f3f4;
        border-bottom: 1px solid #e7eaec;
        padding: 10px 15px;
        font-size: 16px;
        width: 1540px;
    }
    .ibox-content {
        padding: 15px;
    }
    .ibox-content h4 {
        margin-top: 0;
    }

    .form-horizontal .form-group {
        margin-right: 384px;
        margin-left: 3px;
    }
    input[type=file] {
        display: none;
    }
    .form-group {
        margin-bottom: -1px;
    }
    /* 添加一些基础样式 */
    body {
        font-family: Arial, sans-serif;
    }
    /*table {
        width: 500px;
        border-collapse: collapse;
    }
    th, td {
        text-align: left;
        padding: 5px;
        border-bottom: 1px solid #ddd;
    }
    tr:nth-child(even) {
        width: 13px;
        background-color: #f2f2f2;
    }*/
    .hidden-column {
        display: none;
    }


    .customize-table {
        width: 100%;
        border-collapse: collapse;
    }

    .customize-table th, .customize-table td {
        border: 1px solid #ddd;
        padding: 8px;
    }

    .customize-table th {
        background-color: #f2f2f2;
        text-align: left;
    }

    .customize-table tr:nth-child(even) {
        background-color: #f9f9f9;
    }

    .customize-table tr:hover {
        background-color: #ddd;
    }

    /* 新增：选中行的样式 */
    .customize-table tr.selected {
        background-color: #a9a9c5;
        color: white; /* 确保文字可见 */
    }
</style>
</body>
</html>




