123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534 |
- <%@ page contentType="text/html;charset=UTF-8" %>
- <%@ include file="/WEB-INF/views/include/taglib.jsp"%>
- <html>
- <head>
- <title>相关推荐编辑</title>
- <meta name="decorator" content="default"/>
- <style>
- .table th{text-align:center}
- .table td{text-align:center}
- .the-shop label{display:inline-block;margin-right:15px;vertical-align:top;width:70px}
- .shop-img .img{display:inline-block;width:150px;height:100px;background-color:#ccc;border:1px solid #000}
- .shop-img .img img{width:100%;height:100%}
- .default-class label{vertical-align:middle}
- .default-class span{display:inline-block;width:80px;height:20px;line-height:20px;text-align:center;border:1px solid #666;margin-right:15px;border-radius:15px;vertical-align:middle;cursor:pointer}
- .customize-class-ct label{vertical-align:middle}
- .customize-class-ct select{width:100px;height:30px;line-height:30px;margin-right:10px;font-size:14px}
- .active{color:#00bbd3;border-color:#00bbd3!important}
- b.line{margin:0 15px 0 20px;font-weight:normal}
- .flex-wrap .item {margin: 10px 10px 10px 20px;}
- .form-actions {text-align: center;}
- </style>
- </head>
- <body>
- <ul class="nav nav-tabs">
- <li><a href="${ctx}/product/new/list">商品列表</a></li>
- <li class="active"><a href="${ctx}/product/new/recommend?id=${product.productID}">相关推荐编辑</a></li>
- </ul>
- <table class="table table-striped table-bordered table-condensed">
- <caption>
- <p><b>商品名称:</b>${product.name}</p>
- <p><b>推荐列表</b><font color="red">(当前列表记录数 ${dbProductNum}, 最多只能添加15条数据)</font></p>
- </caption>
- <thead>
- <tr>
- <th>ID</th>
- <th>商品名称</th>
- <th>包装规格</th>
- <th>图片</th>
- <th>供应商</th>
- <c:if test="${product.recommendType eq 1}">
- <th>排序</th>
- <shiro:hasPermission name="product:product:edit"><th>操作</th></shiro:hasPermission>
- </c:if>
- </tr>
- </thead>
- <tbody>
- <c:forEach items="${recommendList}" var="cpr">
- <tr>
- <td>
- ${cpr.recommendProductID}
- </td>
- <td>
- ${cpr.productName}
- </td>
- <td>
- ${cpr.unit}
- </td>
- <td><img src="${cpr.img}" width="50" height="50"></td>
- <td>${cpr.shopName}</td>
- <c:if test="${product.recommendType eq 1}">
- <td>
- <input class="input-small sort-input" data-productid="${cpr.recommendProductID}" name="" value="${cpr.sort}">
- </td>
- <shiro:hasPermission name="product:product:edit">
- <td>
- <a href="${ctx}/product/new/recommend/delete?recommendId=${cpr.id}&productID=${cpr.productID}" onclick="return confirmx('确认要删除吗?', this.href)">删除</a>
- </td>
- </shiro:hasPermission>
- </c:if>
- </tr>
- </c:forEach>
- </tbody>
- </table>
- <input type="hidden" id="productID" value="${product.productID}">
- <input type="hidden" id="bigTypeID" value="${bigTypeID}">
- <input type="hidden" id="smallTypeID" value="${smallTypeID}">
- <input type="hidden" id="tinyTypeID" value="${tinyTypeID}">
- <input type="hidden" id="productName" value="${productName}">
- <input type="hidden" id="shopName" value="${shopName}">
- <div class="flex-wrap">
- <div class="item">
- <label><font color="red">*</font><b>设置类型:</b></label>
- <input type="radio" name="recommendType" value="1" onchange="changeRecommendType()" ${recommendType == "1" ? "checked" : ""} />手动选择<b class="line">|</b>
- <input type="radio" name="recommendType" value="0" onchange="changeRecommendType()" ${(recommendType == "0" || recommendType == ""|| recommendType == null) ? "checked" : ""} />自动选择
- <span style="color:#D0D0D0;">(设置自动选择后,系统将会选择该商品所属相同二级分类中销量前7名的商品进行推荐)<span/>
- </div>
- </div>
- <div id="p-list" style="display:none;">
- <div class="flex-wrap">
- <div class="item">
- <label>商品分类:</label>
- <select id="commodityType" class="input-small" onchange="loadBigType()">
- <option value="">请选择</option>
- <option value="1">产品</option>
- <option value="2">仪器</option>
- </select>
- <select id="bigType" class="input-small" onchange="loadSmallType()">
- <option value="">请选择</option>
- </select>
- <select id="smallType" class="input-small" onchange="loadTinyType()">
- <option value="">请选择</option>
- </select>
- <select id="tinyType" class="input-small">
- <option value="">请选择</option>
- </select>
- </div>
- <div class="item">
- <label>商品名称:</label>
- <input id="queryProductName" value="${productName}" htmlEscape="false" maxlength="300" class="input-medium" cssStyle="width: 80px"/>
- </div>
- <div class="item">
- <label>供应商:</label>
- <input id="queryShopName" value="${shopName}" htmlEscape="false" maxlength="300" class="input-medium" cssStyle="width: 80px"/>
- </div>
- <div class="item"><input id="queryBtn" class="btn btn-primary" type="submit" value="查询"/></div>
- </div>
- <table class="table table-striped table-bordered table-condensed">
- <thead>
- <tr>
- <th>ID</th>
- <th>商品名称</th>
- <th>包装规格</th>
- <th>图片</th>
- <th>供应商</th>
- <th>排序</th>
- <shiro:hasPermission name="product:product:edit"><th>操作</th></shiro:hasPermission>
- </tr>
- </thead>
- <tbody>
- <c:forEach items="${list}" var="cpr">
- <tr>
- <td>
- ${cpr.productID}
- </td>
- <td>
- ${cpr.productName}
- </td>
- <td>
- ${cpr.unit}
- </td>
- <td><img src="${cpr.img}" width="50" height="50"></td>
- <td>${cpr.shopName}</td>
- <td>
- <input class="input-small sort-input" data-productid="${cpr.productID}" name="" value="${cpr.sort}">
- </td>
- <shiro:hasPermission name="product:product:edit">
- <td>
- <input type="checkbox" data-productid="${cpr.productID}" ${cpr.check ? 'checked="checked" data-db="1"':'data-db="0"'} ${full == 1 ? 'disabled="true"':''} class="recommendProductID" name="recommendProductID"/>
- </td>
- </shiro:hasPermission>
- </tr>
- </c:forEach>
- </tbody>
- </table>
- </div>
- <div class="form-actions">
- <shiro:hasPermission name="product:product:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/> </shiro:hasPermission>
- <input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
- </div>
- <script type="text/javascript">
- params = [];
- var num = '';
- dbProductNum = Number('${dbProductNum}');
- function page(n,s){
- $("#pageNo").val(n);
- $("#pageSize").val(s);
- $("#searchForm").submit();
- return false;
- }
- $(function () {
- // 获取初始分类
- loadInitType();
- //相关推荐类型 0自动选择; 1手动推荐
- if ('${recommendType}' == '0') {
- $('#p-list').hide();
- }
- if ('${recommendType}' == '1') {
- $('#p-list').show();
- }
- $('body').on('click','#queryBtn', function () {
- var recommendType = $("input[name='recommendType']:checked").val();
- var url = "${ctx}//product/new/recommend?id=" + $("#productID").val() + "&recommendType=" + recommendType;
- if ($("#commodityType").val() != '' && $("#commodityType").val() != '请选择') {
- url += "&commodityType=" + $("#commodityType").val();
- }
- if ($("#bigType").val() != '' && $("#bigType").val() != '请选择') {
- url += "&bigTypeID=" + $("#bigType").val();
- }
- if ($("#smallType").val() != '' && $("#smallType").val() != '请选择') {
- url += "&smallTypeID=" + $("#smallType").val();
- }
- if ($("#tinyType").val() != '' && $("#tinyType").val() != '请选择') {
- url += "&tinyTypeID=" + $("#tinyType").val();
- }
- if ($("#queryProductName").val() != '') {
- url += "&productName=" + $("#queryProductName").val();
- }
- if ($("#queryShopName").val() != '') {
- url += "&shopName=" + $("#queryShopName").val();
- }
- window.location.href = url;
- });
- $('body').on('click','#btnSubmit',function () {
- if ('${full}' == '1' || dbProductNum > 15) {
- alertx("最多只能添加15条相关商品");
- return;
- }
- var recommendType = $("input[name='recommendType']:checked").val();
- var url = "${ctx}/product/new/recommend/add?productID=" + $("#productID").val() + "&recommendType=" + recommendType;
- if (recommendType == '1') { //只有选择了手动推荐相关商品单选框才修改相关商品数据
- for (var i = 0; i < params.length; i++) {
- url += "¶ms=" + params[i];
- }
- }
- //保留搜索条件
- <%--url += "&searchName=${product.searchName}&searchShopID=${product.searchShopID}&searchShopName=${product.searchShopName}&searchBigTypeID=${product.searchBigTypeID}&searchSmallTypeID=${product.searchSmallTypeID}&searchTinyTypeID=${product.searchTinyTypeID}&searchValidFlag=${product.searchValidFlag}&searchActStatus=${product.searchActStatus}&searchProductType=${product.searchProductType}&searchBrandID=${product.searchBrandID}&searchPreferredFlag=${product.searchPreferredFlag}";--%>
- window.location.href = url;
- });
- $('.recommendProductID').on('click', function () {
- $this=$(this);
- var sortInput = $this.parent().prev().find(".sort-input");
- if ($this.is(":checked")) { //选中
- sortInput.val(1);
- params.push(sortInput.data("productid") + ":" + sortInput.val());
- $this.data('db') == '0' && dbProductNum++;
- } else { //没选中
- sortInput.val(null);
- $this.data('db') == '0' && dbProductNum--;
- for (var i = 0; i < params.length; i++) {
- if (params[i].startsWith($this.data("productid") + ":")) {
- params.splice(i, 1);
- break;
- }
- }
- }
- });
- $(".sort-input").change(function(){
- $this=$(this);
- // 控制input只能输入数字
- $this.val($this.val().replace(/[^\d]/g, ""));
- if (typeof($this.val()) == "number" && $this.val() <= 1 || $this.val() == '')
- $this.val(1);
- var data = $this.data("productid") + ":" + $this.val();
- var flag = true;
- for (var i = 0; i < params.length; i++) {
- if (params[i].startsWith($this.data("productid") + ":")) {
- params.splice(i, 1);
- params.push(data);
- flag = false;
- break;
- }
- }
- if (flag) params.push(data);
- $this.parent().next().find("input[name='recommendProductID']").attr("checked","true");
- });
- });
- // 初始化
- /* var currentTinytype = ${product.tinyTypeID};
- var currentSmalltype, currentBigType;
- // 初始分类
- function loadInitType(){
- for(var i=0; i<tinytypeList.length; i++){
- if (currentTinytype == tinytypeList[i].tinyTypeID) {
- currentSmalltype = tinytypeList[i].smallTypeID;
- }
- }
- for(var i=0; i<smalltypeList.length; i++){
- if (currentSmalltype == smalltypeList[i].smallTypeID) {
- currentBigType = smalltypeList[i].bigTypeID;
- }
- }
- if(currentBigType != null && typeof(currentBigType) != "undefined"){
- loadSmallType(currentBigType, '#bigType', '#smallType', '#tinyType');
- setTimeout(function(){
- loadTinyType(currentSmalltype, '#smallType', '#tinyType');
- },0);
- setTimeout(function(){
- $('#tinyType').val(currentTinytype);
- var tinyTypeText = $('#tinyType').find('option:selected').text();
- $('#tinyType').prev().find('.select2-chosen').text(tinyTypeText);
- },500)
- }
- }*/
- // 网站分类
- var currentBigtype = ${product.bigTypeID};
- var currentSmalltype = ${product.smallTypeID};
- var currentTinytype = ${product.tinyTypeID};
- var currentCommodityType = ${product.commodityType}; //商品属性
- var bigTypeList = [
- <c:forEach items="${classify.bigTypeList}" var="bigType" varStatus="index">
- <c:if test="${index.index > 0}">,</c:if>
- {
- bigTypeID: ${bigType.bigTypeID},
- name: "${bigType.name}",
- typeSort: ${bigType.typeSort}
- }
- </c:forEach>
- ];
- var smalltypeList = [
- <c:forEach items="${classify.smalltypeList}" var="smalltype" varStatus="index">
- <c:if test="${index.index > 0}">,</c:if>
- {
- smallTypeID: ${smalltype.smallTypeID},
- name: "${smalltype.name}",
- bigTypeID: ${smalltype.bigTypeID},
- }
- </c:forEach>
- ];
- var tinytypeList = [
- <c:forEach items="${classify.tinytypeList}" var="tinytype" varStatus="index">
- <c:if test="${index.index > 0}">,</c:if>
- {
- tinyTypeID: ${tinytype.tinyTypeID},
- name: "${tinytype.name}",
- smallTypeID: ${tinytype.smallTypeID}
- }
- </c:forEach>
- ];
- // 初始分类
- function loadInitType(){
- if (currentCommodityType == null || typeof (currentCommodityType) == "undefined" || currentCommodityType == '0') {
- $("#bigType").html("");
- $("#bigType").prev().find(".select2-chosen").text("请选择");
- $("#bigType").append("<option value=''>请选择</option>");
- $("#smallType").html("");
- $("#smallType").prev().find(".select2-chosen").text("请选择");
- $("#smallType").append("<option value=''>请选择</option>");
- $("#tinyType").html("");
- $("#tinyType").prev().find(".select2-chosen").text("请选择");
- $("#tinyType").append("<option value=''>请选择</option>");
- document.getElementById("s2id_tinyType").style.cssText = "display: none";
- }else if(currentBigtype != null && typeof(currentBigtype) != "undefined"){
- setTimeout(function(){
- loadBigType();
- },0);
- }
- }
- // 分类联动
- function loadBigType(){
- var commodityType = $("#commodityType").val();
- $("#bigType").html("");
- $("#bigType").prev().find(".select2-chosen").text("请选择");
- $("#bigType").append("<option value=''>请选择</option>");
- $("#smallType").html("");
- $("#smallType").prev().find(".select2-chosen").text("请选择");
- $("#smallType").append("<option value=''>请选择</option>");
- $("#tinyType").html("");
- $("#tinyType").prev().find(".select2-chosen").text("请选择");
- $("#tinyType").append("<option value=''>请选择</option>");
- if(typeof(commodityType) != "undefined") {
- $("#bigType").html("");
- $("#bigType").prev().find(".select2-chosen").text("请选择");
- $("#bigType").append("<option value=''>请选择</option>");
- $("#smallType").html("");
- $("#smallType").prev().find(".select2-chosen").text("请选择");
- $("#smallType").append("<option value=''>请选择</option>");
- $("#tinyType").html("");
- $("#tinyType").prev().find(".select2-chosen").text("请选择");
- $("#tinyType").append("<option value=''>请选择</option>");
- for(var i=0; i<bigTypeList.length; i++){
- if (commodityType == bigTypeList[i].typeSort) {
- if (currentBigtype != null && typeof (currentBigtype) != "undefined" && currentBigtype == bigTypeList[i].bigTypeID) {
- $("#bigType").append("<option selected value='"+bigTypeList[i].bigTypeID+"'>"+bigTypeList[i].name+"</option>");
- $("#bigType").prev().find(".select2-chosen").text(bigTypeList[i].name);
- setTimeout(function(){
- loadSmallType();
- },500);
- }else{
- $("#bigType").append("<option value='"+bigTypeList[i].bigTypeID+"'>"+bigTypeList[i].name+"</option>");
- }
- }
- }
- }
- loadSmallType();
- }
- function loadSmallType(id){
- if(id){
- $("#bigType").val(id);
- $("#bigType").prev().find(".select2-chosen").text($("#bigType option:selected").text());
- }
- var bigType = $("#bigType").val();
- $("#smallType").html("");
- $("#smallType").prev().find(".select2-chosen").text("请选择");
- $("#smallType").append("<option value=''>请选择</option>");
- $("#tinyType").html("");
- $("#tinyType").prev().find(".select2-chosen").text("请选择");
- $("#tinyType").append("<option value=''>请选择</option>");
- if(typeof(bigType) != "undefined" && bigType != "") {
- var smallTypeNum = 0;
- for(var i=0; i<smalltypeList.length; i++){
- if (bigType == smalltypeList[i].bigTypeID) {
- smallTypeNum = smallTypeNum + 1;
- if(currentSmalltype != null && typeof(currentSmalltype) != "undefined" && currentSmalltype == smalltypeList[i].smallTypeID) {
- $("#smallType").append("<option selected value='"+smalltypeList[i].smallTypeID+"'>"+smalltypeList[i].name+"</option>");
- $("#smallType").prev().find(".select2-chosen").text(smalltypeList[i].name);
- setTimeout(function(){
- loadTinyType(currentSmalltype);
- },500);
- }else{
- $("#smallType").append("<option value='"+smalltypeList[i].smallTypeID+"'>"+smalltypeList[i].name+"</option>");
- }
- }
- }
- if (smallTypeNum == 0) {
- $("#smallType").removeClass("required");
- document.getElementById("s2id_smallType").style.cssText = "display: none";
- }else {
- $("#smallType").addClass("required");
- document.getElementById("s2id_smallType").style.cssText = "display: inline-block";
- }
- } else {
- $("#smallType").removeClass("required");
- document.getElementById("s2id_smallType").style.cssText = "display: none";
- }
- loadTinyType();
- }
- function loadTinyType(id) {
- if(id){
- $("#smallType").val(id);
- $("#smallType").prev().find(".select2-chosen").text($("#smallType option:selected").text());
- }
- var smallType = $("#smallType option:selected").val();
- $("#tinyType").html("");
- $("#tinyType").prev().find(".select2-chosen").text("请选择");
- $("#tinyType").append("<option value=''>请选择</option>");
- if(typeof(smallType) != "undefined" && smallType != "") {
- var tinyTypeNum = 0;
- for(var i=0; i<tinytypeList.length; i++){
- if (smallType == tinytypeList[i].smallTypeID) {
- tinyTypeNum = tinyTypeNum + 1;
- if(currentTinytype != null && typeof(currentTinytype) != "undefined" && currentTinytype == tinytypeList[i].tinyTypeID) {
- $("#tinyType").append("<option selected value='"+tinytypeList[i].tinyTypeID+"'>"+tinytypeList[i].name+"</option>");
- $("#tinyType").prev().find(".select2-chosen").text(tinytypeList[i].name);
- }else{
- $("#tinyType").append("<option value='"+tinytypeList[i].tinyTypeID+"'>"+tinytypeList[i].name+"</option>");
- }
- }
- }
- if (tinyTypeNum == 0) {
- $("#tinyType").removeClass("required");
- document.getElementById("s2id_tinyType").style.cssText = "display: none";
- }else {
- $("#tinyType").addClass("required");
- document.getElementById("s2id_tinyType").style.cssText = "display: inline-block";
- }
- } else {
- document.getElementById("s2id_tinyType").style.cssText = "display: none";
- $("#tinyType").removeClass("required");
- }
- }
- /*function loadSmallType(id, big, small, tiny){
- if(id){
- $(big).val(id);
- var text = $(big).find('option:selected').text();
- $(big).prev().find(".select2-chosen").text(text);
- }
- var bigType = $(big).val();
- if(typeof(bigType) != "undefined") {
- $(small).html("");
- $(small).prev().find(".select2-chosen").text("请选择");
- $(small).append("<option value=''>请选择</option>");
- $(tiny).html("");
- $(tiny).prev().find(".select2-chosen").text("请选择");
- $(tiny).append("<option value=''>请选择</option>");
- for(var i=0; i<smalltypeList.length; i++){
- if (bigType == smalltypeList[i].bigTypeID) {
- if(currentSmalltype != null && typeof(currentSmalltype) != "undefined" && currentSmalltype == smalltypeList[i].smallTypeID) {
- $(small).append("<option selected value='"+smalltypeList[i].smallTypeID+"'>"+smalltypeList[i].name+"</option>");
- $(small).prev().find(".select2-chosen").text(smalltypeList[i].name);
- setTimeout(function(){
- loadTinyType(currentSmalltype, small, tiny)
- },i*500);
- }else{
- $(small).append("<option value='"+smalltypeList[i].smallTypeID+"'>"+smalltypeList[i].name+"</option>");
- }
- }
- }
- } else {
- $(small).html("");
- $(small).prev().find(".select2-chosen").text("请选择");
- $(small).append("<option value=''>请选择</option>");
- $(tiny).html("");
- $(tiny).prev().find(".select2-chosen").text("请选择");
- $(tiny).append("<option value=''>请选择</option>");
- }
- }*/
- /*function loadTinyType(id, small, tiny){
- if(id){
- $(small).val(id);
- var text = $(small).find('option:selected').text();
- $(small).prev().find(".select2-chosen").text(text);
- }
- var smallType = $(small).find('option:selected').val();
- if(typeof(smallType) != "undefined") {
- $(tiny).html("");
- $(tiny).prev().find(".select2-chosen").text("请选择");
- $(tiny).append("<option value=''>请选择</option>");
- for(var i=0; i<tinytypeList.length; i++){
- if (smallType == tinytypeList[i].smallTypeID) {
- if(currentTinytype != null && typeof(currentTinytype) != "undefined" && currentTinytype == tinytypeList[i].tinyTypeID) {
- $(tiny).append("<option selected value='"+tinytypeList[i].tinyTypeID+"'>"+tinytypeList[i].name+"</option>");
- $(tiny).prev().find(".select2-chosen").text(tinytypeList[i].name);
- }else{
- $(tiny).append("<option value='"+tinytypeList[i].tinyTypeID+"'>"+tinytypeList[i].name+"</option>");
- }
- }
- }
- } else {
- $(tiny).html("");
- $(tiny).prev().find(".select2-chosen").text("请选择");
- $(tiny).append("<option value=''>请选择</option>");
- }
- }*/
- function changeRecommendType(){
- var recommendType = $("input[name='recommendType']:checked").val();
- if (recommendType == '0') {
- $('#p-list').hide();
- } else if (recommendType == '1') {
- $('#p-list').show();
- }
- }
- </script>
- </body>
- </html>
|