...
|
...
|
@@ -3,10 +3,7 @@ |
|
|
*/
|
|
|
'use strict';
|
|
|
var $ = require('jquery'),
|
|
|
dropDown=require('../common/dropDown');
|
|
|
var grid=require('../common/grid');
|
|
|
require('../util/jquery.gritter');
|
|
|
var select=require('../common/dropDown');
|
|
|
common=require('../common/common');
|
|
|
|
|
|
exports.menu=function(callback){
|
|
|
|
...
|
...
|
@@ -78,19 +75,8 @@ exports.menu=function(callback){ |
|
|
.removeClass('glyphicon-minus').addClass('glyphicon-plus');
|
|
|
}
|
|
|
}
|
|
|
window.menuid=thisVal;
|
|
|
//获取文案
|
|
|
// var c=[];
|
|
|
// function aa(a){
|
|
|
// var b=a.prev();
|
|
|
// if(b.length>0&&b.find(".glyphicon-minus")){
|
|
|
|
|
|
// aa(b);
|
|
|
// }
|
|
|
// c.push($.trim(a.text()));
|
|
|
// }
|
|
|
// aa($(".attr-item-active[data-val="+thisVal+"]"));
|
|
|
window.menuname=$.trim($(".attr-item-active[data-val="+thisVal+"]").text());//c.join('/');
|
|
|
window.sortid=thisVal;
|
|
|
window.sortname=$.trim($(".attr-item-active[data-val="+thisVal+"]").text());//c.join('/');
|
|
|
callback&&callback();
|
|
|
});
|
|
|
|
...
|
...
|
@@ -99,16 +85,13 @@ exports.menu=function(callback){ |
|
|
exports.init = function() {
|
|
|
|
|
|
|
|
|
new select({
|
|
|
el:"#sizeId",
|
|
|
ajax:"sortsize"
|
|
|
});
|
|
|
|
|
|
|
|
|
var g=new grid({
|
|
|
var g=new common.grid({
|
|
|
el:"#basicTable",
|
|
|
parms:function(){
|
|
|
return {
|
|
|
sortId:window.menuid?window.menuid:"",
|
|
|
sortId:window.sortid?window.sortid:"",
|
|
|
};
|
|
|
},
|
|
|
columns:[
|
...
|
...
|
@@ -119,80 +102,57 @@ exports.init = function() { |
|
|
{display:"尺码名",name:"sizeName"},
|
|
|
{display:"排序",name:"orderBy"},
|
|
|
{display:"操作",name:'id',render:function(item){
|
|
|
return '<a data-sortid="'+item.sortId+'" href="javascript:void(0)" class="btn btn-success btn-xs delbtn">删除</a>';
|
|
|
return '<a data-index="'+ item.__index+'" href="javascript:void(0)" class="btn btn-success btn-xs delbtn">删除</a>';
|
|
|
}}
|
|
|
]
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
exports.menu(function(){
|
|
|
g.init('/erpproduct/sortsize/ajax/index');
|
|
|
$("#sortName").val(window.menuname);
|
|
|
});
|
|
|
|
|
|
function __ajax(options,callback){
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: options.url,
|
|
|
dataType: 'json',
|
|
|
data:options.data||{},
|
|
|
success: function(res) {
|
|
|
res=res.data;
|
|
|
if (res.code === 200) {
|
|
|
$.gritter.add({
|
|
|
title: res.message,
|
|
|
class_name: 'growl-success',
|
|
|
sticky: false,
|
|
|
time:1000,
|
|
|
after_open:setTimeout(function() {
|
|
|
callback&&callback();
|
|
|
},1000)
|
|
|
});
|
|
|
} else {
|
|
|
$.gritter.add({
|
|
|
title: res.message,
|
|
|
class_name: 'growl-danger',
|
|
|
sticky: false,
|
|
|
time:1000
|
|
|
});
|
|
|
}
|
|
|
var _model=JSON.parse($("#model").val());
|
|
|
|
|
|
$(document).on("click","#btn-add",function(){
|
|
|
var _title=$(this).text();
|
|
|
common.dialog.confirm(_title,common.util.__template($("#template").html(),{name:_model.name,sortname:window.sortname}),function(){
|
|
|
var data={sortId:window.sortid,sizeId:$("#sizeId").val(),orderBy:$("#orderBy").val()};
|
|
|
if(!data.sortId){
|
|
|
common.util.__tip("尺码不可为空","warning");
|
|
|
return;
|
|
|
}
|
|
|
if(!~data.sizeId){
|
|
|
common.util.__tip("尺码属性不可为空","warning");
|
|
|
return;
|
|
|
}
|
|
|
if(!data.orderBy){
|
|
|
common.util.__tip("排序不可为空","warning");
|
|
|
return;
|
|
|
}
|
|
|
common.util.__ajax({
|
|
|
url:'/erpproduct/sortsize/ajax/add',
|
|
|
data:data
|
|
|
},function(){
|
|
|
g.reload();
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
$(document).on("click",".delbtn",function(){
|
|
|
var _sortid=$(this).data("sortid"),
|
|
|
_sizeid=$(this).data("sizeid");
|
|
|
__ajax({
|
|
|
url:'/erpproduct/sortsize/ajax/delete',
|
|
|
data:{sortId:_sortid,sizeId:_sizeid}
|
|
|
},function(){
|
|
|
g.reload();
|
|
|
$("#addAttr").modal('hide');
|
|
|
new common.dropDown({
|
|
|
el:"#sizeId",
|
|
|
ajax:"sortsize"
|
|
|
});
|
|
|
});
|
|
|
|
|
|
$(document).on("click",".add-attr-btn",function(){
|
|
|
var data={sortId:window.menuid,sizeId:$("#sizeId").val(),orderBy:$("#orderBy").val()};
|
|
|
if(!data.sortId){
|
|
|
alert("尺码不可为空");
|
|
|
return;
|
|
|
}
|
|
|
if(!~data.sizeId){
|
|
|
alert("尺码属性不可为空");
|
|
|
return;
|
|
|
}
|
|
|
if(!data.orderBy){
|
|
|
alert("排序不可为空");
|
|
|
return;
|
|
|
}
|
|
|
__ajax({
|
|
|
url:'/erpproduct/sortsize/ajax/add',
|
|
|
data:data
|
|
|
},function(){
|
|
|
g.reload();
|
|
|
$("#addAttr").modal('hide');
|
|
|
$(document).on("click",".delbtn",function(){
|
|
|
var item=g.rows[$(this).data("index")];
|
|
|
common.dialog.confirm("温馨提示","你确定要删除吗?",function(){
|
|
|
common.util.__ajax({
|
|
|
url:'/erpproduct/sortsize/ajax/delete',
|
|
|
data:{sortId:item.sortId,sizeId:item.sizeId}
|
|
|
},function(){
|
|
|
g.reload();
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
} |
|
|
\ No newline at end of file |
...
|
...
|
|