<%@ Page Title="" Language="C#" MasterPageFile="~/Styles/MasterPage/MasterPage_Edit.master" AutoEventWireup="true" CodeFile="RunningNumberRule_Edit.aspx.cs" Inherits="Base_RunningNumberRule_RunningNumberRule_Edit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <script type="text/javascript">
        var module_code = "<%=xview["module_code"]%>";
        function Save() {
            ShowLoadingMask(); //显示遮罩
            $.ajax({
                type: "POST",
                contentType: "application/json",
                url: 'RunningNumberRule_Service.asmx/Save',
                data: "{module_code:'" + module_code + "',length:'" + $("#length").val() + "',"
                + "rule1:'" + $("#rule1").val() + "',manual1:'" + $("#manual1").val() + "',date1:'" + $("#date1").val() + "',"
                + "rule2:'" + $("#rule2").val() + "',manual2:'" + $("#manual2").val() + "',date2:'" + $("#date2").val() + "',"
                + "rule3:'" + $("#rule3").val() + "',manual3:'" + $("#manual3").val() + "',date3:'" + $("#date3").val() + "'"
                + "}",
                dataType: 'json',
                success: function (result) {
                    HideLoadingMask(); //关闭遮罩
                    var r = result.d;
                    if (r == "success") {
                        AlertOK('保存成功!');
                    } else {
                        alert(r);
                    }
                }
            });
        }
        function change_rule(type) {
            if ($F("rule" + type).value == "manual") {
                $F("manual" + type).style.display = '';
            } else {
                $F("manual" + type).style.display = 'none';
            }
            if ($F("rule" + type).value == "date") {
                $F("date" + type).style.display = '';
            } else {
                $F("date" + type).style.display = 'none';
            }
        }

        //调整流水号
        function edit_number() {
            parent.asyncbox.open({
                id: 'win_modify',
                url: 'RunningNumber_Edit_List.aspx?module_code=' + module_code,
                modal: true,
                height: 400,
                width:600,
                title: '调整流水号'
            });

        }
    </script>
    <!--工具栏-->
    <div class="list_menu_bar">
        <a plain="true" class="easyui-linkbutton" iconcls="icon-save" onclick="javascript:Save()" >保存</a>
        <a plain="true" class="easyui-linkbutton" onclick="javascript:edit_number()" >调整流水号</a>
    </div>
    <div style="width:500px;height:500px;overflow:hidden;">
        <div class="edit_area" style='overflow:hidden;'>
            <table>
            <tr>
                <td style='text-align:right'>前缀1:</td>
                <td>
                    <select id="rule1" onchange="change_rule(1)" style="float:left">
                        <option value=""></option>
                        <option value="manual">手工输入</option>
                        <option value="date">日期</option>
                        <%=xview["options"]%>
                    </select>
                    <input type="text" id="manual1" style="width:60px;float:left"/>
                    <select id="date1" style="float:left">
                        <option value="[year]">年</option>
                        <option value="[year][month]">年月</option>
                        <option value="[year][month][day]">年月日</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td style='text-align:right'>前缀2:</td>
                <td>
                    <select id="rule2" onchange="change_rule(2)" style="float:left">
                        <option value=""></option>
                        <option value="manual">手工输入</option>
                        <option value="date">日期</option>
                        <%=xview["options"]%>
                    </select>
                    <input type="text" id="manual2" style="width:60px;float:left"/>
                    <select id="date2" style="float:left">
                        <option value="[year]">年</option>
                        <option value="[year][month]">年月</option>
                        <option value="[year][month][day]">年月日</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td style='text-align:right'>前缀3:</td>
                <td>
                    <select id="rule3" onchange="change_rule(3)" style="float:left">
                        <option value=""></option>
                        <option value="manual">手工输入</option>
                        <option value="date">日期</option>
                        <%=xview["options"]%>
                    </select>
                    <input type="text" id="manual3" style="width:60px;float:left"/>
                    <select id="date3" style="float:left">
                        <option value="[year]">年</option>
                        <option value="[year][month]">年月</option>
                        <option value="[year][month][day]">年月日</option>
                    </select>
                </td>
            </tr>
            <tr>
                <td style='text-align:right;width:80px'>流水号长度:</td>
                <td>
                    <input type='text' id='length' value='<%=xview["length"]%>' style='width:50px;float:left' maxlength="1"/></td>
            </tr>
            </table>
        </div>
    </div>
    <script type="text/javascript">
        
        //绑定值
        $F("rule1").value = '<%=xview["rule1"]%>';
        $F("rule2").value = '<%=xview["rule2"]%>';
        $F("rule3").value = '<%=xview["rule3"]%>';

        $F("rule1_value").value = '<%=xview["rule1_value"]%>';
        $F("rule2_value").value = '<%=xview["rule2_value"]%>';
        $F("rule3_value").value = '<%=xview["rule3_value"]%>';

        if ('<%=xview["rule1"]%>' == "date") $F("date1").value = "<%=xview["rule1_value"]%>";
        if ('<%=xview["rule2"]%>' == "date") $F("date2").value = "<%=xview["rule2_value"]%>";
        if ('<%=xview["rule3"]%>' == "date") $F("date3").value = "<%=xview["rule3_value"]%>";

        if ('<%=xview["rule1"]%>' == "manual") $F("manual1").value = "<%=xview["rule1_value"]%>";
        if ('<%=xview["rule2"]%>' == "manual") $F("manual2").value = "<%=xview["rule2_value"]%>";
        if ('<%=xview["rule3"]%>' == "manual") $F("manual3").value = "<%=xview["rule3_value"]%>";

        //显示与隐藏
        change_rule(1);
        change_rule(2);
        change_rule(3);
    </script>
</asp:Content>

