Authored by qinchao

add 销售类目功能

  1 +<!DOCTYPE html>
  2 +
  3 +<style>
  4 +.sale-category-detail-page .goods-image {
  5 + display: flex;
  6 +}
  7 +
  8 +
  9 +.sale-category-detail-page .goods-image .img {
  10 + width: 104px;
  11 + height: 104px;
  12 + margin-right: 10px;
  13 + background-size: cover;
  14 + background-repeat: no-repeat;
  15 + background-position: center;
  16 + position: relative;
  17 +}
  18 +
  19 +.sale-category-detail-page .goods-image .img:hover:before {
  20 + content: "删除";
  21 + width: 100%;
  22 + display: block;
  23 + position: absolute;
  24 + top: 0;
  25 + background: #000;
  26 + opacity: 0.5;
  27 + color: #fff;
  28 + text-align: center;
  29 + line-height: 104px;
  30 +}
  31 +</style>
  32 +<div class="sale-category-detail-page" fit="true" style="overflow-y: scroll">
  33 + <form name="categoryEditForm" id="categoryEditForm" method="post" enctype="multipart/form-data">
  34 + <input type="hidden" name="id" />
  35 + <input type="hidden" name="parentId" id="parentId"/>
  36 + <div style="margin-top: 5px;margin-left: 30px">
  37 + <table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab">
  38 + <tr style="height: 60px">
  39 + <td width="20%"><span style="color:red">*</span><label>名称</label></td>
  40 + <td>
  41 + <div style="width:200px;">
  42 + <input class="easyui-textbox" id="categoryName" name="categoryName" data-options="validType:'length[1,30]'" />
  43 + </div>
  44 + </td>
  45 + </tr>
  46 + <tr style="height: 60px">
  47 + <td width="20%"><span style="color:red">*</span><label>排序值</label></td>
  48 + <td>
  49 + <input class="easyui-numberbox" id="orderBy" name="orderBy" data-options="validType:'length[1,10]'" />
  50 + </td>
  51 + </tr>
  52 + </table>
  53 + </div>
  54 +
  55 + <div class="goods-image" style="margin-top: 5px;margin-left: 30px">
  56 + <table border="0" style="width:95%;margin-top:5px;line-height:30px;" >
  57 + <tr style="height: 60px">
  58 + <td width="20%"><span style="color:red">*</span><label>分类图标</label></td>
  59 + <td width="80%">
  60 + <!--<div class="img" data-url="http://img11.static.yhbimg.com/salecategoryimg/2018/12/18/11/01a8ea37ad7b8f112d2727ff1ee507a926.png"
  61 + style="background-image:url(http://img11.static.yhbimg.com/salecategoryimg/2018/12/18/11/01a8ea37ad7b8f112d2727ff1ee507a926.png);"></div>-->
  62 + <div id="imageUpload"></div>
  63 + </td>
  64 + </tr>
  65 + </table>
  66 +
  67 + </div>
  68 +
  69 + <div style="margin-top: 5px;margin-left: 30px">
  70 + <table border="0" style="width:95%;margin-top:5px;line-height:30px;" >
  71 + <tr style="height: 60px">
  72 + <td width="20%"><span style="color:red">*</span><label>跳转类型</label></td>
  73 + <td>
  74 + <div style="width:200px;">
  75 + <input class="easyui-textbox" name="linkType" data-options="validType:'length[1,30]'" />
  76 + </div>
  77 + </td>
  78 + </tr>
  79 + <tr style="height: 60px">
  80 + <td width="20%"><span style="color:red">*</span><label>跳转目的</label></td>
  81 + <td>
  82 + <input class="easyui-textbox" name="linkDetail" data-options="validType:'length[1,10]'" />
  83 + </td>
  84 + </tr>
  85 + </table>
  86 + </div>
  87 + </form>
  88 +</div>
  89 +<script>
  90 + $(function () {
  91 + this.dom = {
  92 + imageUpload: $('#categoryEditForm #imageUpload')
  93 + };
  94 +
  95 + $("#categoryEditForm #categoryName").textbox({
  96 + required: true,
  97 + missingMessage: "销售类目名称不能为空",
  98 + prompt: "请输入",
  99 + width: "200px"
  100 + });
  101 +
  102 + $("#categoryEditForm #orderBy").numberbox({
  103 + required: true,
  104 + precision:0,
  105 + min:1,
  106 + missingMessage: "排序值不能为空",
  107 + prompt: "请输入",
  108 + width:"200px"
  109 + });
  110 +
  111 +
  112 + this.dom.imageUpload.imageUpload({
  113 + width: 104,
  114 + height: 104,
  115 + realInputName: "imageUrl",
  116 + url: contextPath + '/fileupload/upload',
  117 + queryParams: {
  118 + bucket: "salecategoryimg"
  119 + },
  120 + onBeforeSubmit: function () {
  121 + $.messager.progress({
  122 + title: "正在执行",
  123 + msg: "正在执行,请稍后...",
  124 + interval: 500,
  125 + text: ""
  126 + });
  127 + },
  128 + filterFileName: function (data) {
  129 + if (!data || data.code != 200) {
  130 + $.messager.progress("close");
  131 + $.messager.alert("错误", data.message);
  132 + return "";
  133 + }
  134 + return data.data.url;
  135 + },
  136 + onLoadSuccess: function (data) {
  137 + console.log(data.data );
  138 + $.messager.progress("close");
  139 + $(document).find('.file-close').click();
  140 + $('#categoryEditForm #imageUpload').before('<div class="img" data-url="' + data.data + '" style="background-image:url(' + data.data + ');">');
  141 + return false;
  142 + }
  143 + });
  144 +
  145 +
  146 +
  147 +
  148 + $("#categoryEditForm #parentId").val(saleCategoryParentId);
  149 +
  150 + if (saleCategoryId > 0) {
  151 + $.post(contextPath + "/saleCategory/getSaleCategoryById", {
  152 + id: saleCategoryId
  153 + }, function (data) {
  154 + $("#categoryEditForm").form("load", data.data);
  155 +
  156 + });
  157 + }
  158 + });
  159 +
  160 +</script>
@@ -23,6 +23,16 @@ @@ -23,6 +23,16 @@
23 .div_search .easyui-linkbutton { 23 .div_search .easyui-linkbutton {
24 margin-top: 20px; 24 margin-top: 20px;
25 } 25 }
  26 +
  27 + .sale-category-detail-page .img222 {
  28 + width: 104px;
  29 + height: 104px;
  30 + margin-right: 10px;
  31 + background-size: cover;
  32 + background-repeat: no-repeat;
  33 + background-position: center;
  34 + position: relative;
  35 + }
26 </style> 36 </style>
27 <div style="margin-left: 30px;" class="div_search"> 37 <div style="margin-left: 30px;" class="div_search">
28 <a id="addSaleCategory" class="easyui-linkbutton btn-success">添加一级销售类目</a> 38 <a id="addSaleCategory" class="easyui-linkbutton btn-success">添加一级销售类目</a>
@@ -164,7 +174,7 @@ @@ -164,7 +174,7 @@
164 onClick: function () { 174 onClick: function () {
165 //添加子类,当前类的id作为pid 175 //添加子类,当前类的id作为pid
166 var id = $(this).attr("dataId"); 176 var id = $(this).attr("dataId");
167 - alert("开发中"+id); 177 + editRowThird(0,id);
168 } 178 }
169 }); 179 });
170 180
@@ -201,10 +211,10 @@ @@ -201,10 +211,10 @@
201 saleCategoryId = id; 211 saleCategoryId = id;
202 saleCategoryParentId = pid; 212 saleCategoryParentId = pid;
203 var div = $("<div>").appendTo($(document.body)); 213 var div = $("<div>").appendTo($(document.body));
204 - var title = "编辑品类"; 214 + var title = "编辑销售类目";
205 var message = "确认修改销售类目信息吗?"; 215 var message = "确认修改销售类目信息吗?";
206 if (id == 0) { 216 if (id == 0) {
207 - title = "添加品类"; 217 + title = "添加销售类目";
208 message = "确认添加销售类目信息吗?"; 218 message = "确认添加销售类目信息吗?";
209 } 219 }
210 $(div).myDialog({ 220 $(div).myDialog({
@@ -266,6 +276,76 @@ @@ -266,6 +276,76 @@
266 }); 276 });
267 } 277 }
268 278
  279 +
  280 + function editRowThird(id,pid) {
  281 + saleCategoryId = id;
  282 + saleCategoryParentId = pid;
  283 + var div = $("<div>").appendTo($(document.body));
  284 + var title = "编辑销售类目";
  285 + var message = "确认修改销售类目信息吗?";
  286 + if (id == 0) {
  287 + title = "添加销售类目";
  288 + message = "确认添加销售类目信息吗?";
  289 + }
  290 + $(div).myDialog({
  291 + width: "850px",
  292 + height: "500px",
  293 + title: title,
  294 + href: contextPath + "/html/saleCategory/addOrEditThirdLevel.html",
  295 + queryParams: {
  296 + saleCategoryParentId:saleCategoryParentId,
  297 + id: id
  298 + },
  299 + modal: true,
  300 + collapsible: true,
  301 + cache: false,
  302 + buttons: [{
  303 + id: "saveBtn",
  304 + text: "保存",
  305 + handler: function () {
  306 + $.messager.confirm("确认", message, function (flag) {
  307 + if(flag) {
  308 + $("#categoryEditForm").form("submit", {
  309 + url: contextPath + "/saleCategory/saveOrUpdateSaleCategory",
  310 + onSubmit: function () {
  311 + if (!$("#categoryEditForm").form("validate")) {
  312 + return false;
  313 + }
  314 + $.messager.progress({
  315 + title: "正在执行",
  316 + msg: "正在执行,请稍后..."
  317 + });
  318 + return true;
  319 + },
  320 + success: function (data) {
  321 + $.messager.progress("close");
  322 + data = JSON.parse(data);
  323 + if (data.code == 200) {
  324 + $(div).dialog("close");
  325 + $("#saleCategoryTable").treegrid("reload");
  326 + $.messager.show({
  327 + title: "提示",
  328 + msg: title + "成功!",
  329 + height: 120
  330 + });
  331 + } else {
  332 + $.messager.alert("失败", data.message, "error");
  333 + }
  334 + }
  335 + });
  336 + }
  337 + });
  338 + }
  339 + }, {
  340 + text: "关闭",
  341 + iconCls: "icon-cancel",
  342 + handler: function () {
  343 + $(div).dialog("close");
  344 + }
  345 + }]
  346 + });
  347 + }
  348 +
269 function updateBrandStatus(id, status, parentId) { 349 function updateBrandStatus(id, status, parentId) {
270 var message = ""; 350 var message = "";
271 var msg = ""; 351 var msg = "";