Authored by 王钱钧

Merge branch 'develop' of http://git.dev.yoho.cn/platform/yohobuy-portal-fe into develop

... ... @@ -4,6 +4,8 @@ var $ = require('jquery'),
common=require('../common/common');
var pricePercent = 0.2; //yoho币审核比例线
var loadModal = null;
var importYohoCoinData = null;
var ENUM = {
gender: {
1: '男',
... ... @@ -35,6 +37,7 @@ new common.dropDown({
var tabTree = new common.tabTree("#sortTree", {status: 1, sortLevel: 1});
tabTree.init();
//grid列表生成
var g = new common.grid({
el: "#yohoCoin_table",
parms: function() {
... ... @@ -69,6 +72,9 @@ var g = new common.grid({
});
g.init($("#gridurl").val());
//批量上传
ajaxUpload();
/**********************接口*************************/
//保存接口
... ... @@ -82,40 +88,104 @@ function ajaxSave(productSkn, yohoCoin, auditorId, salesPrice){
"auditorId": auditorId
}
},function(rs){
console.log(rs);
console.log("yoho币保存返回" + rs);
if(yohoCoin < (salesPrice * pricePercent)){
$('._' + productSkn).find(".returnYohoCoin").text(yohoCoin);
}
});
}
//批量导入接口
function ajaxUpload(){
var loadModal = null;
common.edit.ajaxfileupload('#yohoCoinUpload',{
params: {
type: "price",
type: "yohoCoin",
__type: "batch-import"
},
onStart: function() {
loadModal = common.dialog.load();
$('.file-name').text($('#upload-input').val().replace("C:\\fakepath\\", ""));
clearImportResult();
},
onComplete: function(response) {
console.log(response);
if (loadModal) {
loadModal.close();
console.log("批量接口返回数据",response);
if (response.code == 200 && response.data.taskId) {
ajaxExeclByTaskId(response.data.taskId);
return true;
}
if (response.code == 200) {
} else {
common.util.__tip(response.message, 'warning');
else if(response.data && response.data.failFileReason.length){
loadingClose();
showImportMessage(response.data.failFileReason.join('<br/>'), "error");
common.util.__tip("上传出错!具体请看批量上传结果。", 'warning');
return false;
}
else{
loadingClose();
showImportMessage(response.message, "error");
common.util.__tip(response.message);
}
}
});
}
/**********************校验*************************/
//异步批量上传接口
function ajaxExeclByTaskId(taskId){
//异步调用的接口importResult/queryBatchImportResult 参数名param
common.util.__ajax({
url: '/yohoCoin/importResult/queryBatchImportResult',
data: {
param:taskId
}
},function(res){
console.log("异步返回接口",res);
if(res.data.length){
loadingClose();
importYohoCoinData = res.data;
showImportTable(res);
showImportMessage("批量导入成功!", "success");
common.util.__tip("批量导入成功!", 'success');
}else{
setTimeout(function(){
ajaxExeclByTaskId.call(null,taskId);
},5000);
}
},true);
}
//批量上传确认
function ajaxUploadSubmit(data){
common.util.__ajax({
url:'',
data: data
},function(rs){
location.href = '';
});
}
/**********************业务方法*************************/
//显示批量导入结果
function showImportMessage(message, statue){
$("#yohoCoinImportMessage").removeAttr("class").addClass(statue).show();
$("#detailMassage").text(message);
}
//显示批量导入数据表
function showImportTable(data){
$("#importResultTable").html(common.util.__template2($("#yohoCoinImportResultTable").html(),data));
$("#yohoCoinImportResultSet").show();
$("#yohoCoinImportResult").show();
}
//初始化批量导入结果及列表
function clearImportResult(){
$("#detailMassage").empty();
$("#importResultTable").empty();
$("#importAuditor").val("");
$("#yohoCoinImportMessage").hide();
$("#yohoCoinImportResultSet").hide();
$("#yohoCoinImportResult").hide();
}
//吊牌价跟销售价校验
function checkPrice(retailPrice, salesPrice){
... ... @@ -163,8 +233,36 @@ function checkAuditor(auditor){
return true;
}
//保存单行数据刷新
function freshYohoCoinRowData(productSkn, yohoCoin, status){
var SknDom = $('._' + productSkn);
SknDom.find(".returnYohoCoin").text(yohoCoin);
SknDom.find(".coinStatus").text(ENUM.status[status]);
}
//关闭loading
function loadingClose(){
if (loadModal) {
loadModal.close();
}
}
/**********************事件*************************/
//批量导入结果列表删除
$(document).on('click', '.btn-delete-yohoCoin', function() {
var index = $(this).data("index");
if(importYohoCoinData){
[].splice.call(importYohoCoinData,index,1);
$("#importResultTable").html(common.util.__template2($("#yohoCoinImportResultTable").html(),data));
}
});
//批量导入结果列表确定
$(document).on('click', '.btn-submit-yohoCoin', function() {
ajaxUploadSubmit();
});
//保存操作
$(document).on('click', '.btn-save', function() {
var productSkn = $(this).data('productskn');
... ... @@ -187,7 +285,10 @@ $(document).on('click', '.btn-save', function() {
$(document).on('click', '.btn-modify', function() {
if($(this).hasClass("openEditor")){
$(this).text("修改").removeClass("openEditor");
$(this).parents(".dataForShow").find(".dataForEditor td").hide();
var dataForShow = $(this).parents(".dataForShow");
dataForShow.find(".dataForEditor td").hide();
dataForShow.find(".editor-yohoCoin").val(dataForShow.find(".returnYohoCoin").text());
dataForShow.find(".editor-auditor").val("");
}else{
$(this).text("收起").addClass("openEditor");
$(this).parents(".dataForShow").find(".dataForEditor td").show();
... ... @@ -196,16 +297,16 @@ $(document).on('click', '.btn-modify', function() {
//显示批量导入
$(document).on('click', '#import-btn', function() {
$('.dataTables_wrapper').hide();
$('#yohoCoin_table').hide();
$('#yohoCoinSearch').hide();
$('.bulk-import').show();
$('#yohoCoin_import').show();
});
//返回列表
$(document).on('click', '#return-btn', function() {
$('.bulk-import').hide();
$('#yohoCoin_import').hide();
$('#yohoCoinSearch').show();
$('.dataTables_wrapper').show();
$('#yohoCoin_table').show();
});
//筛选
... ...
... ... @@ -44,3 +44,54 @@
#yohoCoin_table .error{ border: 2px solid #ff0000}
#yohoCoin_import{
font-family: "Microsoft YaHei";
}
#yohoCoinImportMessage{
display: none;
margin-top: 10px;
font-size: 18px;
font-weight: bold;
padding: 5px 10px;
background: #ccc;
color: #ffffff;
}
#yohoCoin_import .success{
background:#449d44;
}
#yohoCoin_import .error{
background:#ff0000;
}
#yohoCoin_import .title{
padding: 5px 10px;
background: #5bc0de;
height: auto;
text-align: left;
border:1px solid #46b8da;
color: #FFFFFF;
font-size: 14px;
}
#yohoCoinImportResult, #yohoCoinImportResultSet{
display: none;
margin-top: 10px;
}
#yohoCoinImportResultSet .form-inline{
margin: 10px 0 0;
padding: 0 20px;
}
#importResultTable{
padding: 10px 20px;
text-align: center;
}
#importResultTable th, #importResultTable td{
text-align: center;
vertical-align: inherit;
}
... ...
//exports.domain = require('../config/common.js').domain;
exports.domain = 'http://172.16.6.214:8088/platform';
exports.domain = require('../config/common.js').domain;
//exports.domain = 'http://172.16.6.214:8088/platform';
exports.res = [
... ... @@ -60,6 +60,14 @@ exports.res = [
]
},
{//批量上传
route: "/yohoCoin/importResult/queryBatchImportResult",
method: "POST",
url: "/importResult/queryBatchImportResult",
params:[
{name: 'param', type: 'String'},
]
},
/*************************yoho币审核页面接口*******************************/
{//yoho币审核页面渲染
... ...
... ... @@ -120,7 +120,7 @@
<div class="panel">
<div class="dataTables_wrapper no-footer" id="yohoCoin_table"></div>
<div class="panel bulk-import">
<div class="panel bulk-import" id="yohoCoin_import">
<a id="return-btn" href="javascript:;" class="btn btn-info">返回列表</a>
<table class="table table-bordered" style="border:1px solid #ddd; margin-top: 10px">
... ... @@ -142,6 +142,44 @@
</td>
</tr>
</table>
<div id="yohoCoinImportMessage">
<b>批量上传结果:</b><span id="detailMassage"></span>
</div>
<div id="yohoCoinImportResultSet">
<div class="title">返还方式设置:</div>
<div class="form-inline" style="display: none">
<label style="width: 80px">反币时间:</label>
<div class="form-group">
<input type="radio" name="returnCoinTime" value="1">
<label>长期</label>
</div>
<div class="form-group">
<input type="radio" name="returnCoinTime" value="2">
<input type="text" class="form-control" style="width: 150px">&nbsp;~&nbsp;<input type="text" class="form-control" style="width: 150px">
</div>
</div>
<div class="form-inline">
<div class="form-group">
<label style="width: 80px">审核人:</label>
<select id="importAuditor" class="form-control" style="width: 150px">
<option value="">-- 请选择审核人 --</option>
<option value="2965">Tracy</option>
<option value="10235">David Wong</option>
</select>
<span style="color: #ff0000; margin-left: 20px">提示:返回金额大于等于销售价20%时必须填写审核人。</span>
</div>
<div class="form-group">
<a href="javascript:;" class="btn btn-success btn-submit-yohoCoin">确定</a>
</div>
</div>
</div>
<div id="yohoCoinImportResult">
<div class="title">返币列表:</div>
<div id="importResultTable"></div>
</div>
</div>
</div>
</div>
... ... @@ -189,12 +227,14 @@
<td class="center retailPrice" style="width: 5%">[[retailPrice]]</td>
<td class="center salesPrice" style="width: 5%">[[salesPrice]]</td>
<td class="center returnYohoCoin" style="width: 5%">[[productPrice.returnCoin]]</td>
<td class="center" style="width: 8%">[[statusName]]</td>
<td class="center coinStatus" style="width: 8%">[[statusName]]</td>
<td style="width: 12%">
[[if productPrice.founder]]<p>[[productPrice.founder]]</p>[[/if]]
[[if productPrice.updateTime]]<p>[[productPrice.updateTime]]</p>[[/if]]
</td>
[[if productPrice.coinStatus != 1]]
<td class="center" style="width: 5%"><button type="button" class="btn btn-info btn-sm btn-modify">修改</button></td>
[[/if]]
</tr>
<tr class="dataForEditor">
... ... @@ -207,7 +247,7 @@
<td width="20%"><b>操作</b></td>
</tr>
<tr>
<!--td>
<td style="display: none">
<div class="radio" style="margin-top: 0">
<label><input type="radio" name="returnCoinTime" value="option1" checked>永久</label>
</div>
... ... @@ -220,12 +260,12 @@
</form>
</label>
</div>
</td-->
</td>
<td class="center">
<input type="text" class="form-control center editor-yohoCoin" placeholder="YOHO币数量" value="[[productPrice.returnCoin]]" style="width: 100px">
</td>
<td class="center">
<select class="form-control center editor-auditor" tabindex="-1" style="width: 150px">
<select class="form-control center editor-auditor" style="width: 150px">
<option value="">-- 请选择审核人 --</option>
<option value="2965">Tracy</option>
<option value="10235">David Wong</option>
... ... @@ -245,5 +285,30 @@
</div>
</script>
<script id="yohoCoinImportResultTable" type="text/template">
<table class="table table-striped table-bordered" align="center">
<thead>
<tr>
<th>SKN</th>
<th>品牌</th>
<th>吊牌价</th>
<th>反币金额</th>
<th>操作</th>
</tr>
</thead>
<tbody>
[[each data as item _index]]
<tr>
<td>[[item.productSkn]]</td>
<td>[[item.brandName]]</td>
<td>[[item.retailPrice]]</td>
<td>[[item.returnCoin]]</td>
<td><a href="javascript:;" class="btn btn-sm btn-danger btn-delete-yohoCoin" data-index="[[_index]]">删除</a></td>
</tr>
[[/each]]
</tbody>
</table>
</script>
</body>
</html>
\ No newline at end of file
... ...
... ... @@ -104,10 +104,10 @@
<div class="panel">
<ul id="yohoCoinNav" class="nav nav-pills" style="margin-bottom: 10px">
<li data-status="1"><a href="#">待审核</a></li>
<li data-status="1" class="active"><a href="#">待审核</a></li>
<li data-status="2"><a href="#">通过</a></li>
<li data-status="3"><a href="#">驳回</a></li>
<li data-status="" class="active"><a href="#">全部</a></li>
<li data-status=""><a href="#">全部</a></li>
</ul>
<div class="dataTables_wrapper no-footer" id="yohoCoinAudit_table"></div>
... ...