<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('随访任务详情')" />
    <th:block th:include="include :: layout-latest-css" />
    <th:block th:include="include :: ztree-css" />
    <th:block th:include="include :: select2-css" />
    <th:block th:include="include :: bootstrap-editable-css" />

</head>
<style>

    /* 问号图标的样式 */
    .question-mark {
        width: 20px; /* 根据需要调整大小 */
        height: 20px;
        cursor: pointer;
    }

    /* 工具提示内容的默认状态：隐藏 */
    .tooltip-content {
        visibility: hidden;
        opacity: 0;
        transition: visibility 0s, opacity 0.5s;
        position: absolute;
        top: -30px; /* 根据实际情况调整 */
        left: 300px; /* 根据实际情况调整 */
        z-index: 1000;
    }

    /* 当悬停在问号图标上时，显示工具提示内容 */
    .question-mark:hover + .tooltip-content,
    .tooltip-content:hover {
        visibility: visible;
        opacity: 1;
    }

    /* 图片缩放效果 */
    .tooltip-image {
        width: 400px; /* 初始大小 */
        transition: transform 0.3s ease;
    }

    /* 当悬停在图片上时放大图片 */
    .tooltip-image:hover {
        transform: scale(1.5); /* 放大倍数 */
    }


    .select2-dropdown {
        z-index: 9999 !important;
    }
    .tabs-container {
        position: relative;
    }
    label {
        display: inline-block;
        max-width: 100%;
        margin-bottom: 0px;
        font-weight: 700;
    }
    input {
        width: 40px;
    }
    .customize-form-group label {
        width: 250px;
        text-align: right;
        margin-right: 0.5em;
    }
    .font {
        font-size: 16px; /* 字体大小 */
    }
    .form-groupBottom {
        margin-bottom: 30px; /* 调整这个值以改变间距 */
    }


    .content-area {
        margin-top: 50px; /* 调整这个值以确保内容不会被导航栏遮挡 */
    }
    .nav-tabs {
        position: sticky;
        top: 0; /* 距离顶部的距离 */
        background-color: #fff; /* 设置背景颜色，以便覆盖下方的内容 */
        z-index: 1020; /* 确保它位于其他内容之上 */
    }

    .tabs-container {
        position: relative;
    }

    .btn {
        background-color: #f2f2f2;
        border: none;
        color: black;
        padding: 5px 10px;
        text-align: center;
        text-decoration: none;
        display: inline-block;
        font-size: 16px;
        margin: 4px 2px;
        cursor: pointer;
    }

    .btn-primary {
        background-color: #1a7bb9;
        color: white;
    }

    .btn-w-m {
        width: max-content;
    }

    .btn-default {
        background-color: #f2f2f2;
        color: black;
    }
    .btn:hover {
        opacity: 0.8;
    }
    .tab-1a {
        padding-left: 50px;
        width: 100px;
        font-size: 15px
    }
    .tab-1b {
        width: 100px;
        color: blue;
        font-size:15px;
    }
    .task-follow-up {
        display: flex;
        align-items: center;
    }

    .follow-up-person, .plan-buttons {
        flex: 1;
    }

    .plan-buttons {
        text-align: right;
    }
    .ibox-title2 {
        display: flex;
        align-items: center;
        justify-content: start;
        padding: 6px;
        border-bottom: 1px solid #ddd;
    }
    .right-aligned-link {
        float: right;
        margin-left: 20px; /* 增加左侧边距 */
    }

    .right-aligned-link::after {
        content: ">";
        color: blue;
    }
    .task-info {
        flex: 1;
    }

    .task-details {
        flex: 2;
        display: flex;
        align-items: center;
        gap: 0px;
    }

    .task-buttons {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 10px;
    }

    .task-buttons span {
        margin-left: 10px;
    }

    .task-details span {
        display: flex;
        align-items: center;
        gap: 1px;
    }
    .custom-file-upload {
        position: relative;
        overflow: hidden;
        cursor: pointer;
        display: flex;
        justify-content: center;
        align-items: center;
    }

    .custom-file-upload input[type=file] {
        opacity: 0;
        width: 100%;
        height: 100%;
        top: 0;
        left: 0;
        position: absolute;
    }

    .custom-file-upload label {
        background-color: white;
        border: 2px dashed #007bff;
        color: #007bff;
        padding: 20px;
        text-align: center;
        display: block;
        min-height: 150px;
    }
    #hbyyjlTable {
        width: 100%;
        border-collapse: collapse;
    }

    th,
    td {
        padding: 10px;
        text-align: center;
        border-bottom: 1px solid #ddd;
    }

    thead th {
        background-color: #f2f2f2;
        font-weight: bold;
    }

    tbody tr:hover {
        background-color: #f5f5f5;
    }

    .no-data {
        text-align: center;
        padding: 0px;
    }

    .btn-primarys {
        margin-left: 10px;
        color: green;
    }


    .radio-item label {
        /*margin-left: 5px;*/
    }
    .hidden {
        display: none;
    }
    .shown {
        display: block;
    }
</style>
<script>

</script>
<body>
<div class="font">
    <div class="ibox">
        <form id="form-followUp-edit1">
            <div class="ibox-title">
                <button class="btn btn-w-m btn-primary"  onclick="editArchives()">完善档案</button>
                <button type="button" class="btn btn-sm btn-danger pull-right" onclick="closeItem()">返回上一级</button>
            </div>
            <div class="customize-form-group">
                <label>姓名：</label>
                <input name="name" id="name"   class="select-input" type="text"  th:value="${name}" disabled="true"/>
                &nbsp;&nbsp; <i class="fa" th:class="${realNameStatus == 1 ? 'fa fa-check' : 'fa fa-close'}" id="checkName"  ></i>
                &nbsp;
                <input name="realNameStatus" id="realNameStatus" class="status" type="text"   th:value="${realNameStatus == 1 ? '已实名' : (realNameStatus == 0 ? '未实名' : '')}" readonly>
                <label>性别：</label>
                <input name="gender" id="gender"  type="text" class="select-input"  th:value="${gender == 1 ? '女' : (gender == 0 ? '男' : '')}" readonly>
                <span class="span_line" readonly></span>
                <label>出生年月：</label>
                <input name="dateBirth" id="dateBirth" placeholder="出生年月" class="select-input"  type="text"    th:value="${dateBirth}" disabled="true" />
                <span class="status" style="width: 66px">
            <input  name="age" type="text" id="age" th:value="${age}" style="text-align: center;width: 30px;border: none;" readonly />岁</span>
            </div>
            <div class="customize-form-group">
                <div th:each="item : ${dValueList}" style="margin-bottom: 10px; border: 1px solid #ccc; padding: 10px;">
            <span>
                <strong>药品: <code th:text="${item.genericName}"></code></strong><br>
                <strong>用药状态: <code th:text="${item.medication_status}"></code></strong><br>
                <strong>剩余用药天数: <code th:text="${item.sum_total}"></code>天</strong><br>
            </span>
                </div>
            </div>

            <div class="ibox-content">
                <div>
                    <span>档案完善度：已完善---><div></div></span>
                    <div class="stat-percent" th:text="${completenessPercentage} + ' %'"></div>
                    <div class="progress progress-mini">
                        <!-- 使用 Thymeleaf 的 th:style 属性动态设置样式 -->
                        <div class="progress-bar" th:style="'width: ' + ${completenessPercentage} + '%;'"></div>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div class="ui-layout-center">
        <div class="row">
            <div class="col-sm-12">
                <div class="tabs-container">
                    <ul class="nav nav-tabs" id="myUlTabs">
                        <li class="active"><a data-toggle="tab" href="#tab-1" aria-expanded="true"> 基本信息</a>
                        </li>
                        <li class=""><a data-toggle="tab" href="#tab-2" aria-expanded="false">用药购药</a>
                        </li>
                        <li class=""><a data-toggle="tab" href="#tab-3" aria-expanded="false">随访计划</a>
                        </li>
                    </ul>
                    <div class="tab-content">
                        <div id="tab-1" class="tab-pane active">
                            <form class="customize-search-form" id="form-followUp-edit2" >

                                <div class="customize-form-group edit">
                                    <label>手机号码：</label>
                                    <input name="phoneNumber" id="phoneNumber" class="styled-input" type="text" maxlength="30" th:value="${phoneNumber}" disabled="true">
                                    <span class="span_line" readonly></span>
                                </div>

                                <div class="customize-form-group">
                                    <label>配送地址：</label>
                                    <input name="addr" disabled="true"  id="addr" class="styled-input " type="text" th:value="${addr}">
                                    <span class="span_line" readonly></span>
                                </div>
                                <div class="customize-form-group">
                                    <label>联系人手机号：</label>
                                    <input name="contactPhone" disabled="true"  id="contactPhone" class="styled-input" type="text" th:value="${contactPhone}">
                                    <span class="span_line" readonly></span>
                                </div>
                                <div class="customize-form-group">
                                    <label>联系人姓名：</label>
                                    <input name="contactName"disabled="true"  id="contactName" class="styled-input" type="text" th:value="${contactName}">
                                    <span class="span_line" readonly></span>
                                </div>
                                <div class="customize-form-group edit">
                                    <label>D值品名称：</label>
                                    <input name="dvalueName" id="dvalueName" class="styled-input" type="text"  th:value="${dvalueName}" disabled="true">
                                    <span class="span_line" readonly></span>
                                </div>
                                <div class="customize-form-group edit">
                                    <label>D值品天数：</label>
                                    <input name="dvalueDay" id="dvalueDay" class="styled-input" type="text" th:value="${dvalueDay}" disabled="true">
                                    <span class="span_line" readonly></span>
                                </div>
                                <div class="customize-form-group edit select-time">
                                    <label>首次确诊时间：</label>
                                    <input name="timeFirstDiagnosis" disabled="true" class="styled-input"  type="text"  th:value="${timeFirstDiagnosis}">
                                    <span class="span_line" readonly></span>
                                </div>
                                <div class="customize-form-group edit">
                                    <label >证件号码：</label>
                                    <input name="documentType" placeholder="证件类型" class="styled-input short" style="font-size: 13px" type="text"  th:value="${documentType}" disabled="true">
                                    <input name="documentNumber" placeholder="请输入证件号码" class="styled-input" type="text" maxlength="30" th:value="${documentNumber}" disabled="true">
                                    <span class="span_line" readonly></span>
                                </div>
                                <div class="customize-form-group-container">
                                    <div class="customize-form-group">
                                        <label class="col-sm-1 control-label">肿瘤发病部位疾病：</label>
                                        <select id="category-select1"   class="styled-input edit_inputs select2-multiple"  placeholder="肿瘤发病部位疾病" disabled="true">
                                        </select>
                                    </div>
                                    <div class="customize-form-group">
                                        <label class="col-sm-1 control-label">肿瘤治疗并发症与合并症：</label>
                                        <select id="category-select2" class="styled-input edit_inputs select2-multiple"  placeholder="肿瘤治疗并发症与合并症" disabled="true">
                                        </select>
                                    </div>
                                    <div class="customize-form-group">
                                        <label class="col-sm-1 control-label">风湿免疫疾病名称：</label>
                                        <select id="category-select3"   class="styled-input edit_inputs select2-multiple"  placeholder="风湿免疫疾病名称" disabled="true">
                                        </select>
                                    </div>
                                    <div class="customize-form-group">
                                        <label class="col-sm-1 control-label">罕见病疾病：</label>
                                        <select id="category-select4" class="styled-input edit_inputs select2-multiple"  placeholder="罕见病疾病" disabled="true">
                                        </select>
                                    </div>
                                    <div class="customize-form-group">
                                        <label class="col-sm-1 control-label">感染类疾病：</label>
                                        <select id="category-select5"   class="styled-input edit_inputs select2-multiple"  placeholder="感染类疾病" disabled="true">
                                        </select>
                                    </div>
                                    <div class="customize-form-group">
                                        <label class="col-sm-1 control-label">临时慢病：</label>
                                        <select id="category-select6"   class="styled-input edit_inputs select2-multiple"  placeholder="临时慢病" disabled="true">
                                        </select>
                                    </div>
                                </div>
                            </form>
                        </div>
                        <div id="tab-2" class="tab-pane">
                            <div class="panel-body">
                                <div class="row">
                                    <div class="col-sm-12 select-table table-striped">
                                        <table id="bootstrap-table-2"></table>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div id="tab-3" class="tab-pane">
                            <div class="task-follow-up">
                                <div class="follow-up-person">
                                    <label  style="padding-left: 10px;">随访跟进人：</label>
                                    <!--                                    <code style="font-size: 1.5rem;width: 200px;padding-left: 15px;">-->
                                    <!--                                        随访跟进人:-->
                                    <!--                                    </code>-->
                                    <code id="followUpPersonNameCode" style="font-size: 1.5rem;width: 200px;padding-left: 15px;" th:text="${followUpPersonName}">
                                    </code>
                                    <!--                                    <code type="text" id="follow_up_person"  style="border: none; width: 55px; color: red;"  th:value="${follow_up_person}">-->
                                    <!--                                    </code>-->
                                    <input type="hidden" id="followUpPersonId" name="followUpPersonId" th:value="${followUpPersonId}"/>
                                    <input type="hidden" id="followUpPersonName" name="followUpPersonName" th:value="${followUpPersonName}"/>
                                    <a href="#" onclick="editSFGenJinRen()">修改<i class="glyphicon glyphicon-pencil"></i></a>
                                </div>
                                <div class="plan-buttons">
                                    <!--                                    <button class="btn btn-w-m btn-primary" onclick="showAllPlan()">查看全部计划</button>-->
                                </div>
                            </div>
                            <div id="cgsfnormal">

                                <div class="row">
                                    <div class="ibox-content">
                                        <div class="ibox-title2">
                                            <code style="font-size: 1.5rem;width: 200px;" th:text="${productName}">
                                            </code>
                                            <code style="font-size: 1.5rem; width: 200px;" th:text="${specification}">
                                            </code>
                                            <code style="font-size: 1.5rem;color: #00B83F;padding-right: 30px;"><i class="glyphicon glyphicon-ice-lolly" th:text="${businessBelonging}"></i></code>
                                            <code style="font-size: 1.5rem;color: #00B83F;padding-right: 30px;"
                                                  th:text="${status == '关闭'? '已关闭' : status}">
                                                <!-- 默认文本将被 Thymeleaf 动态替换 -->
                                            </code>
                                            <!-- 根据 status 的值决定是否显示关闭计划按钮 -->
                                            <a th:if="${status != '关闭'}" onclick="closePlan(1)" href="#" class="right-aligned-link" data-toggle="modal"   data-target="#myModalClosePlan">关闭计划</a>
                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="ibox-content">
                                        <div class="ibox-title2">
                                            <span style="padding-left: 10px;font-size:15px;">创建人:</span>
                                            <span style="width: 120px;color: #2E2D3C;font-size:15px;padding-right: 40px;" th:text="${createdBy}"></span>
                                            <span style="font-size:15px;">开始时间:</span> <span style="width: 220px;color: #2E2D3C;font-size:15px;padding-right: 70px;" th:text="${createdTime}"></span>
                                            <span style="font-size:15px;">更新人:</span> <span style="width: 100px;color: #2E2D3C;font-size:15px;" th:text="${updatedBy}"></span>
                                            <span style="font-size:15px;">更新时间:</span> <span style="width: 220px;color: #2E2D3C;font-size:15px;padding-right: 70px;" th:text="${updatedTime}"></span>
                                            <!--                                    <a href="javascript:void(0)" onclick="ViewOperationLog()" class="right-aligned-link">查看操作记录</a>-->
                                        </div>

                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-sm-12 select-table table-striped">
                                        <table id="bootstrap-table-4"></table>
                                    </div>
                                </div>
                            </div>
                            <div id="tlzhback">
                                <div class="row">
                                    <div class="ibox-content">
                                        <div class="ibox-title2">
                                            <code style="font-size: 1.5rem;width: 200px;" th:text="${productName2}">
                                            </code>
                                            <code style="font-size: 1.5rem; width: 200px;" th:text="${specification2}">
                                            </code>
                                            <code style="font-size: 1.5rem;color:#ec971f;padding-right: 30px;"><i class="glyphicon glyphicon-ice-lolly-tasted" th:text="${businessBelonging2}"></i></code>
                                            <code style="font-size: 1.5rem;color: #00B83F;padding-right: 30px;"
                                                  th:text="${status2 == '关闭'? '已关闭' : status2}">
                                                <!-- 默认文本将被 Thymeleaf 动态替换 -->
                                            </code>
                                            <a th:if="${status2 != '关闭'}" onclick="closePlan(2)" href="#" class="right-aligned-link" data-toggle="modal"   data-target="#myModalClosePlan">关闭计划</a>
                                            <!-- 关闭计划弹框 -->
                                            <!-- 关闭计划弹框 -->

                                        </div>
                                    </div>
                                </div>
                                <div class="row">
                                    <div class="ibox-content">
                                        <div class="ibox-title2">
                                            <span style="padding-left: 10px;font-size:15px;">创建人:</span>
                                            <span style="width: 120px;color: #2E2D3C;font-size:15px;padding-right: 40px;" th:text="${createdBy2}"></span>
                                            <span style="font-size:15px;">开始时间:</span> <span style="width: 220px;color: #2E2D3C;font-size:15px;padding-right: 70px;" th:text="${createdTime2}"></span>
                                            <span style="font-size:15px;">更新人:</span> <span style="width: 100px;color: #2E2D3C;font-size:15px;" th:text="${updatedBy2}"></span>
                                            <span style="font-size:15px;">更新时间:</span> <span style="width: 220px;color: #2E2D3C;font-size:15px;padding-right: 70px;" th:text="${updatedTime2}"></span>
                                            <!--                                    <a href="javascript:void(0)" onclick="ViewOperationLog()" class="right-aligned-link">查看操作记录</a>-->
                                        </div>

                                    </div>
                                </div>
                                <div class="row">
                                    <div class="col-sm-12 select-table table-striped">
                                        <table id="bootstrap-table-5"></table>
                                    </div>
                                </div>
                            </div>


                            <div class="modal inmodal fade" id="myModalClosePlan" tabindex="-1" role="dialog" aria-hidden="true">
                                <div class="modal-dialog modal-lg" style="width: 1200px">
                                    <div class="modal-content">
                                        <div class="modal-header">
                                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
                                            </button>
                                            <h4 class="modal-title">关闭随访计划</h4>
                                            <!--<small class="font-bold">这里可以显示副标题。</small>-->
                                        </div>
                                        <div class="modal-body">
                                            <div id="ClosePlan" class="row">
                                                <form id="ClosePlanForm" class="form-horizontal" style="font-size: 15px;">
                                                    <div class="col-sm-12">
                                                        <div class="form-group">
                                                            <div >
                                                                <h2><code>关闭原因</code></h2>
                                                            </div>
                                                            <label class="is-required">原因</label>
                                                            <div class="input-groups" th:with="type=${@dict.getType('sys_hzgl_sfrw_closeplan_reason')}" style="width: 900px;">
                                                                <input type="radio" name="reason" class="form-check-radio"  th:each="dict : ${type}"  id="reason" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}">
                                                            </div>

                                                            <div class="form-group hidden" id="drugsStatusDiv" >
                                                                <label class="is-required">用药状态调整为</label>
                                                                <div class="input-groups"  th:with="type=${@dict.getType('sys_hzgl_sfrw_closeplan_drugsstatu')}" style="width: 900px;">
                                                                    <input type="radio" name="drugsStatus" class="form-check-radio"  th:each="dict : ${type}"  id="drugsStatus" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}">
                                                                </div>
                                                            </div>
                                                            <div class="form-group hidden" id="drugsStopDiv ">
                                                                <label class="is-required">永久停药类型</label>
                                                                <div class="input-groups hidden"  th:with="type=${@dict.getType('sys_hzgl_sfrw_closeplan_yjstop')}" style="width: 1200px;">
                                                                    <input type="radio" name="drugsStop" class="form-check-radio"  th:each="dict : ${type}"  id="drugsStop" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}">
                                                                </div>
                                                            </div>

                                                            <div class="form-group hidden" id="flowNoDiv">
                                                                <label class="is-required">随访不配合原因</label>
                                                                <div class="input-groups"  th:with="type=${@dict.getType('sys_gxhpz_yanchi_gyhzyybgf')}" style="width: 900px;">
                                                                    <input type="radio" name="flowNo" class="form-check-radio"  th:each="dict : ${type}"  id="flowNo" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}">
                                                                </div>
                                                            </div>
                                                            <div class="form-group hidden" id="otherReasonDiv">
                                                                <label class="is-required">其他原因请补充</label>
                                                                <div>
                                                                    <input id="otherReason" name="otherReason" placeholder="这里可以输入...其他原因请补充到这里"
                                                                           class="styled-input"
                                                                           style="width: 800px;height: 40px;">
                                                                </div>
                                                            </div>

                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12">
                                                        <div class="form-group">
                                                            <div class="form-group">
                                                                <h2><code>关闭范围</code></h2>
                                                            </div>

                                                            <div class="input-groups" th:with="type=${@dict.getType('sys_hzgl_sfrw_closeplan_scope')}" style="width: 900px;">
                                                                <label class="is-required">关闭计划</label>
                                                                <input type="radio" name="closePlanScope" class="form-check-radio"  th:each="dict : ${type}"  id="closePlanScope" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}">
                                                            </div>

                                                        </div>
                                                    </div>

                                                    <div class="col-sm-12 hidden" id="closeplan_isnoDiv">
                                                        <div class="form-group" >
                                                            <div class="input-groups" th:with="type=${@dict.getType('sys_hzgl_sfrw_closeplan_isno')}" style="width: 900px;">
                                                                <label class="is-required">是否禁用此品的计划</label>
                                                                <input type="radio" name="forbidden" class="form-check-radio"  th:each="dict : ${type}"  id="forbidden" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}">
                                                                <label style="color: grey;font-size: 11px;">&nbsp;&nbsp;&nbsp;选择是，购买相同D值品不会自动触发新计划</label>
                                                            </div>

                                                        </div>

                                                    </div>

                                                    <div class="col-sm-12" id="closeTypeDiv">
                                                        <div class="form-group" >

                                                            <div class="input-groups" th:with="type=${@dict.getType('sys_hzgl_sfrw_closepan_type')}" style="width: 900px;">
                                                                <label class="is-required">关闭类型</label>
                                                                <input type="radio" name="closeType" class="form-check-radio"  th:each="dict : ${type}"  id="closeType" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}">
                                                            </div>

                                                        </div>
                                                    </div>
                                                    <div class="col-sm-12" id="specifiedTypeDiv">
                                                        <div class="form-group">
                                                                <label class="is-required">指定类型</label>
                                                                <div class="input-groups" th:with="type=${@dict.getType('sys_hzgl_sfrw_closepan_istype')}" style="width: 900px;">
                                                                        <input type="checkbox"  th:each="dict, iterStat : ${type}"
                                                                               name="specifiedType"
                                                                               class="form-check-radio"
                                                                               th:id="'specifiedType_' + ${iterStat.index}"
                                                                               th:value="${dict.dictLabel}"
                                                                               th:text="${dict.dictLabel}">
                                                                </div>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>

                                        <div class="modal-footer">
                                            <button type="button" class="btn btn-white" data-dismiss="modal">无需关闭 退出操作</button>
                                            <button type="button" class="btn btn-primary"  onclick="submitClosePlan()">提交</button>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="ibox-content">
            <div class="ibox-title2">
                <div class="task-info">
                    <h4>本次任务 <code style="font-size: 1.5rem;" th:text="${bc_taskStatus}"></code></h4>
                </div>
                <span style="font-size:15px;">任务名称：
                        <span style="font-size:15px;" th:text="${bc_taskName}"></span> &nbsp;&nbsp;&nbsp;&nbsp;
                    </span>
                <span style="font-size:15px;">药品：
                        <span style="font-size:15px;" th:text="${bc_productName}"></span> &nbsp;&nbsp;&nbsp;&nbsp;
                    </span>
                <span style="font-size:15px;">任务主题：
                            <span>
                                <select name="taskTheme" class="styled-input" th:with="type=${@dict.getType('sys_select_dtp_sfrw_rwzt')}">
                                    <option value="">请选择</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}" th:selected="${dict.dictLabel}==${bc_taskTheme}"></option>
                                </select>
                           </span> &nbsp;&nbsp;&nbsp;&nbsp;
                       </span>
                <span style="font-size:15px;">任务跟进人：
                        <input type="hidden" id="bc_taskFollower" name="bc_taskFollower" th:value="bc_taskFollower"/>
                        <span id="bc_taskFollowerCode" style="color: #2E2D3C;font-size:15px;"><code style="font-size: 1.4rem;font-size:15px;" th:text="${bc_taskFollower}" ></code></span>
                       <a onclick="editTaskGenJinRen()" style="font-size:15px;"> 修改 <i class="glyphicon glyphicon-pencil"></i></a>
                    </span>

                <div class="task-buttons">
                    <!--                    <button class="btn btn-w-m btn-primary" onclick="showDetailHistory()">查看历史随访</button>-->
                </div>
            </div>
            <form id="form-defaultValue" class="form-horizontal">
            <input type="hidden" id="id" name="id" th:value="${bc_id}">
            <input type="hidden" id="planId" name="planId" th:value="${planId}">
            <input type="hidden" id="bc_planId" name="bc_planId" th:value="${bc_planId}">
            <input type="hidden" id="planId_cg" name="planId_cg" th:value="${planId_cg}">
            <input type="hidden" id="planId_tl" name="planId_tl" th:value="${planId_tl}">
            <input type="hidden" id="patientId" name="patientId" th:value="${patientId}">
            <input type="hidden" id="mdmCode_tl" name="mdmCode_tl" th:value="${mdmCode_tl}">
            <input type="hidden" id="mdmCode_cg" name="mdmCode_cg" th:value="${mdmCode_cg}">
            </form>
        </div>
        <form id="form-followUp-edit3" class="form-horizontal">
            <div class="row">
              <div class="col-sm-12">
                                <ul class="nav nav-tabs" id="myTabs2">
                                    <li class="active"><a data-toggle="tab" href="#tab-4" aria-expanded="true">本次任务</a>
                                    </li>
                                    <li class=""><a data-toggle="tab" href="#tab-6">用药依从性</a>
                                    </li>
                                    <li class=""><a data-toggle="tab" href="#tab-7" >药物安全性</a>
                                    </li>
                                    <li class=""><a data-toggle="tab" href="#tab-8">药物有效性</i></a>
                                    </li>
                                    <li class=""><a data-toggle="tab" href="#tab-9">治疗方案</a>
                                    </li>
                                    <li class=""><a data-toggle="tab" href="#tab-10">适宜性评估</a>
                                    </li>
                                    <li class=""><a data-toggle="tab" href="#tab-11">用药记录</a>
                                    </li>
                                    <li class=""><a data-toggle="tab" href="#tab-12">量表测评</a>
                                    </li>
                                    <li class=""><a data-toggle="tab" href="#tab-13">患者咨询</a>
                                    </li>
                                    <li class=""><a data-toggle="tab" href="#tab-14">其他</a>
                                    </li>
                                </ul>

                        <div class="panel-body">
                            <div class="tab-content content-area">
                                <div id="tab-4" class="tab-pane active">
                                    <strong> <h4 style="color: #1E9FFF;">| 本次任务</h4> </strong>
                                    <div class="customize-form-group edit">
                                        <div class="tooltip-question">
                                            <label class="is-required">回访方式：</label>

                                            <img th:src="@{/img/wenhao.png}" alt="Question Mark" class="question-mark">
                                            <!-- 这里可以放置您想显示的图片 -->
                                            <div class="tooltip-content">
                                                <img th:src="@{/img/huifanfs.png}" alt="Tooltip Image" class="tooltip-image">
                                            </div>
                                        </div>
                                        <div class="input-groups" th:with="type=${@dict.getType('sys_select_dtp_ysfw_huifangfangshi')}">
                                            <input type="radio" class="form-check-radio" name="returnMethod" id="returnMethod" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"   th:checked="${dict.dictLabel}==${returnMethod}">
                                        </div>

                                        <span class="status"></span>
                                    </div>

                                    <div id="weixin" class="hidden">
                                        <div class="customize-form-group edit">
                                            <label class="is-required" for="returnImgUrl">回访图片：</label>
                                            <div class="custom-file-upload">
                                                <input type="file" id="returnImgUrl" accept=".jpg,.jpeg,.png,.gif">
                                                <label for="returnImgUrl"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#007bff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus-circle"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line></svg></label>
                                            </div>
                                        </div>
                                    </div>

                                    <div id="mianfang" class="hidden">
                                        <div class="customize-form-group edit">
                                            <label>面访记录：</label>
                                            <div class="input-groups"  style="width: 50%">
                                                <input name="InterviewRecord" id="InterviewRecord" placeholder="请输入面访记录" class="styled-input edit_inputs" type="text" th:value="${InterviewRecord}">
                                            </div>
                                            <span class="status"></span>
                                        </div>
                                    </div>
                                    <div class="customize-form-group">
                                        <label>回访对象：</label>
                                        <select name="returnObject" class="select-input edit_inputs" id="returnObject" th:with="type=${@dict.getType('sys_select_dtp_ysfw_huifangduixaing')}">
                                            <option value="">请选择</option>
                                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"
                                                    th:selected="${dict.dictLabel}==${returnObject}"></option>
                                        </select>
                                        <span class="status"></span>
                                    </div>
                                    <div class="customize-form-group edit">
                                        <label class="is-required">是否配合：</label>
                                        <div class="input-groups" th:with="type=${@dict.getType('sys_select_yes_no')}">
                                            <input type="radio" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"  th:checked="${dict.dictValue}==${iscoordinate}"  name="iscoordinate" id="iscoordinate">
                                        </div>
                                        <span class="status"></span>
                                    </div>
                                    <div id="iscoordinateDiv" class="hidden">
                                        <div class="customize-form-group edit">
                                            <label class="is-required">随访不配合原因：</label>
                                            <div class="input-groups" style="width: 90%" th:with="type=${@dict.getType('sys_gxhpz_ysfw_sfbphyy')}">
                                                <input type="radio" id="reasons_uncooperative" name="reasons_uncooperative" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"  th:checked="${dict.dictLabel}==${reasons_uncooperative}"  >
                                            </div>
                                            <span class="status"></span>
                                        </div>
                                        <div class="customize-form-group edit">
                                            <label>不配合：</label>
                                            <div class="input-groups" th:with="type=${@dict.getType('sys_gxhpz_yong_jiu_ting_yao_form')}" style="color: red">
                                                <input type="checkbox" id="stopform" name="stopform" class="form-check-radio"  th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"  th:checked="${dict.dictLabel}==${stopForm}">
                                            </div>
                                            <span class="status"></span>
                                        </div>

                                    </div>

                                </div>
                                <div id="tab-6" class="tab-pane active">
                                    <strong> <h4 style="color: #1E9FFF;">| 用药依从性</h4> </strong>
                                    <div class="customize-form-group edit" >
                                        <label>是否持续用药(用药状态):</label>
                                        <div class="input-groups" style="width: 90%" th:with="type=${@dict.getType('sys_gxhpz_yyycx')}">
                                            <input type="radio" class="form-check-radio" name="medicationStatus" id="medicationStatus"  th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"   th:checked="${dict.dictLabel}==${medicationStatus}" >
                                        </div>
                                        <span class="status"></span>
                                    </div>

                                    <div id="csyzyy" class="hidden">
                                        <div class="customize-form-group edit" >
                                            <label>慈善援助用药：</label>
                                            <div class="input-groups" th:with="type=${@dict.getType('sys_gxhpz_chishan_yzyy')}">
                                                <input type="radio" name="charitable"  class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"  th:checked="${dict.dictLabel}==${chishanyy}"  >
                                            </div>
                                            <span class="status"></span>
                                        </div>
                                    </div>
                                    <div id="yjty" class="hidden">
                                        <div class="customize-form-group edit">
                                            <label>永久停药时间：</label>
                                            <div class="input-groups">
                                                <input name="permanentStopTime" id="permanentStopTime" placeholder="永久停药时间" class="time-input time-input2" type="text"  th:value="${permanentStopTime}" required>
                                            </div>
                                            <span class="status"></span>
                                        </div>
                                        <div class="customize-form-group edit">
                                            <label class="is-required">永久停药原因：</label>
                                            <div class="input-groups" style="width: 90%" th:with="type=${@dict.getType('sys_hzgl_sfrw_closeplan_yjstop')}">
                                                <input type="radio"  name="perpetual_stopdrug_cause" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"  th:checked="${dict.dictLabel}==${perpetual_stopdrug_cause}"  >
                                            </div>
                                            <span class="status"></span>
                                        </div>
                                        <div class="customize-form-group edit">
                                            <label>永久停药：</label>
                                            <div class="input-groups" th:with="type=${@dict.getType('sys_gxhpz_yong_jiu_ting_yao_form')}" style="color: red">
                                                <input type="checkbox" id="stoped" name="stoped" class="form-check-radio"  th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"  th:checked="${dict.dictLabel}==${stoped}"   >
                                            </div>
                                            <span class="status"></span>
                                            <span class="status"></span>
                                        </div>

                                    </div>
                                    <div id="qtgyqgy" class="hidden">
                                        <div class="customize-form-group edit">
                                            <label>其他渠道购药：</label>
                                            <div class="input-groups" style="width: 90%" th:with="type=${@dict.getType('sys_gxhpz_othetqd_gy')}">
                                                <input type="radio" id="other_channels"   name="other_channels" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"  th:checked="${dict.dictLabel}==${other_channels}">
                                            </div>
                                            <span class="status"></span>
                                            <span class="status"></span>
                                        </div>
                                    </div>
                                    <div id="ycgyycjy" class="hidden">
                                        <div class="customize-form-group edit">
                                            <label class="is-required">延迟购药(医嘱建议):</label>
                                            <div class="input-groups" style="width: 90%" th:with="type=${@dict.getType('sys_gxhpz_yanchi_gy_ys_jy')}">
                                                <input type="radio" id="delay_purchase_doctor"   name="delay_purchase_doctor" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"  th:checked="${dict.dictLabel}==${delay_purchase_doctor}">
                                            </div>
                                            <span class="status"></span>
                                        </div>
                                    </div>
                                    <div id="ycgyhzyybgf" class="hidden">
                                        <div class="customize-form-group edit">
                                            <label class="is-required">延迟购药(用药不规范):</label>
                                            <div class="input-groups" style="width: 90%" th:with="type=${@dict.getType('sys_gxhpz_yanchi_gyhzyybgf')}">
                                                <input type="radio" id="delayed_purchase_drugs"   name="delayed_purchase_drugs"  class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"  th:checked="${dict.dictLabel}==${delayed_purchase_drugs}">
                                            </div>
                                            <span class="status"></span>
                                        </div>
                                    </div>
                                </div>
                                <div id="tab-no" class="tab-pane active">
                                    <div class="customize-form-group edit">
                                        <label class="is-required" style="margin-bottom: 0px">确诊后首次用药日期：</label>
                                        <div class="input-groups">
                                            <input name="timeFirstDiagnosis" id="timeFirstDiagnosis" placeholder="确诊后首次用药日期" class="time-input time-input2" type="text"  th:value="${timeFirstDiagnosis}" required>
                                        </div>
                                        <span class="status"></span>
                                    </div>
                                </div>
                                <div id="tab-7-14">
                                <div id="tab-7" class="tab-pane active">
                                    <strong> <h4 style="color: #1E9FFF;">| 药物安全性</h4> </strong>
                                    <div class="customize-form-group edit">
                                        <label class="is-required">是否出现不良反应：</label>
                                        <div class="input-groups" th:with="type=${@dict.getType('sys_yes_no')}">
                                            <input type="radio" class="form-check-radio"  th:each="dict : ${type}"  name="is_adverse_reaction" id="is_adverse_reaction" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"   th:checked="${dict.dictLabel}==${is_adverse_reaction}">
                                        </div>
                                        <span class="status"></span>
                                    </div>
                                    <div id="bulfydiv" class="hidden">

                                        <div class="customize-form-group edit">
                                            <label>不良反应时间：</label>
                                            <div class="input-groups" th:with="type=${@dict.getType('sys_yes_no')}">
                                                <input name="adverse_reaction_time" id="adverse_reaction_time" placeholder="不良反应时间" class="time-input time-input2" type="text"  th:value="${adverse_reaction_time}" required>
                                            </div>
                                            <span class="status"></span>
                                        </div>
                                        <div class="customize-form-group edit">
                                            <span class="status"></span>
                                            <div  class="tab-pane fade in active">
                                                <div class="panel-body">
                                                    <div class="customize-search-form">
                                                        <div class="customize-form-group edit">
                                                            <div style="/*display: flex;*/">
                                                                <label style="width: auto;">不良反应症状:</label>
                                                                <button type="button" data-toggle="modal"  class="btn btn-ms btn-primary" data-target="#myModal5">新增</button>
                                                                <table id="byfyTable" style="width: 800px;">
                                                                    <thead>
                                                                    <tr>
                                                                        <th>序号</th>
                                                                        <th>不良反应症状</th>
                                                                        <th>操作</th>
                                                                    </tr>
                                                                    </thead>
                                                                    <tbody id="blfyTableBody">
                                                                    <!-- 表格行将在这里动态添加 -->
                                                                    </tbody>
                                                                </table>
                                                            </div>

                                                            <div class="modal inmodal fade" id="myModal5" tabindex="-1" role="dialog" aria-hidden="true">
                                                                <div class="modal-dialog modal-lg" style="width: 1000px">
                                                                    <div class="modal-content">
                                                                        <div class="modal-header">
                                                                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span>
                                                                            </button>
                                                                            <h4 class="modal-title">不良反应系统</h4>
                                                                            <!--<small class="font-bold">这里可以显示副标题。</small>-->
                                                                        </div>
                                                                        <div class="modal-body">
                                                                            <div id="element1" class="row">
                                                                                <div class="col-sm-2">
                                                                                    <select class="province form-control m-b" data-first-title="选择不良反应">
                                                                                        <option value="">请选择</option>
                                                                                    </select>
                                                                                </div>
                                                                                <div class="col-sm-3">
                                                                                    <select class="city form-control m-b" data-first-title="选择不良反应位置">
                                                                                        <option value="">请选择</option>
                                                                                    </select>
                                                                                </div>
                                                                                <div class="col-sm-7">
                                                                                    <select class="area form-control m-b" data-first-title="选择不良反应数值">
                                                                                        <option value="">请选择</option>
                                                                                    </select>
                                                                                </div>
                                                                            </div>
                                                                        </div>

                                                                        <div class="modal-footer">
                                                                            <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                                                            <button type="button" class="btn btn-primary" data-dismiss="modal" onclick="selectAdverseReactions(0)">保存</button>
                                                                        </div>
                                                                    </div>
                                                                </div>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>

                                        <div class="customize-form-group edit">
                                            <label class="is-required">不良反应处理方式：</label>
                                            <textarea id="tar" name="tar" class="styled-input edit_inputs textareas"
                                                      style="width: auto;height: 140px ;border: 1px solid ;"
                                                      th:text="${tar}" placeholder="请描述不良反应处理方式..." rows="1.9" cols="112" ></textarea>

                                            <span class="status"></span>
                                        </div>

                                        <div class="customize-form-group edit">
                                            <label class="is-required">合并用药是否引起不良反应：</label>
                                            <div class="input-groups" th:with="type=${@dict.getType('sys_select_yes_no')}">
                                                <input type="radio" class="form-check-radio"  th:each="dict : ${type}"  name="combinedMedicationAdverseReaction" id="combinedMedicationAdverseReaction" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"   th:checked="${dict.dictValue}==${combinedMedicationAdverseReaction}">
                                            </div>
                                            <span class="status"></span>
                                        </div>
                                        <div class="hidden" id="hbyysfyiblfy">
                                        <div class="customize-form-group edit">
                                            <label class="is-required">合并用药其他不良反应描述：</label>
                                            <textarea id="combinedMedicationOtherAdverseReactions" name="combinedMedicationOtherAdverseReactions" class="styled-input edit_inputs textareas"
                                                      style="width: auto;height: 140px ;border: 1px solid ;"
                                                      th:text="${combinedMedicationOtherAdverseReactions}" placeholder="请描述合并用药其他不良反应..." rows="1.9" cols="112" ></textarea>

                                            <span class="status"></span>
                                        </div>
                                        <div class="customize-form-group edit">
                                            <label class="is-required" for="returnImgUrl">合并用药其他不良反应图片：</label>
                                            <div class="custom-file-upload">
                                                <input type="file" id="combinedMedicationOtherAdverseReactionsImage" accept=".jpg,.jpeg,.png,.gif">
                                                <label for="combinedMedicationOtherAdverseReactionsImage"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#007bff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus-circle"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line></svg></label>
                                            </div>
                                        </div>
                                        <div class="customize-form-group edit">
                                            <label>合并用药不良反应处理：</label>
                                            <div class="input-groups">
                                                <input name="combinedMedicationOtherAdverseReactionsHandling" id="combinedMedicationOtherAdverseReactionsHandling" placeholder="请输入合并用药不良反应处理" class="styled-input edit_inputs" type="text"  th:value="${combinedMedicationOtherAdverseReactionsHandling}">
                                            </div>
                                            <span class="status"></span>
                                        </div>
                                        </div>
                                    </div>

                                 </div>
                                <div id="tab-8" class="tab-pane active">
                                    <strong> <h4 style="color: #1E9FFF;">| 药物有效性</h4> </strong>
                                    <div class="customize-form-group edit">
                                        <label class="is-required">是否复查：</label>
                                        <div class="input-groups" th:with="type=${@dict.getType('sys_select_yes_no')}">
                                            <input type="radio" class="form-check-radio"  th:each="dict : ${type}"  name="isReview" id="isReview" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"   th:checked="${dict.dictValue}==${isReview}">
                                        </div>
                                        <span class="status"></span>
                                    </div>
                                    <div class="hidden" id="isReviewDiv">
                                        <div class="customize-form-group edit">
                                            <label class="is-required">影像学检查：</label>
                                            <div class="input-groups" th:with="type=${@dict.getType('sys_select_dtp_ysfw_yxxjc')}" >
                                                <input type="checkbox" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"   id="imagingInsuranceType" name="imagingInsuranceType">
                                            </div>
                                            <span class="status"></span>
                                        </div>
                                        <div class="hidden" id="ctradio">
                                            <div class="customize-form-group edit" >
                                                <label>CT：</label>
                                                <div class="input-groups" th:with="type=${@dict.getType('sys_select_dtp_ysfw_yxxjc_next')}">
                                                    <input type="radio" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"  th:checked="${dict.dictValue}==${ctCheck}"  name="ctCheck" id="ctCheck">
                                                </div>
                                                <span class="status"></span>
                                            </div>

                                            <div class="customize-form-group edit">
                                                <label>CT文本：</label>
                                                <div class="input-groups">
                                                    <input name="ctText" id="ctText" placeholder="请输入CT文本" class="styled-input edit_inputs" type="text"  th:value="${ctText}">
                                                </div>
                                                <span class="status"></span>
                                            </div>
                                        </div>
                                        <div class="hidden" id="bcradio">
                                            <div class="customize-form-group edit">
                                                <label>B超：</label>
                                                <div class="input-groups" th:with="type=${@dict.getType('sys_select_dtp_ysfw_yxxjc_next')}">
                                                    <input type="radio" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"  th:checked="${dict.dictValue}==${ultrasoundCheck}"  name="ultrasoundCheck" >
                                                </div>
                                                <span class="status"></span>
                                            </div>

                                            <div class="customize-form-group edit">
                                                <label>B超文本：</label>
                                                <div class="input-groups">
                                                    <input name="ultrasound_text" id="ultrasound_text" placeholder="请输入B超文本" class="styled-input edit_inputs" type="text"  th:value="${ultrasoundText}">
                                                </div>
                                                <span class="status"></span>
                                            </div>
                                        </div>
                                        <div class="hidden" id="hcradio">
                                            <div class="customize-form-group edit">
                                                <label>核磁：</label>
                                                <div class="input-groups" th:with="type=${@dict.getType('sys_select_dtp_ysfw_yxxjc_next')}">
                                                    <input type="radio" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"  th:checked="${dict.dictValue}==${mriCheck}"  name="mriCheck" id="mriCheck">
                                                </div>
                                                <span class="status"></span>
                                            </div>

                                            <div class="customize-form-group edit">
                                                <label>核磁文本：</label>
                                                <div class="input-groups">
                                                    <input name="mriText" id="mriText" placeholder="请输入核磁文本" class="styled-input edit_inputs" type="text"  th:value="${mriText}">
                                                </div>
                                                <span class="status"></span>
                                            </div>
                                        </div>
                                        <div class="hidden" id="qtradio">
                                            <div class="customize-form-group edit">
                                                <label>影像学检查其它：</label>
                                                <div class="input-groups">
                                                    <input name="otherImagingExaminations" id="otherImagingExaminations" placeholder="请输入影像学检查其它" class="styled-input edit_inputs" type="text"  th:value="${otherImagingExaminations}" >
                                                </div>
                                                <span class="status"></span>
                                            </div>
                                        </div>
                                        <div class="customize-form-group edit">
                                            <label  for="imagingExaminationsImage">影像学检查图片：</label>
                                            <div class="custom-file-upload">
                                                <input type="file" id="imagingExaminationsImage" name="imagingExaminationsImage" accept=".jpg,.jpeg,.png,.gif">
                                                <label for="imagingExaminationsImage"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#007bff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus-circle"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line></svg></label>
                                            </div>
                                            <span class="status"></span>
                                        </div>
                                        <div class="customize-form-group edit">
                                            <label  for="tumor_marker_image">肿瘤物标记检查图片：</label>
                                            <div class="custom-file-upload">
                                                <input type="file" id="tumor_marker_image" name="tumor_marker_image" accept=".jpg,.jpeg,.png,.gif">
                                                <label for="tumor_marker_image"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#007bff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus-circle"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line></svg></label>
                                            </div>
                                            <span class="status"></span>
                                        </div>
                                        <div class="customize-form-group edit">
                                            <label class="is-required">肿瘤标记物检查：</label>
                                            <div class="input-groups" style="width: 800px" th:with="type=${@dict.getType('sys_select_dtp_zlbjwjc')}" id="zlbjwjc">
                                                <input type="checkbox" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"    name="tumorMarkerCheck" id="tumorMarkerCheck">
                                            </div>

                                        </div>

                                        <div class="hidden" id="ceaDiv">
                                            <div class="customize-form-group edit">
                                                <label>CEA：</label>
                                                <div class="input-groups">
                                                    <input name="cea" id="cea" placeholder="请输入CEA" class="styled-input edit_inputs" type="text"  th:value="${cea}">
                                                </div>
                                                <span class="status"></span>
                                            </div>
                                        </div>
                                        <div class="hidden" id="afpDiv">
                                            <div class="customize-form-group edit">
                                                <label>AFP：</label>
                                                <div class="input-groups">
                                                    <input name="afp" id="afp" placeholder="请输入AFP" class="styled-input edit_inputs" type="text"  th:value="${afp}">
                                                </div>
                                                <span class="status"></span>
                                            </div>
                                        </div>
                                        <div class="hidden" id="ca199Div">
                                            <div class="customize-form-group edit">
                                                <label>CA-199：</label>
                                                <div class="input-groups">
                                                    <input name="ca199" id="ca199" placeholder="请输入CA-199" class="styled-input edit_inputs" type="text"  th:value="${ca199}">
                                                </div>
                                                <span class="status"></span>
                                            </div>
                                        </div>
                                        <div class="hidden" id="ca125Div">
                                            <div class="customize-form-group edit">
                                                <label>CA125：</label>
                                                <div class="input-groups">
                                                    <input name="ca125" id="ca125" placeholder="请输入CA125" class="styled-input edit_inputs" type="text"  th:value="${ca125}">
                                                </div>
                                                <span class="status"></span>
                                            </div>
                                        </div>
                                        <div class="hidden" id="ca153Div">
                                            <div class="customize-form-group edit">
                                                <label>CA153：</label>
                                                <div class="input-groups">
                                                    <input name="ca153" id="ca153" placeholder="请输入CA153" class="styled-input edit_inputs" type="text"  th:value="${ca153}">
                                                </div>
                                                <span class="status"></span>
                                            </div>
                                        </div>
                                        <div class="hidden" id="hcgDiv">
                                            <div class="customize-form-group edit">
                                                <label>HCG：</label>
                                                <div class="input-groups">
                                                    <input name="hcg" id="hcg" placeholder="请输入HCG" class="styled-input edit_inputs" type="text"  th:value="${hcg}">
                                                </div>
                                                <span class="status"></span>
                                            </div>
                                        </div>
                                        <div class="hidden" id="nseDiv">
                                            <div class="customize-form-group edit">
                                                <label>NSE：</label>
                                                <div class="input-groups">
                                                    <input name="nse" id="nse" placeholder="请输入NSE" class="styled-input edit_inputs" type="text"  th:value="${nse}">
                                                </div>
                                                <span class="status"></span>
                                            </div>
                                        </div>
                                        <div class="hidden" id="cyfra211Div">
                                            <div class="customize-form-group edit">
                                                <label>CYFRA21-1：</label>
                                                <div class="input-groups">
                                                    <input name="cyfra21" id="cyfra21" placeholder="请输入CYFRA21-1" class="styled-input edit_inputs" type="text"  th:value="${cyfra21}">
                                                </div>
                                                <span class="status"></span>
                                            </div>
                                        </div>
                                        <div class="hidden" id="tgDiv">
                                            <div class="customize-form-group edit">
                                                <label>TG：</label>
                                                <div class="input-groups">
                                                    <input name="tg" id="tg" placeholder="请输入TG" class="styled-input edit_inputs" type="text"  th:value="${tg}">
                                                </div>
                                                <span class="status"></span>
                                            </div>
                                        </div>
                                        <div class="hidden" id="psaDiv">
                                            <div class="customize-form-group edit">
                                                <label>PSA：</label>
                                                <div class="input-groups">
                                                    <input name="psa" id="psa" placeholder="请输入PSA" class="styled-input edit_inputs" type="text"  th:value="${psa}">
                                                </div>
                                                <span class="status"></span>
                                            </div>
                                        </div>


                                        <div class="customize-form-group edit">
                                            <label>实验室检查指标：</label>
                                            <textarea id="labTestIndicators" name="labTestIndicators" class="styled-input edit_inputs textareas"
                                                      style="width: auto;height: 140px ;border: 1px solid ;"
                                                      th:text="${labTestIndicators}" placeholder="实验室检查指标..." rows="1.9" cols="112" ></textarea>

                                            <span class="status"></span>
                                        </div>
                                        <div class="customize-form-group edit">
                                            <label>提示</label>
                                            <input  id="tishi" placeholder="可填写中性粒细胞（NEUT）、血小板（PLT）、白蛋白（AIB）、谷丙转氨酶（ALT）、谷草转氨酶（AST）、肌酐（Crea）、总胆红素（T-BIL）" class="styled-input"
                                                   style="border: none" type="text"  value="可填写中性粒细胞（NEUT）、血小板（PLT）、白蛋白（AIB）、谷丙转氨酶（ALT）、谷草转氨酶（AST）、肌酐（Crea）、总胆红素（T-BIL）" readonly>
                                            <span class="status"></span>
                                        </div>
                                        <div class="customize-form-group edit">
                                            <label  for="labTestIndicatorsImage">实验室检查指标图片：</label>
                                            <div class="custom-file-upload">
                                                <input type="file" id="labTestIndicatorsImage" name="labTestIndicatorsImage" accept=".jpg,.jpeg,.png,.gif">
                                                <label for="labTestIndicatorsImage"><svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="#007bff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus-circle"><circle cx="12" cy="12" r="10"></circle><line x1="12" y1="8" x2="12" y2="16"></line><line x1="8" y1="12" x2="16" y2="12"></line></svg></label>
                                            </div>
                                            <span class="status"></span>
                                        </div>

                                    </div>

                                </div>
                                <div id="tab-9" class="tab-pane active">
                                    <strong> <h4 style="color: #1E9FFF;">| 治疗方案</h4> </strong>
                                        <div class="customize-form-group edit">
                                            <label class="is-required">治疗类型：</label>
                                            <div class="input-groups" th:with="type=${@dict.getType('sys_select_dtp_ysfw_treatmenttype')}" >
                                                <input type="checkbox" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"  id="treatmentType" name="treatmentType">
                                            </div>
                                            <span class="status"></span>
                                        </div>
                                    <div class="customize-form-group edit hidden" id="treatmentTypeDiv">
                                        <div style="display: flex;">
                                            <label>用药前治疗方案:</label>
                                            <button type="button"  data-toggle="modal" data-target="#myModal1" class="btn-primarys">+新增</button>
                                            <table id="preMedicationPlanTable" style="width: 500px;">
                                                <thead>
                                                <tr>
                                                    <th>序号</th>
                                                    <th>治疗方案</th>
                                                    <th>治疗时间</th>
                                                    <th>操作</th>
                                                </tr>
                                                </thead>
                                                <tbody id="preMedicationPlanTableBody">

                                                </tbody>
                                            </table>
                                        </div>
                                        <div class="modal inmodal" id="myModal1" tabindex="-1" role="dialog" aria-hidden="true">
                                            <div class="modal-dialog">
                                                <form class="form-horizontal" id="form-yyqzlfa-add">
                                                    <div class="modal-content animated bounceInRight">
                                                        <div class="modal-header">
                                                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span>
                                                            </button>
                                                            <h4 class="modal-title">用药前治疗方案</h4>
                                                        </div>
                                                        <div class="modal-body">
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >治疗时间</label>
                                                                    <input type="text" name="pre_medication_time" placeholder="治疗时间" class="time-input time-input2"  style="width: 200px;" id="pre_medication_time">
                                                                </div>
                                                            </div>
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label>治疗方案</label>
                                                                    <select name="pre_medication_plan" class="styled-input edit_inputs"  style="width: 200px;" th:with="type=${@dict.getType('sys_select_dtp_sfrw_zlfa')}" id="pre_medication_plan">
                                                                        <option value="">请选择治疗方案</option>
                                                                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"
                                                                                ></option>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="modal-footer">
                                                            <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                                            <button type="button" class="btn btn-primary" onclick="saveRow(1)">保存</button>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>

                                    <div class="customize-form-group edit hidden" id="currentTreatmentPlanDiv">
                                        <div style="display: flex;">
                                            <label>目前治疗方案:</label>
                                            <button type="button"  data-toggle="modal" data-target="#myModal2" class="btn-primarys">+新增</button>
                                            <table id="currentTreatmentPlanTable" style="width: 500px;">
                                                <thead>
                                                <tr>
                                                    <th>序号</th>
                                                    <th>治疗方案</th>
                                                    <th>治疗时间</th>
                                                    <th>操作</th>
                                                </tr>
                                                </thead>
                                                <tbody id="currentTreatmentPlanTableBody">

                                                </tbody>
                                            </table>
                                        </div>
                                        <div class="modal inmodal" id="myModal2" tabindex="-1" role="dialog" aria-hidden="true">
                                            <div class="modal-dialog">
                                                <form class="form-horizontal" id="form-mqzlfa-add">
                                                    <div class="modal-content animated bounceInRight">
                                                        <div class="modal-header">
                                                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span>
                                                            </button>
                                                            <h4 class="modal-title">目前治疗方案</h4>
                                                        </div>
                                                        <div class="modal-body">
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >治疗时间</label>
                                                                    <input type="text" name="current_treatment_plan_time" placeholder="治疗时间" class="time-input time-input2"  style="width: 200px;" id="current_treatment_plan_time">
                                                                </div>
                                                            </div>
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label>治疗方案</label>
                                                                    <select name="current_treatment_plan" class="styled-input edit_inputs"  style="width: 200px;" th:with="type=${@dict.getType('sys_select_dtp_sfrw_zlfa')}" id="current_treatment_plan">
                                                                        <option value="">请选择治疗方案</option>
                                                                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"
                                                                               ></option>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="modal-footer">
                                                            <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                                            <button type="button" class="btn btn-primary" onclick="saveRow(2)">保存</button>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="customize-form-group edit hidden" id="postProgressionTreatmentPlanDiv">
                                        <div style="display: flex;">
                                            <label>进展后治疗方案:</label>
                                            <button type="button"  data-toggle="modal" data-target="#myModal3" class="btn-primarys">+新增</button>
                                            <table id="postProgressionTreatmentPlanTable" style="width: 500px;">
                                                <thead>
                                                <tr>
                                                    <th>序号</th>
                                                    <th>治疗方案</th>
                                                    <th>治疗时间</th>
                                                    <th>操作</th>
                                                </tr>
                                                </thead>
                                                <tbody id="postProgressionTreatmentPlanTableBody">

                                                </tbody>
                                            </table>
                                        </div>
                                        <div class="modal inmodal" id="myModal3" tabindex="-1" role="dialog" aria-hidden="true">
                                            <div class="modal-dialog">
                                                <form class="form-horizontal" id="form-jzhzlfa-add">
                                                    <div class="modal-content animated bounceInRight">
                                                        <div class="modal-header">
                                                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span>
                                                            </button>
                                                            <h4 class="modal-title">进展后治疗方案</h4>
                                                        </div>
                                                        <div class="modal-body">
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >治疗时间</label>
                                                                    <input type="text" name="post_progression_treatment_time" placeholder="治疗时间" class="time-input time-input2"  style="width: 200px;" id="post_progression_treatment_time">
                                                                </div>
                                                            </div>
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label>治疗方案</label>
                                                                    <select name="post_progression_treatment_plan" class="styled-input edit_inputs"  style="width: 200px;" th:with="type=${@dict.getType('sys_select_dtp_sfrw_zlfa')}" id="post_progression_treatment_plan">
                                                                        <option value="">请选择治疗方案</option>
                                                                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"
                                                                                ></option>
                                                                    </select>
                                                                </div>
                                                            </div>
                                                        </div>
                                                        <div class="modal-footer">
                                                            <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                                            <button type="button" class="btn btn-primary" onclick="saveRow(3)">保存</button>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>

                                </div>
                                <div id="tab-10" class="tab-pane active">
                                    <strong> <h4 style="color: #1E9FFF;">| 适宜性评估</h4> </strong>
                                    <div class="customize-form-group edit">
                                        <label class="is-required">有无药品适应症：</label>
                                        <div class="input-groups" th:with="type=${@dict.getType('sys_select_yes_no')}">
                                            <input type="radio" class="form-check-radio"  th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"   th:checked="${dict.dictValue}==${hasMedicationIndications}" name="hasMedicationIndications" id="hasMedicationIndications">
                                        </div>
                                        <span class="status"></span>
                                    </div>
                                    <span class="status"></span>
                                    <span class="status"></span>
                                    <div class="customize-form-group edit">
                                        <label  >药物对该疾病是否有效：</label>
                                        <div class="input-groups" th:with="type=${@dict.getType('sys_gxhpz_ysfw_ywdgjbsfyx')}">
                                            <input type="radio" class="form-check-radio"  th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"   th:checked="${dict.dictValue}==${drugEffectiveness}" name="drugEffectiveness" id="drugEffectiveness">
                                        </div>
                                        <span class="status"></span>
                                    </div>

                                    <div class="customize-form-group edit font form-groupBottom">
                                        <label class="is-required form-groupBottom">药物间是否存在临床相互作用：</label>
                                        <div class="input-groups form-groupBottom" th:with="type=${@dict.getType('sys_select_yes_no')}">
                                            <input type="radio" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"  th:checked="${dict.dictValue}==${clinicalInteraction}"  name="clinicalInteraction" id="clinicalInteraction">
                                        </div>
                                        <span class="status"></span>
                                    </div>
                                    <span class="status"></span>
                                    <span class="status"></span>
                                    <div class="hidden form-groupBottom" id="clinicalInteractionDiv">
                                        <div class="customize-form-group edit form-groupBottom">
                                            <label class="is-required form-groupBottom font">请描述临床相互作用：</label>

                                            <textarea id="clinicalInteractionDescription" name="clinicalInteractionDescription" class="styled-input font edit_inputs textareas"
                                                      style="width: auto;height: 140px ;border: 1px solid ;"
                                                      th:text="${clinicalInteractionDescription}" placeholder="请描述临床相互作用..." rows="1.9" cols="112" ></textarea>

                                            <span class="status"></span>
                                        </div>
                                    </div>
                                    <div class="customize-form-group edit">
                                        <label>是否有不必要重复用药：</label>
                                        <div class="input-groups" th:with="type=${@dict.getType('sys_select_yes_no')}">
                                            <input type="radio" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"  th:checked="${dict.dictValue}==${unnecessaryRepeatedMedication}"  name="unnecessaryRepeatedMedication">
                                        </div>
                                        <span class="status"></span>
                                        <span class="status"></span>
                                    </div>
                                    <span class="status"></span>
                                    <span class="status"></span>
                                    <div class="form-groupBottom hidden" id="unnecessaryRepeatedMedicationDiv">
                                        <div class="form-groupBottom customize-form-group edit">
                                            <label class="form-groupBottom is-required">重复用药使用日期：</label>
                                            <div class="form-groupBottom input-groups select-time">
                                                <input name="repeatedMedicationFirstUseDate" id="repeatedMedicationFirstUseDate" placeholder="重复用药首次使用日期" class="time-input-new styled-input" type="text"  th:value="${repeatedMedicationFirstUseDate}">
                                                <span class="status"></span>
                                                <span class="status"></span>
                                            </div>

                                        </div>
                                        <span class="status"></span>
                                        <span class="status"></span>
                                        <div class="form-groupBottom customize-form-group edit">
                                            <label class="is-required">请描述不必要重复用药：</label>
                                            <textarea id="unnecessaryRepeatedMedicationDescription" name="unnecessaryRepeatedMedicationDescription" class="styled-input edit_inputs textareas"
                                                      style="width: auto;height: 140px ;border: 1px solid ;"
                                                      th:text="${unnecessaryRepeatedMedicationDescription}" placeholder="请描述不必要重复用药..." rows="1.9" cols="112" ></textarea>

                                            <span class="status"></span>
                                            <span class="status"></span>
                                        </div>
                                    </div>

                                    <div class="form-groupBottom customize-form-group edit">
                                        <label>是否出现用药错误：</label>
                                        <div class="input-groups" th:with="type=${@dict.getType('sys_select_yes_no')}">
                                            <input type="radio" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"  th:checked="${dict.dictValue}==${medicationError}"  name="medicationError">
                                        </div>
                                        <span class="status"></span>
                                        <span class="status"></span>
                                    </div>
                                    <div class="form-groupBottom hidden" id="medicationErrorDiv">
                                        <div class="form-groupBottom customize-form-group edit">
                                            <label class="form-groupBottom is-required">用药错误出现时间：</label>
                                            <div class="form-groupBottom input-groups select-time">
                                                <input name="medicationErrorTime" placeholder="用药错误出现时间" class="time-input-new styled-input" type="text"  th:value="${medicationErrorTime}" id="medicationErrorTime">
                                            </div>
                                            <span class="status"></span>
                                        </div>
                                        <div class="form-groupBottom customize-form-group edit">
                                            <label class="is-required">请描述用药错误：</label>
                                            <textarea id="medicationErrorDescription" name="medicationErrorDescription" class="styled-input edit_inputs textareas"
                                                      style="width: auto;height: 140px ;border: 1px solid ;"
                                                      th:text="${medicationErrorDescription}" placeholder="请描述用药错误..." rows="1.9" cols="112" ></textarea>
                                            <span class="status"></span>
                                            <span class="status"></span>
                                        </div>
                                    </div>
                                </div>
                                <div id="tab-11" class="tab-pane active">
                                    <strong> <h4 style="color: #1E9FFF;">| 用药记录</h4> </strong>
                                    <div class="form-groupBottom customize-form-group edit">
                                        <div style="display: flex;">
                                            <label>用药记录:</label>
                                            <button type="button"  data-toggle="modal" data-target="#myModal4" class="btn-primarys">+新增</button>
                                            <table id="medicationRecordTable" style="width: 800px;">
                                                <thead>
                                                <tr>
                                                    <th>序号</th>
                                                    <th>药品名称</th>
                                                    <th>剂量</th>
                                                    <th>用药频率</th>
                                                    <th>开始用药时间</th>
                                                    <th>停药时间</th>
                                                    <th>最后一次用药时间</th>
                                                    <th>注意事项</th>
                                                    <th>操作</th>
                                                </tr>
                                                </thead>
                                                <tbody id="medicationRecordTableBody">

                                                </tbody>
                                            </table>
                                        </div>
                                        <div class="modal inmodal" id="myModal4" tabindex="-1" role="dialog" aria-hidden="true">
                                            <div class="modal-dialog">
                                                <form class="form-horizontal" id="form-yyjl-add">
                                                    <div class="modal-content animated bounceInRight">
                                                        <div class="modal-header">
                                                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span>
                                                            </button>
                                                            <h4 class="modal-title">用药记录</h4>
                                                        </div>
                                                        <div class="modal-body">
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >名称</label>
                                                                    <input type="text" name="durgName" placeholder="请输入药品名称" class="styled-input edit_inputs"  style="width: 200px;" id="durgName">
                                                                </div>
                                                            </div>
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >剂量</label>
                                                                    <input type="text" name="jiliang" placeholder="请输入剂量" class="styled-input edit_inputs"  style="width: 200px;" id="jiliang">
                                                                </div>
                                                            </div>

                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >开始用药时间</label>
                                                                    <input type="text" name="startyyTime" placeholder="请选择开始用药时间" class="time-input time-input2"  style="width: 200px;" id="startyyTime">
                                                                </div>
                                                            </div>
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >停药药时间</label>
                                                                    <input type="text" name="tyTime" placeholder="请选择停药药时间" class="time-input time-input2"  style="width: 200px;" id="tyTime">
                                                                </div>
                                                            </div>
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >最后一次用药时间</label>
                                                                    <input type="text" name="lastsyTime" placeholder="请选择最后一次用药时间" class="time-input time-input2"  style="width: 200px;" id="lastsyTime">
                                                                </div>
                                                            </div>
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >使用频率</label>
                                                                    <input type="text" name="shiypv" placeholder="请输入使用频率" class="styled-input edit_inputs"  style="width: 200px;" id="shiypv">
                                                                </div>
                                                            </div>
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >注意事项</label>
                                                                    <input type="text" name="zhuyishix" placeholder="请输入注意事项" class="styled-input edit_inputs"  style="width: 200px;" id="zhuyishix">
                                                                </div>
                                                            </div>

                                                        </div>
                                                        <div class="modal-footer">
                                                            <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                                            <button type="button" class="btn btn-primary" onclick="saveRow(4)">保存</button>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="customize-form-group edit">
                                        <div style="display: flex;">
                                            <label>合并用药记录:</label>
                                            <button type="button"  data-toggle="modal" data-target="#myModal6" class="btn-primarys">+新增</button>
                                            <table id="combinedMedicationRecordTable" style="width: 800px;">
                                                <thead>
                                                <tr>
                                                    <th>序号</th>
                                                    <th>药品名称</th>
                                                    <th>剂量</th>
                                                    <th>用药频率</th>
                                                    <th>开始用药时间</th>
                                                    <th>停药时间</th>
                                                    <th>最后一次用药时间</th>
                                                    <th>注意事项</th>
                                                    <th>操作</th>
                                                </tr>
                                                </thead>
                                                <tbody id="combinedMedicationRecordTableBody">

                                                </tbody>
                                            </table>
                                        </div>
                                        <div class="modal inmodal" id="myModal6" tabindex="-1" role="dialog" aria-hidden="true">
                                            <div class="modal-dialog">
                                                <form class="form-horizontal" id="form-hbyyjl-add">
                                                    <div class="modal-content animated bounceInRight">
                                                        <div class="modal-header">
                                                            <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">关闭</span>
                                                            </button>
                                                            <h4 class="modal-title">合并用药记录</h4>
                                                        </div>
                                                        <div class="modal-body">
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >名称</label>
                                                                    <input type="text" name="hbdurgName" placeholder="请输入药品名称" class="styled-input edit_inputs"  style="width: 200px;" id="hbdurgName">
                                                                </div>
                                                            </div>
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >剂量</label>
                                                                    <input type="text" name="hbjiliang" placeholder="请输入剂量" class="styled-input edit_inputs"  style="width: 200px;" id="hbjiliang">
                                                                </div>
                                                            </div>

                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >开始用药时间</label>
                                                                    <input type="text" name="hbstartyyTime" placeholder="请选择开始用药时间" class="time-input time-input2"  style="width: 200px;" id="hbstartyyTime">
                                                                </div>
                                                            </div>
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >停药药时间</label>
                                                                    <input type="text" name="hbtyTime" placeholder="请选择停药药时间" class="time-input time-input2"  style="width: 200px;" id="hbtyTime">
                                                                </div>
                                                            </div>
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >最后一次用药时间</label>
                                                                    <input type="text" name="hblastsyTime" placeholder="请选择最后一次用药时间" class="time-input time-input2"  style="width: 200px;" id="hblastsyTime">
                                                                </div>
                                                            </div>
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >使用频率</label>
                                                                    <input type="text" name="hbshiypv" placeholder="请输入使用频率" class="styled-input edit_inputs"  style="width: 200px;" id="hbshiypv">
                                                                </div>
                                                            </div>
                                                            <div class="customize-search-form">
                                                                <div class="customize-form-group edit">
                                                                    <label >注意事项</label>
                                                                    <input type="text" name="hbzhuyishix" placeholder="请输入注意事项" class="styled-input edit_inputs"  style="width: 200px;" id="hbzhuyishix">
                                                                </div>
                                                            </div>

                                                        </div>
                                                        <div class="modal-footer">
                                                            <button type="button" class="btn btn-white" data-dismiss="modal">关闭</button>
                                                            <button type="button" class="btn btn-primary" onclick="saveRow(5)">保存</button>
                                                        </div>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <div id="tab-12" class="tab-pane active">
                                    <strong> <h4 style="color: #1E9FFF;">| 量表测评</h4> </strong>
                                    <div class="customize-form-group edit">
                                        <label >疼痛标准评分NRS：</label>
                                        <div class="input-groups" th:with="type=${@dict.getType('sys_select_dtp_ysfw_nrs')}">
                                            <input type="radio" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"  th:checked="${dict.dictValue}==${painNrsScore}"  name="painNrsScore" id="painNrsScore">
                                        </div>
                                        <span class="status"></span>
                                    </div>
                                    <div class="customize-form-group form-groupBottom edit">
                                        <label>体力状况评分：</label>
                                        <select name="physicalConditionScore"  style="width: 600px" class="select-input" th:with="type=${@dict.getType('sys_gxhpz_ysfw_tlzkpf')}">
                                            <option value="">请选择</option>
                                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"
                                                    th:selected="${dict.dictValue}==${physicalConditionScore}"></option>
                                        </select>
                                        <span class="status"></span>
                                    </div>

                                </div>
                                <div id="tab-13" class="tab-pane active">
                                    <strong> <h4 style="color: #1E9FFF;">| 患者咨询</h4> </strong>
                                    <div class="customize-form-group edit">
                                        <label>本次回访是否咨询：</label>
                                        <div class="input-groups" th:with="type=${@dict.getType('sys_select_yes_no')}">
                                            <input type="radio" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"  th:checked="${dict.dictValue}==${isConsultation}"  name="isConsultation">
                                        </div>
                                        <span class="status"></span>
                                    </div>
                                    <div class="hidden" id="isConsultationDiv">
                                        <div class="form-groupBottom customize-form-group edit">
                                            <label class="is-required">咨询问题类型：</label>
                                            <select name="consultationType" style="width: 450px" class="select-input" th:with="type=${@dict.getType('sys_gxhpz_ysfw_zxwtlx')}">
                                                <option value="">请选择</option>
                                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"
                                                        th:selected="${dict.dictLabel}==${consultationType}"></option>
                                            </select>
                                            <span class="status"></span>
                                        </div>
                                        <div class="form-groupBottom customize-form-group edit">
                                            <label>具体问题：</label>
                                            <textarea id="specificQuestion" name="specificQuestion" class="styled-input edit_inputs textareas"
                                                      style="width: auto;height: 140px ;border: 1px solid ;"
                                                      th:text="${specificQuestion}" placeholder="具体问题..." rows="1.9" cols="112" ></textarea>
                                            <span class="status"></span>
                                        </div>
                                        <div class="form-groupBottom customize-form-group edit">
                                            <label>药师解答：</label>
                                            <textarea id="pharmacistResponse" name="pharmacistResponse" class="styled-input edit_inputs textareas"
                                                      style="width: auto;height: 140px ;border: 1px solid ;"
                                                      th:text="${pharmacistResponse}" placeholder="1-未按随访进度联系上 2-未按时取药 3-减量或停药 4-不良反应不能耐受 5-医生说要调整治疗方案 6-挂不到医生床位/转院 7-医保不够，经济压力 8-情绪不好，生活压力 9-其他" rows="1.9" cols="112" ></textarea>
                                            <span class="status"></span>
                                        </div>
                                    </div>
                                </div>
                                <div id="tab-14" class="tab-pane active">
                                <strong> <h4 style="color: #1E9FFF;">| 其他</h4> </strong>
                                    <div class="form-groupBottom customize-form-group edit">
                                        <label>患者病情评估：</label>
                                        <select name="patientConditionAssessment" style="width: 450px" class="select-input" th:with="type=${@dict.getType('sys_gxhpz_ysfw_hzbqpg')}">
                                            <option value="">请选择</option>
                                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"
                                                    th:selected="${dict.dictLabel}==${patientConditionAssessment}"></option>
                                        </select>
                                        <span class="status"></span>
                                    </div>
                                    <div class="form-groupBottom customize-form-group edit">
                                        <label class="form-groupBottom">共建项目描述：</label>
                                        <textarea id="projectDescription" name="projectDescription" class="styled-input edit_inputs textareas"
                                                  style="width: auto;height: 140px ;border: 1px solid ;"
                                                  th:text="${projectDescription}" placeholder="请输入共建项目描述" rows="1.9" cols="112" ></textarea>
                                        <span class="status"></span>
                                    </div>
                                </div>
                                </div>
                            </div>
                        </div>
             </div>
            <div class="ibox-content" style="background-color: #f5f3f3;">
                <div class="ibox-title2">
                    <div class="task-info">
                        <h4>下次随访时间
                            <input name="next_follow_time"  id="next_follow_time" placeholder="下次随访时间" class="time-input-new styled-input" type="text"  th:value="${bc_next_follow_time}"/>
                        </h4>
                    </div>
                    <div class="task-details">
                        <!--                        <h4> <span>间隔本次任务：<span id="interval_this_time" style="color: #1a7bb9;" th:text="${interval_this_time}"></span >天</span></h4>-->
                        <span class="status">&nbsp;&nbsp;&nbsp;&nbsp;</span>
                        <h4> <span>下次任务主题：<span style="color: #1a7bb9;">
                                    <select name="next_taskTheme" class="styled-input" th:with="type=${@dict.getType('sys_select_dtp_sfrw_rwzt')}">
                                      <option value="">请选择</option>
                                      <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}" th:selected="${dict.dictLabel}==${bc_next_taskTheme}"></option>
                                    </select>
                                </span>
                                </span></h4>
                    </div>
                    <div class="task-buttons">
                        <div class="ibox-title2">
                            <button type="button" class="btn btn-warning" style="background-color: #f56666;" onclick="closeItem()">关闭</button>
                            <div class="task-buttons">
                                <button type="button" class="btn btn-primary" onclick="submitHandler()">保 存</button>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            </div>
        </form>
    </div>
</div>
</div>

<th:block th:include="include :: footer" />
<th:block th:include="include :: select2-js" />
<th:block th:include="include :: jquery-cxselect-js" />
<th:block th:include="include :: layout-latest-js" />
<th:block th:include="include :: bootstrap-table-fixed-columns-js" />
<th:block th:include="include :: ztree-js" />
<th:block th:include="include :: bootstrap-table-editable-js" />
<th:block th:include="include :: select2-css" />
<th:block th:include="include :: bootstrap-select-css" />
</body>
<th:block th:include="include :: bootstrap-select-js" />
<th:block th:include="include :: select2-css" />
</html>

<script th:inline="javascript">
    var formSubmitted = true;
    var prefix = ctx + "dtp/pmService";
    var prefix_task = ctx + "task/followTask";
    var blfyindex = 0;
    var closePlanFlag;
    //购药记录
    var recordsData;
    // 回显数据随访计划
    var listPlan1;
    var listPlan2;
    // 回显数据随访任务
    var listTask1;
    var listTask2;
    var pcTypes = [];
    var dosageFrequencyOptions;
    var dosageFrequencyLookup = {};
    var planId;
    var mdmCode


    var preMedicationPlans = [];
    var currentTreatmentPlans = [];
    var postProgressionTreatmentPlans = [];
    var medicationRecords = [];
    var combinedMedicationRecords = [];
    var good_response_symptom_ids = [];

    function submitHandler() {
        var selectedValue = $('input[name="returnMethod"]:checked').val();
        if (!selectedValue) {
            $.modal.alertWarning('请选择回访方式！');
            return;
        }
        if (selectedValue === '微信' && !$('#returnImgUrl')[0].files.length) {
            $.modal.alertWarning('微信回访时，回访图片为必填项！');
            return;
        }
        if (selectedValue === '面访' && !$('#InterviewRecord').val()) {
            $.modal.alertWarning('面访时，面访记录为必填项！');
            return;
        }
        var iscoordinate = $('input[name="iscoordinate"]:checked').val();//是否配合
        if (!iscoordinate) {
            $.modal.alertWarning('请选择是否配合！');
            return;
        }
        var returnObject = $("#form-followUp-edit3").serializeArray().find(item => item.name === 'returnObject');
        if (returnObject.value === '') {
            $.modal.alertWarning("请选择回访对象");
            return;
        }

        //var data = $("#form-followUp-edit3").serializeArray();
        var patientId = $("#patientId").val();
        var id = $("#id").val();
        console.log("id=", id);
        var planId = $("#planId_cg").val();

        // data.push({name:"patientId",value:patientId});
        // data.push({name:"id",value:id});
        // data.push({name:"planId",value:planId});

        var is_adverse_reaction = $('input[name="is_adverse_reaction"]:checked').val();
        if (!is_adverse_reaction) {
            $.modal.alertWarning('请选择是否出现不良反应！');
            return;
        }
        var filteredData = []
        debugger
        // 获取所有 name 为 'treatmentType' 的复选框
        var tumorMarkerCheck = document.querySelectorAll('input[name="tumorMarkerCheck"]:checked');
        // 收集选中的复选框的值
        var tumorMarkerCheckList = [];
        tumorMarkerCheck.forEach(function(checkbox) {
            tumorMarkerCheckList.push(checkbox.value);
        });
        filteredData.push({name: "tumorMarkerCheckList", value: JSON.stringify(tumorMarkerCheckList)});

        var treatmentType = document.querySelectorAll('input[name="treatmentType"]:checked');
        // 收集选中的复选框的值
        var treatmentTypeList = [];
        treatmentType.forEach(function(checkbox) {
            treatmentTypeList.push(checkbox.value);
        });
        filteredData.push({name: "treatmentTypeList", value: JSON.stringify(treatmentTypeList)});
        var imagingInsuranceType = document.querySelectorAll('input[name="imagingInsuranceType"]:checked');
        // 收集选中的复选框的值
        var imagingInsuranceTypeList = [];
        imagingInsuranceType.forEach(function(checkbox) {
            imagingInsuranceTypeList.push(checkbox.value);
        });
        filteredData.push({name: "imagingInsuranceTypeList", value: JSON.stringify(imagingInsuranceTypeList)});
        // 获取表单数据并过滤
        var formData = $("#form-followUp-edit3").serializeArray();
        $.each(formData, function (index, field) {
            var element = $('#' + field.name);

            // 检查元素本身是否隐藏或其祖先元素是否隐藏
            if (element.closest(':hidden').length === 0 && field.value !== '') {
                filteredData.push(field);
            }
        });

        console.log(filteredData); // 输出过滤后的数据
        if (is_adverse_reaction === '是') {
            var adverse_reaction_time = $("#form-followUp-edit3").serializeArray().find(item => item.name === 'adverse_reaction_time');
            if (adverse_reaction_time.value === '') {
                $.modal.alertWarning("请选择是否出现不良反应");
                return;
            }


            const blfyTableBody = document.getElementById('blfyTableBody');
            const rows2 = blfyTableBody.getElementsByTagName('tr');
            if (rows2.length > 0) {
                const rowsbyfys = [];//不良反应table
                $('#blfyTableBody tr').each(function () {
                    const row = {
                        id: $("#id").val(),
                        byfyData: $(this).find('td:eq(1)').text(),
                    };
                    rowsbyfys.push(row);
                });
                filteredData.push({name: "good_response_symptom_id", value: JSON.stringify(rowsbyfys)})
            }


        }
        var pre_medication_plan = extractTableData('preMedicationPlanTable');//用药前治疗方案
        var current_treatment_plan = extractTableData('currentTreatmentPlanTable');//目前治疗方案
        var post_progression_treatment_plan = extractTableData('postProgressionTreatmentPlanTable');//进展后治疗方案
        var medication_record = extractTableData('medicationRecordTable');//用药记录
        var combined_medication_record = extractTableData('combinedMedicationRecordTable');//合并用药记录

        // 将合并后的数据push到filteredData
        filteredData.push({name: "pre_medication_plan", value: JSON.stringify(pre_medication_plan)});
        filteredData.push({name: "current_treatment_plan", value: JSON.stringify(current_treatment_plan)});
        filteredData.push({
            name: "post_progression_treatment_plan",
            value: JSON.stringify(post_progression_treatment_plan)
        });
        filteredData.push({name: "medication_record", value: JSON.stringify(medication_record)});
        filteredData.push({name: "combined_medication_record", value: JSON.stringify(combined_medication_record)});
        var defaultFormData = $("#form-defaultValue").serializeArray();

        // 合并两个数据集 到这里开始写后端接口了
        filteredData = filteredData.concat(defaultFormData);
        $.operate.saveTab(prefix_task + "/followTaskEdit", filteredData);

    }

    function extractTableData(tableId) {

        const dataRows = [];
        if (tableId == 'preMedicationPlanTable') {
            const tableBody = document.getElementById(tableId + 'Body');
            if (tableBody) {
                const rows = tableBody.getElementsByTagName('tr');
                if (rows.length > 0) {
                    const rowsbyfys = [];
                    $('#preMedicationPlanTableBody tr').each(function () {
                        const row = {
                            taskId: $("#id").val(),
                            id: $(this).find('td:eq(0)').text(),
                            pre_medication_plan: $(this).find('td:eq(1)').text(),
                            pre_medication_plan_time: $(this).find('td:eq(2)').text(),

                        };
                        dataRows.push(row);
                    });
                }
            }
        }
        if (tableId == 'currentTreatmentPlanTable') {

            const tableBody = document.getElementById(tableId + 'Body');
            if (tableBody) {
                const rows = tableBody.getElementsByTagName('tr');
                if (rows.length > 0) {
                    $('#currentTreatmentPlanTableBody tr').each(function () {
                        const row = {
                            taskId: $("#id").val(),
                            id: $(this).find('td:eq(0)').text(),
                            current_treatment_plan: $(this).find('td:eq(1)').text(),
                            current_treatment_plan_time: $(this).find('td:eq(2)').text(),

                        };
                        dataRows.push(row);
                    });
                }
            }

        }
        if (tableId == 'postProgressionTreatmentPlanTable') {

            const tableBody = document.getElementById(tableId + 'Body');
            if (tableBody) {
                const rows = tableBody.getElementsByTagName('tr');
                if (rows.length > 0) {
                    $('#postProgressionTreatmentPlanTableBody tr').each(function () {
                        const row = {
                            taskId: $("#id").val(),
                            id: $(this).find('td:eq(0)').text(),
                            post_progression_treatment_plan: $(this).find('td:eq(1)').text(),
                            post_progression_treatment_time: $(this).find('td:eq(2)').text(),

                        };
                        dataRows.push(row);
                    });
                }
            }
        }
        if (tableId == 'medicationRecordTable') {

            const tableBody = document.getElementById(tableId + 'Body');
            if (tableBody) {
                const rows = tableBody.getElementsByTagName('tr');
                if (rows.length > 0) {
                    $('#medicationRecordTableBody tr').each(function () {
                        const row = {
                            taskId: $("#id").val(),
                            id: $(this).find('td:eq(0)').text(),
                            durgName: $(this).find('td:eq(1)').text(),
                            jiliang: $(this).find('td:eq(2)').text(),
                            startyyTime: $(this).find('td:eq(3)').text(),
                            tyTime: $(this).find('td:eq(4)').text(),
                            lastsyTime: $(this).find('td:eq(5)').text(),
                            shiypv: $(this).find('td:eq(6)').text(),
                            zhuyishix: $(this).find('td:eq(7)').text(),
                        };
                        dataRows.push(row);
                    });
                }
            }

        }
        if (tableId == 'combinedMedicationRecordTable') {
            const tableBody = document.getElementById(tableId + 'Body');
            if (tableBody) {
                const rows = tableBody.getElementsByTagName('tr');
                if (rows.length > 0) {
                    $('#combinedMedicationRecordTableBody tr').each(function () {
                        const row = {
                            taskId: $("#id").val(),
                            id: $(this).find('td:eq(0)').text(),
                            hbdurgName: $(this).find('td:eq(1)').text(),
                            hbjiliang: $(this).find('td:eq(2)').text(),
                            hbstartyyTime: $(this).find('td:eq(3)').text(),
                            hbtyTime: $(this).find('td:eq(4)').text(),
                            hbhblastsyTime: $(this).find('td:eq(5)').text(),
                            hbshiypv: $(this).find('td:eq(6)').text(),
                            hbzhuyishix: $(this).find('td:eq(7)').text(),
                        };
                        dataRows.push(row);
                    });
                }
            }

        }

        return dataRows;
    }

    function deleteRow(button) {
        const row = button.parentNode.parentNode;
        row.remove();
        updateIndices(); // 删除后更新所有行的序号
    }

    // 更新所有行的序号
    function updateIndices(value) {
        if (value == 0) {
            $('#blfyTableBody tr').each(function (index) {
                $(this).find('td:first-child').text(index + 1); // 设置序号为当前索引加1
            });
        }
        if (value == 1) {
            $('#preMedicationPlanTableBody tr').each(function (index) {
                $(this).find('td:first-child').text(index + 1); // 设置序号为当前索引加1
            });
        }
        if (value == 2) {
            $('#currentTreatmentPlanTableBody tr').each(function (index) {
                $(this).find('td:first-child').text(index + 1); // 设置序号为当前索引加1
            });
        }
        if (value == 3) {
            $('#postProgressionTreatmentPlanTableBody tr').each(function (index) {
                $(this).find('td:first-child').text(index + 1); // 设置序号为当前索引加1
            });
        }
        if (value == 4) {
            $('#medicationRecordTableBody tr').each(function (index) {
                $(this).find('td:first-child').text(index + 1); // 设置序号为当前索引加1
            });
        }
        if (value == 5) {
            $('#combinedMedicationRecordTableBody tr').each(function (index) {
                $(this).find('td:first-child').text(index + 1); // 设置序号为当前索引加1
            });
        }

    }

    function selectAdverseReactions(value) {

        var province = $('.province').val();
        var city = $('.city').val();
        var area = $('.area').val();
        $('.province, .city, .area').val('');

        // 打印不良选择的不良反应
        console.log('Selected: ' + province + ', ' + city + ', ' + area);
        var row = '<tr>' +
            '<td></td>' +
            '<td>' + province + ', ' + city + ', ' + area + '</td>' +
            '<td><button class="btn-danger" onclick="deleteRow(this)">删除</button></td>' +
            '</tr>';
        $('#blfyTableBody').append(row);
        blfyindex++; // 增加索引
        updateIndices(0); // 添加后更新所有行的序号
    };

    function saveRow(button) {
        if (button == 1) {
            // 获取表单数据
            var pre_medication_time = document.getElementById('pre_medication_time').value;
            var pre_medication_plan = document.getElementById('pre_medication_plan').value;

            // 检查数据是否为空
            if (!pre_medication_time || !pre_medication_plan) {
                $.modal.alertWarning('请填写方案信息！');
                return;
            }
            var row = '<tr>' +
                '<td></td>' +
                '<td>' + pre_medication_plan + '</td>' +
                '<td>' + pre_medication_time + '</td>' +
                '<td><button class="btn-danger" onclick="deleteRow(this)">删除</button></td>' +
                '</tr>';
            $('#preMedicationPlanTableBody').append(row);
            blfyindex++; // 增加索引
            updateIndices(1); // 添加后更新所有行的序号
            // 清空表单输入框
            document.getElementById('pre_medication_time').value = '';
            document.getElementById('pre_medication_plan').selectedIndex = 0;
            // 关闭模态框 currentTreatmentPlanTableBody postProgressionTreatmentPlanTableBody
            $('#myModal1').modal('hide');
        }
        if (button == 2) {
            // 获取表单数据
            var current_treatment_plan_time = document.getElementById('current_treatment_plan_time').value;
            var current_treatment_plan = document.getElementById('current_treatment_plan').value;

            // 检查数据是否为空
            if (!current_treatment_plan || !current_treatment_plan_time) {
                $.modal.alertWarning('请填写方案信息！');
                return;
            }
            var row = '<tr>' +
                '<td></td>' +
                '<td>' + current_treatment_plan + '</td>' +
                '<td>' + current_treatment_plan_time + '</td>' +
                '<td><button class="btn-danger" onclick="deleteRow(this)">删除</button></td>' +
                '</tr>';
            $('#currentTreatmentPlanTableBody').append(row);
            blfyindex++; // 增加索引
            updateIndices(2); // 添加后更新所有行的序号
            // 清空表单输入框
            $("#form-mqzlfa-add")[0].reset();
            //document.getElementById('current_treatment_plan_time').value = '';
            //document.getElementById('current_treatment_plan').selectedIndex = 0;
            // 关闭模态框
            $('#myModal2').modal('hide');
        }
        if (button == 3) {
            // 获取表单数据
            var post_progression_treatment_time = document.getElementById('post_progression_treatment_time').value;
            var post_progression_treatment_plan = document.getElementById('post_progression_treatment_plan').value;

            // 检查数据是否为空
            if (!post_progression_treatment_time || !post_progression_treatment_plan) {
                $.modal.alertWarning('请填写方案信息！');
                return;
            }
            var row = '<tr>' +
                '<td></td>' +
                '<td>' + post_progression_treatment_plan + '</td>' +
                '<td>' + post_progression_treatment_time + '</td>' +
                '<td><button class="btn-danger" onclick="deleteRow(this)">删除</button></td>' +
                '</tr>';
            $('#postProgressionTreatmentPlanTableBody').append(row);
            blfyindex++; // 增加索引
            updateIndices(3); // 添加后更新所有行的序号
            // 清空表单输入框
            $("#form-jzhzlfa-add")[0].reset();
            document.getElementById('post_progression_treatment_time').value = '';
            document.getElementById('post_progression_treatment_plan').selectedIndex = 0;
            // 关闭模态框 currentTreatmentPlanTableBody postProgressionTreatmentPlanTableBody
            $('#myModal3').modal('hide');
        }
        if (button == 4) {
            // 获取表单数据
            var durgName = document.getElementById('durgName').value;
            var jiliang = document.getElementById('jiliang').value;
            var startyyTime = document.getElementById('startyyTime').value;
            var tyTime = document.getElementById('tyTime').value;
            var lastsyTime = document.getElementById('lastsyTime').value;
            var shiypv = document.getElementById('shiypv').value;
            var zhuyishix = document.getElementById('zhuyishix').value;
            // 检查数据是否为空
            if (!durgName) {
                $.modal.alertWarning('请填写名称！');
                return;
            }
            if (!jiliang) {
                $.modal.alertWarning('请填写剂量！');
                return;
            }

            var row = '<tr>' +
                '<td></td>' +
                '<td>' + durgName + '</td>' +
                '<td>' + jiliang + '</td>' +
                '<td>' + startyyTime + '</td>' +
                '<td>' + tyTime + '</td>' +
                '<td>' + lastsyTime + '</td>' +
                '<td>' + shiypv + '</td>' +
                '<td>' + zhuyishix + '</td>' +
                '<td><button class="btn-danger" onclick="deleteRow(this)">删除</button></td>' +
                '</tr>';
            $('#medicationRecordTableBody').append(row);
            blfyindex++; // 增加索引
            updateIndices(4); // 添加后更新所有行的序号
            // 清空表单输入框
            $("#form-yyjl-add")[0].reset();
            $('#myModal4').modal('hide');
        }
        if (button == 5) {


            // 获取表单数据
            var hbdurgName = document.getElementById('hbdurgName').value;
            var hbjiliang = document.getElementById('hbjiliang').value;
            var hbstartyyTime = document.getElementById('hbstartyyTime').value;
            var hbtyTime = document.getElementById('hbtyTime').value;
            var hblastsyTime = document.getElementById('hblastsyTime').value;
            var hbshiypv = document.getElementById('hbshiypv').value;
            var hbzhuyishix = document.getElementById('hbzhuyishix').value;
            // 检查数据是否为空
            if (!hbdurgName) {
                $.modal.alertWarning('请填写名称！');
                return;
            }
            if (!hbjiliang) {
                $.modal.alertWarning('请填写剂量！');
                return;
            }
            var row = '<tr>' +
                '<td></td>' +
                '<td>' + hbdurgName + '</td>' +
                '<td>' + hbjiliang + '</td>' +
                '<td>' + hbstartyyTime + '</td>' +
                '<td>' + hbtyTime + '</td>' +
                '<td>' + hblastsyTime + '</td>' +
                '<td>' + hbshiypv + '</td>' +
                '<td>' + hbzhuyishix + '</td>' +
                '<td><button class="btn-danger" onclick="deleteRow(this)">删除</button></td>' +
                '</tr>';
            $('#combinedMedicationRecordTableBody').append(row);
            blfyindex++; // 增加索引
            updateIndices(5); // 添加后更新所有行的序号
            // 清空表单输入框
            $("#form-hbyyjl-add")[0].reset();
            $('#myModal6').modal('hide');
        }

    }

    //初始化加载
    $(document).ready(function () {
        // 通过默认url获取
        var urlChina = prefix + '/selectAdverseReactions';
        $.cxSelect.defaults.url = urlChina;
        $('#element1').cxSelect({
            selects: ['province', 'city', 'area'],
            nodata: 'none'
        });
        $("#myModal5").hide();


        // 监听点击事件，激活指定的选项卡
        $('#myUlTabs li a').click(function (e) {
            // 阻止默认行为
            //e.preventDefault();
            // 获取当前点击的选项卡链接
            var $this = $(this);
            if ($this.attr('href') === '#tab-1') {
                formSubmitted = true;
            }
            if ($this.attr('href') === '#tab-2') {
                formSubmitted = false;
                // 添加 active 类到当前点击的选项卡
                $(this).addClass('active');
                $this.attr('aria-expanded', 'true');

            }
            // 检查是否为“用药购药”选项卡
            if ($this.attr('href') === '#tab-2') {
                // 初始化表格
                initializeTableForTab('tab-2');
            }
            if ($this.attr('href') === '#tab-3') {
                // 初始化表格
                initializeTableForTab('tab-3');
                // 初始化表格
                initializeTableForTab('tab-4');
            }

        });

        $('#myTabs2 li a').click(function (e) {
            // 阻止默认行为
            e.preventDefault();
            // 获取当前点击的选项卡链接
            var $this = $(this);
            // 移除所有选项卡的 active 类
            //$('#myTabs li').removeClass('active');
            //$('.tab-pane').removeClass('active in');
            $('#myTabs2 li a').addClass('active');
            // 添加 active 类到当前点击的选项卡
            $this.parent().addClass('active');
            // 获取目标选项卡面板的 ID
            var target = $this.attr('href');
            // 展示对应的选项卡面板，并更新 aria-expanded
            $(target).addClass('active in');
            $this.attr('aria-expanded', 'true');
            // 执行点击链接对应的动作
            $this.tab('show');
            // 移除所有选项卡的激活类
            //$('.active').removeClass('active');
            $(this).addClass('active');
            // 滚动到目标选项卡位置
            // 将目标内容区滚动到视口中央
            $('html, body').animate({
                scrollTop: $(target).offset().top - ($(window).height() / 2)
            }, 500); // 500毫秒动画时间
            // scrollToTab($this);
            // 重新初始化当前选项卡内的表格
            var tableId = target.replace('#', '');
            // initializeTableForTab(tableId);
        });


        // 初始化 Select2 插件
        for (let i = 1; i <= 6; i++) {
            $(`#category-select${i}`).select2({
                placeholder: "",
                allowClear: true
            });
        }

        // 获取所有下拉选项的数据
        $.ajax({
            url: ctx + 'sp/sp/typeDate',
            method: 'GET',
            dataType: 'json',
            success: function (data) {
                var selects = [
                    $('#category-select1'),
                    $('#category-select2'),
                    $('#category-select3'),
                    $('#category-select4'),
                    $('#category-select5'),
                    $('#category-select6')
                ];
                // 清空已有选项（除了第一个默认选项）
                selects.forEach(function (select) {
                    select.find('option').not(':first').remove();
                });
                // 添加默认选项到每个下拉列表
                selects.forEach(function (select) {
                    if (!select.find('option:first').length) { // 检查是否已经有默认选项
                        $('<option>', {
                            value: '',
                            text: '请选择疾病'
                        }).prependTo(select); // 使用 prependTo 确保它成为第一个选项
                    }
                });
                // 解析 dl 数据并获取 ID 数组
                var dl = /*[[${dl}]]*/ '';
                var dlParsed = JSON.parse(dl);
                var dlIds = Array.isArray(dlParsed) ? dlParsed.map(item => item.id.toString()) : [];
                // 遍历返回的数据并添加选项
                $.each(data.value || [], function (index, item) {
                    var selectIndex = item.dict_key - 1; // 假设 dict_key 是从 1 开始的索引
                    if (selectIndex >= 0 && selectIndex < selects.length) {
                        $('<option>', {
                            value: item.id,
                            text: item.categoryName
                        }).appendTo(selects[selectIndex]);
                        // 设置选中的值（仅当 dlIds 包含该项 id 时）
                        if (dlIds.includes(item.id.toString())) {
                            selects[selectIndex].val(item.id).trigger('change');
                        }
                    }
                });
                // 如果使用 Select2 插件，则初始化或刷新它们
                selects.forEach(function (select) {
                    select.trigger('change');
                });
            },
            error: function (xhr, status, error) {
                console.error("Failed to load disease categories:", error);
            }
        });
        //购药记录
        recordsData = /*[[${recordsData}]]*/ [];
        // 回显数据随访计划
        listPlan1 = /*[[${Plan1}]]*/ '';
        listPlan2 = /*[[${Plan2}]]*/ '';

        // 回显数据随访计划
        listTask1 = /*[[${listTask1}]]*/ [];
        listTask2 = /*[[${listTask2}]]*/ [];
        /*<![CDATA[*/
        pcTypes = /*[[${@dict.getType('sys_select_dtp_ysfw_sfpx')}]]*/ [];
        /*]]>*/
        // 提取 dictLabel 字段
        dosageFrequencyOptions = pcTypes.map(function (item) {
            return {
                value: item.dictValue, // 存储的值
                text: item.dictLabel   // 显示的文本
            };
        });
        // 提取 dictLabel 和 dictValue 字段，并创建一个查找表
        pcTypes.forEach(function (item) {
            dosageFrequencyLookup[item.dictValue] = {label: item.dictLabel, value: item.dictValue};
        });
        // 构建 options 用于 editable 插件
        dosageFrequencyOptions = pcTypes.map(function (item) {
            return {
                value: item.dictValue, // 存储的值
                text: item.dictLabel   // 显示的文本
            };
        });
        console.log(pcTypes);
        var planId_cg = /*[[${planId_cg}]]*/ '';
        var planId_tl = /*[[${planId_tl}]]*/ '';
        if (planId_cg) {

            $('#cgsfnormal').show();
        } else {
            $('#cgsfnormal').hide();
        }
        if (planId_tl) {
            $('#tlzhback').show();
        } else {
            $('#tlzhback').hide();
        }

        /*<![CDATA[*/
        var imagingInsuranceTypeList = /*[[${imagingInsuranceType}]]*/ '[]';
        /*]]>*/

        if (imagingInsuranceTypeList && imagingInsuranceTypeList !== '[]') {
            check(imagingInsuranceTypeList);
        }


        /*<![CDATA[*/
        var tumorMarkerCheckList = /*[[${tumorMarkerCheck}]]*/ '[]';
        /*]]>*/
        if(tumorMarkerCheckList && tumorMarkerCheckList !== '[]'){
            check2(tumorMarkerCheckList);
        }


        /*<![CDATA[*/
        var treatmentTypeList = /*[[${treatmentType}]]*/ '[]';
        /*]]>*/
        if(treatmentTypeList && treatmentTypeList !== '[]'){
            check3(treatmentTypeList);
        }
        // 初始化时回显 影像学检查 已选中的值
        function check(imagingInsuranceTypeList) {
            // 将字符串转换为数组
            var imagingInsuranceType = JSON.parse(imagingInsuranceTypeList.replace(/'/g, '"'));

            $.each(imagingInsuranceType, function(index, value) {
                var trimmedValue = value.trim();
                console.log("Checking for value:", trimmedValue);

                // 使用 jQuery 的属性选择器函数形式来避免手动拼接字符串的问题
                var checkbox = $('input[name="imagingInsuranceType"]').filter(function() {
                    var checkboxValue = $(this).val().trim(); // 确保值也去除空格
                    console.log("Checkbox value:", checkboxValue);
                    return checkboxValue === trimmedValue;
                });

                if (checkbox.length > 0) {
                    console.log("Found checkbox with value:", trimmedValue);
                    checkbox.prop('checked', true);
                } else {
                    console.warn("No checkbox found with value:", trimmedValue);
                }
            });
        }
       // 初始化时回显 影像学检查 已选中的值
        function check2(tumorMarkerCheckList) {
            // 将字符串转换为数组
            var tumorMarkerCheck = JSON.parse(tumorMarkerCheckList.replace(/'/g, '"'));

            $.each(tumorMarkerCheck, function(index, value) {
                var trimmedValue = value.trim();
                console.log("Checking for value:", trimmedValue);

                // 使用 jQuery 的属性选择器函数形式来避免手动拼接字符串的问题
                var checkbox = $('input[name="tumorMarkerCheck"]').filter(function() {
                    var checkboxValue = $(this).val().trim(); // 确保值也去除空格
                    console.log("Checkbox value:", checkboxValue);
                    return checkboxValue === trimmedValue;
                });

                if (checkbox.length > 0) {
                    console.log("Found checkbox with value:", trimmedValue);
                    checkbox.prop('checked', true);
                } else {
                    console.warn("No checkbox found with value:", trimmedValue);
                }
            });
        }
        // 初始化时回显 影像学检查 已选中的值
        function check3(treatmentTypeList) {
            // 将字符串转换为数组
            var treatmentType = JSON.parse(treatmentTypeList.replace(/'/g, '"'));

            $.each(treatmentType, function(index, value) {
                var trimmedValue = value.trim();
                console.log("Checking for value:", trimmedValue);

                // 使用 jQuery 的属性选择器函数形式来避免手动拼接字符串的问题
                var checkbox = $('input[name="treatmentType"]').filter(function() {
                    var checkboxValue = $(this).val().trim(); // 确保值也去除空格
                    console.log("Checkbox value:", checkboxValue);
                    return checkboxValue === trimmedValue;
                });

                if (checkbox.length > 0) {
                    console.log("Found checkbox with value:", trimmedValue);
                    checkbox.prop('checked', true);
                } else {
                    console.warn("No checkbox found with value:", trimmedValue);
                }
            });
        }




        //表单中的几个table初始化
        preMedicationPlans = /*[[${preMedicationPlan}]]*/ [];
        // 如果后端传递的是JSON字符串，先解析成数组
        if (typeof preMedicationPlans === 'string') {
            try {
                preMedicationPlans = JSON.parse(preMedicationPlans);
            } catch (e) {
                console.error("解析JSON字符串失败:", e);
                preMedicationPlans = []; // 解析失败时初始化为空数组
            }
        }
        currentTreatmentPlans = /*[[${currentTreatmentPlan}]]*/ [];
        // 如果后端传递的是JSON字符串，先解析成数组
        if (typeof currentTreatmentPlans === 'string') {
            try {
                currentTreatmentPlans = JSON.parse(currentTreatmentPlans);
            } catch (e) {
                console.error("解析JSON字符串失败:", e);
                currentTreatmentPlans = []; // 解析失败时初始化为空数组
            }
        }
        postProgressionTreatmentPlans = /*[[${postProgressionTreatmentPlan}]]*/ [];
        // 如果后端传递的是JSON字符串，先解析成数组
        if (typeof postProgressionTreatmentPlans === 'string') {
            try {
                postProgressionTreatmentPlans = JSON.parse(postProgressionTreatmentPlans);
            } catch (e) {
                console.error("解析JSON字符串失败:", e);
                postProgressionTreatmentPlans = []; // 解析失败时初始化为空数组
            }
        }
        medicationRecords = /*[[${medicationRecord}]]*/ [];
        // 如果后端传递的是JSON字符串，先解析成数组
        if (typeof medicationRecords === 'string') {
            try {
                medicationRecords = JSON.parse(medicationRecords);
            } catch (e) {
                console.error("解析JSON字符串失败:", e);
                medicationRecords = []; // 解析失败时初始化为空数组
            }
        }
        combinedMedicationRecords = /*[[${combinedMedicationRecord}]]*/ [];
        // 如果后端传递的是JSON字符串，先解析成数组
        if (typeof combinedMedicationRecords === 'string') {
            try {
                combinedMedicationRecords = JSON.parse(combinedMedicationRecords);
            } catch (e) {
                console.error("解析JSON字符串失败:", e);
                combinedMedicationRecords = []; // 解析失败时初始化为空数组
            }
        }
        good_response_symptom_ids = /*[[${good_response_symptom_id}]]*/ [];
        // 如果后端传递的是JSON字符串，先解析成数组
        if (typeof good_response_symptom_ids === 'string') {
            try {
                good_response_symptom_ids = JSON.parse(good_response_symptom_ids);
            } catch (e) {
                console.error("解析JSON字符串失败:", e);
                good_response_symptom_ids = []; // 解析失败时初始化为空数组
            }
        }
        addRowsToTable(preMedicationPlans,'preMedicationPlanTableBody');
        addRowsToTable(currentTreatmentPlans,'currentTreatmentPlanTableBody');
        addRowsToTable(postProgressionTreatmentPlans,'postProgressionTreatmentPlanTableBody');
        addRowsToTable(medicationRecords,'medicationRecordTableBody');
        addRowsToTable(combinedMedicationRecords,'combinedMedicationRecordTableBody');
        addRowsToTable(good_response_symptom_ids,'blfyTableBody');




        // 监听回访方式的选择变化
        $('input[name="returnMethod"]').on('change', updateVisibility1);
        //是否配合
        $('input[name="iscoordinate"]').on('change', updateVisibility2);

        // 监听不良反应的选择变化
        $('input[name="is_adverse_reaction"]').on('change', updateVisibility3);
        //监听合并用药是否引起不良反应
        $('input[name="combinedMedicationAdverseReaction"]').on('change', updateVisibility3);

        // 监听用药状态的选择变化
        $('input[name="medicationStatus"]').on('change', updateVisibility4);

        $('input[name="stoped"]').on('change', updateVisibility5);
        $('input[name="stopform"]').on('change', updateVisibility5);

        // 监听弹框 关闭计划原因
        $('input[name="reason"]').on('change', updateVisibility6);
        $('input[name="drugsStatus"]').on('change', updateVisibility6);//用药状态调整
        $('input[name="drugsStop"]').on('change', updateVisibility6);//永久停药类型
        $('input[name="flowNo"]').on('change', updateVisibility6);//随访不配合原因
        $('input[name="closePlanScope"]').on('change', updateVisibility6);//关闭计划范围
        $('input[name="closeType"]').on('change', updateVisibility6);//计划类型


        // 监听治疗类型选择 是否复查 变化
        $('input[name="isReview"]').on('change', updateVisibility7);//治疗类型
        $('input[name="imagingInsuranceType"]').on('change', updateVisibility8);//治疗类型
        $('input[name="clinicalInteraction"]').on('change', updateVisibility9);//计划类型
        $('input[name="unnecessaryRepeatedMedication"]').on('change', updateVisibility10);//计划类型
        $('input[name="medicationError"]').on('change', updateVisibility11);//计划类型
        $('input[name="isConsultation"]').on('change', updateVisibility12);//计划类型
        $('input[name="treatmentType"]').on('change', updateVisibility13);//治疗类型
        $('input[name="tumorMarkerCheck"]').on('change', updateVisibility14);//肿瘤标记物检查

        // 初始化时设置默认显示状态
        updateVisibility1();
        updateVisibility2();
        updateVisibility3();
        updateVisibility4();
        updateVisibility5();
        updateVisibility7();
        updateVisibility8();
        updateVisibility9();
        updateVisibility10();
        updateVisibility11();
        updateVisibility12();
        updateVisibility13();
        updateVisibility14();

    });

    function addRowsToTable(data,tbodyId) {
        // 检查 data 是否为 null 或 undefined
        if (!Array.isArray(data)) {
            console.warn("提供的数据不是数组", data);
            return;
        }
        if(data.length > 0){
            var tbody = document.getElementById(tbodyId);
            if(tbodyId === 'blfyTableBody'){
                data.forEach(function(item, index) {
                    var row = document.createElement('tr');
                    // 序号
                    var tdIndex = document.createElement('td');
                    tdIndex.textContent = index + 1;
                    row.appendChild(tdIndex);
                    // 不良反应症状
                    var tdPlan = document.createElement('td');
                    tdPlan.textContent = item.byfyData;
                    row.appendChild(tdPlan);
                    // 操作（这里可以添加按钮或其他交互元素）
                    var tdAction = document.createElement('td');
                    // 示例: 添加一个删除按钮
                    var deleteButton = document.createElement('button');
                    deleteButton.textContent = '删除';
                    deleteButton.onclick = function() { deleteRow(this); };
                    tdAction.appendChild(deleteButton);
                    row.appendChild(tdAction);

                    tbody.appendChild(row);
                });

            }
            if(tbodyId === 'preMedicationPlanTableBody' || tbodyId === 'currentTreatmentPlanTableBody' || tbodyId === 'postProgressionTreatmentPlanTableBody'){
                if(tbodyId === 'preMedicationPlanTableBody'){
                    data.forEach(function(item, index) {
                        var row = document.createElement('tr');

                        // 序号
                        var tdIndex = document.createElement('td');
                        tdIndex.textContent = item.id;
                        row.appendChild(tdIndex);

                        // 治疗方案
                        var tdPlan = document.createElement('td');
                        tdPlan.textContent = item.pre_medication_plan;
                        row.appendChild(tdPlan);

                        // 治疗时间
                        var tdTime = document.createElement('td');
                        tdTime.textContent = item.pre_medication_plan_time;
                        row.appendChild(tdTime);

                        // 操作（这里可以添加按钮或其他交互元素）
                        var tdAction = document.createElement('td');
                        // 示例: 添加一个删除按钮
                        var deleteButton = document.createElement('button');
                        deleteButton.textContent = '删除';
                        deleteButton.onclick = function() { deleteRow(this); };
                        tdAction.appendChild(deleteButton);
                        row.appendChild(tdAction);

                        tbody.appendChild(row);
                        updateIndices(1);
                    });
                }
                if(tbodyId === 'currentTreatmentPlanTableBody'){
                    data.forEach(function(item, index) {
                        var row = document.createElement('tr');

                        // 序号
                        var tdIndex = document.createElement('td');
                        tdIndex.textContent = item.id;
                        row.appendChild(tdIndex);

                        // 治疗方案
                        var tdPlan = document.createElement('td');
                        tdPlan.textContent = item.current_treatment_plan;
                        row.appendChild(tdPlan);

                        // 治疗时间
                        var tdTime = document.createElement('td');
                        tdTime.textContent = item.current_treatment_plan_time;
                        row.appendChild(tdTime);

                        // 操作（这里可以添加按钮或其他交互元素）
                        var tdAction = document.createElement('td');
                        // 示例: 添加一个删除按钮
                        var deleteButton = document.createElement('button');
                        deleteButton.textContent = '删除';
                        deleteButton.onclick = function() { deleteRow(this); };
                        tdAction.appendChild(deleteButton);
                        row.appendChild(tdAction);

                        tbody.appendChild(row);
                        updateIndices(2);
                    });
                }
                if(tbodyId === 'postProgressionTreatmentPlanTableBody'){
                    data.forEach(function(item, index) {
                        var row = document.createElement('tr');

                        // 序号
                        var tdIndex = document.createElement('td');
                        tdIndex.textContent = item.id;
                        row.appendChild(tdIndex);

                        // 治疗方案
                        var tdPlan = document.createElement('td');
                        tdPlan.textContent = item.post_progression_treatment_plan;
                        row.appendChild(tdPlan);

                        // 治疗时间
                        var tdTime = document.createElement('td');
                        tdTime.textContent = item.post_progression_treatment_plan_time;
                        row.appendChild(tdTime);

                        // 操作（这里可以添加按钮或其他交互元素）
                        var tdAction = document.createElement('td');
                        // 示例: 添加一个删除按钮
                        var deleteButton = document.createElement('button');
                        deleteButton.textContent = '删除';
                        deleteButton.onclick = function() { deleteRow(this); };
                        tdAction.appendChild(deleteButton);
                        row.appendChild(tdAction);

                        tbody.appendChild(row);
                        updateIndices(3);
                    });

                }
        }



        }
        if(tbodyId === 'medicationRecordTableBody' || tbodyId === 'combinedMedicationRecordTableBody'){
            if(tbodyId === 'medicationRecordTableBody'){
                data.forEach(function(item, index) {
                    var row = document.createElement('tr');

                    // 序号
                    var tdIndex = document.createElement('td');
                    tdIndex.textContent = item.id;
                    row.appendChild(tdIndex);

                    // 1
                    var durgName = document.createElement('td');
                    durgName.textContent = item.durgName;
                    row.appendChild(durgName);

                    // 2
                    var jiliang = document.createElement('td');
                    jiliang.textContent = item.jiliang;
                    row.appendChild(jiliang);
                    // 1
                    var startyyTime = document.createElement('td');
                    startyyTime.textContent = item.startyyTime;
                    row.appendChild(startyyTime);

                    // 2
                    var tyTime = document.createElement('td');
                    tyTime.textContent = item.tyTime;
                    row.appendChild(tyTime);
                    // 1
                    var lastsyTime = document.createElement('td');
                    lastsyTime.textContent = item.lastsyTime;
                    row.appendChild(lastsyTime);

                    // 2
                    var shiypv = document.createElement('td');
                    shiypv.textContent = item.shiypv;
                    row.appendChild(shiypv);
                    // 7
                    var zhuyishix = document.createElement('td');
                    zhuyishix.textContent = item.zhuyishix;
                    row.appendChild(zhuyishix);
                    // 操作（这里可以添加按钮或其他交互元素）
                    var tdAction = document.createElement('td');
                    // 示例: 添加一个删除按钮
                    var deleteButton = document.createElement('button');
                    deleteButton.textContent = '删除';
                    deleteButton.onclick = function() { deleteRow(this); };
                    tdAction.appendChild(deleteButton);
                    row.appendChild(tdAction);

                    tbody.appendChild(row);
                    updateIndices(4);
                });


            }
            if(tbodyId === 'combinedMedicationRecordTableBody'){
                data.forEach(function(item, index) {
                    var row = document.createElement('tr');
                    // 序号
                    var tdIndex = document.createElement('td');
                    tdIndex.textContent = item.id;
                    row.appendChild(tdIndex);
                    // 1
                    var durgName = document.createElement('td');
                    durgName.textContent = item.hbdurgName;
                    row.appendChild(durgName);

                    // 2
                    var jiliang = document.createElement('td');
                    jiliang.textContent = item.hbjiliang;
                    row.appendChild(jiliang);
                    // 1
                    var startyyTime = document.createElement('td');
                    startyyTime.textContent = item.hbstartyyTime;
                    row.appendChild(startyyTime);

                    // 2
                    var tyTime = document.createElement('td');
                    tyTime.textContent = item.hbtyTime;
                    row.appendChild(tyTime);
                    // 1
                    var lastsyTime = document.createElement('td');
                    lastsyTime.textContent = item.hblastsyTime;
                    row.appendChild(lastsyTime);

                    // 2
                    var shiypv = document.createElement('td');
                    shiypv.textContent = item.shiypv;
                    row.appendChild(shiypv);
                    // 7
                    var zhuyishix = document.createElement('td');
                    zhuyishix.textContent = item.hbzhuyishix;
                    row.appendChild(zhuyishix);

                    // 操作（这里可以添加按钮或其他交互元素）
                    var tdAction = document.createElement('td');
                    // 示例: 添加一个删除按钮
                    var deleteButton = document.createElement('button');
                    deleteButton.textContent = '删除';
                    deleteButton.onclick = function() { deleteRow(this); };
                    tdAction.appendChild(deleteButton);
                    row.appendChild(tdAction);

                    tbody.appendChild(row);
                    updateIndices(5);
                });


            }

        }

    }
    function updateVisibility1() {
        var weixinDiv = $('#weixin');
        var mianfangDiv = $('#mianfang');

        var selectedValue = $('input[name="returnMethod"]:checked').val();
        if (selectedValue === '微信') {
            weixinDiv.removeClass('hidden');
            mianfangDiv.addClass('hidden');
        } else if (selectedValue === '电话') {
            weixinDiv.addClass('hidden');
            mianfangDiv.addClass('hidden');
        } else if (selectedValue === '面访') {
            weixinDiv.addClass('hidden');
            mianfangDiv.removeClass('hidden');
        }
    }

    function updateVisibility2() {
        var iscoordinate = $('input[name="iscoordinate"]:checked').val();
        var stopForm = $('input[name="stopform"]:checked').val();
        var iscoordinateDiv = $('#iscoordinateDiv');
        var formAllArea = $('#tab-7-14')
        var tab6 = $('#tab-6')
        if (iscoordinate === '2') {
            iscoordinateDiv.removeClass('hidden');
        } else {
            iscoordinateDiv.addClass('hidden');
        }
        if (iscoordinate === '2' && stopForm === '不填写完整表单') {
            // 取消选中所有具有相同name属性的单选按钮
            var radios2 = document.querySelectorAll('input[name="medicationStatus"]');
            radios2.forEach(function (radio) {
                radio.checked = false;
            });
            formAllArea.addClass('hidden');
            tab6.addClass('hidden');
        }

    }

    function updateVisibility3() {
        //是否出现不良反应
        var bulfydiv = $('#bulfydiv');
        var hbyysfyiblfy = $('#hbyysfyiblfy');
        var is_adverse_reaction = $('input[name="is_adverse_reaction"]:checked').val();
        var combinedMedicationAdverseReaction = $('input[name="combinedMedicationAdverseReaction"]:checked').val();

        if (is_adverse_reaction === '是') {
            bulfydiv.removeClass('hidden');
        }
        if (is_adverse_reaction === '否') {
            bulfydiv.addClass('hidden');
        }

        if (combinedMedicationAdverseReaction === '1') {
            hbyysfyiblfy.removeClass('hidden');
        }
        if (combinedMedicationAdverseReaction === '2') {
            hbyysfyiblfy.addClass('hidden');
        }

    }

    function updateVisibility4() {
        var csyzyy = $('#csyzyy');//慈善援助用药
        var yjty = $('#yjty');//永久停药
        var qtgyqgy = $('#qtgyqgy');//其他渠道购药
        var ycgyycjy = $('#ycgyycjy');//延迟购药(医嘱建议)
        var ycgyhzyybgf = $('#ycgyhzyybgf');//延迟购药(患者用药不规范
        var formAllArea = $('#tab-7-14');

        var medicationStatus = $('input[name="medicationStatus"]:checked').val();
        if (medicationStatus === '持续购药') {
            csyzyy.addClass('hidden');
            yjty.addClass('hidden');
            qtgyqgy.addClass('hidden');
            ycgyycjy.addClass('hidden');
            ycgyhzyybgf.addClass('hidden');
            formAllArea.removeClass('hidden');
        }
        if (medicationStatus === '领取慈善赠药') {
            csyzyy.removeClass('hidden');
            yjty.addClass('hidden');
            qtgyqgy.addClass('hidden');
            ycgyycjy.addClass('hidden');
            ycgyhzyybgf.addClass('hidden');
            formAllArea.removeClass('hidden');
        }
        if (medicationStatus === '永久停药') {
            yjty.removeClass('hidden');
            csyzyy.addClass('hidden');
            qtgyqgy.addClass('hidden');
            ycgyycjy.addClass('hidden');
            ycgyhzyybgf.addClass('hidden');
        }
        if (medicationStatus === '其他渠道购药') {
            qtgyqgy.removeClass('hidden');
            yjty.addClass('hidden');
            csyzyy.addClass('hidden');
            ycgyycjy.addClass('hidden');
            ycgyhzyybgf.addClass('hidden');
            formAllArea.removeClass('hidden');
        }
        if (medicationStatus === '延迟用药（医嘱建议）') {
            ycgyycjy.removeClass('hidden');
            qtgyqgy.addClass('hidden');
            yjty.addClass('hidden');
            csyzyy.addClass('hidden');
            ycgyhzyybgf.addClass('hidden');
            formAllArea.removeClass('hidden');
        }
        if (medicationStatus === '延迟购药 (患者用药不规范)') {
            ycgyhzyybgf.removeClass('hidden');
            qtgyqgy.addClass('hidden');
            yjty.addClass('hidden');
            csyzyy.addClass('hidden');
            ycgyycjy.addClass('hidden');
            formAllArea.removeClass('hidden');
        }
        if (medicationStatus != '永久停药') {
            $('input[name="stoped"]').prop('checked', false);
        }
    }

    function updateVisibility5() {
        //不填写完整表单
        var formAllArea = $('#tab-7-14')
        var tab6 = $('#tab-6')
        var yjty = $('#yjty');//永久停药
        var stoped = $('input[name="stoped"]:checked').val();
        var stopForm = $('input[name="stopform"]:checked').val();

        if (stoped === '不填写完整表单') {
            formAllArea.addClass('hidden');
        } else {
            formAllArea.removeClass('hidden');
        }
        // if (stoped === '不填写完整表单' || stopForm === '不填写完整表单') {
        //     formAllArea.addClass('hidden');
        // } else {
        //     formAllArea.removeClass('hidden');
        // }

        if (stopForm === '不填写完整表单') {
            // 取消选中所有具有相同name属性的单选按钮
            var radios = document.querySelectorAll('input[name="medicationStatus"]');
            radios.forEach(function (radio) {
                radio.checked = false;
            });

            yjty.addClass('hidden');
            formAllArea.addClass('hidden');
            tab6.addClass('hidden');
        }
    }

    function updateVisibility6() {
        //原因
        var drugsStatusDiv = $('#drugsStatusDiv');//用药状态调整
        var flowNoDiv = $('#flowNoDiv');
        var otherReasonDiv = $('#otherReasonDiv');
        var drugsStopDiv = $('#drugsStopDiv');
        var closeplan_isnoDiv = $('#closeplan_isnoDiv');
        var closeTypeDiv = $('#closeTypeDiv');
        var specifiedTypeDiv = $('#specifiedTypeDiv');

        var reason = $('input[name="reason"]:checked').val();//原因
        var drugsStatus = $('input[name="drugsStatus"]:checked').val();//原因
        var closePlanScope = $('input[name="closePlanScope"]:checked').val();//范围 选中 仅关闭当前计划
        var specifiedType = $('input[name="specifiedType"]:checked').val();//指定类型 选中点击带过来的
        var drugsStop = $('input[name="drugsStop"]:checked').val();//永久关闭是否
        var closeType = $('input[name="closeType"]:checked').val();//关闭类型 选中点击带过来的
        if (reason === '用药状态调整') {
            drugsStatusDiv.removeClass('hidden');
        } else {
            drugsStatusDiv.addClass('hidden');
            drugsStopDiv.addClass('hidden');
        }
        if (reason === '随访不配合') {
            flowNoDiv.removeClass('hidden');
        } else {
            flowNoDiv.addClass('hidden');
        }
        if (reason === '其他') {
            otherReasonDiv.removeClass('hidden');
        } else {
            otherReasonDiv.addClass('hidden');
        }
        if (closePlanScope === '关闭当前药品的全部计划') {
            closeplan_isnoDiv.removeClass('hidden');
        } else {
            closeplan_isnoDiv.addClass('hidden');
        }
        if (drugsStatus === '永久停药') {
            drugsStopDiv.removeClass('hidden');
        } else {
            drugsStopDiv.addClass('hidden');
        }
        if (drugsStatus === '永久停药' && reason != '用药状态调整') {
            drugsStopDiv.addClass('hidden');
        }

        if (drugsStop === '离世' && closePlanScope === '关闭患者当前的全部计划') {
            closeplan_isnoDiv.removeClass('hidden');
        }
        if (closeType === '指定类型') {
            specifiedTypeDiv.removeClass('hidden');
        }
        if (closeType === '全部类型') {
            specifiedTypeDiv.addClass('hidden');

        }
    }

    function updateVisibility7() {
        var isReview = $('input[name="isReview"]:checked').val();//
        var isReviewDiv = $('#isReviewDiv');//
        if (isReview === '1') {
            isReviewDiv.removeClass('hidden');
        } else {
            isReviewDiv.addClass('hidden');
        }
    }

    function updateVisibility8() {
        var imagingInsuranceType = $('input[name="imagingInsuranceType"]:checked').map(function () {
            return $(this).val();
        }).get();
        var ctradio = $('#ctradio');//
        var bcradio = $('#bcradio');//
        var hcradio = $('#hcradio');//
        var qtradio = $('#qtradio');//
        if (imagingInsuranceType.includes('CT')) {
            ctradio.removeClass('hidden');
        } else {
            ctradio.addClass('hidden');
        }
        if (imagingInsuranceType.includes('B超')) {
            bcradio.removeClass('hidden');
        } else {
            bcradio.addClass('hidden');
        }
        if (imagingInsuranceType.includes('核磁')) {
            hcradio.removeClass('hidden');
        } else {
            hcradio.addClass('hidden');
        }
        if (imagingInsuranceType.includes('其他')) {
            qtradio.removeClass('hidden');
        } else {
            qtradio.addClass('hidden');
        }
    }

    function updateVisibility9() {
        var clinicalInteraction = $('input[name="clinicalInteraction"]:checked').val();//
        var clinicalInteractionDiv = $('#clinicalInteractionDiv');//
        if (clinicalInteraction === '1') {
            clinicalInteractionDiv.removeClass('hidden');
        } else {
            clinicalInteractionDiv.addClass('hidden');
        }
    }

    function updateVisibility10() {
        var unnecessaryRepeatedMedication = $('input[name="unnecessaryRepeatedMedication"]:checked').val();//
        var unnecessaryRepeatedMedicationDiv = $('#unnecessaryRepeatedMedicationDiv');//
        if (unnecessaryRepeatedMedication === '1') {
            unnecessaryRepeatedMedicationDiv.removeClass('hidden');
        } else {
            unnecessaryRepeatedMedicationDiv.addClass('hidden');
        }
    }

    function updateVisibility11() {
        var medicationError = $('input[name="medicationError"]:checked').val();//
        var medicationErrorDiv = $('#medicationErrorDiv');//
        if (medicationError === '1') {
            medicationErrorDiv.removeClass('hidden');
        } else {
            medicationErrorDiv.addClass('hidden');
        }
    }

    function updateVisibility12() {
        var isConsultation = $('input[name="isConsultation"]:checked').val();//
        var isConsultationDiv = $('#isConsultationDiv');//
        if (isConsultation === '1') {
            isConsultationDiv.removeClass('hidden');
        } else {
            isConsultationDiv.addClass('hidden');
        }
    }

    function updateVisibility13() {
        var treatmentTypeDiv = $('#treatmentTypeDiv');//
        var currentTreatmentPlanDiv = $('#currentTreatmentPlanDiv');//
        var postProgressionTreatmentPlanDiv = $('#postProgressionTreatmentPlanDiv');//
        // 获取所有选中的复选框的值 repeatedMedicationFirstUseDateDiv
        var selectedValues = $('input[name="treatmentType"]:checked').map(function () {
            return $(this).val();
        }).get();
        // 遍历所有可能的值并根据是否选中来显示或隐藏对应的 div
        if (selectedValues.includes('用药前治疗方案')) {
            treatmentTypeDiv.removeClass('hidden');
        } else {
            treatmentTypeDiv.addClass('hidden');
        }
        if (selectedValues.includes('目前治疗方案')) {
            currentTreatmentPlanDiv.removeClass('hidden');
        } else {
            currentTreatmentPlanDiv.addClass('hidden');
        }
        if (selectedValues.includes('进展后治疗方案')) {
            postProgressionTreatmentPlanDiv.removeClass('hidden');
        } else {
            postProgressionTreatmentPlanDiv.addClass('hidden');
        }
    }

    function updateVisibility14() {
        //全量表单控制
        var tumorMarkerChecks = $('input[name="tumorMarkerCheck"]:checked').map(function () {
            return $(this).val();
        }).get();
        var ceaDiv = $('#ceaDiv');
        var afpDiv = $('#afpDiv');
        var ca199Div = $('#ca199Div');
        var ca125Div = $('#ca125Div');
        var ca153Div = $('#ca153Div');
        var hcgDiv = $('#hcgDiv');
        var nseDiv = $('#nseDiv');
        var cyfra211Div = $('#cyfra211Div');
        var tgDiv = $('#tgDiv');
        var psaDiv = $('#psaDiv');

        // 遍历所有可能的值并根据是否选中来显示或隐藏对应的 div
        if (tumorMarkerChecks.includes('CEA')) {
            ceaDiv.removeClass('hidden');
        } else {
            ceaDiv.addClass('hidden');
        }
        if (tumorMarkerChecks.includes('AFP')) {
            afpDiv.removeClass('hidden');
        } else {
            afpDiv.addClass('hidden');
        }
        if (tumorMarkerChecks.includes('CA-199')) {
            ca199Div.removeClass('hidden');
        } else {
            ca199Div.addClass('hidden');
        }
        if (tumorMarkerChecks.includes('CA125')) {
            ca125Div.removeClass('hidden');
        } else {
            ca125Div.addClass('hidden');
        }
        if (tumorMarkerChecks.includes('CA153')) {
            ca153Div.removeClass('hidden');
        } else {
            ca153Div.addClass('hidden');
        }
        if (tumorMarkerChecks.includes('HCG')) {
            hcgDiv.removeClass('hidden');
        } else {
            hcgDiv.addClass('hidden');
        }
        if (tumorMarkerChecks.includes('NSE')) {
            nseDiv.removeClass('hidden');
        } else {
            nseDiv.addClass('hidden');
        }
        if (tumorMarkerChecks.includes('CYFRA21-1')) {
            cyfra211Div.removeClass('hidden');
        } else {
            cyfra211Div.addClass('hidden');
        }
        if (tumorMarkerChecks.includes('TG')) {
            tgDiv.removeClass('hidden');
        } else {
            tgDiv.addClass('hidden');
        }
        if (tumorMarkerChecks.includes('PSA')) {
            psaDiv.removeClass('hidden');
        } else {
            psaDiv.addClass('hidden');
        }

    }


    function initializeTableForTab(tabId) {

        var tableId = 'bootstrap-table-' + tabId.substring(4);
        var tableElement = $('#' + tableId);

        var data = {
            "patientPhone": $('#phoneNumber').val(),
            "patientName": $('#name').val(),
            "id": $('#id').val(),
            "flag": tabId.substring(4),
        };
        console.log("tabId=" + tabId.substring(4));
        if (tabId === 'tab-2') {
            //购药记录
            var data2 = [];
            data2 = recordsData;
            var options = {
                data: data2,
                columns: [
                    {field: 'id', title: 'ID', visible: false},
                    {field: 'salesOrderNumber', title: '销售单号'},
                    {field: 'prescriptionNumber', title: '处方编号'},
                    {field: 'prescriptionDate', title: '处方日期'},
                    {field: 'hospital', title: '医院'},
                    {field: 'prescribingDoctor', title: '处方医生'},
                    {field: 'department', title: '科室', visible: false},
                    {field: 'attendingDoctor', title: '主管医生'},  // 注意这里使用的是 "attendingDoctor" 而不是 "attendingPhysician"
                    {field: 'prescriptionDiagnosis', title: '处方诊断'},
                    {field: 'genericName', title: '药品通用名'},
                    {field: 'productName', title: '商品名'},
                    {field: 'specification', title: '规格'},
                    {field: 'packageQuantity', title: '取药数量'},
                    {
                        field: 'singleDoseValue',
                        title: '单次剂量',
                        editable: {
                            type: 'text',
                            title: '单次剂量',
                            validate: function (value) {
                                if ($.trim(value) === '') return '单次剂量不能为空';
                            }
                        }
                    },
                    {
                        field: 'singleDoseUnit',
                        title: '单次剂量单位',
                        editable: {
                            type: 'select',
                            source: [
                                "mg",    // 毫克
                                "g",     // 克
                                "μg",    // 微克
                                "L",     // 升
                                "ml",    // 毫升
                                "μL",    // 微升
                                "U",     // 单位（通常用于生物制剂）
                                "IU",    // 国际单位
                                "T",     // 可能指大写字母T，在特定上下文中有特殊意义
                                "S",     // 可能指大写字母S，在特定上下文中有特殊意义
                                "片",    // 片剂
                                "丸",    // 丸剂
                                "粒",    // 小颗粒状药物或物品
                                "支",    // 一支，可能指液体或固体的包装单位
                                "袋",    // 袋装
                                "瓶",    // 瓶装
                                "盒",    // 盒装
                                "板",    // 板状物，如药板
                                "包",    // 包装
                                "小盒"   // 小盒子
                            ], // 示例单位列表
                            title: '单次剂量单位',
                            validate: function (value) {
                                if ($.trim(value) === '') return '单次剂量单位不能为空';
                            }
                        }
                    },
                    {
                        field: 'dosageFrequency', title: '用药频次',
                        editable: {
                            type: 'select',
                            source: dosageFrequencyOptions,
                            valueField: 'value', // 指定存储的值字段
                            textField: 'text',   // 指定显示的文本字段
                            validate: function (value) {
                                if ($.trim(value) === '') return '用药频次不能为空';
                            }
                        }
                    },
                    {field: 'medicationRoute', title: '用药途径', visible: false},
                    {field: 'registrant', title: '登记人', visible: false},
                    {field: 'registrationDate', title: '登记日期', visible: false},
                    {field: 'saleDate', title: '销售日期', visible: false},
                    {mdmCode: 'mdmCode', title: '药品编码', visible: false},
                    {field: 'pharmacyName', title: '购药门店名称'},
                    {
                        field: 'actions',
                        title: '操作',
                        formatter: actionFormatter,
                        events: window.actionEvents
                    }
                ]

            };
            if (Array.isArray(data2) && data2.length > 0) {
                tableElement.bootstrapTable(options);
            } else if (!Array.isArray(data2)) {
                console.error('listTask1 is not a valid array:', data2);
            } else {
                console.log('No data available');
            }

        }
        if (tabId === 'tab-3') {
            var tableElement4 = $('#bootstrap-table-4');
            // 回显数据随访计划
            var data4 = [];
            data4 = listTask1;
            var options4 = {
                // 配置表格的相关属性
                // 例如数据源、列定义等
                // 示例配置
                data: data4,
                fitColumns: true,
                striped: true,
                autoRowHeight: true,
                rowNumbers: true,
                showFooter: true,  //是否显示表格底部区域。
                clickToSelect: true, //是否启用点击行时选中整行的功能。
                singleSelect: false, //是否仅允许选择一行
                fixedColumns: true,
                //fixedNumber: 3,
                fixedRightNumber: 1,
                columns: [
                    {field: 'id', title: '序号'},
                    {field: 'taskName', title: '任务名称'},
                    {field: 'taskTheme', title: '任务类型'},
                    {field: 'appointmentDate', title: '预约时间'},
                    {field: 'completionTime', title: '完成时间'},
                    {field: 'taskFollower', title: '任务跟进人'},
                    {field: 'taskStatus', title: '任务状态'},
                    {
                        title: '操作',
                        align: 'center',
                        width: '180px',
                        formatter: function (value, row, index) {
                            if (row.id && !['已取消', '已完成'].includes(row.taskStatus)) {
                                var actions = [];
                                actions.push('<a class="btn-xs" href="javascript:void(0)" onclick="edit(\'' + row.id + '\')">查看</a> ');
                                actions.push('<a class="btn-xs" href="javascript:void(0)" onclick="closeTask(\'' + row.id + '\')">关闭任务</a> ');
                                return actions.join('');
                            }
                            if (row.id && ['已取消', '已完成'].includes(row.taskStatus)) {
                                var actions = [];
                                actions.push('<a class="btn-xs" href="javascript:void(0)" onclick="edit(\'' + row.id + '\')">查看</a> ');
                                return actions.join('');
                            } else {
                                return "";
                            }
                        }
                    }
                ]
            };
            if (Array.isArray(data4) && data4.length > 0) {
                tableElement4.bootstrapTable(options4);
            } else if (!Array.isArray(data4)) {
                console.error('listTask1 is not a valid array:', data4);
            } else {
                console.log('No data available');
            }


            var data5 = [];
            data5 = listTask2;
            var tableElement5 = $('#bootstrap-table-5');
            var options5 = {
                // 配置表格的相关属性
                // 例如数据源、列定义等
                // 示例配置
                data: data5,
                fitColumns: true,
                striped: true,
                autoRowHeight: true,
                rowNumbers: true,
                showFooter: true,  //是否显示表格底部区域。
                clickToSelect: true, //是否启用点击行时选中整行的功能。
                singleSelect: false, //是否仅允许选择一行
                fixedColumns: true,
                //fixedNumber: 3,
                fixedRightNumber: 1,
                columns: [
                    {field: 'id', title: '序号'},
                    {field: 'taskName', title: '任务名称'},
                    {field: 'taskTheme', title: '任务类型'},
                    {field: 'appointmentDate', title: '预约时间'},
                    {field: 'completionTime', title: '完成时间'},
                    {field: 'taskFollower', title: '任务跟进人'},
                    {field: 'taskStatus', title: '任务状态'},
                    {
                        title: '操作',
                        align: 'center',
                        width: '180px',
                        formatter: function (value, row, index) {
                            if (row.id && !['已取消', '已完成'].includes(row.taskStatus)) {
                                var actions = [];
                                actions.push('<a class="btn-xs" href="javascript:void(0)" onclick="edit(\'' + row.id + '\')">查看</a> ');
                                actions.push('<a class="btn-xs" href="javascript:void(0)" onclick="closeTask(\'' + row.id + '\')">关闭任务</a> ');
                                return actions.join('');
                            }
                            if (row.id && ['已取消', '已完成'].includes(row.taskStatus)) {
                                var actions = [];
                                actions.push('<a class="btn-xs" href="javascript:void(0)" onclick="edit(\'' + row.id + '\')">查看</a> ');
                                return actions.join('');
                            } else {
                                return "";
                            }
                        }
                    }
                ]
            };
            if (Array.isArray(data5) && data5.length > 0) {
                tableElement5.bootstrapTable(options5);
            } else if (!Array.isArray(data5)) {
                console.error('listTask1 is not a valid array:', data4);
            } else {
                console.log('No data available');
            }

        }
    }

    // 定义操作列的事件处理
    window.actionEvents = {
        'click .save': function (e, value, row, index) {
            saveDrug(row, index);
        }
    };

    // 定义操作列的格式化函数
    function actionFormatter(value, row, index) {
        return [
            '<button class="save ml10 btn btn-success btn-xs" type="button">保存</button>'
        ].join('');
    }

    // 定义保存药品记录的方法
    function saveDrug(row, index) {
        // 查找对应的 dictLabel 和 dictValue 并添加到 row 对象中
        var option = dosageFrequencyLookup[row.dosageFrequency];
        if (option) {
            row.dosageFrequencyLabel = option.label; // 添加 dictLabel 到 row 对象中
            row.dosageFrequencyValue = option.value; // 添加 dictValue 到 row 对象中
        } else {
            row.dosageFrequencyLabel = ''; // 或者设置为默认值
            row.dosageFrequencyValue = ''; // 或者设置为默认值
        }

        // 发送 AJAX 请求更新数据
        $.ajax({
            cache: true,
            type: "POST",
            url: ctx + "dtp/pmService/updateDrugPurchaseRecord",
            data: row,
            async: false,
            success: function (data) {
                $.modal.msg("保存成功");
            },
            error: function (error) {
                $.modal.msg("更新失败");
            }
        });
    };

    function editArchives() {
        var id = $("#patientId").val();
        // table.set();
        var prefix = ctx + "dtp/pmService/archivesEdit/{id}";
        $.modal.openTab("修改档案", prefix.replace("{id}", id));
    }

    // 关闭计划  提交关闭原因
    function submitClosePlan() {
        var flag = false;
        var reason = $('input[name="reason"]:checked').val(); // 原因
        if (!reason) {
            $.modal.msgError("请选择关闭原因");
            return;
        }
        var drugsStatus = $('input[name="drugsStatus"]:checked').val(); // 用药状态调整为
        // 检查是否需要显示确认弹框
        var needsConfirmation = (reason === '电话号码错误' || drugsStatus === '无需购药永久领取援助用药');
        if (needsConfirmation) {
            $.modal.confirm("确认要关闭计划吗? 若关闭计划,同时关闭此任务", function () {
                executeClosePlan();
            });
        } else {
            executeClosePlan();
        }
    }

    function executeClosePlan() {
        // 获取指定类型的选中值 常规随访 脱落召回
        var specifiedType = [];
        $('input[name="specifiedType"]:checked').each(function () {
            specifiedType.push($(this).val());
        });
        var taskId, planId_cg, planId_tl, patientId, mdmCode_cg, mdmCode_tl;
        // 根据选中的指定类型设置相应的planId
        specifiedType.forEach(function (type) {
            if (type === '常规随访') {
                planId_cg = $("#planId_cg").val();
                mdmCode_cg = $("#mdmCode_cg").val();
            } else if (type === '脱落召回') {
                planId_tl = $("#planId_tl").val();
                mdmCode_tl = $("#mdmCode_tl").val();
            }
        });
        patientId = $("#patientId").val();
        taskId = $("#id").val();

        // 收集所有非隐藏的表单项
        var formData = new FormData();
        $('#ClosePlanForm').find(':not(.hidden)').find('input, select, textarea').each(function () {
            var $this = $(this);
            if ($this.is(':radio')) {
                if ($this.is(':checked')) {
                    formData.append($this.attr('name'), $this.val());
                }
            } else if ($this.is(':checkbox')) {
                if ($this.is(':checked')) {
                    formData.append($this.attr('name'), $this.val());
                }
            } else if ($this.attr('type') !== 'submit' && $this.attr('type') !== 'button') {
                formData.append($this.attr('name'), $this.val());
            }
        });

        // 添加额外的参数
        formData.append('taskId', taskId);
        formData.append('planId_cg', planId_cg || '');
        formData.append('planId_cg', planId_cg || '');
        formData.append('planId', planId || '');
        formData.append('mdmCode_tl', mdmCode_tl || '');
        formData.append('mdmCode_cg', mdmCode_cg || '');
        formData.append('mdmCode', mdmCode || '');
        formData.append('patientId', patientId);

        // 如果有指定类型被选中，添加到formData
        if (specifiedType.length > 0) {
            formData.append('specifiedType', specifiedType.join(','));
        }

        console.log(formData);

        $.ajax({
            url: prefix_task + "/closePlan",
            data: formData,
            method: 'POST',
            processData: false, // 防止 jQuery 自动转换数据
            contentType: false, // 不设置内容类型
            dataType: 'json',
            error: function (data) {
                $.modal.alertError("关闭计划失败");
                flag = true;
            },
            success: function (data) {
                if (data.code == 0) {
                    $.modal.alertSuccess("关闭计划成功");
                    updateTabState('#tab-3');
                    window.location.reload();
                    flag = false;
                } else {
                    $.modal.alertError("关闭计划失败");
                    flag = true;
                }

            }
        });

        if (flag == false) {
            $('#myModalClosePlan').hide();
        } else {
            $('#myModalClosePlan').show();
        }
    }

    /* 去关联 */
    function correlation(id) {
        //弹框做操作
        // $.modal.confirm("确认要启用用户吗？", function() {
        //     $.operate.post(prefix + "/toCorrelation", { "id": id, "status": 1 });
        // })
        onclick = "$.operate.edit(\'' + row.id + '\')"
        var options = {
            title: '添加复购品',
            url: prefix + "/toCorrelation" + id,
            callBack: doSubmit2
        };
        $.modal.openOptions(options);
    }

    // 关闭计划
    function closePlan(planFlag) {
        closePlanFlag = planFlag;
        var taskId;

        if (planFlag === 1) {
            taskId = $("#id").val();
            planId = $("#planId_cg").val();
            mdmCode = $("#mdmCode_cg").val();
            // 设置默认选中的选项
            $('input[name="closeType"][value="指定类型"]').prop('checked', true);
            $('input[name="specifiedType"][value="常规随访"]').prop('checked', true);
        } else if (planFlag === 2) {
            $('input[name="closeType"][value="指定类型"]').prop('checked', true);
            $('input[name="specifiedType"][value="脱落召回"]').prop('checked', true);
            taskId = $("#id").val();
            planId = $("#planId_tl").val();
            mdmCode = $("#mdmCode_tl").val();
        }
        $('#myModalClosePlan').show();
        //$.operate.addSetwht('关闭计划',prefix_task + "/closePlanPage",800,500)
        $('input[name="closePlanScope"][value="仅关闭当前计划"]').prop('checked', true);
        // 更新界面元素的可见性
        updateVisibility();


    }

    // 关闭任务
    function closeTask(id) {
        $.modal.confirm("确认要关闭任务吗? 关闭任务后将停止该任务的随访操作", function () {
            var formData = new FormData();
            formData.append('id', id);

            $.ajax({
                url: prefix_task + "/closeTask",
                data: formData,
                method: 'POST',
                processData: false, // 防止 jQuery 自动转换数据
                contentType: false, // 不设置内容类型
                success: function (data) {
                    $.modal.alertSuccess("关闭任务成功");
                    // $.modal.reload();
                    window.location.reload();
                },
                error: function (xhr, status, error) {
                    $.modal.alertError("关闭任务失败");
                }
            });
        });
    }

    // 辅助函数：用于更新选项卡状态
    function updateTabState(tabId) {
        // 移除所有 li 的 active 类
        $('#myUlTabs .nav-item').removeClass('active');
        // 设置指定 tab 的 li 为 active
        $(tabId).closest('.nav-tabs').find('a[href="' + tabId + '"]').parent().addClass('active');

        // 更新 a 标签的 aria-expanded 属性
        $('#myUlTabs a').attr('aria-expanded', 'false');
        $(tabId).closest('.nav-tabs').find('a[href="' + tabId + '"]').attr('aria-expanded', 'true');

        // 移除所有 tab-pane 的 active 和 in 类
        $('.tab-pane').removeClass('active in show'); // 注意这里使用了 'show' 类，取决于你使用的 Bootstrap 版本
        // 为指定 tab-pane 添加 active 和 in 类
        $(tabId).addClass('active in show'); // 同上，确保与你的 Bootstrap 版本匹配
    }

    function editSFGenJinRen() {
        //随访计划跟进人
        var followUpPersonId = /*[[${followUpPersonId}]]*/ '';
        var followUpPersonName = /*[[${followUpPersonName}]]*/ '';
        // $.operate.addSetwht('分配跟进人','dtp/pmService/followUpAssignAdd',800,800)
        //var followUpPersonId=$('#followUpPersonId').val()
        //alert("编辑随访跟进人"+followUpPersonId);
        var options = {
            title: '分配跟进人',
            width: 800,
            height: 600,
            url: prefix + '/followUpAssignAdd',
            callBack: doSubmit2
        };
        $.modal.openOptions(options);
    }

    // callBack获取父窗口方法（方式二）
    function doSubmit2(index, layero) {
        var hzparam;
        var rows = layero.find("iframe")[0].contentWindow.selectTableObject();
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        var followUpPersonId = $('#followUpPersonId').val();//s_dtp_ysfw_follow_up_assign
        rows.forEach(function (item) {
            // 动态选择所有列并映射到更具描述性的名称
            hzparam = {
                id: item.id,
                pharmacistName: item.pharmacistName,
                position: item.position,
                storeName: item.storeName,
                phone: item.phone,
                storeId: item.storeId,
                followUpPersonId: followUpPersonId
            };

        });
        $.ajax({
            cache: true,
            type: "POST",
            url: prefix + '/editFollowUpAssign', // 替换为实际的搜索 URL
            data: hzparam,
            async: false,
            success: function (data) {
                $.modal.msg("操作成功");
                // 更新 <code> 标签的内容
                var followUpPersonName = hzparam.pharmacistName; // 假设需要第一个对象的 pharmacistName
                $('#followUpPersonNameCode').text(followUpPersonName);
                $('#followUpPersonName').val(followUpPersonName); // 更新输入框的值

            },
            error: function (error) {
                $.modal.alertError("失败");
            }
        });
        $.modal.close(index);
    }

    function editTaskGenJinRen() {
        //任务跟进人

        var options = {
            title: '分配跟进人',
            width: 800,
            height: 600,
            url: prefix + '/followUpAssignAdd',
            callBack: doSubmit1
        };
        $.modal.openOptions(options);
    }

    function doSubmit1(index, layero) {
        var bc_id = $('#bc_id').val()
        var hzparam;
        var rows = layero.find("iframe")[0].contentWindow.selectTableObject();
        if (rows.length == 0) {
            $.modal.alertWarning("请至少选择一条记录");
            return;
        }
        rows.forEach(function (item) {
            // 动态选择所有列并映射到更具描述性的名称
            hzparam = {
                id: item.id,
                pharmacistName: item.pharmacistName,
                position: item.position,
                storeName: item.storeName,
                phone: item.phone,
                storeId: item.storeId,
                taskId: bc_id
            };

        });
        $.ajax({
            cache: true,
            type: "POST",
            url: prefix + '/editFollowTaskAssignById', // 替换为实际的搜索 URL
            data: hzparam,
            async: false,
            success: function (data) {
                $.modal.msg("操作成功");
                // 更新 <code> 标签的内容
                var followUpPersonName = hzparam.pharmacistName; // 假设需要第一个对象的 pharmacistName
                $('#bc_taskFollowerCode').text(followUpPersonName);
                $('#bc_taskFollower').val(followUpPersonName); // 更新输入框的值

            },
            error: function (error) {
                $.modal.alertError("失败");
            }
        });
        $.modal.close(index);
    }


    function updateInterval(nextFollowTimeStr) {
        // 获取当前时间
        const now = new Date();
        if (nextFollowTimeStr) {
            // 将字符串转换为日期对象
            const nextFollowTime = new Date(nextFollowTimeStr);

            // 计算间隔天数
            const intervalDays = Math.floor((nextFollowTime - now) / (1000 * 60 * 60 * 24));

            // 显示间隔天数
            const intervalThisTimeSpan = $('#interval_this_time');
            if (intervalDays < 0) {
                intervalThisTimeSpan.css('color', 'red').text(intervalDays);
            } else {
                intervalThisTimeSpan.css('color', '#1a7bb9').text(intervalDays);
            }
        } else {
            // 如果没有选择下次随访时间，清除间隔天数显示
            const intervalThisTimeSpan = $('#interval_this_time');
            intervalThisTimeSpan.text('');
        }
    }

    function onselectsf() {
        // 初始化时检查是否有预设的下次随访时间
        const initialNextFollowTime = $('#next_follow_time').val();
        if (initialNextFollowTime) {
            $('#next_follow_time').val(initialNextFollowTime);
            updateInterval(initialNextFollowTime);
        }
    }
</script>
