Authored by dongjunjie

代销变价

... ... @@ -41,6 +41,8 @@ module.exports=function(app) {
app.post("/product/getProductPrice", "price_getProductPrice");
app.post("/product/updateProductPrice", "price_updateProductPrice");
app.post("/product/queryProductPriceListBySkn","price_queryProductPriceListBySkn");
app.post("/product/batchUpdateProductPrice", "price_batchUpdateProductPrice");
... ...
... ... @@ -45,6 +45,13 @@ module.exports={
{name: 'vip3_price',type: 'number'}
]
},
queryProductPriceListBySkn:{
title:'变价记录',
url: '/product/queryProductPriceListBySkn',
params: [
{name: 'param', type: 'Number'}
]
},
batchUpdateProductPrice:{
title: "批量变价接口",
url: '/product/batchUpdateProductPrice',
... ...
<%include '../../../common/views/__ui/header'%>
<%include '../../../common/views/__partail/ListHeader'%>
<div class="contentpanel">
<div class="panel panel-default" id="priceChangeSearch" style="margin-bottom:10px;">
<div class="panel-body">
<div class="row">
<div class="panel-col2">
<div class="panel-col">
<input id="skn" class="form-control panel-input height40" type="text" placeholder="请输入SKN" onkeyup="this.value=this.value.replace(/\D/gi,'')">
</div>
... ... @@ -25,10 +22,6 @@
</div>
<div class="panel-col">
<input id="brandInput" class="form-control panel-input height40" type="text" placeholder="请输入品牌名称">
</div>
<div class="panel-col">
<select name="supplier" id="supplier" tabindex="-1" title="" class="form-control">
<option value="-1">请选择供应商</option>
</select>
... ... @@ -72,123 +65,186 @@
</div>
<div class="panel-col">
<select name="brandCooperation" id="brandCooperation" tabindex="-1" title="" class="form-control">
<option value="-1">合作模式</option>
<option value="1">代销</option>
<option value="2">经销</option>
<option value="3">自主</option>
</select>
</div>
<div class="panel-col">
<select name="brandCooperationSet" id="brandCooperationSet" tabindex="-1" title="" class="form-control">
<option value="0">未设置</option>
<option value="-1">全部</option>
<option value="1">已设置</option>
</select>
</div>
<div class="panel-col">
<a id="filter-btn" href="javascript:;" class="btn btn-info">筛选</a>
<a id="all-btn" href="javascript:;" class="btn btn-info">全部</a>
</div>
<div class="panel-col" style="margin: 0 0 0 -5px;">
<a id="import-btn" href="javascript:;" class="btn btn-info">批量导入</a>
<a id="import-btn" href="javascript:;" class="btn btn-primary">批量导入</a>
</div>
</div>
</div>
</div>
<div class="panel">
<div class="dataTables_wrapper no-footer" id="basicTable"></div>
<div class="panel bulk-import" style='padding:20px'>
<a id="return-btn" href="javascript:;" class="btn btn-info" style="margin-bottom: 10px">返回列表</a>
<div class="import-hd" style="padding: 10px 20px; border: 1px solid #cccccc">
<span class="excel-upload-wrap">
<label>选择文件</label>
<input id="upload-input" name="file" class="btn btn-default excel-upload" type="file">
</span>
<a class="excel-model" href="/ajax/link/batchUpdatePrice">表头下载</a>
<input id="sure-change" class="btn btn-primary" type="button" value="确定变价">
<div class="panel bulk-import" id="priceChange_import" style="padding: 20px;">
<a id="return-btn" href="javascript:;" class="btn btn-info">返回列表</a>
<a id="download-btn" href="javascript:;" class="btn btn-success" style="display: none">
<span class="glyphicon glyphicon-arrow-down"></span> 下载导入结果
</a>
<table class="table table-bordered" style="border:1px solid #ddd; margin-top: 10px">
<tr>
<td width="120px" style="line-height: 37px"><b>上传EXCEL:</b></td>
<td style="position: relative;">
<input id="priceChangeUpload" name="file" type="file" style="cursor: pointer; height: 37px; top: 8px;">
<div class="file-name btn btn-primary">请选择文件</div>
</td>
</tr>
<tr>
<td width="120px"><b>说明:</b></td>
<td>
1、上传文件必须是<span style="color:red;">.xlsx</span>文件<br>
2、Excel表头为:<span style="color: #67D267;">SKN、吊牌价、销售价、VIP折扣类型、VIP价、白金价、金卡价、银卡价</span><br>
3、第一行为表头内容,第二行开始为正式内容<br>
4、每个文件控制在2500行以内<br>
5、<a href="/ajax/link/batchUpdatePrice" style="margin: 0; text-decoration: underline">下载样例.xlsx</a>
</td>
</tr>
</table>
<div id="priceChangeImportMessage">
<b>批量上传结果:</b>
<span id="detailMassage"></span>
<div class="clearfix"></div>
</div>
<ol id="error-msg" class="error-msg" style="color: red"></ol>
<div class="priceTable-wrap">
<div class="panel panel-warning" style="margin: 0;">
<div class="panel-heading">SKN变价<a id="delete-all" class="btn btn-danger" style="margin-left: 50px;" href="javascript:;">全部删除</a></div>
<div id="priceChangeImportResultSet">
<div class="title">
<span>生效时间设置:</span>
<div class="clearfix"></div>
</div>
<div class="form-inline">
<label>价格生效时间:</label>
<div class="form-group">
<input id="importStartDate" jsaction="date:end:importEndDate" type="text" class="form-control" placeholder="开始日期" style="width: 150px">
&nbsp;~&nbsp;
<input id="importEndDate" jsaction="date:start:importStartDate" type="text" class="form-control" placeholder="结束日期" style="width: 150px">
</div>
<div class="form-group">
<a href="javascript:;" class="btn btn-success btn-submit-priceChange">确定提交</a>
</div>
</div>
<div class="dataTables_wrapper no-footer" id="priceTable"></div>
</div>
<div class="success-wrap" style="display: none;">
<a class="btn btn-info" href="">返回变价列表</a>
<a id="download-btn" class="btn btn-success" data-domain="{{domain}}" href="javascript:;">下载导入结果</a>
<div id="priceChangeImportResult">
<div class="title">
<span>批量变价列表:(成功导入的变价)</span>
<a id="deleteAllImport" href="javascript:;" class="btn btn-xs btn-danger" style="float: right;padding-right: 10px">全部删除</a>
<div class="clearfix"></div>
</div>
<div id="importResultTable"></div>
</div>
</div>
</div>
</div>
<input type="hidden" id="btnAuthority" value="<%bottons%>">
<input type="hidden" id="gridurl" value="<%gridurl%>">
<script id="template" type="text/template">
<tr class="product-detail">
<td colspan="15">
<form>
<table class="table table-striped table-bordered">
<tr>
<th>SKN</th>
<th>销售价</th>
<th>VIP折扣类型</th>
<th>VIP</th>
<th>白金价</th>
<th>金卡价</th>
<th>银卡价</th>
<th>进货价</th>
<th>进货折扣</th>
<th>成本</th>
<th>操作</th>
</tr>
<tr>
<td class="skn-value"></td>
<td>
<input class="sale-price" type="text" value="{sales_price}">
</td>
<td>
<select class="discount-select">
<option value="1">正常折扣</option>
<option value="2">统一折扣</option>
<option value="3">无折扣</option>
<option value="4">固定折扣</option>
<option value="5">自定义折扣</option>
</select>
</td>
<td>
<input class="vip-price" type="text" value="{vip_price}">
</td>
<td>
<input class="vip3-price" type="text" value="{vip3_price}" disabled>
</td>
<td>
<input class="vip2-price" type="text" value="{vip2_price}" disabled>
</td>
<td>
<input class="vip1-price" type="text" value="{vip1_price}" disabled>
</td>
<td>{purchase_price}</td>
<td>{purchase_discount}</td>
<td>{cost_price}</td>
<td><a class="sure-modify" href="javascript:;">确认修改</a></td>
</tr>
</table>
</form>
</td>
</tr>
<td colspan="15" style="padding: 0">
<table class="table table-striped table-bordered" style="margin: 0;border: 0">
<tr>
<th style="border-top: 0; border-left: 0">销售价</th>
<th style="border-top: 0">VIP折扣类型</th>
<th style="border-top: 0">VIP</th>
<th style="border-top: 0">白金价</th>
<th style="border-top: 0">金卡价</th>
<th style="border-top: 0">银卡价</th>
<th style="border-top: 0">价格生效时间</th>
<th style="border-top: 0">进货价</th>
<th style="border-top: 0">进货折扣</th>
<th style="border-top: 0">成本</th>
<th style="border-top: 0">操作</th>
</tr>
<tr>
<td style="border-bottom: 0; border-left: 0">
<input class="sale-price form-control" type="text" value="{sales_price}" onkeyup="this.value=this.value.replace(/\D/gi,'')">
</td>
<td style="border-bottom: 0">
<select class="discount-select form-control" style="width: 110px">
<option value="1">正常折扣</option>
<option value="2">统一折扣</option>
<option value="3">无折扣</option>
<option value="4">固定折扣</option>
<option value="5">自定义折扣</option>
</select>
</td>
<td style="border-bottom: 0">
<input class="vip-price form-control" type="text" value="{vip_price}" onkeyup="this.value=this.value.replace(/\D/gi,'')">
</td>
<td style="border-bottom: 0">
<input class="vip3-price form-control" type="text" value="{vip3_price}" disabled>
</td>
<td style="border-bottom: 0">
<input class="vip2-price form-control" type="text" value="{vip2_price}" disabled>
</td>
<td style="border-bottom: 0">
<input class="vip1-price form-control" type="text" value="{vip1_price}" disabled>
</td>
<td class="form-inline" style="border-bottom: 0">
<input id="start_{product_skn}" jsaction="date:end:end_{product_skn}" class="startDate form-control" type="text" value="{cgpriceStartTime}" placeholder="开始日期" style='background-color:#fff'>
<label>&nbsp;~&nbsp;</label>
<input id="end_{product_skn}" jsaction="date:start:start_{product_skn}" class="endDate form-control" type="text" value="{cgpriceEndTime}" placeholder="结束日期" style='background-color:#fff'>
</td>
<td style="border-bottom: 0">{purchase_price}</td>
<td style="border-bottom: 0">{purchase_discount}</td>
<td style="border-bottom: 0">{cost_price}</td>
<td style="border-bottom: 0">
<a href="javascript:;" class="btn btn-success btn-xs sure-modify">保存</a>
</td>
</tr>
</table>
</td>
</script>
<script id="template2" type="text/template">
<div class="productInfo">
<table class="table table-striped table-bordered">
<thead>
<tr align="center">
<th>SKN</th>
<th>商品名称</th>
<th>品牌</th>
<th>类目</th>
</tr>
</thead>
<tbody>
<tr>
<td>[[productSkn]]</td>
<td>[[goodsName]]</td>
<td>[[brandName]]</td>
<td>
[[maxSortName]]
[[if midleSortName]]&nbsp;>&nbsp;[[midleSortName]][[/if]]
[[if smallSortName]]&nbsp;>&nbsp;[[smallSortName]][[/if]]
</td>
</tr>
</tbody>
</table>
</div>
<h2 style="color: #999; font-family: 'Microsoft YaHei'; font-size: 14px;">—— 变价记录表 ——</h2>
<div class="historyList">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>吊牌价</th>
<th>销售价</th>
<th>价格生效时间</th>
<th>变价时间</th>
<th>变价人</th>
</tr>
</thead>
<tbody>
[[each list as item index]]
<tr>
<td>[[item.retailPrice]]</td>
<td>[[item.salesPrice]]</td>
<td>[[item.effectiveTime]]</td>
<td>[[item.createTime]]</td>
<td>[[item.founderName]]</td>
</tr>
[[/each]]
</tbody>
</table>
</div>
</script>
<%include '../../../common/views/__ui/footer'%>
\ No newline at end of file
... ...
... ... @@ -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 += '&nbsp;>&nbsp;' + item.middle_sort_name;}
if(item.small_sort_name) {html += '&nbsp;>&nbsp;' + 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
... ...
... ... @@ -19,5 +19,6 @@
@import "module/template";
@import "module/shop-pc";
@import "module/shop-app";
@import "module/priceChange";
@import "module/base";
@import "module/shopsReport";
... ...
/*********************代销变价*******************/
#priceChange_import{
font-family: "Microsoft YaHei";
}
#priceChangeImportMessage{
display: none;
margin-top: 10px;
font-size: 18px;
font-weight: bold;
padding: 5px 10px;
background: #ccc;
color: #ffffff;
}
#priceChangeImportMessage b, #priceChangeImportMessage span{
display: block;
float: left;
}
#priceChange_import .success{
background:#449d44;
}
#priceChange_import .error{
background:#ff0000;
}
#priceChange_import select.error{
border: 2px solid #ff0000;
background: none;
}
#priceChange_import .title{
padding: 5px 10px;
background: #5bc0de;
height: auto;
text-align: left;
border:1px solid #46b8da;
color: #FFFFFF;
font-size: 14px;
}
#priceChange_import .title span{
display: block;
float: left;
line-height: 27px;
font-size: 15px;
}
#priceChange_import .title a.btn{
float: right;
margin-right: 10px;
}
#priceChangeImportResult, #priceChangeImportResultSet{
display: none;
margin-top: 10px;
}
#priceChangeImportResultSet .form-inline{
margin: 10px 0 0;
padding: 0 20px;
}
\ No newline at end of file
... ...