<%@ Page Title="" Language="C#" MasterPageFile="~/Styles/MasterPage/MasterPage_Edit.master" AutoEventWireup="true" CodeFile="VendorClass_Edit.aspx.cs" Inherits="Base_VendorClass_VendorClass_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: 'VendorClass_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()" >保存</a>
        <a plain="true" class="easyui-linkbutton" onclick="parent.DesignModuleFormat('Base_VendorClass_Input');CloseDivWin();" style='<%=auth.FormatView()%>'>格式</a>
    </div>
    <div style="width:350px;height:300px;overflow:hidden;">
        <div class="edit_area">
        <%=xview["input_ui"]%>
        </div>
    </div>
    <script type="text/javascript">
        //弹出窗口_选择供应商分类
        function AdvancedSearch_VendorClass(keyword) {
            var url = "../../Component/AdvancedSearch/VendorClass_List.aspx?keyword=" + escape(keyword);
            parent.asyncbox.open({
                id: 'win_select',
                url: url,
                modal: true,
                width: 400,
                height: 400,
                title: '选择供应商分类'
            });
        }
        //通过主键_获取供应商分类
        function SearchService_VendorClass(vc_id) {
            $.ajax({
                type: "POST",
                contentType: "application/json",
                url: '../../Base/Vendor/VendorClass_Service.asmx/Get',
                data: "{vc_id:'" + vc_id + "'}",
                dataType: 'json',
                success: function (result) {
                    $("#parent_id").val(result.d.vc_id);
                    $("#parent_name").val(result.d.vc_name);
                }
            });
        }
        //初始化页面
        function init_page() {
            $F("trigger_parent_name").onclick = function () {
                AdvancedSearch_VendorClass($("#parent_name").val());
            };
            if(action == "Add"){
                //新增时带出父类编码作为当前编码方便输入
                $F("vc_code").value = '<%=xview["parent_code"]%>';
                //新增时带出父类
                $F("parent_id").value = '<%=xview["parent_id"]%>';
                $F("parent_name").value = '<%=xview["parent_name"]%>';
            }
            <%if(action.Equals("Update")){ %>
                $F("parent_name").value = '<%=m.parent.vc_name%>';
            <%} %>
        }
        init_page();
    </script>
</asp:Content>

