From 89e2b353cb22e38dbe0a7144b26fa69766cf7f9b Mon Sep 17 00:00:00 2001 From: Helius <wangdoubleone@gmail.com> Date: Tue, 28 Sep 2021 10:12:50 +0800 Subject: [PATCH] Merge branch 'master' of http://120.27.238.55:7000/r/xc-mall --- src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html | 172 ++++++++++++++++++++++++++++++++++----------------------- 1 files changed, 103 insertions(+), 69 deletions(-) diff --git a/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html b/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html index 1929f68..7a5cca0 100644 --- a/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html +++ b/src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html @@ -23,12 +23,8 @@ <div class="layui-col-lg6"> <label class="layui-form-label febs-form-item-require">所属分类:</label> <div class="layui-input-block"> - <select name="categoryId" - value="categoryId" - lay-verify="required" - xm-select-direction="down" - xm-select="user-add-goods" - xm-select-skin="default"> + <select name="categoryId" class="categary-update-category" > + <option value="">请选择</option> </select> </div> </div> @@ -61,7 +57,7 @@ </div> <div class="layui-row layui-col-space10 layui-form-item"> <div class="layui-col-lg6"> - <label class="layui-form-label">规格:</label> + <label class="layui-form-label">样式:</label> <div class="layui-input-block"> <input type="text" name="addMallGoodsSkuDtos" autocomplete="off" class="layui-input" id="attrName"> </div> @@ -71,9 +67,8 @@ </div> </div> <div id="attrWrap"></div> - <div class="layui-form-item"> - <label class="layui-form-label">缩略图:</label> + <label class="layui-form-label febs-form-item-require">缩略图:</label> <div class="layui-input-block"> <div class="layui-upload"> <button type="button" class="layui-btn layui-btn-normal layui-btn-xs" id="test2">上传</button> @@ -86,13 +81,32 @@ <div class="layui-form-item febs-hide"> <label class="layui-form-label">缩略图链接:</label> <div class="layui-input-block"> - <input type="text" id="thumb" name="thumb" autocomplete="off" class="layui-input" readonly> + <input type="text" id="thumb" lay-verify="required" name="thumb" autocomplete="off" class="layui-input" readonly> </div> </div> + <div class="layui-form-item"> - <label class="layui-form-label">商品详情:</label> + <label class="layui-form-label febs-form-item-require">轮播图:</label> <div class="layui-input-block"> - <textarea id="lay_edit" lay-verify="goodsDetails" name = "goodsDetails" class="layui-textarea"></textarea> + <div class="layui-upload"> + <button type="button" class="layui-btn layui-btn-normal layui-btn-xs" id="thumbsBanner">上传</button> + <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;"> + <div class="layui-upload-list" id="thumbsBanners"></div> + </blockquote> + </div> + </div> + </div> + <div class="layui-form-item febs-hide"> + <label class="layui-form-label">缩略图链接:</label> + <div class="layui-input-block"> + <input type="text" id="thumbs" lay-verify="required" name="thumbs" autocomplete="off" class="layui-input" readonly> + </div> + </div> + + <div class="layui-form-item"> + <label class="layui-form-label febs-form-item-require">商品详情:</label> + <div class="layui-input-block"> + <textarea id="lay_edit" lay-verify="required" name = "goodsDetails" class="layui-textarea"></textarea> </div> </div> <div class="layui-row layui-col-space10 layui-form-item"> @@ -140,32 +154,42 @@ formSelects.render(); - formSelects.config('user-add-goods', { - searchUrl: ctx + 'admin/goodsCategory/categorys', - response: { - statusCode: 200 - }, - beforeSuccess: function (id, url, searchVal, result) { - var data = result.data; - var tranData = []; - for (var i = 0; i < data.length; i++) { - tranData.push({ - name: data[i].name, - value: data[i].id - }) + + //(下拉框) + $.get(ctx + 'admin/goodsCategory/categorys/tree', function (data) { + for (var k in data) + { + $(".categary-update-category").append("<option value='" + data[k].parentId + "'>" + data[k].name + "</option>"); + } + layui.use('form', function () { + var form = layui.form; + // $("#categarySelect").val(member.parentId) + form.render(); + }); + }); + + //多图片上传 + upload.render({ + elem: '#thumbsBanner' + ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 + ,multiple: true + ,before: function(obj){ + //预读本地文件示例,不支持ie8 + obj.preview(function(index, file, result){ + $('#thumbsBanners').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img" style="width: 100px">') + }); + } + ,done: function(res){ + var thumbs = $("#thumbs").val(); + if(thumbs == ''){ + $("#thumbs").val(res.data.src); + }else{ + $("#thumbs").val(thumbs + ',' + res.data.src); } - result.data = tranData; - console.log(result); - return result; - }, - success: function () { - formSelects.value('user-add-goods', result.id); - }, - error: function (id, url, searchVal, err) { - console.error(err); - febs.alert.error('获取分类列表失败'); + // alert($("#thumb").val()); } }); + //多图片上传 upload.render({ elem: '#test2' @@ -174,16 +198,16 @@ ,before: function(obj){ //预读本地文件示例,不支持ie8 obj.preview(function(index, file, result){ - $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img">') + $('#demo2').append('<img src="'+ result +'" alt="'+ file.name +'" class="layui-upload-img" style="width: 100px">') }); } ,done: function(res){ - var thumbs = $("#thumb").val(); - if(thumbs == ''){ + // var thumbs = $("#thumb").val(); + // if(thumbs == ''){ $("#thumb").val(res.data.src); - }else{ - $("#thumb").val(thumbs + ',' + res.data.src); - } + // }else{ + // $("#thumb").val(thumbs + ',' + res.data.src); + // } // alert($("#thumb").val()); } }); @@ -208,43 +232,53 @@ $('#test3').on('click', function (){ var index = $("#attrWrap").children().length; + let attrNameVal = $('#attrName').val(); + if(attrNameVal==null || attrNameVal==""){ + febs.alert.warn('样式名称不能为空'); + return false; + } $('#attrWrap').append(` <div class="layui-form-item item"> <div style="float:left" > - <input type="text" name="skuName` + index + `" autocomplete="off" class="layui-input" value="` + $('#attrName').val() + `" readonly > + <input type="text" name="styleName` + index + `" value="` + $('#attrName').val() + `" autocomplete="off" class="layui-input" readonly > + </div> + <div style="float:left" > + <div> + <input type="text" name="skuName` + index +`" placeholder="名称" autocomplete="off" class="layui-input" > + </div> </div> <div style="float:left" > <label class="layui-form-label">图片:</label> <div class="layui-input-block"> <div class="layui-upload"> - <button type="button" class="layui-btn layui-btn-normal layui-btn-xs sku-img" id="` + index + `">上传</button> - <input type="text" id="skuImage` + index +`" name="skuImage` + index + `" autocomplete="off" - class="layui-input"> + <button type="button" class="layui-btn layui-btn-normal layui-btn-xs sku-img" id="skuImg` + index + `">上传</button> + <img class="layui-upload-img" id="imageUrls` + index + `" style="width: 100px" > </div> </div> </div> - <div style="float:left" > - <label class="layui-form-label">库存:</label> - <div class="layui-input-block"> - <input type="text" name="stock` + index +`" autocomplete="off" class="layui-input" > + <div style="float:left" class="febs-hide"> + <div> + <input type="text" id="skuImage` + index +`" name="skuImage` + index + `" autocomplete="off" class="layui-input"> </div> </div> <div style="float:left" > - <label class="layui-form-label">销售数量:</label> - <div class="layui-input-block"> - <input type="text" name="skuVolume` + index +`" autocomplete="off" class="layui-input" > + <div> + <input type="number" name="stock` + index +`" placeholder="库存" autocomplete="off" class="layui-input" > </div> </div> <div style="float:left" > - <label class="layui-form-label">原价:</label> - <div class="layui-input-block"> - <input type="text" name="originalPrice` + index +`" autocomplete="off" class="layui-input" > + <div> + <input type="number" name="skuVolume` + index +`" placeholder="销售数量" autocomplete="off" class="layui-input" > </div> </div> <div style="float:left" > - <label class="layui-form-label">现价:</label> - <div class="layui-input-block"> - <input type="text" name="presentPrice` + index + `" autocomplete="off" class="layui-input" > + <div> + <input type="number" name="originalPrice` + index +`" placeholder="原价" autocomplete="off" class="layui-input" > + </div> + </div> + <div style="float:left" > + <div> + <input type="number" name="presentPrice` + index + `" placeholder="现价" autocomplete="off" class="layui-input" > </div> </div> <div style="float:left" > @@ -254,30 +288,25 @@ `) //普通图片上传 upload.render({ - elem: '.sku-img' + elem: '#skuImg' + index ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 ,done: function(res){ febs.alert.success(res.data.src); - var cid = this.item.attr('id'); - $('#skuImgPreview' + cid).attr('src', res.data.src); - $('#skuImage'+cid).val(res.data.src); + $('#imageUrls' + index).attr('src', res.data.src); + $('#skuImage'+ index).val(res.data.src); } }); }); upload.render({ - elem: '.sku-img' + elem: '#skuImg'+index ,url: ctx + 'admin/goods/uploadFileBase64' //改成您自己的上传接口 ,done: function(res){ febs.alert.success(res.data.src); - var cid = this.item.attr('id'); - $('#skuImgPreview' + cid).attr('src', res.data.src); - $('#skuImage'+cid).val(res.data.src); + $('#imageUrls' + index).attr('src', res.data.src); + $('#skuImage'+ index).val(res.data.src); } }); $("#attrWrap").on("click",".del-attr-btn",function(){ - // console.log(this) - // console.log($(this).index()) - // console.log($(this).attr('data-index')) var index = $(this).attr('data-index') $($("#attrWrap").find(".item")[index].remove()); }); @@ -286,6 +315,7 @@ var skuArr = $("#attrWrap").find(".item"); for(var i = 0;i < skuArr.length;i++){ skuArrs.push({ + styleName: $("input[name='styleName" + i + "']").val(), skuName: $("input[name='skuName" + i + "']").val(), skuImage: $("input[name='skuImage" + i + "']").val(), stock: $("input[name='stock" + i + "']").val(), @@ -294,6 +324,10 @@ presentPrice: $("input[name='presentPrice" + i + "']").val() }) } + // if(skuArr.length < 0){ + // febs.alert.warn("请填写商品规格"); + // return false; + // } // console.log(skuArrs) data.field.addMallGoodsSkuDtos = skuArrs; // console.log(data.field) -- Gitblit v1.9.1