<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('患者管理品编辑页面')" />
</head>
<body>
<div class="ui-layout-center">
    <form id="form-SSpglJfspProductinfo-edit" class="customize-search-form">

        <div class="customize-form-group-container">
            <input type="hidden" id="id" name="id" th:value="${id}">
            <div class="customize-form-group">
                <label class="is-required">药品编码:</label>
                <input name="mdmCode" placeholder="药品编码" th:value="${mdmCode}" class="styled-input" type="text" readonly>
            </div>
            <div class="customize-form-group">
                <label>D值品编码:</label>
                <input name="d_value_code" placeholder="D值品编码" th:value="${d_value_code}" class="styled-input" type="text" disabled>
            </div>
            <div class="customize-form-group">
                <label>D值品名称:</label>
                <input name="dValueName" placeholder="D值品名称" th:value="${dValueName}" class="styled-input" type="text" disabled>
            </div>
            <div class="customize-form-group">
                <label>规格:</label>
                <input name="specification" placeholder="规格" th:value="${specification}" class="styled-input" type="text" disabled>
            </div>
            <div class="customize-form-group">
                <label>包装:</label>
                <input name="packaging" placeholder="包装" th:value="${packaging}" class="styled-input" type="text" disabled>
            </div>

            <div class="customize-form-group">
                <label class="is-required">通用名:</label>
                <input name="genericName" placeholder="通用名" th:value="${genericName}" class="styled-input" type="text" readonly>
            </div>
            <div class="customize-form-group">
                <label class="is-required">商品名:</label>
                <input name="productName" placeholder="请输入商品名" th:value="${productName}" class="styled-input" type="text" readonly>
            </div>
            <div class="customize-form-group">
                <label>厂家简称:</label>
                <input name="manufacturerShortName" placeholder="请输入厂家简称" th:value="${manufacturerShortName}" class="styled-input" type="text">
            </div>
            <div class="customize-form-group">
                <label class="is-required">是否随访管理品:</label>
                <select name="isFollowUpManaged" id="isFollowUpManaged" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yes_no')}" th:value="${isFollowUpManaged}" required>
                    <option value="">请选择</option>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"  th:selected="${dict.dictValue}==${isFollowUpManaged}"></option>
                </select>
            </div>
            <div class="customize-form-group">
                <label>是否冷链管理品:</label>
                <select name="isColdChainManaged" id="isColdChainManaged" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yes_no')}" th:value="${isColdChainManaged}" >
                    <option value="">请选择</option>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:selected="${dict.dictValue}==${isColdChainManaged}"></option>
                </select>
            </div>
            <div class="customize-form-group">
                <label class="is-required">是否登记管理品:</label>
                <select name="isRegisteredManaged" id="isRegisteredManaged" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yes_no')}" th:value="${isRegisteredManaged}" required>
                    <option value="">请选择</option>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:selected="${dict.dictValue}==${isRegisteredManaged}"></option>
                </select>
            </div>
            <div class="customize-form-group">
                <label>是否慈善援助管理品:</label>
                <select name="isCharityAidManaged" id="isCharityAidManaged" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yes_no')}" th:value="${isCharityAidManaged}" >
                    <option value="">请选择</option>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:selected="${dict.dictValue}==${isCharityAidManaged}"></option>
                </select>
            </div>
            <div class="customize-form-group">
                <label>给药方式:</label>
                <select name="administrationMethod" id="administrationMethod" class="styled-input" th:with="type=${@dict.getType('sys_select_dtp_yyff')}" th:value="${administrationMethod}" >
                    <option value="">请选择</option>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:selected="${dict.dictLabel}==${administrationMethod}"></option>
                </select>
            </div>
            <div class="customize-form-group">
                <label>企业流向管理方式:</label>
                <select name="enterpriseFlowManagement" id="enterpriseFlowManagement" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yppz_qylxglfs')}" th:value="${enterpriseFlowManagement}" >
                    <option value="">请选择</option>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:selected="${dict.dictValue}==${enterpriseFlowManagement}"></option>
                </select>
            </div>

            <div class="rule-info-section">
                <hr /> 用药规则配置信息<hr />
                <span>这里是规则用药规则配置信息：最大剂量数量=每天用药数量,最大剂量单位=例如: mg,g,ml。购药包装单位数值=关键信息-是指更据药品规格选取的值，提供给系统自动计算D值的必要参数</span>
            </div>
                <div class="customize-form-group">
                    <label class="is-required">最大剂量数量：</label>
                    <input type="number" name="dosage_max"  placeholder="最大剂量数量" th:value="${dosage_max}" class="styled-input" required />
                </div>
                <div class="customize-form-group">
                    <label class="is-required">最大剂量单位：</label>
                    <select name="unit_max" class="styled-input" style="height: auto"  placeholder="最大剂量单位" th:with="type=${@dict.getType('sys_gxhpz_gg_unitall')}" required>
                        <option value="">请选择</option>
                        <option th:each="dict : ${type}" th:value="${dict.dictValue}" th:selected="${dict.dictValue}==${unit_max}" th:text="${dict.dictLabel}"></option>
                    </select>
                </div>

                <div class="customize-form-group">
                    <label>常用剂量数量：</label>
                    <input type="number" name="dosage_normal"  placeholder="常用剂量数量" th:value="${dosage_normal}"   class="styled-input" />
                </div>
                <div class="customize-form-group">
                    <label>常用剂量单位：</label>
                    <select name="unit_normal" class="styled-input" style="height: auto"  placeholder="常用剂量单位" th:with="type=${@dict.getType('sys_gxhpz_gg_unitall')}">
                        <option value="">请选择</option>
                        <option th:each="dict : ${type}" th:value="${dict.dictValue}" th:selected="${dict.dictValue}==${unit_normal}" th:text="${dict.dictLabel}"></option>
                    </select>
                </div>
                <div class="customize-form-group">
                    <label class="is-required">最小剂量数量：</label>
                    <input type="number" name="dosage_min"  placeholder="最小剂量数量" th:value="${dosage_min}"  class="styled-input" required />
                </div>
                <div class="customize-form-group">
                    <label class="is-required">最小剂量单位：</label>
                    <select name="unit_min" class="styled-input" style="height: auto" placeholder="最小剂量单位" th:with="type=${@dict.getType('sys_gxhpz_gg_unitall')}" required>
                        <option value="">请选择</option>
                        <option th:each="dict : ${type}" th:value="${dict.dictValue}" th:selected="${dict.dictValue}==${unit_min}" th:text="${dict.dictLabel}"></option>
                    </select>
                </div>
                <div class="customize-form-group">
                    <label class="is-required">购药包装单位数值：</label>
                    <input type="number" name="packing_value"  placeholder="购药包装单位数值" th:value="${packing_value}"  class="styled-input" required />
                </div>
                <div class="customize-form-group">
                    <label>包装单位：</label>
                    <select name="packing_unit" class="styled-input" style="height: auto" placeholder="包装单位"  th:with="type=${@dict.getType('sys_gxhpz_gg_unitall')}">
                        <option value="">请选择</option>
                        <option th:each="dict : ${type}" th:value="${dict.dictValue}" th:selected="${dict.dictValue}==${packing_unit}" th:text="${dict.dictLabel}"></option>
                    </select>
                </div>
        </div>
    </form>
</div>
<div class="main-content">
    <div class="col-sm-offset-5 col-sm-10">
    </div>
</div>
<th:block th:include="include :: footer" />
</body>
</html>
<script>
    function edit() {
        var data = $("#form-SSpglJfspProductinfo-edit").serializeArray();
        data.push({name: 'type', value: '0'});
        console.log(data);
        $.ajax({
            cache : true,
            type : "POST",
            url : ctx + "yppz/drugConfig/editDrugConfig",
            data : data,
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                $.operate.successCallback(data);
            }
        });
    }

    function submitHandler() {
        var dosage_max = $("#form-SSpglJfspProductinfo-edit").serializeArray().find(item => item.name === 'dosage_max');
        if (dosage_max.value === '') {
            $.modal.alertWarning("请选择最大剂量数量！");
            return null;
        }
        var dosage_min = $("#form-SSpglJfspProductinfo-edit").serializeArray().find(item => item.name === 'dosage_min');
        if (dosage_min.value === '') {
            $.modal.alertWarning("请选择最小剂量数量！");
            return null;
        }
        var unit_max = $("#form-SSpglJfspProductinfo-edit").serializeArray().find(item => item.name === 'unit_max');
        if (unit_max.value === '') {
            $.modal.alertWarning("请选择最大剂量单位！");
            return null;
        }
        var unit_min = $("#form-SSpglJfspProductinfo-edit").serializeArray().find(item => item.name === 'unit_min');
        if (unit_min.value === '') {
            $.modal.alertWarning("请选择最小剂量单位！");
            return null;
        }
        var unit_normal = $("#form-SSpglJfspProductinfo-edit").serializeArray().find(item => item.name === 'unit_normal');
        if (unit_normal.value === '') {
            $.modal.alertWarning("请选择常见计量单位！");
            return null;
        }
        var dosage_normal = $("#form-SSpglJfspProductinfo-edit").serializeArray().find(item => item.name === 'dosage_normal');
        if (dosage_normal.value === '') {
            $.modal.alertWarning("请选择常见计量数量！");
            return null;
        }
        var packing_value = $("#form-SSpglJfspProductinfo-edit").serializeArray().find(item => item.name === 'packing_value');
        if (packing_value.value === '') {
            $.modal.alertWarning("请选择包装单位值！");
            return null;
        }
        var packing_unit = $("#form-SSpglJfspProductinfo-edit").serializeArray().find(item => item.name === 'packing_unit');
        if (packing_unit.value === '') {
            $.modal.alertWarning("请选择包装单位！");
            return null;
        }
        if ($.validate.form()) {
            edit();
        }
    }
</script>
<style>
    .form-grid1 {
        display: grid;
        grid-template-columns: 1fr 1fr; /* 创建两列 */
        gap: 20px; /* 设置列之间的间距 */
    }

    .form-field-left, .form-field-right {
        display: flex;
        flex-direction: column;
    }

    .form-field-left , .form-field-right {
        margin-bottom: 5px; /* 给标签与输入框之间留出一些空间 */
    }

    .styled-input1 {
        padding: 8px;
        border: 1px solid #ccc;
        border-radius: 4px;
        width: 100%; /* 确保输入框占满整个宽度 */
    }

    .span_line1 {
        display: block;
        height: 1px;
        background-color: #e0e0e0;
        margin-top: 10px;
    }
    .rule-info-section {
        /*display: flex;*/
        align-items: center;
        justify-content: center;
        margin-bottom: 20px; /* 调整与下面表单元素的距离 */
    }

    .rule-info-section hr {
        flex-grow: 1;
        margin: 0 10px; /* 线条与文案之间的间距 */
        border: 0;
        height: 1px;
        background-color: #ccc; /* 线条颜色 */
    }

    .rule-info-section span {
        background: #efe9c4;
        padding: 0 10px; /* 文案与线条之间的内边距 */
        font-size: 14px;
        color: #dd1b20; /* 文案颜色 */
    }
</style>
