<%@ Page Title="" Language="C#" MasterPageFile="~/Styles/MasterPage/MasterPage_Edit.master" AutoEventWireup="true" CodeFile="Customer_Edit.aspx.cs" Inherits="Base_Customer_Customer_Edit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <script type="text/javascript">
        var action = '<%=xview["action"]%>';
        //保存
        function Save() {
            <%=xview["Script_GetInput"] %>
            var action = '<%=xview["action"]%>';
            parent.ShowLoadingMask(); //显示遮罩
            $.ajax({
                type: "POST",
                contentType: "application/json",
                url: 'Customer_Service.asmx/Save',
                data: "{action:'" + action + "',<%=xview["Script_SaveJSON"]%>}",
                dataType: 'json',
                success: function (result) {
                    parent.HideLoadingMask(); //关闭遮罩
                    var r = result.d;
                    if (r == "success") {
                        parent.AlertOK('保存成功!');
                        parent.search_grid();
                        parent.load_tree();
                        CloseDivWin(); //关闭窗口
                    } else {
                        parent.AlertNO(r);
                    }
                }
            });
        }
    </script>
    <!--工具栏-->
    <div class="list_menu_bar">
        <a plain="true" class="easyui-linkbutton" iconcls="icon-save" onclick="Save()" style='<%=auth.AuthView("Base_Customer_Edit")%>'>保存</a>
        <a plain="true" class="easyui-linkbutton" onclick="parent.DesignModuleFormat('Base_Customer_Input');CloseDivWin();" style='<%=auth.FormatView()%>'>格式</a>
    </div>
    <div style="width:800px;height:500px;overflow:auto;">
        <div class="edit_area">
        <%=xview["input_ui"]%>
        </div>
    </div>
    <script type="text/javascript">
        //初始化页面
        function init_page() {
            var is_stop = $F("is_stop");
            AddOption(is_stop,'否','0');
            AddOption(is_stop, '是', '1');
            var bao_bei = $F("bao_bei");
            AddOption(bao_bei, '否', '0');
            AddOption(bao_bei, '是', '1');
            FastSearch_Employee(); //专管业务员

            //选择自定义项档案
            <%for(int i=1;i<=5;i++){ %>
                $F("trigger_sdefine<%=i%>").onclick = function () {
                    AdvancedSearch_DefineItem($("#sdefine<%=i%>").val(),'Customer_sdefine<%=i%>','sdefine<%=i%>');
                };
            <%}
              for(int i=1;i<=5;i++){ %>
                $F("trigger_ndefine<%=i%>").onclick = function () {
                    AdvancedSearch_DefineItem($("#ndefine<%=i%>").val(),'Customer_ndefine<%=i%>','ndefine<%=i%>');
                };
            <%} %>

            $F("trigger_cc_name").onclick = function () {
                AdvancedSearch_CustomerClass($("#cc_name").val());
            };
            //弹出窗口_选择客户分类
            function AdvancedSearch_CustomerClass(keyword) {
                var url = "../../Component/AdvancedSearch/CustomerClass_List.aspx?keyword=" + escape(keyword);
                parent.asyncbox.open({
                    id: 'win_select',
                    url: url,
                    modal: true,
                    width: 400,
                    height: 400,
                    title: '选择客户分类'
                });
            }
            <%if(action.Equals("Update")){ %>
                is_stop.value = '<%=m.is_stop%>';
                bao_bei.value = '<%=m.bao_bei%>';
                $F("cc_name").value = '<%=m.customer_class.cc_name%>';
                $F("ele_name").value = '<%=m.employee==null?"":m.employee.ele_name%>';
            <%} %>
            if(action == "Add"){
                $F("cc_id").value = '<%=xview["cc_id"]%>';
                $F("cc_name").value = '<%=xview["cc_name"]%>';
            }
        }
        init_page();
    </script>
</asp:Content>

