• 产品配件删除,内容保存


    唉,原先所设置的样式也好js也好,都要删掉。那时候,写这个还写了蛮久,(没办法,技术太渣)。

    只好先放在这里,以作留念

    HTML

    <!-- TAB2 配件-->
                <div class="tab-pane" id="panel-2">
                    <input type="hidden" name="ProAccessory" />
                    <input type="hidden" name="ProAccessPro" />
                    @*<div class="row">
                        <div class="form-group col-xs-12">
                            <div class="col-xs-2">
                                <a class="btn btn-xs red" title='添加配件' href="javascript:void 0" onclick="createAccess(this)">
                                    添加配件</a>
                            </div>
                        </div>
                    </div>*@
                    @if (ViewData["accessList"] != null && ViewData["accessProductList"] != null)
                    {//配件肯定会对应有下属产品,如果没有也就都不用显示了
                        var accessProductList = ViewData["accessProductList"] as List<AccessProductDTO>;
                        foreach (var access in ViewData["accessList"]
                            as List<ProductAccessory>)
                        {
                            var radioname = "access" + access.ID;
                        <div class="row border" name="Accessory">
                            <div class="form-group col-xs-12">
                                <label class="col-xs-2 control-label">
                                    配件名称:
                                </label>
                                <div class="col-xs-1">
                                </div>
                                <div class="col-xs-5">
                                    <input name="access_title" value="" placeholder="名称" class="form-control" />
                                </div>
                                <div class="col-xs-1">
                                    <a class="btn btn-warning" title='删除此组配件' href="javascript:void 0" onclick="del_accessory(this)">
                                        删除此组配件</a>
                                </div>
                            </div>
                            <div class="form-group col-xs-12">
                                <label class="col-xs-2 control-label">
                                    最小购买量:
                                </label>
                                <div class="col-xs-1">
                                </div>
                                <div class="col-xs-5">
                                    <input name="access_minpurchase" value="" placeholder="0" class="form-control" />
                                </div>
                            </div>
                            <div class="form-group col-xs-12">
                                <label class="col-xs-2 control-label">
                                    最大购买量:
                                </label>
                                <div class="col-xs-1">
                                </div>
                                <div class="col-xs-5">
                                    <input name="access_maxpurchase" value="" placeholder="0" class="form-control" />
                                </div>
                            </div>
                            <div class="form-group col-xs-12">
                                <label class="col-xs-2 control-label">
                                    配件优惠:
                                </label>
                                <div class="col-xs-1">
                                </div>
                                <div class="col-xs-5">
                                    <label class="radio-inline">
                                        <input type="radio" id="" name="@radioname" value="0" checked="checked" />
                                        优惠某个折扣
                                    </label>
                                    <label class="radio-inline">
                                        <input type="radio" id="" name="@radioname" value="1" />
                                        优惠一定金额
                                    </label>
                                    <input type="hidden" id="@radioname" value="" name="chooseProduct" />
                                </div>
                            </div>
                            <div class="form-group col-xs-12">
                                <label class="col-xs-2 control-label self">
                                    优惠百分比:
                                </label>
                                <div class="col-xs-1">
                                </div>
                                <div class="col-xs-5">
                                    <input name="access_discount" value="" placeholder="0" class="form-control" />
                                </div>
                                <div class="col-xs-4">
                                    <span class="help-inline">(无优惠可不填;优惠9折就输入0.9,优惠100元就输入100)</span>
                                </div>
                            </div>
                            <div class="form-group col-xs-12">
                                <label class="col-xs-2 control-label">
                                    选择配件产品:
                                </label>
                                <div class="col-xs-1">
                                    <a class="btn btn-xs blue thickbox" title='配件选择' href="@Url.Action("AccessList", "Product")?excludeID=@Model.ID&returnid=@radioname&TB_iframe=true&height=250&width=400" name="chooseAccess">
                                        选择配件</a>
                                </div>
                                <div class="col-xs-5">
                                    <div accpro="@radioname" name="setproaccpro" onclick="addAccessPro(this)" style="display:none;">
                                        放响应按钮的</div>
                                    @if (accessProductList.Count > 0)
                                    {
                                        var x = accessProductList.Where(u => u.AccessID == access.ID).ToList();
                                        if (x.Count > 0)
                                        {
                                            foreach (var item in x)
                                            {
                                        <div>
                                            <label class="checkbox-inline col-xs-12" name="@radioname" accessid="@item.ProductID">
                                                <a class="" title="删除配件" href="javascript:void 0" onclick="del_access(this)"><i class="fa fa-trash">
                                                </i></a>@item.ProductTitle
                                            </label>
                                        </div>
                                            }
                                        }
                                    }
                                </div>
                            </div>
                        </div>
                        }
                    }
                </div>
    

    JS

    function FormatDate() {
                    var date = new Date();
                    var str = date.getFullYear().toString() + (date.getMonth() + 1).toString() + date.getDate().toString() + date.getHours().toString() + date.getMinutes().toString() + date.getSeconds().toString() + date.getMilliseconds().toString();
                    return str;
                }
    
    @*tab3配件处理*@
            <script type="text/javascript">
                function del_access(obj) {
                    $(obj).parent().parent().remove();
                }
    
                function del_accessory(obj) {
                    $(obj).parent().parent().parent().remove();
                }
                var accessory_count = 0;
                var radioinline_count = 7;
                var product_id = $("input[name=OnlyID]").val();
                function createAccess(obj) {
                    accessory_count++;
                    var _html = '<input type="radio" name="accessory' + accessory_count + '" id="" value="0" checked="checked" class="selfradio" />'
                    + '优惠某个折扣'
                    + '    '
                    + '<input type="radio" name="accessory' + accessory_count + '" id="" value="1" class="selfradio"/>'
                    + '优惠一定金额'
                    + '<input type="hidden" id="accessory' + accessory_count + '" value="" name="chooseProduct" />';
    
                    $("#accessory_template").find("a[name=chooseAccess]").attr("href", "/cms/product/accesslist?returnid=accessory" + accessory_count + "&excludeID=" + product_id + "&TB_iframe=true&height=250&width=400");
                    $("#accessory_template").find("div[name=accessprivilege]").empty();
                    $("#accessory_template").find("div[name=accessprivilege]").append(_html);
                    $("#accessory_template").find("div[name=setproaccpro]").attr("accpro", "accessory" + accessory_count);
                    $(obj).parent().parent().parent().parent().append($("#accessory_template").html());
                    $('a.thickbox').unbind('click');
                    tb_init('a.thickbox');
                }
    
                function addAccessPro(obj) {
                    var name = $(obj).attr("accpro");
                    var value = $(obj).parent().parent().parent().find("input[id=" + name + "]").val().split(',');
                    for (var i = 0; i < value.length; i++) {
                        var temp = value[i].trim();
                        if (temp == "") {
                            continue;
                        }
                        var title = temp.split(':')[1].trim();
                        var accessid = temp.split(':')[0].trim();
                        if (title == "" || accessid == "") {
                            continue;
                        }
                        var _html = '<div>'
                        + '<label class="checkbox-inline col-xs-12" name="' + name + '" accessid="' + accessid + '">'
                        + '<a class="" title="删除配件" href="javascript:void 0" onclick="del_access(this)"><i class="fa fa-trash"></i></a>'
                        + title
                        + '</label></div>';
                        $(obj).after(_html);
                    }
    
                }
         </script>
  • 相关阅读:
    装饰器 转载自 http://www.cnblogs.com/huxi/archive/2011/03/01/1967600.html
    no_merge hint
    优化实例- not use hash to avoid temp space issue
    明日计划
    优化实例- not in 和 not exists
    insert into varchar2(8000)
    图像的批处理
    图像数据类型及颜色空间转换
    图像的读取,显示与保存(基于skimage模块)
    图像直方图
  • 原文地址:https://www.cnblogs.com/danlis/p/5058695.html
Copyright © 2020-2023  润新知