<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="ProductEdit.aspx.cs" Inherits="OAWeb.crm.product.ProductEdit" ValidateRequest="false" %>

<%@ Register Src="../../UserControls/ProductNav.ascx" TagName="ProductNav" TagPrefix="uc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlace" runat="server">
    <script src="/js/jquery.form.js" type="text/javascript"></script>
    <script language="javascript" type="text/javascript" src='<%=ResolveUrl("~/ckeditor/ckeditor.js")%>'></script>
    <style type="text/css">
        .table_form .right
        {
            width: 150px;
        }
        .list .table_list th, .list .table_list td
        {
            line-height: 14px;
            height: 14px;
        }
    </style>
    <!--主体左侧-->
    <table id="plc_profile" cellpadding="0" cellspacing="0" border="0">
        <tr>
            <td class="main_left">
                <uc1:ProductNav ID="ProductNav1" runat="server" />
            </td>
            <td class="main_center">
                <!--主体-->
                <div class="page_main">
                    <div class="page_content">
                        <div class="div_pane bgColor01" style="border: solid 1px #ddd; border-bottom: none;">
                            <em style="float: left">
                                <img src="/images/01.gif" />
                            </em>
                            <%=Id == Guid.Empty ? "新增":"编辑"%>商品
                        </div>
                        <div class="form" style="border: solid 1px #ddd; padding: 5px;">
                            <table cellpadding="0" cellspacing="0" border="0" class="table_form">
                                <tr>
                                    <td class="title" colspan="2">
                                        <h1>
                                            基本信息</h1>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right">
                                        所属分类:
                                    </td>
                                    <td>
                                        <span class="color01">
                                            <asp:Literal ID="ltlCategoryText" runat="server"></asp:Literal></span> <a href="SelectCategory.aspx<%=Id != Guid.Empty ? ("?Id="+Id) : "" %>">
                                                [编辑]</a>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right ">
                                        商品类型:
                                    </td>
                                    <td>
                                        <asp:DropDownList ID="ddlTypeId" runat="server" CssClass="product_type">
                                            <asp:ListItem Value="0">请选择商品类型</asp:ListItem>
                                        </asp:DropDownList>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right ">
                                        <span class="red">*</span> 商品名称:
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtProductName" Text="" runat="server" CssClass="text width400 txtProductName"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right ">
                                        商品编码:
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtProductCode" Text="" runat="server" CssClass="text width200 txtProductCode"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right ">
                                        计量单位:
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtUnit" Text="" runat="server" CssClass="text width200"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right ">
                                        <span class="red">*</span> 成本价:
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtCost" runat="server" CssClass="text width200 txtCost" Text="0.00"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right ">
                                        <span class="red">*</span> 零售价格:
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtSalePrice" runat="server" CssClass="text width200 txtSalePrice"
                                            Text="0.00"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right ">
                                        <span class="red">*</span> 市场价:
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtMarketPrice" runat="server" CssClass="text width200" Text="0.00"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right ">
                                        <span class="red">*</span> 经销商价格:
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtWholeSalePrice" runat="server" CssClass="text width200 txtWholeSalePrice"
                                            Text="0.00"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right ">
                                        商品主图:
                                    </td>
                                    <td>
                                        <asp:FileUpload ID="FileUpload1" runat="server" />
                                        <a style="margin-left: 15px" id="LinkImg" runat="server">[ 产品相册 ]</a>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right ">
                                    </td>
                                    <td>
                                        <asp:Image ID="imgThumbnail_pic" runat="server" Visible="false" />
                                    </td>
                                </tr>
                                <tr>
                                    <td class="title" colspan="2">
                                        <h1>
                                            相关设置</h1>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right ">
                                        销售状态:
                                    </td>
                                    <td>
                                        <asp:RadioButtonList ID="rdoIs_Active" runat="server" RepeatDirection="Horizontal"
                                            RepeatLayout="Flow">
                                            <asp:ListItem Value="0">下架</asp:ListItem>
                                            <asp:ListItem Selected="True" Value="1">上架</asp:ListItem>
                                        </asp:RadioButtonList>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right ">
                                        开启序列号:
                                    </td>
                                    <td>
                                        <asp:RadioButtonList ID="rdoHasSN" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
                                            <asp:ListItem Value="1" Selected="True">开启</asp:ListItem>
                                            <asp:ListItem Value="0">禁用</asp:ListItem>
                                        </asp:RadioButtonList>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right ">
                                        商品性质:
                                    </td>
                                    <td>
                                        <asp:RadioButtonList ID="rdoSellorRent" runat="server" RepeatDirection="Horizontal"
                                            RepeatLayout="Flow">
                                            <asp:ListItem Value="1" Selected="True">销售</asp:ListItem>
                                            <asp:ListItem Value="2">租用</asp:ListItem>
                                        </asp:RadioButtonList>
                                    </td>
                                </tr>
                                <tr class="is_AotuDelivery hide">
                                    <td class="right ">
                                        发货设置:
                                    </td>
                                    <td>
                                        <asp:CheckBox ID="chkIsAotuDelivery" runat="server" Text="自动发货" />
                                    </td>
                                </tr>
                                <tr class="spec_list" style="display: none;">
                                    <td class="title" colspan="2">
                                        <h1>
                                            商品规格</h1>
                                    </td>
                                </tr>
                                <tr class="spec_list" style="display: none;">
                                    <td class="right ">
                                    </td>
                                    <td>
                                        <div class="list_spec" style="width: 98%">
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="title" colspan="2">
                                        <h1>
                                            描述</h1>
                                    </td>
                                </tr>
                                <tr style="display: none;">
                                    <td class="right ">
                                        商品图片:
                                    </td>
                                    <td>
                                        <div class="uploadimages">
                                            <div class="preview">
                                                暂无图片
                                            </div>
                                            <div class="uploadaction">
                                                <a href="javascript:void(0);">上传图片</a><input name="file_uploader1" type="file" class="input_file"
                                                    pic_id="1" />
                                            </div>
                                        </div>
                                        <div class="uploadimages">
                                            <div class="preview">
                                                暂无图片
                                            </div>
                                            <div class="uploadaction">
                                                <a href="javascript:void(0);">上传图片</a><input name="file_uploader2" type="file" class="input_file"
                                                    pic_id="2" />
                                            </div>
                                        </div>
                                        <div class="uploadimages">
                                            <div class="preview">
                                                暂无图片
                                            </div>
                                            <div class="uploadaction">
                                                <a href="javascript:void(0);">上传图片</a><input name="file_uploader3" type="file" class="input_file"
                                                    pic_id="3" />
                                            </div>
                                        </div>
                                        <div class="uploadimages">
                                            <div class="preview">
                                                暂无图片
                                            </div>
                                            <div class="uploadaction">
                                                <a href="javascript:void(0);">上传图片</a><input name="file_uploader4" type="file" class="input_file"
                                                    pic_id="4" />
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right ">
                                        商品简介:
                                    </td>
                                    <td style="padding: 10px;">
                                        <asp:TextBox ID="txtBrief" runat="server" CssClass="text" Width="97%" TextMode="MultiLine"
                                            Height="45px"></asp:TextBox>
                                    </td>
                                </tr>
                                <tr>
                                    <td class="right ">
                                        商品描述:
                                    </td>
                                    <td>
                                        <asp:TextBox ID="txtDescription" runat="server" CssClass="text" Width="99%" Height="200px"
                                            TextMode="MultiLine"></asp:TextBox>
                                        <script type="text/javascript">
                                            CKEDITOR.replace('<%=txtDescription.ClientID %>',
                    {
                        skin: 'v2',
                        width: '98%',
                        height: '239',
                        font_names: '宋体/宋体;黑体/黑体;仿宋/仿宋_GB2312;楷体/楷体_GB2312;隶书/隶书;幼圆/幼圆;微软雅黑/微软雅黑;',
                        toolbar: [
                        ['Bold', 'Italic', 'Underline', 'Strike', '-', 'NumberedList', 'BulletedList', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'Link', 'Unlink', 'Anchor', '-', 'Table', 'HorizontalRule', 'SpecialChar'],
                        ['Format', 'Font', 'FontSize', 'TextColor', 'BGColor']
                        ],
                        language: 'zh-cn'
                    })
                   
                                        </script>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2" style="text-align: center">
                                        <input id="btnSave" type="button" value=" 保 存 " class="btn_77px" />
                                        <input id="btnClose" type="button" value=" 返 回 " onclick="window.location.href = '<%=ReturnUrl %>'"
                                            class="btn_77px" />
                                    </td>
                                </tr>
                            </table>
                        </div>
                    </div>
                </div>
            </td>
        </tr>
    </table>
    <script type="text/javascript">    
        $(document).ready(function () {
            $(".input_file").change(function(){
                  var preview_pic = $(this).parent().parent().find(".preview");
                  var uploader = "file_uploader" + $(this).attr("pic_id");
                  $("#aspnetForm").ajaxSubmit({
                    url: "/crm/product/ProductEdit.aspx?op=UploadPic&uploader=" + uploader + "&Id=<%=Id %>",
                    success: function (result) {
                        var json = eval("(" + result + ")");
                        if(json.result == "ok")
                        {                            
                            preview_pic.html("<img src='" + json.src + "' />");
                            preview_pic.addClass("select");
                        }
                        else
                        {
                            alert(result);
                        }                        
                    }
                });
                return false;
            })
            $("#btnSave").click(function () {
                //把编辑值赋值到实际文本框，编辑器只在有post动作时才把值赋值给实际文本框。
                CKEDITOR.instances.<%=txtDescription.ClientID %>.updateElement(); 
                FormPostAjax("/crm/product/ProductEdit.aspx?op=Save&categoryId=<%=CategoryId %>&Id=<%=Id %>&r="+Math.random(), "ok",  function () { window.location.href = '<%=ReturnUrl %>'; }); 
                return false;
            })
            $("input[name='ctl00$ContentPlace$rdoIs_Active']").change(function(){
                $(".active_check").attr("checked", $(this).val() == "1"); 
            })
            $(".active_check").live("change",function(){
                if($('input:radio[name="ctl00$ContentPlace$rdoIs_Active"]:checked').val() != "1" && $(this).attr("checked") == "checked")
                {
                    alert("商品必须设置为上架。");
                    $(this).attr("checked",false);
                    return;
                }
            })
            $("input[name='<%=rdoHasSN.UniqueID %>']").change(function(){
                ShowAotuDelivery();
            })
            $("input[name='<%=rdoSellorRent.UniqueID %>']").change(function(){
                ShowAotuDelivery();
            })
            ShowAotuDelivery();
        });
        <%=GetSpecJson() %>
        function ShowAotuDelivery(){
           var hasSN = $('input:radio[name="<%=rdoHasSN.UniqueID %>"]:checked').val();
           var sellorRent = $('input:radio[name="<%=rdoSellorRent.UniqueID %>"]:checked').val();
           if(hasSN == "1" && sellorRent == "2")
               $(".is_AotuDelivery").show();
           else
               $(".is_AotuDelivery").hide();
        }
    </script>
    <script src="specs.helper.js" type="text/javascript"></script>
</asp:Content>
