|
|
|
|
|
var $ = require('jquery'),
|
|
|
common = require('../../../common/common');
|
|
|
|
|
|
|
|
|
|
|
|
var tabTree = new common.tabTree("#sortTree");
|
|
|
tabTree.init();
|
|
|
|
|
|
new common.dropDown({
|
|
|
el: '#stortTypeId',
|
|
|
ajax: 'queryStortType',
|
|
|
hash: true,
|
|
|
params:function(){
|
|
|
return {sortId: smallSortId};
|
|
|
}
|
|
|
});
|
|
|
|
|
|
var smallSortId=tabTree.selected[2] ? tabTree.selected[2].id : "";
|
|
|
|
|
|
var g = new common.grid({
|
|
|
el: "#basicTable",
|
|
|
usepagesize:true,
|
|
|
parms: function () {
|
|
|
return {
|
|
|
sortId: tabTree.selected[2] ? tabTree.selected[2].id : "",
|
|
|
sortName: tabTree.selected[2] ? tabTree.selected[2].sortName : ""
|
|
|
|
|
|
};
|
|
|
},
|
|
|
columns: [ {
|
|
|
display: 'ID',
|
|
|
name: 'id',
|
|
|
}, {
|
|
|
display: '类别名称',
|
|
|
render: function(item) {
|
|
|
return item.standardSortName;
|
|
|
}
|
|
|
}, {
|
|
|
display: '所属分类',
|
|
|
render: function(item) {
|
|
|
var parmList = getAllSortName();
|
|
|
return appendAllSortName(parmList);
|
|
|
}
|
|
|
},{
|
|
|
display: '排序',
|
|
|
name: 'orderBy'
|
|
|
}, {
|
|
|
display: '操作',
|
|
|
render: function(items) {
|
|
|
var HtmArr = [];
|
|
|
HtmArr.push('<a data-index="'+ items.__index+ '" href="JavaScript:;" class="btn btn-info btn-xs edit-class-btn">编辑</a>');
|
|
|
HtmArr.push('<a data-index="' + items.__index + '" href="JavaScript:;" class="btn btn-danger btn-xs del-standardSort">删除</a>');
|
|
|
return HtmArr.join('');
|
|
|
}
|
|
|
}]
|
|
|
});
|
|
|
g.init("/erpproduct/standardSort/list");
|
|
|
|
|
|
//筛选
|
|
|
$("#filter-btn").click(function () {
|
|
|
g.reload(1);
|
|
|
});
|
|
|
|
|
|
//删除
|
|
|
$('tbody').on('click', '.del-standardSort', function() {
|
|
|
var item=g.rows[$(this).data("index")];
|
|
|
common.dialog.confirm("温馨提示", "你确定要删除吗?", function () {
|
|
|
common.util.__ajax({
|
|
|
url:'/erpproduct/standardSort/del',
|
|
|
data:{id:item.id}
|
|
|
},function(){
|
|
|
g.reload();
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
|
|
|
var getAllSortName = function(){
|
|
|
var sortNames = [];
|
|
|
for (var i = 0; i < 3; i++) {
|
|
|
if(tabTree.selected[i]){
|
|
|
sortNames.push(tabTree.selected[i].sortName);
|
|
|
}
|
|
|
}
|
|
|
return sortNames;
|
|
|
};
|
|
|
|
|
|
var appendAllSortName = function(allSorts){
|
|
|
if(allSorts === 'undefined' || allSorts.length === 0){
|
|
|
return '';
|
|
|
}
|
|
|
var sortName="";
|
|
|
for (var i = 0;i < allSorts.length; i++) {
|
|
|
sortName = sortName + allSorts[i]+"/";
|
|
|
}
|
|
|
return sortName.substr(0,sortName.lastIndexOf("/"));
|
|
|
}
|
|
|
|
|
|
$(document).on('click', '.edit-class-btn', function () {
|
|
|
var item = g.rows[$(this).data("index")];
|
|
|
var sortName="";
|
|
|
if(tabTree.selected[0]){
|
|
|
sortName=sortName+tabTree.selected[0].sortName+"/";
|
|
|
}
|
|
|
if(tabTree.selected[1]){
|
|
|
sortName=sortName+tabTree.selected[1].sortName+"/";
|
|
|
}
|
|
|
if(tabTree.selected[2]){
|
|
|
sortName=sortName+tabTree.selected[2].sortName;
|
|
|
}
|
|
|
var standardSort = {
|
|
|
id: item.id,
|
|
|
sortId: item.sortId,
|
|
|
standardName: item.standardSortName,
|
|
|
orderBy: item.orderBy
|
|
|
};
|
|
|
common.dialog.confirm("修改参数",
|
|
|
common.util.__template($("#template").html(),standardSort)
|
|
|
, function () {
|
|
|
common.util.__ajax({
|
|
|
url: '/erpproduct/standardSort/update',
|
|
|
data: (function () {
|
|
|
var input = $('#standardSortName').val();
|
|
|
if (input === '' || $.trim(input) === '')return "参数名称不能为空";
|
|
|
return {
|
|
|
id: item.id,
|
|
|
standardSortName: $("#standardSortName").val(),
|
|
|
orderBy: $("#orderBy").val(),
|
|
|
sortId: $("#sortId").val()
|
|
|
};
|
|
|
})()
|
|
|
}, function () {
|
|
|
g.reload();
|
|
|
});
|
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
...
|
...
|
|