...
|
...
|
@@ -2,6 +2,15 @@ |
|
|
var $ = require('jquery'),
|
|
|
common = require('../../../common/common');
|
|
|
|
|
|
//存储批量选中的sourceId
|
|
|
window.batchChooseSourceIds = [];
|
|
|
//存储批量选中的直通车名称
|
|
|
window.batchChooseSourceNames = [];
|
|
|
//存储批量取消选中的sourceId
|
|
|
window.batchUnChooseSourceIds = [];
|
|
|
//存储批量取消选中的直通车名称
|
|
|
window.batchUnChooseSourceNames = [];
|
|
|
|
|
|
var EMUN = {
|
|
|
status: {
|
|
|
0: '关闭',
|
...
|
...
|
@@ -9,6 +18,16 @@ var EMUN = { |
|
|
}
|
|
|
}
|
|
|
|
|
|
//筛选
|
|
|
$(document).on('click', '#filter-btn', function () {
|
|
|
g.reload(1);
|
|
|
});
|
|
|
//全部
|
|
|
$(document).on('click', '#all-btn', function () {
|
|
|
location.href = '';
|
|
|
});
|
|
|
|
|
|
var pageChooseSourceIds = [];
|
|
|
var g = new common.grid({
|
|
|
el: "#basicTable",
|
|
|
parms: function() {
|
...
|
...
|
@@ -20,8 +39,37 @@ var g = new common.grid({ |
|
|
},
|
|
|
columns: [
|
|
|
{
|
|
|
display: '',
|
|
|
type: 'checkbox',
|
|
|
render: function (item) {
|
|
|
var htmlContent = "";
|
|
|
if(item.state == 1){
|
|
|
return htmlContent;
|
|
|
}
|
|
|
if(batchChooseSourceIds.length == 0 ){
|
|
|
htmlContent = "<input type='checkbox' class='wqt_checkbox' data-index='"+item.__index+"'>";
|
|
|
}else{
|
|
|
$.each(batchChooseSourceIds,function(n,value) {
|
|
|
if(item.sourceId == value){
|
|
|
htmlContent = "<input type='checkbox' checked='checked' class='wqt_checkbox' data-index='"+item.__index+"'>";
|
|
|
return false
|
|
|
}else{
|
|
|
htmlContent = "<input type='checkbox' class='wqt_checkbox' data-index='"+item.__index+"'>";
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
return htmlContent;
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
display: '资源位直通车id',
|
|
|
name: 'sourceId'
|
|
|
name: 'sourceId',
|
|
|
render: function (item) {
|
|
|
if(item.state != 1) {
|
|
|
pageChooseSourceIds.push(item.sourceId);
|
|
|
}
|
|
|
return item.sourceId;
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
display: '资源位直通车名称',
|
...
|
...
|
@@ -46,21 +94,34 @@ var g = new common.grid({ |
|
|
}
|
|
|
|
|
|
}
|
|
|
}]
|
|
|
}],
|
|
|
selectedCallback:function(item){
|
|
|
if($.inArray(item.sourceId, batchChooseSourceIds) === -1 ){
|
|
|
batchChooseSourceIds.push(item.sourceId);
|
|
|
batchChooseSourceNames.push(item.sourceName);
|
|
|
}
|
|
|
},
|
|
|
unselectedCallback:function(item){
|
|
|
var _index = $.inArray(item.sourceId, batchChooseSourceIds);
|
|
|
if( _index !== -1 ){
|
|
|
batchChooseSourceIds.splice(_index,1);
|
|
|
batchChooseSourceNames.splice(_index, 1);
|
|
|
}
|
|
|
},
|
|
|
complete:function(){
|
|
|
$.each(pageChooseSourceIds, function (i, pageItem) {
|
|
|
if($.inArray(pageItem, batchChooseSourceIds) == -1 ) {
|
|
|
$(".wqt_all").prop("checked", false);
|
|
|
return false;
|
|
|
}
|
|
|
$(".wqt_all").prop("checked", true);
|
|
|
});
|
|
|
pageChooseSourceIds = [];
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
g.init('/categorySource/queryCategorySourceList');
|
|
|
|
|
|
//筛选
|
|
|
$(document).on('click', '#filter-btn', function () {
|
|
|
g.reload(1);
|
|
|
});
|
|
|
//全部
|
|
|
$(document).on('click', '#all-btn', function () {
|
|
|
location.href = '';
|
|
|
});
|
|
|
|
|
|
var pageUnChooseSourceIds = [];
|
|
|
var sc = new common.grid({
|
|
|
el: "#basicTable",
|
|
|
parms: function() {
|
...
|
...
|
@@ -71,8 +132,31 @@ var sc = new common.grid({ |
|
|
},
|
|
|
columns: [
|
|
|
{
|
|
|
display: '',
|
|
|
type: 'checkbox',
|
|
|
render: function (item) {
|
|
|
var htmlContent = "";
|
|
|
if(batchUnChooseSourceIds.length === 0 ){
|
|
|
htmlContent = "<input type='checkbox' class='wqt_checkbox' data-index='"+item.__index+"'>";
|
|
|
}else{
|
|
|
$.each(batchUnChooseSourceIds,function(n,value) {
|
|
|
if(item.sourceId == value){
|
|
|
htmlContent = "<input type='checkbox' checked='checked' class='wqt_checkbox' data-index='"+item.__index+"'>";
|
|
|
return false
|
|
|
}else{
|
|
|
htmlContent = "<input type='checkbox' class='wqt_checkbox' data-index='"+item.__index+"'>";
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
return htmlContent;
|
|
|
}
|
|
|
}, {
|
|
|
display: '资源位直通车id',
|
|
|
name: 'sourceId'
|
|
|
name: 'sourceId',
|
|
|
render: function (item) {
|
|
|
pageUnChooseSourceIds.push(item.sourceId);
|
|
|
return item.sourceId;
|
|
|
}
|
|
|
},
|
|
|
{
|
|
|
display: '资源位直通车名称',
|
...
|
...
|
@@ -92,24 +176,113 @@ var sc = new common.grid({ |
|
|
render: function(item) {
|
|
|
return '<a class="btn btn-xs btn-warning close-btn" data-title="' + item.sourceName + '" _id="' + item.sourceId + '" href="javascript:;">取消选中</a>';
|
|
|
}
|
|
|
}]
|
|
|
}],
|
|
|
selectedCallback:function(item){
|
|
|
if($.inArray(item.sourceId, batchUnChooseSourceIds) === -1 ){
|
|
|
batchUnChooseSourceIds.push(item.sourceId);
|
|
|
batchUnChooseSourceNames.push(item.sourceName);
|
|
|
}
|
|
|
},
|
|
|
unselectedCallback:function(item){
|
|
|
var _index = $.inArray(item.sourceId, batchUnChooseSourceIds);
|
|
|
if(_index !== -1 ){
|
|
|
batchUnChooseSourceIds.splice(_index,1);
|
|
|
batchUnChooseSourceNames.splice(_index, 1);
|
|
|
}
|
|
|
},
|
|
|
complete:function(){
|
|
|
$.each(pageUnChooseSourceIds, function (i, pageItem) {
|
|
|
if($.inArray(pageItem, batchUnChooseSourceIds) == -1 ) {
|
|
|
$(".wqt_all").prop("checked", false);
|
|
|
return false;
|
|
|
}
|
|
|
$(".wqt_all").prop("checked", true);
|
|
|
});
|
|
|
pageUnChooseSourceIds = [];
|
|
|
}
|
|
|
});
|
|
|
|
|
|
|
|
|
$('input[name="state"]').on('change', function() {
|
|
|
$(this).parent().addClass('current').siblings().removeClass('current');
|
|
|
var state = $('.state-select').find('.current').find('input').val();
|
|
|
if(state == 0){
|
|
|
batchChooseSourceIds = [];
|
|
|
batchChooseSourceNames = [];
|
|
|
$("#productSearchLabelSearch").show();
|
|
|
g.init('/categorySource/queryCategorySourceList');
|
|
|
$("#batchChoose-btn").show();
|
|
|
$("#batchUnChoose-btn").hide();
|
|
|
g.init('/categorySource/queryCategorySourceList');
|
|
|
}else if(state == 1){
|
|
|
$('#sourceName').setValue='';
|
|
|
batchUnChooseSourceIds = [];
|
|
|
batchUnChooseSourceNames = [];
|
|
|
$("#productSearchLabelSearch").hide();
|
|
|
$("#batchChoose-btn").hide();
|
|
|
$("#batchUnChoose-btn").show();
|
|
|
sc.init('/categorySource/queryCategorySourceList');
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
$(document).on('click', '.batchChoose-btn', function(){
|
|
|
if(batchChooseSourceIds.length === 0){
|
|
|
common.util.__tip("未勾选任何直通车!", 'warning');
|
|
|
return false;
|
|
|
}
|
|
|
var content = "";
|
|
|
$.each(batchChooseSourceNames, function(i, item) {
|
|
|
var chooseName ="【" + item + "】";
|
|
|
content += "</br>";
|
|
|
content += chooseName;
|
|
|
});
|
|
|
common.dialog.confirm("温馨提示", "确定  <b><font color='#449d44'>选中 </font></b>以下直通车吗?<b>"+content+"</b>", function() {
|
|
|
var sourceIdList = batchChooseSourceIds;
|
|
|
common.util.__ajax({
|
|
|
url: '/categorySource/batchInsertCategorySourceLink',
|
|
|
data: {
|
|
|
sourceIdList: sourceIdList,
|
|
|
categoryId: getCategoryId()
|
|
|
}
|
|
|
}, function(res){
|
|
|
if (res.code == 200) {
|
|
|
g.reload();
|
|
|
}
|
|
|
})
|
|
|
});
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
//批量取消选中
|
|
|
$(document).on('click', '.batchUnChoose-btn', function() {
|
|
|
if(batchUnChooseSourceIds.length === 0) {
|
|
|
common.util.__tip("未勾选任何直通车!", 'warning');
|
|
|
return false;
|
|
|
}
|
|
|
var content = "";
|
|
|
$.each(batchUnChooseSourceNames, function(i, item) {
|
|
|
var chooseName ="【" + item + "】";
|
|
|
content += "</br>";
|
|
|
content += chooseName;
|
|
|
});
|
|
|
common.dialog.confirm("温馨提示", "确定  <b><font color='#449d44'>取消选中 </font></b>以下直通车吗?<b>"+content+"</b>", function() {
|
|
|
var sourceIdList = batchUnChooseSourceIds;
|
|
|
common.util.__ajax({
|
|
|
url: '/categorySource/batchDeleteCategorySourceLink',
|
|
|
data: {
|
|
|
sourceIdList: sourceIdList,
|
|
|
categoryId: getCategoryId()
|
|
|
}
|
|
|
}, function(res){
|
|
|
if (res.code == 200) {
|
|
|
g.reload();
|
|
|
}
|
|
|
})
|
|
|
});
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
$(document).on('click', '.open-btn', function() {
|
|
|
var id = $(this).attr('_id');
|
|
|
common.dialog.confirm("温馨提示", "确定  <b><font color='#449d44'>选中 </font>【" + $(this).data('title') + "】</b> 吗?", function() {
|
...
|
...
|
@@ -121,6 +294,12 @@ $(document).on('click', '.open-btn', function() { |
|
|
}
|
|
|
}, function(res){
|
|
|
if (res.code == 200) {
|
|
|
var chooseId = parseInt(id);
|
|
|
var _index = $.inArray(chooseId, batchChooseSourceIds);
|
|
|
if(_index !== -1 ){
|
|
|
batchChooseSourceIds.splice(_index,1);
|
|
|
batchChooseSourceNames.splice(_index, 1);
|
|
|
}
|
|
|
g.reload();
|
|
|
}
|
|
|
})
|
...
|
...
|
@@ -139,6 +318,12 @@ $(document).on('click', '.close-btn', function() { |
|
|
}
|
|
|
}, function(res){
|
|
|
if (res.code == 200) {
|
|
|
var unChooseId = parseInt(id);
|
|
|
var _index = $.inArray(unChooseId, batchUnChooseSourceIds);
|
|
|
if(_index !== -1 ){
|
|
|
batchUnChooseSourceIds.splice(_index,1);
|
|
|
batchUnChooseSourceNames.splice(_index, 1);
|
|
|
}
|
|
|
sc.reload();
|
|
|
}
|
|
|
})
|
...
|
...
|
|