<%@ Page Title="" Language="C#" MasterPageFile="~/Styles/MasterPage/MasterPage_Edit.master" AutoEventWireup="true" CodeFile="Inventory_Edit.aspx.cs" Inherits="Base_Inventory_Inventory_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: 'Inventory_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_Inventory_Edit")%>'>保存</a>
        <a plain="true" class="easyui-linkbutton" onclick="parent.DesignModuleFormat('Base_Inventory_Input');CloseDivWin();" style='<%=auth.FormatView()%>'>格式</a>
    </div>
    <div style="width:800px;height:500px;overflow:auto;margin:auto;text-align:center">
        <div class="edit_area">
        <%=xview["input_ui"]%>
        </div>
    </div>
    <script type="text/javascript">
        //初始化页面
        function init_page() {
            var on_free1 = $F("on_free1");
            AddOption(on_free1,'否','0');
            AddOption(on_free1,'是','1');

            var on_free2 = $F("on_free2");
            AddOption(on_free2,'否','0');
            AddOption(on_free2,'是','1');

            var on_batch = $F("on_batch");
            AddOption(on_batch,'否','0');
            AddOption(on_batch,'是','1');

            var is_sale = $F("is_sale");
            AddOption(is_sale,'否','0');
            AddOption(is_sale,'是','1');

            var is_purchase = $F("is_purchase");
            AddOption(is_purchase,'否','0');
            AddOption(is_purchase,'是','1');

            var is_self = $F("is_self");
            AddOption(is_self,'否','0');
            AddOption(is_self,'是','1');

            var is_outsource = $F("is_outsource");
            AddOption(is_outsource,'否','0');
            AddOption(is_outsource, '是', '1');

            var is_service = $F("is_service");
            AddOption(is_service, '否', '0');
            AddOption(is_service, '是', '1');

            var valuation = $F("valuation");
            AddOption(valuation,'','');
            AddOption(valuation,'移动平均法','1');
            AddOption(valuation,'全月平均法','2');

            $F("trigger_ic_name").onclick = function () {
                AdvancedSearch_InventoryClass($("#ic_name").val());
            };

            //选择自定义项档案
            <%for(int i=1;i<=5;i++){ %>
                $F("trigger_sdefine<%=i%>").onclick = function () {
                    AdvancedSearch_DefineItem($("#sdefine<%=i%>").val(),'Inventory_sdefine<%=i%>','sdefine<%=i%>');
                };
            <%}
              for(int i=1;i<=5;i++){ %>
                $F("trigger_ndefine<%=i%>").onclick = function () {
                    AdvancedSearch_DefineItem($("#ndefine<%=i%>").val(),'Inventory_ndefine<%=i%>','ndefine<%=i%>');
                };
            <%} %>
            //单位作自定义项
            $F("trigger_munit").onclick = function () {
                AdvancedSearch_DefineItem($("#trigger_munit").val(), 'Inventory_munit', 'munit');
            };
            $F("trigger_aunit").onclick = function () {
                AdvancedSearch_DefineItem($("#trigger_aunit").val(), 'Inventory_aunit', 'aunit');
            };
            <%if(action.Equals("Update")){ %>
                on_free1.value = '<%=m.on_free1%>';
                on_free2.value = '<%=m.on_free2%>';
                on_batch.value = '<%=m.on_batch.ToString()%>';
                is_sale.value = '<%=m.is_sale==null?"":m.is_sale.ToString()%>';
                is_purchase.value = '<%=m.is_purchase==null?"":m.is_purchase.ToString()%>';
                is_self.value = '<%=m.is_self==null?"":m.is_self.ToString()%>';
                is_outsource.value = '<%=m.is_outsource==null?"":m.is_outsource.ToString()%>';
                is_service.value = '<%=m.is_service==null?"":m.is_service.ToString()%>';
                valuation.value = '<%=m.valuation==null?"":m.valuation.ToString()%>';
                $F("ic_name").value = '<%=m.inventory_class==null?"":m.inventory_class.ic_name%>';
                $F("vd_name").value = '<%=m.vendor==null?"":m.vendor.vd_name%>';
                $F("vd_name").value = '<%=m.vendor==null?"":m.vendor.vd_name%>';
                $F("wh_name").value = '<%=m.warehouse==null?"":m.warehouse.wh_name%>';
            <%} %>

            FastSearch_Warehouse();//查询仓库
            FastSearch_Vendor();//查询供应商

            if(action == "Add"){
                $F("ic_id").value = '<%=xview["ic_id"]%>';
                $F("ic_name").value = '<%=xview["ic_name"]%>';
                //默认启用销售、采购属性
                $F("is_sale").value = '1';
                $F("is_purchase").value = '1';
            }
        }
        $(document).ready(function(){
            init_page();
        });
    </script>
</asp:Content>

