lvhao 14 ore fa
parent
commit
52f9b96f88
1 ha cambiato i file con 146 aggiunte e 1 eliminazioni
  1. 146 1
      template/erp/goodimglibrary_add.html

+ 146 - 1
template/erp/goodimglibrary_add.html

@@ -8,7 +8,7 @@
 {Template common_product}
 <div style="clear:both;"></div>
 </ul>
-<div class="button"><font class="datasave">提 交</font> <font class="fh">关 闭</font></div>
+<div class="button"><font class="new_datasave">提 交</font> <font class="fh">关 闭</font></div>
 </div>
 <script>
 var addedit="/goodimglibrary/add/";
@@ -47,4 +47,149 @@ $("select[name='category']").on("change", function () {
 
 <script src="{$theme}js/goodsrules.js?v={time()}"></script>
 
+<script>
+// 独立提交方法,只提交页面可见的表单元素
+// 同名元素以 .pttab 中可见的为准(覆盖 .datalist 中的值)
+$(document).ready(function() {
+    $(".new_datasave").click(function() {
+        $(".ts p").html("<i class='fa fa-2x fa-cog fa-spin'></i> &nbsp; 正在添加中,请稍后...");
+        $(".ts").show();
+        
+        // 用对象存储,同名key后遍历的覆盖先遍历的
+        var dataObj = {};
+        
+        // 先收集 .datalist 区域可见的select
+        $(".datalist .select").each(function() {
+            var $li = $(this).closest("li");
+            if ($li.length && $li.is(":visible")) {
+                dataObj[$(this).attr("name")] = $(this).children("option:selected").val();
+            }
+        });
+        // 再收集 .pttab 区域可见的select(同名覆盖 .datalist 的值)
+        $(".pttab .select").each(function() {
+            var $li = $(this).closest("li");
+            if ($li.length && $li.is(":visible")) {
+                dataObj[$(this).attr("name")] = $(this).children("option:selected").val();
+            }
+        });
+        
+        // 拼装select参数
+        var f = "";
+        for (var key in dataObj) {
+            f = f + key + "=" + dataObj[key] + "&";
+        }
+        
+        $("input:text").each(function() {
+            var str2 = $(this).val().replace(/\</g,"&lt;");
+            str2 = str2.replace(/\>/g,"&gt;");
+            str2 = str2.replace(/\+/g,"%2B");
+            str2 = str2.replace(/&/g,"%26");
+            f = f + $(this).attr("name") + "=" + str2 + "&";
+        });
+        $("input:password").each(function() {
+            f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+        });
+        $("input:hidden").each(function() {
+            f = f + $(this).attr("name") + "=" + $(this).val() + "&";
+        });
+        
+        if($("#content").length > 0) {
+            var vl = $("#content").html().replace(/\+/g,"%2B");
+            vl = vl.replace(/\&/g,"%26");
+            f = f + "content=" + encodeURI(vl) + "&";
+        }
+        
+        $("textarea").each(function() {
+            var str2 = $(this).val().replace(/\+/g,"%2B");
+            str2 = str2.replace(/&/g,"%26");
+            f = f + $(this).attr("name") + "=" + str2 + "&";
+        });
+        
+        if($(".scimg img").length > 0 || $(".scimg video").length > 0) {
+            var a = '';
+            for (var b = 0; b < $(".scimg .upimg img").length; b++) {
+                a = a + $(".scimg .upimg img")[b].src + "|";
+            }
+            for (var b = 0; b < $(".scimg .upimg video").length; b++) {
+                a = a + $('.scimg .upimg video')[b].src + "|";
+            }
+            a = a.replace(/\+/g,"%2B");
+            a = a.replace(/&/g,"%26");
+            f = f + "img=" + a + "&";
+        }
+        if($(".scimg_two img").length > 0 || $(".scimg_two video").length > 0) {
+            var a = '';
+            for (var b = 0; b < $(".scimg_two .upimg_two img").length; b++) {
+                a = a + $(".scimg_two .upimg_two img")[b].src + "|";
+            }
+            for (var b = 0; b < $(".scimg_two .upimg_two video").length; b++) {
+                a = a + $('.scimg_two .upimg_two video')[b].src + "|";
+            }
+            a = a.replace(/\+/g,"%2B");
+            a = a.replace(/&/g,"%26");
+            f = f + "img_two=" + a + "&";
+        }
+        
+        for(i=0;i<$(".checkbox").length;i++) {
+            var checkid = ""; var checkname = "";
+            $(".checkbox:eq("+i+") .ckrows input:checked").each(function(){
+                checkname = $(this).attr("name");
+                checkid = checkid + $(this).val()+",";
+            });
+            if(checkname == "") {
+                $(".ts p").text($(".checkbox:eq("+i+")").prevAll("em").text()+"为必填项");
+                $(".ts").show();
+                setTimeout('$(".ts").fadeOut()', 600);
+                return false;
+            }
+            f = f + checkname + "=" + checkid + "&";
+        }
+        
+        for(i=0;i<$(".checkboxfbt").length;i++) {
+            var checkid = ""; var checkname = "";
+            $(".checkboxfbt:eq("+i+") .ckrows input:checked").each(function(){
+                checkname = $(this).attr("name");
+                checkid = checkid + $(this).val()+",";
+            });
+            if(checkname != "") {
+                f = f + checkname + "=" + checkid + "&";
+            }
+        }
+        
+        var ab = 0;
+        $(".must").each(function() {
+            if ($.trim($(this).val()).length == 0) {
+                $(this).css("border", "1px solid #F66");
+                ab = ab + 1;
+            }
+        });
+        if (ab > 0) {
+            $(".ts p").text("红框为必填项");
+            $(".ts").show();
+            setTimeout('$(".ts").fadeOut()', 600);
+            return false;
+        }
+        
+        $.ajax({
+            url: addedit,
+            data: f,
+            type: "POST",
+            dataType: "json",
+            success: function(a) {
+                if (a && a.success) {
+                    $(".ts").hide();
+                    $(".express p:eq(0)").html(a.msg+"是否关闭?");
+                    $(".express p:eq(1)").html("<font class='fh'>确 定</font><font class='esc'>取 消</font>");
+                    $(".express").show();
+                } else {
+                    $(".ts").hide();
+                    $(".ts p").html(a.msg);
+                    $(".ts").fadeIn();
+                    setTimeout('$(".ts").fadeOut()', 800);
+                }
+            }
+        });
+    });
+});
+</script>
 {Template footer}