Authored by weiqingting

搭配提交

@@ -56,7 +56,9 @@ var g=new common.grid({ @@ -56,7 +56,9 @@ var g=new common.grid({
56 }, 56 },
57 columns:[ 57 columns:[
58 {display:"ID",name:"id"}, 58 {display:"ID",name:"id"},
59 - {display:"图片",name:"imageUrl"}, 59 + {display:"图片",name:"imageUrl",render:function(item){
  60 + return "<img src="+item.imageUrl+" width=120 height=80 />";
  61 + }},
60 {display:"介绍",name:"content"}, 62 {display:"介绍",name:"content"},
61 {display:"排序",name:"orderBy"}, 63 {display:"排序",name:"orderBy"},
62 {display:"发表时间",render:function(item){ 64 {display:"发表时间",render:function(item){
@@ -73,9 +75,87 @@ var g=new common.grid({ @@ -73,9 +75,87 @@ var g=new common.grid({
73 75
74 g.init('/netSale/selectCollocationListBySkn'); 76 g.init('/netSale/selectCollocationListBySkn');
75 77
  78 +var Bll={
  79 + posData:[],
  80 + toast:function(title,item,url){
  81 + var e=new common.edit("#dapei-form",{
  82 + bucket:"goodsimg"
  83 + });
  84 +
  85 + var d=new common.dialog({
  86 + title:title,
  87 + width:1200,
  88 + content:common.util.__template2($("#wqt-template1").html(),item),
  89 + button:[
  90 + {
  91 + value:"提交",
  92 + callback:function(){
  93 + e.submit(url,function(option){
  94 + option.data.id=item.id;
  95 + option.data.productSkn=productSkn;
  96 + option.data.infoStr=JSON.stringify(Bll.posData);
  97 + console.log(option.data);
  98 + option.success=function(res){
  99 + res = res.data;
  100 + if(res.code == +"200") {
  101 + e.$tip("提交成功", function() {
  102 + d.close();
  103 + g.reload();
  104 + }, 'growl-success');
  105 + }else{
  106 + e.$tip(res.message);
  107 + }
  108 + }
  109 + });
  110 + return false;
  111 + },
  112 + css: "btn-primary"
  113 + },
  114 + {
  115 + value:"取消"
  116 + }
  117 + ]
  118 + });
  119 +
  120 + e.init();
  121 + e.on("callback", function(obj) {
  122 + if (obj.key == "file_onComplete_imageUrl") {
  123 + // $("#editimg").attr("src",obj.data);
  124 + $(".poseditimg").html("<img src='"+obj.data+"'/>");
  125 + }
  126 + });
  127 + }
  128 +}
  129 +/*编辑*/
  130 +
  131 +$(document).on("dblclick",".poseditimg img",function(e){
  132 + var pos={
  133 + top:e.pageY-$(this).offset().top,
  134 + left:e.pageX-$(this).offset().left
  135 + }
  136 + Bll.posData.push(pos);
  137 + var _pos=$(common.util.__template2($("#kapian").html(),{__index:Bll.posData.length-1}));
  138 + _pos.css({
  139 + top:pos.top+"px",
  140 + left:pos.left+"px"
  141 + });
  142 +
  143 + $(".poseditimg").append(_pos);
  144 +});
  145 +$(document).on("click",".poseditimg .close",function(e){
  146 + var index=$(this).data("index");
  147 + $(this).parent(".pos").remove();
  148 + Bll.posData.splice(index,1);
  149 +});
  150 +$(document).on("change",".poseditimg .pos-text",function(){
  151 + var item=Bll.posData[$(this).data("index")];
  152 + item.id=$(this).val();
  153 +});
  154 +
  155 +
76 //添加 156 //添加
77 $(document).on("click","#dapeiadd",function(){ 157 $(document).on("click","#dapeiadd",function(){
78 - 158 + Bll.toast("添加搭配",{},"/netSale/insertCollocation");
79 }); 159 });
80 //保存 160 //保存
81 $(document).on("click","#dapeisave",function(){ 161 $(document).on("click","#dapeisave",function(){
@@ -83,12 +163,28 @@ $(document).on("click","#dapeisave",function(){ @@ -83,12 +163,28 @@ $(document).on("click","#dapeisave",function(){
83 }); 163 });
84 //删除 164 //删除
85 $(document).on("click","#dapeiTable .delete",function(){ 165 $(document).on("click","#dapeiTable .delete",function(){
86 - var __index=$(this).data("index");  
87 - g.rows.splice(__index,1);  
88 - g.reload(); 166 + var item=g.rows[$(this).data("index")];
  167 + common.util.__ajax({
  168 + url:'/netSale/delCollocationById',
  169 + data:{
  170 + param:item.id
  171 + }
  172 + },function(){
  173 + g.reload();
  174 + });
89 }); 175 });
90 //修改 176 //修改
91 $(document).on("click","#dapeiTable .edit",function(){ 177 $(document).on("click","#dapeiTable .edit",function(){
92 - 178 + var item=g.rows[$(this).data("index")];
  179 + // common.util.__ajax({
  180 + // url:'/netSale/selectCollocationById',
  181 + // data:{
  182 + // param:item.id
  183 + // }
  184 + // },function(data){
  185 + // Bll.toast("添加搭配",data.data,"/netSale/updateCollocation");
  186 + // });
  187 + item.infoStr=[{"top":223,"left":380,"id":"ffffff"},{"top":454,"left":309,"id":"ggggg"}];
  188 + Bll.toast("添加搭配",item,"/netSale/updateCollocation");
93 }); 189 });
94 190
@@ -62,4 +62,23 @@ input[type=date], input[type=time], input[type=datetime-local], input[type=month @@ -62,4 +62,23 @@ input[type=date], input[type=time], input[type=datetime-local], input[type=month
62 height: 100%; 62 height: 100%;
63 line-height: 150px; 63 line-height: 150px;
64 } 64 }
  65 +}
  66 +.poseditimg{
  67 + position: relative;
  68 + width: 700px;
  69 + height: 600px;
  70 + img{
  71 + display: block;
  72 + width: 100%;
  73 + height: 100%;
  74 + }
  75 + .pos{
  76 + position: absolute;
  77 + z-index: 10;
  78 + width: 220px;
  79 + .pos-text{
  80 + border:0 none;
  81 + border-bottom:1px solid #ccc;
  82 + }
  83 + }
65 } 84 }
@@ -40,6 +40,17 @@ exports.res = [ @@ -40,6 +40,17 @@ exports.res = [
40 {name: 'param', type: 'Number'} 40 {name: 'param', type: 'Number'}
41 ] 41 ]
42 }, 42 },
  43 +{//添加单个搭配
  44 + route:'/netSale/insertCollocation',
  45 + method:'POST',
  46 + url: '/collocation/insertCollocation',
  47 + params: [
  48 + {name: 'productSkn', type: 'Number'},
  49 + {name: 'imageUrl', type: 'String'},
  50 + {name: 'content', type: 'String'},
  51 + {name: 'infoStr', type: 'String'}
  52 + ]
  53 +},
43 {//更新单个搭配 54 {//更新单个搭配
44 route:'/netSale/updateCollocation', 55 route:'/netSale/updateCollocation',
45 method:'POST', 56 method:'POST',
@@ -4,18 +4,64 @@ @@ -4,18 +4,64 @@
4 <div class="panel-btns" style="display: none;"> 4 <div class="panel-btns" style="display: none;">
5 <a href="" class="panel-minimize tooltips" data-toggle="tooltip" title=""><i class="fa fa-minus"></i></a> 5 <a href="" class="panel-minimize tooltips" data-toggle="tooltip" title=""><i class="fa fa-minus"></i></a>
6 </div> 6 </div>
7 - <h2 class="panel-title">搭配搭配</h2> 7 + <h2 class="panel-title">搭配</h2>
8 </div> 8 </div>
9 <div class="panel-body nopadding"> 9 <div class="panel-body nopadding">
10 - <button class="btn btn-primary" id="dapeiadd">添加</button> 10 +
11 <div id="dapeiTable"></div> 11 <div id="dapeiTable"></div>
12 </div> 12 </div>
13 <div class="panel-footer"> 13 <div class="panel-footer">
  14 + <button class="btn btn-primary" id="dapeiadd">添加搭配</button>
14 <button class="btn btn-primary" id="dapeisave">保存</button> 15 <button class="btn btn-primary" id="dapeisave">保存</button>
15 </div> 16 </div>
16 </form> 17 </form>
17 </div> 18 </div>
18 19
19 <script type="text/template" id="wqt-template1"> 20 <script type="text/template" id="wqt-template1">
20 - 21 +<div class="rows">
  22 + <div class="form-group">
  23 + <div class="col-sm-8">
  24 + <div class="poseditimg">
  25 + [[if imageUrl]]
  26 + <img src="[[imageUrl]]">
  27 + [[/if]]
  28 + [[each infoStr as item __index]]
  29 + <div class="pos form-control" style="left:[[item.left]]px;top:[[item.top]]px;">
  30 + <input type="text" class="pos-text" data-index='[[__index]]' value="[[item.id]]" />
  31 + <span class="close" data-index='[[__index]]'>×</span>
  32 + </div>
  33 + [[/each]]
  34 + </div>
  35 + </div>
  36 + <div class="col-sm-4">
  37 + <div class="rows" id="dapei-form">
  38 + <div class="form-group">
  39 + <label for="endTime" class="col-sm-2 control-label"><i class="red">*</i> 介绍</label>
  40 + <div class="col-sm-10">
  41 + <input type="text" id="content" class="form-control panel-input hasDatepicker" placeholder="介绍" value="[[content]]" required>
  42 + </div>
  43 + </div>
  44 + <div class="form-group">
  45 + <label for="endTime" class="col-sm-2 control-label"><i class="red">*</i> 图片</label>
  46 + <div class="col-sm-10">
  47 + <input type="file" id="imageUrl" name="imageUrl" value="[[imageUrl]]" required/>
  48 + </div>
  49 + </div>
  50 + <div class="form-group">
  51 + <label for="endTime" class="col-sm-2 control-label"><i class="red">*</i> 排序</label>
  52 + <div class="col-sm-10">
  53 + <input type="number" id="orderBy" class="form-control panel-input hasDatepicker" placeholder="排序" value="[[orderBy]]" required>
  54 + </div>
  55 + </div>
  56 + </div>
  57 + </div>
  58 + </div>
  59 +</div>
  60 +</script>
  61 +
  62 +<script type="text/template" id="kapian">
  63 + <div class="pos form-control">
  64 + <input type="text" class="pos-text" data-index='[[__index]]' value="[[id]]" />
  65 + <span class="close" data-index='[[__index]]'>×</span>
  66 + </div>
21 </script> 67 </script>