 <!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('新建患者咨询')" />
</head>
<style>

</style>
<script>

</script>
<body>
    <div class="ui-layout-center">
        <form id="form-patientCounseling-add" class="customize-search-form">
            <div class="customize-form-group-container">
                <div class="customize-form-group">
                    <label class="col-sm-1 control-label">咨询日期：</label>
                    <div class="customize-form-group select-time">
                        <input name="consultationTime" placeholder="咨询日期"  id="consultationTime" class="time-input time-input2" type="text">
                    </div>
                </div>
                <div class="customize-form-group">
                    <label class="col-sm-1 control-label">问题类型：</label>
                    <select name="questionType" class="styled-input" th:with="type=${@dict.getType('sys_select_dtp_hzzx_wtlx')}" >
                        <option>请选择</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"></option>
                    </select>
                </div>
                <div class="customize-form-group">
                    <label class="col-sm-1 control-label">咨询问题：</label>
                    <textarea id="consultationQuestion" name="consultationQuestion" class="styled-input edit_inputs textareas"
                     style="width: auto;height: 140px ;border: 1px solid ;" placeholder="咨询问题..." rows="1" cols="65" ></textarea>
                </div>

                <div class="customize-form-group">
                    <label class="col-sm-1 control-label">药师解答：</label>
                    <textarea id="pharmacistAnswer" name="pharmacistAnswer" class="styled-input edit_inputs textareas"
                              style="width: auto;height: 140px ;border: 1px solid ;" placeholder="药师解答..." rows="1" cols="65" ></textarea>
                </div>
                <div class="customize-form-group">
                    <label class="col-sm-1 control-label">知识链接：</label>
                    <div class="input-groups" th:with="type=${@dict.getType('sys_select_dtp_ysfw_zslj')}" id="KnowledgeLinkDiv">
                        <input type="checkbox" class="form-check-radio" th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" name="KnowledgeLink">
                    </div>
                </div>
                <div class="customize-form-group">
                    <label class="col-sm-1 control-label is-required" >关联患者：</label>
                    <select name="patientId" class="styled-input" >
                        <option>请选择</option>
                        <option th:each="patient : ${patients}" th:text="${patient.name}" th:value="${patient.id}"></option>
                    </select>
                </div>
                <div class="customize-form-group">
                    <label class="col-sm-1 control-label">联系人与患者关系：</label>
                    <select name="contactRelation" class="styled-input" th:with="type=${@dict.getType('sys_select_dtp_ysfw_lxryhzgx')}">
                        <option>请选择</option>
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictLabel}"
                        ></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
	<th:block th:include="include :: footer" />
</body>
</html>

<script>
    var prefix = ctx + "dtp/pmService";
    function submitHandler() {
        var KnowledgeLinks = []; //睡眠状况
        $('input[name="KnowledgeLink"]:checked').each(function() {
            KnowledgeLinks.push($(this).val());
        });
        if ($.validate.form()) {
            var data = $("#form-patientCounseling-add").serializeArray();
            var consultationQuestion = document.getElementById('consultationQuestion').value;
            var pharmacistAnswer = document.getElementById('pharmacistAnswer').value;
            data.push({name:"consultationQuestion",value:consultationQuestion})
            data.push({name:"pharmacistAnswer",value:pharmacistAnswer})
            data.push({name:"KnowledgeLinksValue",value:KnowledgeLinks.join(',')})
            $.ajax({
                cache : true,
                type : "POST",
                url : prefix + "/patientCounselingAdd",
                data : data,
                async : false,
                error : function(data) {
                    $.modal.alertError(data.msg);
                },
                success : function(data) {
                    //$.table.refresh()
                    $.operate.successCallback(data);
                }
            });
        }
    }
</script>
