<%@ Page Title="" Language="C#" MasterPageFile="~/Styles/MasterPage/MasterPage_Edit.master" AutoEventWireup="true" CodeFile="IOType_Edit.aspx.cs" Inherits="Base_IOType_IOType_Edit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <script type="text/javascript">
        var action = '<%=xview["action"]%>';
        function Save() {
            <%=xview["Script_GetInput"] %>
            if (iot_name == "") {
                parent.AlertNO('请输入类型名称!');
                return;
            }
           
            var action = '<%=xview["action"]%>';
            parent.ShowLoadingMask(); //显示遮罩
            $.ajax({
                type: "POST",
                contentType: "application/json",
                url: 'IOType_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_IOType_Edit")%>'>保存</a>
        <a plain="true" class="easyui-linkbutton" onclick="parent.DesignModuleFormat('Base_IOType_Input');CloseDivWin();" style='<%=auth.FormatView()%>'>格式</a>
    </div>
    <div style="width:500px;height:350px;overflow:auto;">
        <div class="edit_area">
        <%=xview["input_ui"]%>
        </div>
    </div>
    <script type="text/javascript">
        //初始化页面
        function init_page() {
            var iot_flag = $F("iot_flag");
            AddOption(iot_flag,'收','1');
            AddOption(iot_flag,'发','0');

            $F("trigger_parent_name").onclick = function () {
                var iot_flag = $("#iot_flag").val();
                AdvancedSearch_IOType($("#parent_name").val(),iot_flag);
            };
            //弹出窗口_选择收发类型
            function AdvancedSearch_IOType(keyword, iot_flag) {
                var url = "../../Component/AdvancedSearch/IOType_List.aspx?keyword=" + escape(keyword) + "&iot_flag=" + iot_flag;
                parent.asyncbox.open({
                    id: 'win_select',
                    url: url,
                    modal: true,
                    width: 400,
                    height: 400,
                    title: '选择收发类型'
                });
            }
            <%if(action.Equals("Update")){ %>
                $F("parent_name").value = '<%=m.parent.iot_name%>';
                iot_flag.value = '<%=m.iot_flag%>';
            <%} %>
            if(action == "Add"){
                //新增时带出父类编码作为当前编码方便输入
                $F("iot_code").value = '<%=xview["parent_code"]%>';
                //新增时带出父类
                $F("parent_id").value = '<%=xview["parent_id"]%>';
                $F("parent_name").value = '<%=xview["parent_name"]%>';
            }
            
        }
        init_page();
        //通过主键_获取类型
        function SearchService_IOType(iot_id) {
            $.ajax({
                type: "POST",
                contentType: "application/json",
                url: '../../Base/IOType/IOType_Service.asmx/Get',
                data: "{iot_id:'" + iot_id + "'}",
                dataType: 'json',
                success: function (result) {
                    $("#parent_id").val(result.d.iot_id);
                    $("#parent_name").val(result.d.iot_name);
                }
            });
        }
    </script>
</asp:Content>

