...
|
...
|
@@ -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();
|
|
|
});
|
|
|
|
|
|
//筛选
|
...
|
...
|
|