<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('任务跟进人新增')" />
    <th:block th:include="include :: ztree-css" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form id="form-SSpglJfspProductinfo-add" class="customize-search-form">

            <div class="customize-form-group-container">
            <div class="customize-form-group edit">
                <label>跟进人姓名:</label>
                <input name="pharmacistName" placeholder="请输入跟进人姓名" id="pharmacistName" class="styled-input" type="text">
            </div>

            <div class="customize-form-group">
                <label>手机号:</label>
                <input name="phone" placeholder="请输入手机号" id="phone" class="styled-input" 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}"></option>
                </select>
            </div>
                <div class="customize-form-group">
                    <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}"></option>
                    </select>
                </div>
            <div class="customize-form-group">
                <label>所属门店:</label>
                <input name="storeName" placeholder="请输入所属门店" id="storeName" class="styled-input" type="text">
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<th:block th:include="include :: ztree-js" />
<script type="text/javascript">

    function submitHandler() {
        var selectedValue = $('#default_follow_up').val();

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

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