|
|
/**
|
|
|
* Created by yoho on 2016/6/28.
|
|
|
*/
|
|
|
'use strict';
|
|
|
var $ = require('jquery'),
|
|
|
common = require('../../../common/common');
|
|
|
|
|
|
var renderHd = false;//加载表格头部
|
|
|
var tabTree = new common.tabTree("#sort");
|
|
|
tabTree.init();
|
|
|
//分类Id
|
|
|
new common.dropDown({
|
|
|
el: "#SortId", ajax: "fuzzySearchProductSortIds"
|
|
|
});
|
|
|
//分类级别
|
|
|
new common.dropDown({
|
|
|
el: "#SortLevel", ajax: "searchAllSortLevel"
|
|
|
});
|
|
|
var Bll = {
|
|
|
dataList: [],
|
|
|
searchList: {},
|
|
|
selectSort: function () {
|
|
|
var select = tabTree.getAddress();
|
|
|
if (select[0].id) {
|
|
|
Bll.searchList.sortNameId = select[select.length - 1].id;
|
|
|
}
|
|
|
},
|
|
|
getDataList: function () {
|
|
|
Bll.selectSort();
|
|
|
common.util.__ajax({
|
|
|
url: "/product/queryProductSortRefundAllReferdSortInfo",
|
|
|
async: false,
|
|
|
data: Bll.searchList
|
|
|
}, function (res) {
|
|
|
Bll.dataList = res.data;
|
|
|
}, true);
|
|
|
},
|
|
|
reload: function () {
|
|
|
renderHd = false;
|
|
|
Bll.getDataList();
|
|
|
g.init(Bll.dataList);
|
|
|
}
|
|
|
};
|
|
|
/**
|
|
|
* 获取数据
|
|
|
*/
|
|
|
|
|
|
|
|
|
var g = new common.grid({
|
|
|
el: "#basicTable",
|
|
|
columns: [
|
|
|
{
|
|
|
display: '',
|
|
|
name: 'foler',
|
|
|
render: function (item) {
|
|
|
var html = "", top = true, isRefundExchange = 1;
|
|
|
if (!renderHd) {
|
|
|
html += $('#tableHdTemp').html();
|
|
|
init(item);
|
|
|
renderHd = true;
|
|
|
} else {
|
|
|
init(item)
|
|
|
}
|
|
|
return html;
|
|
|
function init(item) {
|
|
|
if (top) {
|
|
|
html += "<div id='category_id_" + item.id + "' class='level-wrap clearfix'>";
|
|
|
if (item.isRefundExchange == 0) {
|
|
|
isRefundExchange = 0;
|
|
|
}
|
|
|
top = false;
|
|
|
} else {
|
|
|
html += "<div id='category_id_" + item.id + "' class='level-wrap clearfix level_" + item.sortLevel + "' style='display: none'>";
|
|
|
if (item.isRefundExchange == 0) {
|
|
|
isRefundExchange = 0;
|
|
|
}
|
|
|
}
|
|
|
html += common.util.__template2($('#tableTemp2').html(), item);
|
|
|
if (item.subList) {
|
|
|
for (var i = 0; i < item.subList.length; i++) {
|
|
|
if (isRefundExchange == 0) {
|
|
|
item.subList[i].isok = true;
|
|
|
}
|
|
|
init(item.subList[i]);
|
|
|
}
|
|
|
}
|
|
|
html += "</div>";
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
});
|
|
|
Bll.getDataList();
|
|
|
g.init(Bll.dataList);
|
|
|
|
|
|
//打开层级类目
|
|
|
$(document).on('click', '.folder', function () {
|
|
|
var $wrap = $(this).parent();
|
|
|
if (!$(this).hasClass('open')) {
|
|
|
if ($wrap.find('> .level-wrap').size() > 0) {
|
|
|
var position = $(this).css("background-position");
|
|
|
var a = position.substring(0, position.indexOf("px"));
|
|
|
$wrap.find('> .level-wrap').show().find(".folder").css("background-position", (parseInt(a) + 36) + "px");
|
|
|
$(this).addClass('open');
|
|
|
}
|
|
|
} else {
|
|
|
$(this).removeClass('open');
|
|
|
if ($wrap.find('.level-wrap').size() > 0) {
|
|
|
$wrap.find('.level-wrap').hide().find(".folder").removeClass('open').css("background-position", "12px center");
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//切换状态重载列表
|
|
|
$('input[name="state"]').on('change', function () {
|
|
|
$(this).parent().addClass('current').siblings().removeClass('current');
|
|
|
g.reload();
|
|
|
});
|
|
|
|
|
|
$(document).on('change', '#categoryName', function () {
|
|
|
$(this).removeClass("error")
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 监控筛选项
|
|
|
*/
|
|
|
$(document).on('change', '#SortId', function () {
|
|
|
if ($(this).val() == -1) {
|
|
|
Bll.searchList.sortId = ""
|
|
|
} else {
|
|
|
Bll.searchList.sortId = $(this).val() ? $(this).val() : "";
|
|
|
}
|
|
|
|
|
|
});
|
|
|
$(document).on('change', '#SortLevel', function () {
|
|
|
if ($(this).val() == -1) {
|
|
|
Bll.searchList.sortLevel = ""
|
|
|
} else {
|
|
|
Bll.searchList.sortLevel = $(this).val() ? $(this).val() : "";
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/**
|
|
|
* 筛选按钮
|
|
|
*/
|
|
|
$(document).on('click', "#filter-btn", function () {
|
|
|
Bll.reload();
|
|
|
});
|
|
|
//导出
|
|
|
$(document).on('click', '#export-btn', function () {
|
|
|
Bll.selectSort();
|
|
|
var queryConf = JSON.stringify(Bll.searchList);
|
|
|
window.open("/ajax/down?queryConf=" + queryConf + "&type=productSortRefundExchangeExport");
|
|
|
});
|
|
|
/**
|
|
|
* 开启
|
|
|
*/
|
|
|
$(document).on('click', ".close-category", function () {
|
|
|
var id = $(this).parent().data('id');
|
|
|
common.dialog.confirm("警告",
|
|
|
"确认开启?",
|
|
|
function () {
|
|
|
common.util.__ajax({
|
|
|
url: '/product/closeProductSortRefundExchange',
|
|
|
data: {
|
|
|
param: id
|
|
|
}
|
|
|
}, function () {
|
|
|
Bll.reload();
|
|
|
}, true);
|
|
|
});
|
|
|
});
|
|
|
/**
|
|
|
* 关闭
|
|
|
*/
|
|
|
$(document).on('click', ".open-category", function () {
|
|
|
var id = $(this).parent().data('id');
|
|
|
common.dialog.confirm("警告",
|
|
|
"确认关闭?",
|
|
|
function () {
|
|
|
common.util.__ajax({
|
|
|
url: '/product/openProductSortRefundExchange',
|
|
|
data: {
|
|
|
param: id
|
|
|
}
|
|
|
}, function () {
|
|
|
Bll.reload();
|
|
|
}, true);
|
|
|
});
|
|
|
}); |
|
|
\ No newline at end of file |
...
|
...
|
|