<!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-container">
                <div class="customize-form-group-container">
                    <div class="customize-form-group">
                        <label id="shys">审核药师:</label>
                        <label id="task">跟进人姓名:</label>
                        <input name="pharmacistName" placeholder="请输入审核药师" id="pharmacistName" th:value="${pharmacistName}" class="styled-input" type="text">
                    </div>
                    <div class="customize-form-group" id="pwd">
                        <label >审核密码:</label>
                        <input name="reviewPassword" placeholder="请输入审核密码" id="reviewPassword" th:value="${reviewPassword}" class="styled-input" type="text">
                    </div>
                    <div class="customize-form-group" id="ssjh">
                        <label >手机号:</label>
                        <input name="phone" placeholder="请输入手机号" id="phone" class="styled-input" th:value="${phone}" type="number" maxlength="11">
                    </div>
                    <div class="customize-form-group">
                        <label>角色:</label>
                        <select name="position" id="position" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_yppz_roles')}" required>
                            <option value="">请选择</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:selected="${position}==${dict.dictValue}"></option>
                        </select>
                    </div>
                    <div class="customize-form-group" id="default_follow_upId" >
                        <label>是否默认为任务跟进人:</label>
                        <select name="default_follow_up" id="default_follow_up" class="styled-input" th:with="type=${@dict.getType('sys_select_yes_no')}" required>
                            <option value="">请选择</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:selected="${default_follow_up}==${dict.dictValue}"></option>
                        </select>
                    </div>
                    <div class="customize-form-group">
                        <label>所属门店:</label>
                        <input name="storeName" placeholder="请输入所属门店" id="storeName" th:value="${storeName}" class="styled-input" type="text">
                    </div>
                    <div class="customize-form-group" id="statusDIv">
                        <label>在职状态:</label>
                        <select name="status" id="status" class="styled-input" th:with="type=${@dict.getType('sys_gxhpz_job_status')}" required>
                            <option value="">请选择</option>
                            <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}" th:selected="${status}==${dict.dictValue}"></option>
                        </select>
                    </div>
            </div>
        </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 th:inline="javascript">

    var positionFlag=false;
    //初始化加载
    $(document).ready(function() {
        var id = $("#id").val();
        var position = $("#position").val();
        var ssjh = $("#ssjh").val();
        var pwd = $("#pwd").val();
        var task = $("#task").val();
        var shys = $("#shys").val();
        if(position=="审核药师"){
            positionFlag=false;
            $("#ssjh").hide();
            $("#task").hide();
            $("#default_follow_upId").hide();
           // $("#statusDIv").hide();

        }else if(position=="任务跟进人"){
            var selectedValue = $('#default_follow_up').val();
            if (selectedValue === '1') {
                positionFlag=true;
            }
            $("#pwd").hide();
            $("#shys").hide();
        }else {
            positionFlag=false;
            $("#ssjh").hide();
            $("#task").hide();
            $("#default_follow_upId").hide();
        }




    });
    function edit() {
        var data = $("#form-SSpglJfspProductinfo-edit").serializeArray();
        $.ajax({
            cache : true,
            type : "POST",
            url : ctx + "gxhpz/pharmacists/pharmacistsEdit",
            data : data,
            async : false,
            error : function(request) {
                $.modal.alertError("系统错误");
            },
            success : function(data) {
                $.operate.successCallback(data);
            }
        });
    }

    function submitHandler() {
        if ($.validate.form()) {

            if(positionFlag){
                var selectedValue = $('#default_follow_up').val();
                if (selectedValue === '1') {
                    $.modal.confirm("设置该用户为默认任务跟进人,将替换已有的的默认任务跟进人", function() {
                        edit();
                    });
                } else {
                    edit();
                }
            }else {
                edit();
            }

        }
    }



</script>
