{layout:default} {class:Shop.Admin.product.subproduct_Edit}
<lbhead>
    <title><%if (modelp.id > 0) { Response.Write(Shop.Bussiness.Language.Content(modelp.Name, CurrentLanguage.Code) + "-"); } %><%=Tag("商品管理")%>-<%=site.title%></title>
</lbhead>
<lbpath>
    <h3 class="text-themecolor m-b-0 m-t-0"><%=Tag("子商品")%></h3>
    <ol class="breadcrumb">
        <li class="breadcrumb-item"><a href="<%=site.AdminPath %>/Ajax/ajax_admin.aspx?__Action=MenuJump&pid=0"><%=Tag("管理首页")%></a></li>
        <li class="breadcrumb-item"><a href="<%=site.AdminPath %>/product/"><%=Tag("商品列表")%></a></li>
        <li class="breadcrumb-item active"><%=Shop.Bussiness.Language.Content(modelp.Name, CurrentLanguage.Code) %></li>
    </ol>
</lbpath>
<lbbody>
    <div class="col-12">
        <div class="card">
            <div class="card-body">
                <div class="row">
                    <div class="col-md-12 m-b-10">
                        <%if (PageReturnMsg == ""){%>
                        <button class="btn btn-success" onclick="CreateProductConfirm();"><i class="ti-loop"></i> <%=Tag("生成")%></button>
                        <button class="btn btn-success" onclick="Product_Edit_muti();"><i class="ti-check"></i> <%=Tag("保存")%></button>
                        <button class="btn btn-danger" onclick="DeleteConfirm()"><i class="ti-trash"></i> <%=Tag("删除")%></button>
                        <button class="btn btn-default" onclick="Product_Image_Edit();"><i class="ti-pencil-alt"></i> <%=Tag("修改图片")%></button>
                        <button class="btn btn-default" onclick="Product_Status_Edit_muti(1);"><i class="ti-arrow-up"></i> <%=Tag("上架")%></button>
                        <button class="btn btn-default" onclick="Product_Status_Edit_muti(0);"><i class="ti-arrow-down"></i> <%=Tag("下架")%></button>
                        <%}%>
                    </div>
                </div>
                <div class="form-group">
                    <label for="ProPertyMain"><%=Tag("主规格")%>：</label>
                    <select id="ProPertyMain" name="ProPertyMain" class="form-control" shop="true" sonproduct="true">
                        <option value="0"><%=Tag("不设置")%></option>
                        <%foreach (DB.LebiShop.Lebi_ProPerty pro in ggs){%>
                        <option value="<%=pro.id %>" <%=modelp.ProPertyMain==pro.id?"selected":"" %>><%=Lang(pro.Name)%></option>
                        <%} %>
                    </select>
                </div>
                <%foreach (DB.LebiShop.Lebi_ProPerty pro in ggs){%>
                <div class="form-group">
                    <label for=""><%=Lang(pro.Name)%>：</label>
                    <div class="input-group">
                        <%=Getpro131List(pro.id)%>
                    </div>
                </div>
                <%} %>
            </div>
        </div>
        <div class="card">
            <div class="card-body">
                <div class="table-responsive sorttable">
                    <table class="table table-hover no-wrap">
                        <thead>
                            <tr>
                                <th style="width: 40px;">
                                    <a href="javascript:void(0);" onclick="$('input[name=\'sonproductid\']').attr('checked',!$(this).attr('checked'));$(this).attr('checked',!$(this).attr('checked'));">
                                        <%=Tag("全选")%>
                                    </a>
                                </th>
                                <th>
                                    <%=Tag("图片")%>
                                </th>
                                <th>
                                    <%=Tag("编号")%>
                                </th>
                                <th>
                                    <%=Tag("规格")%>
                                </th>
                                <th>
                                    <%=Tag("商品名称")%>
                                </th>
                                <th style="width: 7%">
                                    <%=Tag("市场价")%>
                                </th>
                                <th style="width: 7%">
                                    <%=Tag("销售价")%>
                                </th>
                                <%if (modelp.Type_id_ProductType == 321){ %>
                                <th style="width: 7%">
                                    <%=Tag("抢购价")%>
                                </th>
                                <%}else if (modelp.Type_id_ProductType == 322){ %>
                                <th style="width: 7%">
                                    <%=Tag("团购价")%>
                                </th>
                                <%}else if (modelp.Type_id_ProductType == 323){ %>
                                <th style="width: 7%">
                                    <%=Tag("换购积分")%>
                                </th>
                                <%} %>
                                <%if (Shop.Bussiness.EX_Admin.CheckPower("product_price_cost")){ %>
                                <th style="width: 7%">
                                    <%=Tag("成本价")%>
                                </th>
                                <%} %>
                                <th style="width: 7%">
                                    <%=Tag("库存")%>
                                </th>
                                <!--<th>
                                    <%=Tag("冻结库存")%>
                                </th>
                                <th>
                                    <%=Tag("销量")%>
                                </th>-->
                                <th style="width: 7%">
                                    <%=Tag("销量")%>
                                </th>
                                <th style="width: 8%">
                                    <%=Tag("状态")%>
                                </th>
                                <th>
                                    <%=Tag("操作")%>
                                </th>
                            </tr>
                        </thead>
                        <tbody id="subproducts"></tbody>
                    </table>
                </div>
            </div>
        </div>
    </div>
</lbbody>
<lbscripts>
    <input type="hidden" id="Pro_Type_id" name="Pro_Type_id" shop="true" sonproduct="true" value="<%=modelp.Pro_Type_id %>">
    <script src="<%=site.AdminJsPath %>/ajaxfileupload.js"></script>
    <script>
        function uploadImage(id) {
            $.ajaxFileUpload({
                url: WebPath + '/ajax/imageupload.aspx',
                secureuri: false,
                fileElementId: 'file_' + id,
                dataType: 'json',
                success: function (data, status) {
                    if (data.msg != 'OK') {
                        MsgBox(2, data.msg, "");
                    }
                    else {
                        var imageUrl = data.img;
                        if (imageUrl.length > 0) {
                            $("#image_" + id + "").html('<img src="<%=webconfig.ImageURL%>' + imageUrl + '" height="24">');
                            $("#" + id + "").val(imageUrl);
                        }
                    }
                }
            })
        }
        function CreateProductConfirm() {
            $("#Modal-Confirm").modal("show");
            $("#Confirm-Content").html("<%=Tag("确认要生成同款的商品数据吗？")%>");
            $("#Modal-Confirm .btn-success.btn-ok").attr("onclick", "CreateProduct();");
        }
        function CreateProduct() {
            $("#Modal-Confirm").modal("hide");
            var ggs = GetChkCheckedValues("Property131");
            var pid = "<%=id %>";
            var tid = $("#Pro_Type_id").val();
            var postData = { "ggs": ggs, "pid": pid, "tid": tid };
            var url = "<%=site.AdminPath %>/ajax/ajax_product.aspx?__Action=CreateProductGuiGe";
            RequestAjax(url, postData, function () { MsgBox(1, "<%=Tag("操作成功")%>", ""); getsubproducts(); });
        }
        function DeleteConfirm() {
            $("#Modal-Confirm").modal("show");
            $("#Confirm-Content").html("<%=Tag("确认要删除吗？")%>");
            $("#DeleteConfirm .btn-success.btn-ok").attr("onclick", "Product_Del();");
        }
        function Product_Del() {
            $("#Modal-Confirm").modal("hide");
            var postData = GetFormJsonData("ShopKeyID");
            var url = "<%=site.AdminPath %>/ajax/ajax_product.aspx?__Action=Product_Del";
            RequestAjax(url, postData, function () { MsgBox(1, "<%=Tag("操作成功")%>", ""); getsubproducts(); });
        }
        function Product_Edit_muti() {
            var postData = GetFormJsonData("sonproduct");
            var url = "<%=site.AdminPath %>/ajax/ajax_product.aspx?__Action=Product_Edit_muti_price_store&pid=<%=id %>";
            RequestAjax(url, postData, function () { MsgBox(1, "<%=Tag("操作成功")%>", "#") });
        }
        function Product_Status_Edit_muti(status) {
            var postData = GetFormJsonData("ShopKeyID");
            var url = "<%=site.AdminPath %>/ajax/ajax_product.aspx?__Action=Product_Status_Edit_muti&status=" + status;
            RequestAjax(url, postData, function () { MsgBox(1, "<%=Tag("操作成功")%>", ""); getsubproducts(); });
        }
        function Product_Name_Edit(id) {
            $("#EditModal").modal("show");
            $.ajax({
                url: "product_name_edit_window.aspx",
                type: "GET",
                cache: false,
                data: { id: id, pid: '<%=id %>', subproduct: 1 },
            }).done(function (result) {
                $("#EditModal .modal-content").html(result);
            });
        }
        function Product_Image_Edit() {
            var ids = GetChkCheckedValues("sonproductid");
            if (ids == "") {
                MsgBox(2, "<%=Tag("请选择要修改的商品")%>", "");
                return;
            }
            $("#EditModal").modal("show");
            $.ajax({
                url: "product_image_edit_window.aspx",
                type: "GET",
                cache: false,
                data: { id: '<%=id %>', ids: ids, subproduct: 1 },
            }).done(function (result) {
                $("#EditModal .modal-content").html(result);
            });
        }
        function getsubproducts() {
            $.ajax({
                type: "POST",
                url: "subproduct_list.aspx?pid=<%=modelp.id %>",
                data: '',
                success: function (res) {
                    $("#subproducts").html(res);
                }
            });
        }
        $(function () {
            getsubproducts();
        });
    </script>
</lbscripts>