<%@ Page Title="" Language="C#" MasterPageFile="~/Styles/MasterPage/MasterPage_Edit.master" AutoEventWireup="true" CodeFile="Cost_Edit.aspx.cs" Inherits="Base_Cost_Cost_Edit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <script type="text/javascript">
        var action = '<%=xview["action"]%>';
        function Save() {
            <%=xview["Script_GetInput"] %>
            if (cst_name == "") {
                parent.AlertNO('请输入费用名称!');
                return;
            }
           
            var action = '<%=xview["action"]%>';
            parent.ShowLoadingMask(); //显示遮罩
            $.ajax({
                type: "POST",
                contentType: "application/json",
                url: 'Cost_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_Cost_Input');CloseDivWin();">格式</a>
    </div>
    <div style="width:400px;height:300px;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');
            $F("trigger_parent_name").onclick = function () {
                AdvancedSearch_Cost($("#parent_name").val());
            };
            <%if(action.Equals("Update")){ %>
                is_stop.value = '<%=m.is_stop%>';
                $F("parent_name").value = '<%=m.parent.cst_name%>';
            <%} %>
            if(action == "Add"){
                //新增时带出父类编码作为当前编码方便输入
                $F("cst_code").value = '<%=xview["parent_code"]%>';
                //新增时带出父类
                $F("parent_id").value = '<%=xview["parent_id"]%>';
                $F("parent_name").value = '<%=xview["parent_name"]%>';
            }
        }
        init_page();
        //通过主键_获取费用
        function SearchService_Cost(cst_id) {
            $.ajax({
                type: "POST",
                contentType: "application/json",
                url: '../../Base/Cost/Cost_Service.asmx/Get',
                data: "{cst_id:'" + cst_id + "'}",
                dataType: 'json',
                success: function (result) {
                    $("#parent_id").val(result.d.cst_id);
                    $("#parent_name").val(result.d.cst_name);
                }
            });
        }
    </script>
</asp:Content>

