From ad04c582fbda7f095866d37993143880b57af7a4 Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Mon, 27 Sep 2021 17:36:36 +0800
Subject: [PATCH] 20210927

---
 src/main/resources/templates/febs/views/modules/goods/goodsAddNew.html |  108 ++++++++++++++++++++++++++++++++++--------------------
 1 files changed, 68 insertions(+), 40 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..f228ff3 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>
@@ -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());
             }
         });
@@ -294,6 +318,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