...
|
...
|
@@ -2,21 +2,7 @@ |
|
|
var $ = require('jquery'),
|
|
|
common = require('../../common/common');
|
|
|
|
|
|
var ENUM = {
|
|
|
vipType: {
|
|
|
1: '正常折扣',
|
|
|
2: '统一折扣',
|
|
|
3: '无折扣',
|
|
|
4: '固定折扣',
|
|
|
5: '自定义折扣'
|
|
|
},
|
|
|
gender: {
|
|
|
1: '男',
|
|
|
2: '女',
|
|
|
3: '通用'
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/***********************变价列表***********************/
|
|
|
|
|
|
new common.dropDown({
|
|
|
el: '#shop',
|
...
|
...
|
@@ -47,6 +33,21 @@ new common.dropDown({ |
|
|
el: "#sex"
|
|
|
});
|
|
|
|
|
|
var ENUM = {
|
|
|
vipType: {
|
|
|
1: '正常折扣',
|
|
|
2: '统一折扣',
|
|
|
3: '无折扣',
|
|
|
4: '固定折扣',
|
|
|
5: '自定义折扣'
|
|
|
},
|
|
|
gender: {
|
|
|
1: '男',
|
|
|
2: '女',
|
|
|
3: '通用'
|
|
|
}
|
|
|
};
|
|
|
|
|
|
//多级菜单
|
|
|
var tabTree = new common.tabTree("#sortTree");
|
|
|
tabTree.init();
|
...
|
...
|
@@ -56,8 +57,8 @@ var g = new common.grid({ |
|
|
parms: function() {
|
|
|
var select = tabTree.getAddress();
|
|
|
return {
|
|
|
shop_id: common.util.__input("shopId"),
|
|
|
product_skn: common.util.__input("skn"),
|
|
|
shop_id: common.util.__input("shop"),
|
|
|
brand_id: common.util.__input("brand"),
|
|
|
supplier_id: common.util.__input("supplier"),
|
|
|
is_jit: common.util.__input("jit"),
|
...
|
...
|
@@ -67,391 +68,432 @@ var g = new common.grid({ |
|
|
max_sort_id: select[0] ? select[0].id : "",
|
|
|
middle_sort_id: select[1] ? select[1].id : "",
|
|
|
small_sort_id: select[2] ? select[2].id : ""
|
|
|
};
|
|
|
},
|
|
|
columns: [{
|
|
|
display: 'SKN',
|
|
|
name: 'product_skn'
|
|
|
}, {
|
|
|
display: '商品信息',
|
|
|
name: 'info',
|
|
|
render: function(item) {
|
|
|
return '<p>名称:' + item.product_name + '</p><p>品牌:' + item.brand_name + '</p><p>类目:' + item.middle_sort_name + '/' + item.small_sort_name + '</p>';
|
|
|
}
|
|
|
}, {
|
|
|
display: '供应商/店铺',
|
|
|
name: 'supplier_name'
|
|
|
}, {
|
|
|
display: '性别',
|
|
|
name: 'gender',
|
|
|
render: function(item) {
|
|
|
},
|
|
|
columns: [
|
|
|
{display: 'SKN', name: 'product_skn'},
|
|
|
{display: '商品信息', render: function(item) {
|
|
|
var html = '<p>名称:' + item.product_name + '</p><p>品牌:' + item.brand_name + '</p>' +
|
|
|
'<div>类目:'+ item.middle_sort_name;
|
|
|
if(item.middle_sort_name) {html += ' > ' + item.middle_sort_name;}
|
|
|
if(item.small_sort_name) {html += ' > ' + item.small_sort_name;}
|
|
|
return html + "</div>";
|
|
|
}},
|
|
|
{display: '供应商/店铺', render: function(item) {
|
|
|
var html = '';
|
|
|
if (item.supplier_name) {
|
|
|
html += item.supplier_name;
|
|
|
if (item.shop_name) {html += '/';}
|
|
|
}
|
|
|
if (item.shop_name) {html += item.shop_name;}
|
|
|
return html;
|
|
|
}},
|
|
|
{display: '性别', render: function(item) {
|
|
|
return ENUM.gender[item.gender];
|
|
|
}
|
|
|
}, {
|
|
|
display: '吊牌价',
|
|
|
name: 'retail_price'
|
|
|
}, {
|
|
|
display: '销售价',
|
|
|
name: 'sales_price'
|
|
|
}, {
|
|
|
display: 'VIP折扣类型',
|
|
|
name: 'vip_discount_type',
|
|
|
render: function(item) {
|
|
|
}},
|
|
|
{display: '吊牌价', name: 'retail_price'},
|
|
|
{display: '销售价', name: 'sales_price'},
|
|
|
{display: 'VIP折扣类型', render: function(item) {
|
|
|
return ENUM.vipType[item.vip_discount_type];
|
|
|
}
|
|
|
}, {
|
|
|
display: 'VIP价',
|
|
|
name: 'vip_price'
|
|
|
}, {
|
|
|
display: '白金',
|
|
|
name: 'vip3_price'
|
|
|
}, {
|
|
|
display: '金卡',
|
|
|
name: 'vip2_price'
|
|
|
}, {
|
|
|
display: '银卡',
|
|
|
name: 'vip1_price'
|
|
|
}, {
|
|
|
display: '操作信息',
|
|
|
name: 'operateInfo',
|
|
|
render: function(item) {
|
|
|
}},
|
|
|
{display: 'VIP价', name: 'vip_price'},
|
|
|
{display: '白金', name: 'vip3_price'},
|
|
|
{display: '金卡', name: 'vip2_price'},
|
|
|
{display: '银卡', name: 'vip1_price'},
|
|
|
{display: '生效时间', name: 'effectiveTime'},
|
|
|
{display: '操作信息', render: function(item) {
|
|
|
var html = '';
|
|
|
if (item.founder_name) {
|
|
|
html += '<p>' + item.founder_name + '</p>';
|
|
|
}
|
|
|
|
|
|
if (item.updateTime) {
|
|
|
html += '<p>' + item.updateTime + '</p>';
|
|
|
}
|
|
|
if (item.founder_name) {html += '<p>' + item.founder_name + '</p>';}
|
|
|
if (item.updateTime) {html += '<div style="color: #999;font-size: 12px">' + item.updateTime + '</div>';}
|
|
|
return html;
|
|
|
}},
|
|
|
{display: '操作', render: function(item) {
|
|
|
return '<a href="javascript:;" class="btn btn-info btn-xs modify-btn" data-skn="' + item.product_skn + '">修改</a><br>' +
|
|
|
'<a href="javascript:;" class="btn btn-primary btn-xs history-btn" data-skn="' + item.product_skn + '" style="margin-top: 10px">变价记录</a>'
|
|
|
}
|
|
|
}, {
|
|
|
display: '操作',
|
|
|
render: function(item) {
|
|
|
return '<a href="javascript:;" class="btn btn-info btn-xs modify-btn" data-skn="' + item.product_skn + '">修改</a>'
|
|
|
}
|
|
|
}]
|
|
|
}]
|
|
|
});
|
|
|
g.init('/product/queryProductPriceList');
|
|
|
|
|
|
g.init($("#gridurl").val());
|
|
|
|
|
|
//单个变价
|
|
|
$('#basicTable').on('click', '.modify-btn', function() {
|
|
|
//单个变价修改
|
|
|
$(document).on('click', '.modify-btn', function() {
|
|
|
var skn = $(this).data('skn'),
|
|
|
that = this;
|
|
|
|
|
|
if ($(that).data('detail')) {
|
|
|
$(that).parents('tr').next('.product-detail').toggle();
|
|
|
return;
|
|
|
parentTr = $(this).parent().parent(),
|
|
|
sknTd = parentTr.find('td').eq(0);
|
|
|
|
|
|
if($(this).hasClass('open')){
|
|
|
$(this).removeClass('open');
|
|
|
$(this).text('修改');
|
|
|
sknTd.removeAttr('rowspan','2');
|
|
|
parentTr.next('.product-detail').remove();
|
|
|
parentTr.next('.extraTr').remove();
|
|
|
}else{
|
|
|
$(this).addClass('open');
|
|
|
$(this).text('收起');
|
|
|
sknTd.attr('rowspan','2');
|
|
|
parentTr.after('<tr class="product-detail"><td colspan="15">加载中...若长时间加载不出来,请重新刷新页面!</td>' +
|
|
|
'</tr><tr class="extraTr"></tr>');
|
|
|
|
|
|
common.util.__ajax({
|
|
|
url:'/product/getProductPrice',
|
|
|
data: {param: skn}
|
|
|
},function(rs){
|
|
|
var data = rs.data;
|
|
|
parentTr.next('.product-detail').html($(common.util.__template($("#template").html(), data)));
|
|
|
new common.edit(".product-detail").init();
|
|
|
|
|
|
var $wrap = parentTr.next('.product-detail'),
|
|
|
$price = $wrap.find('.sale-price'),
|
|
|
$select = $wrap.find('.discount-select'),
|
|
|
$vipPrice = $wrap.find('.vip-price'),
|
|
|
$vip3Price = $wrap.find('.vip3-price'),
|
|
|
$vip2Price = $wrap.find('.vip2-price'),
|
|
|
$vip1Price = $wrap.find('.vip1-price'),
|
|
|
$startDate = $wrap.find('.startDate'),
|
|
|
$endDate = $wrap.find('.endDate'),
|
|
|
$submitBtn = $wrap.find('.sure-modify');
|
|
|
$select.val(data.vip_discount_type);
|
|
|
|
|
|
vipPrice($wrap);
|
|
|
$select.on('change', function() {
|
|
|
vipPrice($wrap);
|
|
|
});
|
|
|
$vipPrice.on('blur', function() {
|
|
|
vipPrice($wrap);
|
|
|
});
|
|
|
$price.on('blur', function() {
|
|
|
vipPrice($wrap);
|
|
|
});
|
|
|
$submitBtn.on('click', function() {
|
|
|
common.util.__ajax({
|
|
|
url: '/product/updateProductPrice',
|
|
|
data: {
|
|
|
product_skn: skn,
|
|
|
sales_price: $price.val(),
|
|
|
vip_discount_type: $select.val(),
|
|
|
vip_price: $vipPrice.val(),
|
|
|
vip1_price: $vip1Price.val(),
|
|
|
vip2_price: $vip2Price.val(),
|
|
|
vip3_price: $vip3Price.val(),
|
|
|
cgpriceStartTime:$startDate.val(),
|
|
|
cgpriceEndTime:$endDate.val()
|
|
|
}
|
|
|
}, function(res) {
|
|
|
if (res.code == 200) {g.reload()}
|
|
|
})
|
|
|
});
|
|
|
},true);
|
|
|
}
|
|
|
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
url: '/product/getProductPrice',
|
|
|
dataType: 'json',
|
|
|
data: {
|
|
|
param: skn
|
|
|
}
|
|
|
}).then(function(res) {
|
|
|
var data = res.data;
|
|
|
|
|
|
$(that).data('detail', true).parents('tr')
|
|
|
.after($(common.util.__template($("#template").html(), data)))
|
|
|
.next('.product-detail').find('.skn-value').text(skn);
|
|
|
|
|
|
var $wrap = $(that).parents('tr').next('.product-detail'),
|
|
|
$price = $wrap.find('.sale-price'),
|
|
|
function vipPrice($wrap) {
|
|
|
var $price = $wrap.find('.sale-price'),
|
|
|
$select = $wrap.find('.discount-select'),
|
|
|
$vipPrice = $wrap.find('.vip-price'),
|
|
|
$vip3Price = $wrap.find('.vip3-price'),
|
|
|
$vip2Price = $wrap.find('.vip2-price'),
|
|
|
$vip1Price = $wrap.find('.vip1-price'),
|
|
|
$submitBtn = $wrap.find('.sure-modify');
|
|
|
|
|
|
$select.val(data.vip_discount_type);
|
|
|
|
|
|
function vipPrice() {
|
|
|
var price = $price.val(),
|
|
|
vipPrice = $vipPrice.val(),
|
|
|
selectVal = $select.val() - 1,
|
|
|
priceArr = [];
|
|
|
|
|
|
priceArr.push([price * 0.95, price * 0.9, price * 0.88]);
|
|
|
priceArr.push([price * 0.95, price * 0.95, price * 0.95]);
|
|
|
priceArr.push([price, price, price]);
|
|
|
priceArr.push([$vipPrice.val(), $vipPrice.val(), $vipPrice.val()]);
|
|
|
|
|
|
if (selectVal == 4) {
|
|
|
$vip1Price.removeAttr('disabled');
|
|
|
$vip2Price.removeAttr('disabled');
|
|
|
$vip3Price.removeAttr('disabled');
|
|
|
} else {
|
|
|
$vip1Price.attr('disabled', true).val(Number(priceArr[selectVal][0]).toFixed(2));
|
|
|
$vip2Price.attr('disabled', true).val(Number(priceArr[selectVal][1]).toFixed(2));
|
|
|
$vip3Price.attr('disabled', true).val(Number(priceArr[selectVal][2]).toFixed(2));
|
|
|
$vip1Price = $wrap.find('.vip1-price');
|
|
|
|
|
|
var price = $price.val(),
|
|
|
vipPrice = $vipPrice.val(),
|
|
|
selectVal = $select.val() - 1,
|
|
|
priceArr = [];
|
|
|
|
|
|
priceArr.push([price * 0.95, price * 0.9, price * 0.88]);
|
|
|
priceArr.push([price * 0.95, price * 0.95, price * 0.95]);
|
|
|
priceArr.push([price, price, price]);
|
|
|
priceArr.push([vipPrice, vipPrice, vipPrice]);
|
|
|
|
|
|
if (selectVal == 4) {
|
|
|
$vip1Price.removeAttr('disabled');
|
|
|
$vip2Price.removeAttr('disabled');
|
|
|
$vip3Price.removeAttr('disabled');
|
|
|
} else {
|
|
|
$vip1Price.attr('disabled', true).val(Number(priceArr[selectVal][0]).toFixed(2));
|
|
|
$vip2Price.attr('disabled', true).val(Number(priceArr[selectVal][1]).toFixed(2));
|
|
|
$vip3Price.attr('disabled', true).val(Number(priceArr[selectVal][2]).toFixed(2));
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
//变价记录
|
|
|
$(document).on('click', '.history-btn', function () {
|
|
|
var skn = $(this).data('skn');
|
|
|
var option = {
|
|
|
title:'变价记录详情',
|
|
|
content:"<div class='historyDetail'>加载变价记录...</div>",
|
|
|
width:'70%',
|
|
|
button:[{value:"关闭", css:"btn-primary"}]
|
|
|
};
|
|
|
new common.dialog(option);
|
|
|
$.ajax({
|
|
|
type: 'POST',
|
|
|
dataType: 'json',
|
|
|
url: '/product/queryProductPriceListBySkn',
|
|
|
data: {param: skn},
|
|
|
success: function (rs) {
|
|
|
var data = rs;
|
|
|
$('.historyDetail').html($(common.util.__template2($("#template2").html(), data.data)));
|
|
|
if(data.code != 200){
|
|
|
common.util.__tip(data.message);
|
|
|
}
|
|
|
},
|
|
|
error: function (rs) {
|
|
|
$('.historyDetail').html($(common.util.__template2($("#template2").html(), {})));
|
|
|
common.util.__tip(rs.data.message);
|
|
|
}
|
|
|
|
|
|
vipPrice();
|
|
|
$select.on('change', function() {
|
|
|
vipPrice();
|
|
|
});
|
|
|
|
|
|
$vipPrice.on('blur', function() {
|
|
|
vipPrice();
|
|
|
});
|
|
|
|
|
|
$price.on('blur', function() {
|
|
|
vipPrice();
|
|
|
});
|
|
|
|
|
|
$submitBtn.on('click', function() {
|
|
|
common.util.__ajax({
|
|
|
url: '/product/updateProductPrice',
|
|
|
data: {
|
|
|
product_skn: skn,
|
|
|
sales_price: $price.val(),
|
|
|
vip_discount_type: $select.val(),
|
|
|
return_coin: $wrap.find('.return-coin').val(),
|
|
|
vip_price: $vipPrice.val(),
|
|
|
vip1_price: $vip1Price.val(),
|
|
|
vip2_price: $vip2Price.val(),
|
|
|
vip3_price: $vip3Price.val()
|
|
|
}
|
|
|
}, function(res) {
|
|
|
if (res.code == 200) {
|
|
|
g.reload();
|
|
|
}
|
|
|
})
|
|
|
});
|
|
|
|
|
|
});
|
|
|
});
|
|
|
|
|
|
//筛选
|
|
|
$("#filter-btn").click(function() {
|
|
|
$(document).on('click', '#filter-btn', function () {
|
|
|
g.reload(1);
|
|
|
});
|
|
|
|
|
|
//回车筛选
|
|
|
$('#skn').on('keyup', function(event) {
|
|
|
$(document).on('keyup', 'body', function (event) {
|
|
|
if (event.keyCode == 13) {
|
|
|
$("#filter-btn").trigger('click');
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//全部
|
|
|
$("#all-btn").click(function() {
|
|
|
$(document).on('click', '#all-btn', function () {
|
|
|
location.href = '';
|
|
|
});
|
|
|
|
|
|
//批量导入按钮点击事件
|
|
|
$('#import-btn').on('click', function() {
|
|
|
$(document).on('click', '#import-btn', function () {
|
|
|
$('#basicTable').hide();
|
|
|
$('#priceChangeSearch').hide();
|
|
|
$('.bulk-import').show();
|
|
|
});
|
|
|
|
|
|
//返回列表
|
|
|
$('#return-btn').on('click', function() {
|
|
|
$('.bulk-import').hide();
|
|
|
$('#basicTable').show();
|
|
|
$('#priceChangeSearch').show();
|
|
|
});
|
|
|
|
|
|
//批量导入
|
|
|
var successList = null,
|
|
|
$error = $('#error-msg'),
|
|
|
loadModal = null;
|
|
|
$('#upload-input').after('<div class="file-name btn btn-default">请选择文件</div>');
|
|
|
common.edit.ajaxfileupload("#upload-input", {
|
|
|
params: {
|
|
|
type: "price",
|
|
|
__type: "batch-import",
|
|
|
shop: common.util.__input("shopId")
|
|
|
},
|
|
|
onStart: function() {
|
|
|
loadModal = common.dialog.load();
|
|
|
$('.file-name').text($('#upload-input').val().replace("C:\\fakepath\\", ""));
|
|
|
},
|
|
|
onComplete: function(response) {
|
|
|
console.log(response);
|
|
|
if (loadModal) {
|
|
|
loadModal.close();
|
|
|
}
|
|
|
if (response.code == 200) {
|
|
|
var data = response.data,
|
|
|
li = '';
|
|
|
|
|
|
$('#priceTable').show();
|
|
|
$('.success-wrap').hide();
|
|
|
successList = data.successList;
|
|
|
$.each(data.failFileReason, function(i, value) {
|
|
|
li += '<li>' + value + '</li>';
|
|
|
});
|
|
|
$error.empty().html(li);
|
|
|
p.init(successList);
|
|
|
} else {
|
|
|
common.util.__tip(response.message, 'warning');
|
|
|
}
|
|
|
|
|
|
|
|
|
}
|
|
|
});
|
|
|
|
|
|
/***********************批量导入***********************/
|
|
|
|
|
|
|
|
|
var isFirst = false,
|
|
|
tableHtml = '';
|
|
|
var loadModal = null;
|
|
|
var importPriceChangeData;
|
|
|
var path = ''; //确定变价后返回的excel名
|
|
|
var p = new common.grid({
|
|
|
el: "#priceTable",
|
|
|
columns: [{
|
|
|
display: 'SKN',
|
|
|
render: function(item) {
|
|
|
el: "#importResultTable",
|
|
|
columns: [
|
|
|
{display: 'SKN', render: function(item) {
|
|
|
return item.newProductPriceBo.product_skn;
|
|
|
}
|
|
|
}, {
|
|
|
display: '吊牌价',
|
|
|
render: function(item) {
|
|
|
return item.newProductPriceBo.retail_price + '<p style="color: #ccc;">' + item.oldProductPriceBo.retail_price + '</p>';
|
|
|
}
|
|
|
}, {
|
|
|
display: '销售价',
|
|
|
render: function(item) {
|
|
|
}},
|
|
|
{display: '吊牌价', render: function(item) {
|
|
|
return '<p>'+item.newProductPriceBo.retail_price + '</p><div style="color: #999;">' + item.oldProductPriceBo.retail_price + '</div>';
|
|
|
}},
|
|
|
{display: '销售价', render: function(item) {
|
|
|
var newPrice = item.newProductPriceBo,
|
|
|
newPriceHtml = newPrice.sales_price;
|
|
|
|
|
|
newPriceHtml = '<p>'+newPrice.sales_price+'</p>';
|
|
|
if (newPrice.sales_price < (newPrice.retail_price / 2)) {
|
|
|
newPriceHtml = '<p style="color: red">' + newPrice.sales_price + '</p>';
|
|
|
}
|
|
|
|
|
|
return newPriceHtml + '<p style="color: #ccc;">' + item.oldProductPriceBo.sales_price + '</p>';
|
|
|
}
|
|
|
}, {
|
|
|
display: 'VIP折扣类型',
|
|
|
render: function(item) {
|
|
|
return ENUM.vipType[item.newProductPriceBo.vip_discount_type] +
|
|
|
'<p style="color: #ccc;">' + ENUM.vipType[item.oldProductPriceBo.vip_discount_type] + '</p>';
|
|
|
}
|
|
|
}, {
|
|
|
display: 'VIP价',
|
|
|
render: function(item) {
|
|
|
return newPriceHtml + '<div style="color: #999;">' + item.oldProductPriceBo.sales_price + '</div>';
|
|
|
}},
|
|
|
{display: 'VIP折扣类型', render: function(item) {
|
|
|
return '<p>'+ENUM.vipType[item.newProductPriceBo.vip_discount_type] + '</p>'+
|
|
|
'<div style="color: #999;">' + ENUM.vipType[item.oldProductPriceBo.vip_discount_type] + '</div>';
|
|
|
}},
|
|
|
{display: 'VIP价', render: function(item) {
|
|
|
var newPrice = item.newProductPriceBo,
|
|
|
newPriceHtml = '';
|
|
|
|
|
|
if (newPrice.vip_price) {
|
|
|
newPriceHtml = newPrice.vip_price;
|
|
|
|
|
|
if (newPrice.vip_price < (newPrice.retail_price / 2)) {
|
|
|
newPriceHtml = '<p style="color: red">' + newPrice.vip_price + '</p>';
|
|
|
}else{
|
|
|
newPriceHtml = '<p>'+newPrice.vip_price+'</p>';
|
|
|
}
|
|
|
} else {
|
|
|
newPriceHtml = '-'
|
|
|
newPriceHtml = '<p>-</p>'
|
|
|
}
|
|
|
return newPriceHtml + '<p style="color: #ccc;">' + item.oldProductPriceBo.vip_price + '</p>';
|
|
|
}
|
|
|
}, {
|
|
|
display: '白金价',
|
|
|
render: function(item) {
|
|
|
if(item.oldProductPriceBo.vip_price){
|
|
|
newPriceHtml += '<div style="color: #999;">' + item.oldProductPriceBo.vip_price + '</div>';
|
|
|
}else{
|
|
|
newPriceHtml += '<div>-</div>';
|
|
|
}
|
|
|
return newPriceHtml;
|
|
|
}},
|
|
|
{display: '白金价', render: function(item) {
|
|
|
var newPrice = item.newProductPriceBo,
|
|
|
newPriceHtml = newPrice.vip3_price;
|
|
|
|
|
|
if (newPrice.vip3_price < (newPrice.retail_price / 2)) {
|
|
|
newPriceHtml = '<p style="color: red">' + newPrice.vip3_price + '</p>';
|
|
|
newPriceHtml = '';
|
|
|
if (newPrice.vip3_price){
|
|
|
if (newPrice.vip3_price < (newPrice.retail_price / 2)) {
|
|
|
newPriceHtml = '<p style="color: red">' + newPrice.vip3_price + '</p>';
|
|
|
}else{
|
|
|
newPriceHtml = '<p>'+newPrice.vip3_price+'</p>';
|
|
|
}
|
|
|
}else{
|
|
|
newPriceHtml = '<p>-</p>'
|
|
|
}
|
|
|
|
|
|
return newPriceHtml + '<p style="color: #ccc;">' + item.oldProductPriceBo.vip3_price + '</p>';
|
|
|
}
|
|
|
}, {
|
|
|
display: '金卡价',
|
|
|
render: function(item) {
|
|
|
if(item.oldProductPriceBo.vip3_price){
|
|
|
newPriceHtml += '<div style="color: #999;">' + item.oldProductPriceBo.vip3_price + '</div>';
|
|
|
}else{
|
|
|
newPriceHtml += '<div>-</div>';
|
|
|
}
|
|
|
return newPriceHtml;
|
|
|
}},
|
|
|
{display: '金卡价', render: function(item) {
|
|
|
var newPrice = item.newProductPriceBo,
|
|
|
newPriceHtml = newPrice.vip2_price;
|
|
|
|
|
|
if (newPrice.vip2_price < (newPrice.retail_price / 2)) {
|
|
|
newPriceHtml = '<p style="color: red">' + newPrice.vip2_price + '</p>';
|
|
|
newPriceHtml = '';
|
|
|
if (newPrice.vip2_price){
|
|
|
if (newPrice.vip2_price < (newPrice.retail_price / 2)) {
|
|
|
newPriceHtml = '<p style="color: red">' + newPrice.vip2_price + '</p>';
|
|
|
}else {
|
|
|
newPriceHtml = '<p>'+newPrice.vip2_price+'</p>';
|
|
|
}
|
|
|
}else{
|
|
|
newPriceHtml = '<p>-</p>'
|
|
|
}
|
|
|
|
|
|
return newPriceHtml + '<p style="color: #ccc;">' + item.oldProductPriceBo.vip2_price + '</p>';
|
|
|
}
|
|
|
}, {
|
|
|
display: '银卡价',
|
|
|
render: function(item) {
|
|
|
if(item.oldProductPriceBo.vip2_price){
|
|
|
newPriceHtml += '<div style="color: #999;">' + item.oldProductPriceBo.vip2_price + '</div>';
|
|
|
}else{
|
|
|
newPriceHtml += '<div>-</div>';
|
|
|
}
|
|
|
return newPriceHtml;
|
|
|
}},
|
|
|
{display: '银卡价', render: function(item) {
|
|
|
var newPrice = item.newProductPriceBo,
|
|
|
newPriceHtml = newPrice.vip1_price;
|
|
|
|
|
|
if (newPrice.vip1_price < (newPrice.retail_price / 2)) {
|
|
|
newPriceHtml = '<p style="color: red">' + newPrice.vip1_price + '</p>';
|
|
|
newPriceHtml = '';
|
|
|
if (newPrice.vip1_price){
|
|
|
if (newPrice.vip1_price < (newPrice.retail_price / 2)) {
|
|
|
newPriceHtml = '<p style="color: red">' + newPrice.vip1_price + '</p>';
|
|
|
}else{
|
|
|
newPriceHtml = '<p>'+newPrice.vip1_price+'</p>';
|
|
|
}
|
|
|
}else{
|
|
|
newPriceHtml = '<p>-</p>'
|
|
|
}
|
|
|
if(item.oldProductPriceBo.vip1_price){
|
|
|
newPriceHtml += '<div style="color: #999;">' + item.oldProductPriceBo.vip1_price + '</div>';
|
|
|
}else{
|
|
|
newPriceHtml += '<div>-</div>';
|
|
|
}
|
|
|
return newPriceHtml;
|
|
|
}},
|
|
|
{display: '操作', render: function(item) {
|
|
|
return '<a class="btn btn-danger btn-xs deleteImport" data-index="' + item.__index + '" href="javascript:;">删除</a>';
|
|
|
}}
|
|
|
]
|
|
|
});
|
|
|
|
|
|
return newPriceHtml + '<p style="color: #ccc;">' + item.oldProductPriceBo.vip2_price + '</p>';
|
|
|
}
|
|
|
}, {
|
|
|
display: '操作',
|
|
|
render: function(item) {
|
|
|
return '<a class="btn btn-info delete-btn" data-index="' + item.__index + '" href="javascript:;">删除</a>';
|
|
|
common.edit.ajaxfileupload("#priceChangeUpload", {
|
|
|
params: {
|
|
|
type: "price",
|
|
|
__type: "batch-import"
|
|
|
},
|
|
|
onStart: function() {
|
|
|
loadModal = common.dialog.load();
|
|
|
clearImportResult()
|
|
|
},
|
|
|
onComplete: function(response) {
|
|
|
console.log("批量接口返回数据",response);
|
|
|
if (loadModal) loadModal.close();
|
|
|
|
|
|
if(response.code == 200){
|
|
|
if(response.data.failFileReason && response.data.failFileReason.length > 0){
|
|
|
showImportMessage(response.data.failFileReason.join('<br/>'), "error");
|
|
|
}else {
|
|
|
showImportMessage("批量导入全部成功!", "success");
|
|
|
}
|
|
|
if(response.data.successList && response.data.successList.length > 0){
|
|
|
showImportTable(response.data);
|
|
|
}
|
|
|
}else{
|
|
|
showImportMessage(response.message, "error");
|
|
|
common.util.__tip(response.message);
|
|
|
}
|
|
|
}]
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//全部删除按钮
|
|
|
$('#delete-all').on('click', function() {
|
|
|
$('#priceTable').empty();
|
|
|
$error.empty();
|
|
|
successList.length = 0;
|
|
|
})
|
|
|
|
|
|
|
|
|
//批量变价列表单个删除
|
|
|
$('#priceTable').on('click', '.delete-btn', function() {
|
|
|
//var index = p.rows[$(this).data('index')];
|
|
|
successList.splice($(this).data('index'), 1);
|
|
|
p.reload();
|
|
|
// console.log(p.rows);
|
|
|
//显示批量导入结果
|
|
|
function showImportMessage(message, statue){
|
|
|
$("#priceChangeImportMessage").removeAttr("class").addClass(statue).show();
|
|
|
$("#detailMassage").html(message);
|
|
|
}
|
|
|
//显示批量导入数据表
|
|
|
function showImportTable(data){
|
|
|
importPriceChangeData = data.successList;
|
|
|
|
|
|
p.init(importPriceChangeData);
|
|
|
$("#priceChangeImportResultSet").show();
|
|
|
$("#priceChangeImportResult").show();
|
|
|
new common.edit("#priceChangeImportResultSet").init();
|
|
|
}
|
|
|
//清除批量导入结果及列表
|
|
|
function clearImportResult(){
|
|
|
$("#detailMassage").empty();
|
|
|
$("#importResultTable").empty();
|
|
|
$("#priceChangeImportResultSet input").val('');
|
|
|
|
|
|
$('#download-btn').hide();
|
|
|
$("#priceChangeImportMessage").hide();
|
|
|
$("#priceChangeImportResultSet").hide();
|
|
|
$("#priceChangeImportResult").hide();
|
|
|
}
|
|
|
|
|
|
//全部删除
|
|
|
$(document).on('click', '#deleteAllImport', function () {
|
|
|
common.dialog.confirm(
|
|
|
'删除确认提示',
|
|
|
'你确定<b><font color="#ff0000">全部删除</font></b>已成功导入的变价么?',
|
|
|
function () {
|
|
|
importPriceChangeData.length = 0;
|
|
|
p.reload();
|
|
|
}
|
|
|
);
|
|
|
});
|
|
|
|
|
|
|
|
|
//确定变价
|
|
|
var path = ''; //确定变价后返回的excel名
|
|
|
$('#sure-change').on('click', function() {
|
|
|
var arr = [],
|
|
|
data = '';
|
|
|
|
|
|
if (!successList || successList.length == 0) {
|
|
|
alert('请上传批量变价文件');
|
|
|
return;
|
|
|
//单个删除
|
|
|
$(document).on('click', '.deleteImport', function () {
|
|
|
common.dialog.confirm(
|
|
|
'删除确认提示',
|
|
|
'你确定<b><font color="#ff0000">删除</font></b>该变价么?',
|
|
|
function () {
|
|
|
var index = $(this).data("index");
|
|
|
if(importPriceChangeData){
|
|
|
[].splice.call(importPriceChangeData,index,1);
|
|
|
p.reload();
|
|
|
}
|
|
|
}
|
|
|
);
|
|
|
});
|
|
|
//确定提交批量
|
|
|
$(document).on('click', '.btn-submit-priceChange', function () {
|
|
|
if(importPriceChangeData.length < 1){
|
|
|
common.util.__tip("没有可提交的变价,请重新导入!");
|
|
|
return false;
|
|
|
}
|
|
|
console.log(successList);
|
|
|
$.each(successList, function(i, value) {
|
|
|
arr.push(value.newProductPriceBo);
|
|
|
});
|
|
|
|
|
|
// var count=Math.ceil(arr.length/200);
|
|
|
// for(var i=0;i<count;i++){
|
|
|
// item=arr.slice(i*200,(i+1)*200);
|
|
|
// }
|
|
|
// while(item=arr.slice(2,4)){
|
|
|
|
|
|
// }
|
|
|
|
|
|
data = JSON.stringify(arr);
|
|
|
console.log(data);
|
|
|
common.util.__ajax({
|
|
|
url: '/product/batchUpdateProductPrice',
|
|
|
data: {
|
|
|
batchList: data,
|
|
|
shop_id: common.util.__input("shopId")
|
|
|
common.dialog.confirm(
|
|
|
'提交确认提示',
|
|
|
'你确定<b><font color="#449d44">提交并保存</font></b>成功导入的变价么?',
|
|
|
function () {
|
|
|
var arr = [];
|
|
|
$.each(importPriceChangeData, function(i, value) {
|
|
|
arr.push(value.newProductPriceBo);
|
|
|
});
|
|
|
common.util.__ajax({
|
|
|
url: '/product/batchUpdateProductPrice',
|
|
|
data: {
|
|
|
batchList: JSON.stringify(arr),
|
|
|
cgpriceStartTime:$('#importStartDate').val(),
|
|
|
cgpriceEndTime:$('#importEndDate').val()
|
|
|
}
|
|
|
}, function(res) {
|
|
|
path = res.data;
|
|
|
importPriceChangeData.length = 0;
|
|
|
clearImportResult();
|
|
|
if(path && path != ''){
|
|
|
$('#download-btn').show();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
}, function(res) {
|
|
|
$('#priceTable').hide();
|
|
|
$('.success-wrap').show();
|
|
|
path = res.data;
|
|
|
successList.length = 0;
|
|
|
});
|
|
|
|
|
|
);
|
|
|
});
|
|
|
|
|
|
$('#download-btn').on('click', function() {
|
|
|
//下载导入结果
|
|
|
$(document).on('click', '#download-btn', function() {
|
|
|
location.href = '/ajax/download?path=' + path;
|
|
|
});
|
|
|
//返回列表
|
|
|
$(document).on('click', '#return-btn', function () {
|
|
|
if(path == ''){
|
|
|
$('.bulk-import').hide();
|
|
|
$('#basicTable').show();
|
|
|
$('#priceChangeSearch').show();
|
|
|
}else{
|
|
|
location.href = '';
|
|
|
}
|
|
|
}); |
|
|
\ No newline at end of file |
...
|
...
|
|