| | |
| | | <div class="layui-form-mid layui-word-aux"> |
| | | <button href="javascript:void(0);" class="add-brand layui-btn layui-btn-normal layui-btn-xs">添加品牌</button> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | | <label for="areaId" class="layui-form-label ">所属地区</label> |
| | | <div class="layui-input-block layui-inline-4 address-class"> |
| | | <input type="hidden" name="areaId"> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="layui-form-item"> |
| | |
| | | 'Authorization': Authorization |
| | | } |
| | | }); |
| | | /*****************************************************************/ |
| | | //地区选择 |
| | | function changeareaIdArea(i, max_i) { |
| | | //清除后面节点 |
| | | for (var x = i + 1; x <= 6; x++) { //最多6层,足够了 |
| | | $("select[name='areaId_" + x + "']").remove(); |
| | | } |
| | | var val = $("select[name='areaId_" + i + "']").val(); |
| | | if (val != "") { |
| | | //取子节点数据,然后显示下一级 |
| | | coreHelper.Post("Api/Tools/GetAreaChildren", { id: val }, function (e) { |
| | | if (debug) { console.log(e); } //开启调试返回数据 |
| | | |
| | | if (e.length > 0) { |
| | | var str = ""; |
| | | str += "<select lay-ignore name='areaId_" + (i + 1) + "' dep='" + (i + 1) + "' class='select-address'>"; |
| | | str += "<option value='' >请选择</option>"; |
| | | $.each(e, function (h, z) { |
| | | str += "<option value='" + z.id + "' >" + z.name + "</option>"; |
| | | }); |
| | | str += "</select>"; |
| | | $("select[name='areaId_" + i + "']").after(str); |
| | | //以上数据输出完,以下绑定事件 |
| | | $("select[name='areaId_" + (i + 1) + "']").change(function () { |
| | | changeareaIdArea(i + 1, i + 2); |
| | | }); |
| | | |
| | | //如果有返回值,就说明省市区没有选择到最终节点 |
| | | if (1 == 1) { |
| | | $("input[name='areaId']").val(""); |
| | | } else { |
| | | $("input[name='areaId']").val($("select[name='areaId_" + i + "']").val()); |
| | | } |
| | | } else { |
| | | $("input[name='areaId']").val($("select[name='areaId_" + i + "']").val()); |
| | | } |
| | | }); |
| | | } else { |
| | | if (1 == 1) { |
| | | $("input[name='areaId']").val(""); |
| | | } else { |
| | | //第一级的元素就直接赋值为空就是了 |
| | | if (i == 1) { |
| | | $("input[name='areaId']").val(""); |
| | | } else { |
| | | i--; |
| | | $("input[name='areaId']").val($("select[name='areaId_" + i + "']").val()); |
| | | } |
| | | |
| | | } |
| | | } |
| | | } |
| | | coreHelper.Post("Api/Tools/GetAreaCheckedList", { id: 0 }, function (data) { |
| | | |
| | | |
| | | var str = ""; |
| | | $.each(data, function (i, n) { |
| | | |
| | | str += "<select lay-ignore name='areaId_" + (i + 1) + "' dep='" + (i + 1) + "' class='select-address'>"; |
| | | str += `<option value= ${(d.data.areaId??0)===0?" selected='selected'":''} >请选择</option>`; |
| | | if(n.list.length>0) |
| | | { $.each(n.list, function (h, z) { |
| | | if (n.hasOwnProperty('info') && n.info?.id == z.id) { |
| | | str += "<option value='" + z.id + "' selected='selected'>" + z.name + "</option>"; |
| | | } else { |
| | | str += "<option value='" + z.id + "' >" + z.name + "</option>"; |
| | | } |
| | | }); |
| | | } |
| | | else |
| | | { |
| | | $.each(n.thisList, function (h, z) { |
| | | if (n.hasOwnProperty('info') && n.info?.id == z.id) { |
| | | str += "<option value='" + z.id + "' selected='selected'>" + z.name + "</option>"; |
| | | } else { |
| | | str += "<option value='" + z.id + "' >" + z.name + "</option>"; |
| | | } |
| | | }); |
| | | } |
| | | str += "</select>"; |
| | | }); |
| | | $("input[name='areaId']").after(str); |
| | | //以上数据输出完,以下绑定事件 |
| | | $.each(data, function (i, n) { |
| | | |
| | | if (i < (data.length)) { |
| | | $("select[name='areaId_" + (i + 1) + "']").change(function () { |
| | | changeareaIdArea(i + 1, data.length); |
| | | }); |
| | | } |
| | | }); |
| | | }); |
| | | /*****************************************************************/ |
| | | //获取商品类型 |
| | | types = d.data.types; |
| | | // 渲染商品分类 |
| | |
| | | goods.unit = field['goods[unit]']; |
| | | goods.weight = field['goods[weight]']; |
| | | goods.openSpec = parseInt(field.openSpec); |
| | | if (isNumericString(field["areaId_1"])) { |
| | | goods.areaCode+=`${field["areaId_1"]}`; |
| | | if (isNumericString(field["areaId_2"])) |
| | | goods.areaCode+=`,${field["areaId_2"]}`; |
| | | if (isNumericString(field["areaId_3"])) |
| | | goods.areaCode+=`,${field["areaId_3"]}`; |
| | | } else { |
| | | |
| | | } |
| | | //多参数产品库生成列表集合 |
| | | var products = []; |
| | | var productsCount = parseInt(field['productsCount']); |