...
|
...
|
@@ -3,6 +3,9 @@ |
|
|
var $ = require('jquery'),
|
|
|
common=require('../common/common');
|
|
|
|
|
|
var pricePercent = 0.2; //yoho币审核比例线
|
|
|
var loadModal = null;
|
|
|
var importYohoCoinData = null;
|
|
|
var ENUM = {
|
|
|
gender: {
|
|
|
1: '男',
|
...
|
...
|
@@ -10,100 +13,46 @@ var ENUM = { |
|
|
3: '通用'
|
|
|
},
|
|
|
status: {
|
|
|
0: '未设置',
|
|
|
1: '<font color="#428bca">待审核</font>',
|
|
|
2: '<font color="#5cb85c">通过</font>',
|
|
|
3: '<font color="#d9534f">驳回</font>'
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
var g = new common.grid({
|
|
|
el: "#yohoCoin_table1",
|
|
|
parms: function() {
|
|
|
return {
|
|
|
product_skn: common.util.__input("skn"),
|
|
|
shop_id: common.util.__input("shop"),
|
|
|
brand_id: common.util.__input("brand"),
|
|
|
supplier_id: common.util.__input("supplier"),
|
|
|
gender: common.util.__input("gender")
|
|
|
};
|
|
|
},
|
|
|
columns: [{
|
|
|
display: 'SKN',
|
|
|
name: 'product_skn'
|
|
|
}, {
|
|
|
display: '商品信息',
|
|
|
name: 'info',
|
|
|
render: function(item) {
|
|
|
return '<div>名称:' + item.product_name + '</div>' +
|
|
|
'<div>品牌:' + item.brand_name + '</div>' +
|
|
|
'<div>类目:' + item.middle_sort_name + '<b> ></b> ' + item.small_sort_name + '</div>';
|
|
|
}
|
|
|
}, {
|
|
|
display: '供应商 / 店铺',
|
|
|
name: 'supplier_name',
|
|
|
render: function(item) {
|
|
|
var html = '';
|
|
|
if (item.supplier_name) {
|
|
|
html += item.supplier_name;
|
|
|
}
|
|
|
if (item.shop_name) {
|
|
|
html += '/' + item.shop_name;
|
|
|
}
|
|
|
return html;
|
|
|
}
|
|
|
}, {
|
|
|
display: '性别',
|
|
|
name: 'gender',
|
|
|
render: function(item) {
|
|
|
return ENUM.gender[item.gender];
|
|
|
}
|
|
|
}, {
|
|
|
display: '吊牌价',
|
|
|
name: 'retail_price'
|
|
|
}, {
|
|
|
display: '销售价',
|
|
|
name: 'sales_price'
|
|
|
}, {
|
|
|
display: '返币金额',
|
|
|
name: 'return_coin'
|
|
|
}, {
|
|
|
display: '状态',
|
|
|
name: 'status',
|
|
|
render: function(item) {
|
|
|
return ENUM.status[item.status];
|
|
|
}
|
|
|
},{
|
|
|
display: '操作信息',
|
|
|
name: 'operateInfo',
|
|
|
render: function(item) {
|
|
|
var html = '';
|
|
|
if (item.founder_name) {
|
|
|
html += '<div>' + item.founder_name + '</div>';
|
|
|
}
|
|
|
if (item.updateTime) {
|
|
|
html += '<div>' + item.updateTime + '</div>';
|
|
|
}
|
|
|
return html;
|
|
|
}
|
|
|
}, {
|
|
|
display: '操作',
|
|
|
render: function(item) {
|
|
|
return '<a href="javascript:;" class="btn btn-info btn-xs btn-modify" data-skn="' + item.product_skn + '">修改</a>'
|
|
|
}
|
|
|
}]
|
|
|
new common.dropDown({
|
|
|
el: '#shop',
|
|
|
ajax: 'shopsRest'
|
|
|
});
|
|
|
new common.dropDown({
|
|
|
el: '#brand',
|
|
|
ajax: 'brand'
|
|
|
});
|
|
|
new common.dropDown({
|
|
|
el: '#supplier',
|
|
|
ajax: 'querySupplier'
|
|
|
});
|
|
|
*/
|
|
|
|
|
|
//多级菜单
|
|
|
var tabTree = new common.tabTree("#sortTree", {status: 1, sortLevel: 1});
|
|
|
tabTree.init();
|
|
|
|
|
|
//grid列表生成
|
|
|
var g = new common.grid({
|
|
|
el: "#yohoCoin_table",
|
|
|
parms: function() {
|
|
|
var select = tabTree.getAddress();
|
|
|
return {
|
|
|
product_skn: common.util.__input("skn"),
|
|
|
shop_id: common.util.__input("shop"),
|
|
|
brand_id: common.util.__input("brand"),
|
|
|
supplier_id: common.util.__input("supplier"),
|
|
|
gender: common.util.__input("gender")
|
|
|
productSkn: common.util.__input("skn"),
|
|
|
shopId: common.util.__input("shop"),
|
|
|
brandId: common.util.__input("brand"),
|
|
|
supplierId: common.util.__input("supplier"),
|
|
|
gender: common.util.__input("gender"),
|
|
|
auditStatus: common.util.__input("auditStatus"),
|
|
|
maxSortId: select[0] ? select[0].id : "",
|
|
|
middleSortId: select[1] ? select[1].id : "",
|
|
|
smallSortId: select[2] ? select[2].id : "",
|
|
|
sortId: select[3] ? select[3].id : ""
|
|
|
};
|
|
|
},
|
|
|
columns: [{
|
...
|
...
|
@@ -114,21 +63,263 @@ var g = new common.grid({ |
|
|
$("#yohoCoin_table").find("thead tr th").html($("#coinListHead").html());
|
|
|
}
|
|
|
item.genderName = ENUM.gender[item.gender];
|
|
|
item.statusName = ENUM.status[item.productPrice.coinStatus];
|
|
|
|
|
|
html += common.util.__template2($("#coinList").html(),item);
|
|
|
return html;
|
|
|
}
|
|
|
}]
|
|
|
});
|
|
|
|
|
|
g.init($("#gridurl").val());
|
|
|
|
|
|
//批量上传
|
|
|
ajaxUpload();
|
|
|
|
|
|
/**********************接口*************************/
|
|
|
|
|
|
//保存接口
|
|
|
function ajaxSave(productSkn, yohoCoin, auditorId, salesPrice){
|
|
|
common.util.__ajax({
|
|
|
url:'/good/yohoCoin/set',
|
|
|
data: {
|
|
|
"productSkn": productSkn,
|
|
|
"returnCoin": yohoCoin,
|
|
|
"salesPrice": salesPrice,
|
|
|
"auditorId": auditorId
|
|
|
}
|
|
|
},function(rs){
|
|
|
console.log("yoho币保存返回" + rs);
|
|
|
if(yohoCoin < (salesPrice * pricePercent)){
|
|
|
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//批量导入接口
|
|
|
function ajaxUpload(){
|
|
|
common.edit.ajaxfileupload('#yohoCoinUpload',{
|
|
|
params: {
|
|
|
type: "yohoCoin",
|
|
|
__type: "batch-import"
|
|
|
},
|
|
|
onStart: function() {
|
|
|
loadModal = common.dialog.load();
|
|
|
clearImportResult();
|
|
|
},
|
|
|
onComplete: function(response) {
|
|
|
console.log("批量接口返回数据",response);
|
|
|
if (response.code == 200 && response.data.taskId) {
|
|
|
ajaxExeclByTaskId(response.data.taskId);
|
|
|
return true;
|
|
|
}
|
|
|
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){
|
|
|
if(retailPrice == salesPrice){
|
|
|
return true;
|
|
|
}else{
|
|
|
common.util.__tip("销售价与吊牌价不同,YOHO币只能为0!");
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//yoho币金额校验
|
|
|
function checkYohoCoin(yohoCoin, auditor, price){
|
|
|
if(yohoCoin.val()){
|
|
|
if(!isNaN(yohoCoin.val())){
|
|
|
if(yohoCoin.val() < 0){
|
|
|
yohoCoin.focus().select().addClass("error");
|
|
|
common.util.__tip("YOHO币金额不能小于0!");
|
|
|
return false;
|
|
|
}
|
|
|
//yoho币大于等于销售额的20%需要校验审核人
|
|
|
if(yohoCoin.val() >= (price * pricePercent)){
|
|
|
return checkAuditor(auditor);
|
|
|
}
|
|
|
}else{
|
|
|
yohoCoin.focus().select().addClass("error");
|
|
|
common.util.__tip("YOHO币金额必须为数字!");
|
|
|
return false;
|
|
|
}
|
|
|
}else{
|
|
|
yohoCoin.focus().addClass("error");
|
|
|
common.util.__tip("YOHO币金额不能为空!");
|
|
|
return false;
|
|
|
}
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
//审核人校验
|
|
|
function checkAuditor(auditor){
|
|
|
if(auditor.val() == ""){
|
|
|
auditor.focus().addClass("error");
|
|
|
common.util.__tip("审核人不能为空!");
|
|
|
return false;
|
|
|
}
|
|
|
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');
|
|
|
var sknDom = $('._' + productSkn);
|
|
|
|
|
|
var retailPrice = sknDom.find('.retailPrice').text(); //吊牌价
|
|
|
var salesPrice = sknDom.find('.salesPrice').text(); //销售价
|
|
|
|
|
|
if(checkPrice(retailPrice, salesPrice)){
|
|
|
var yohoCoinInput = sknDom.find('.editor-yohoCoin');
|
|
|
var auditorInput = sknDom.find('.editor-auditor');
|
|
|
|
|
|
if(checkYohoCoin(yohoCoinInput, auditorInput, salesPrice)){
|
|
|
ajaxSave(productSkn, yohoCoinInput.val(), auditorInput.val(), salesPrice);
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//显示修改
|
|
|
$(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();
|
|
|
}
|
|
|
});
|
|
|
|
|
|
//显示批量导入
|
|
|
$(document).on('click', '#import-btn', function() {
|
|
|
$('#yohoCoin_table').hide();
|
|
|
$('#yohoCoinSearch').hide();
|
|
|
$('#yohoCoin_import').show();
|
|
|
});
|
|
|
|
|
|
//返回列表
|
|
|
$(document).on('click', '#return-btn', function() {
|
|
|
$('#yohoCoin_import').hide();
|
|
|
$('#yohoCoinSearch').show();
|
|
|
$('#yohoCoin_table').show();
|
|
|
});
|
|
|
|
|
|
//筛选
|
|
|
$(document).on('click', '#filter-btn', function() {
|
|
|
g.reload(1);
|
|
|
});
|
|
|
|
|
|
//全部
|
|
|
$(document).on('click', '#all-btn', function() {
|
|
|
location.href = '';
|
|
|
});
|
|
|
|
|
|
//校验失败编辑
|
|
|
$(document).on('change', '#yohoCoin_table .error', function() {
|
|
|
$(this).removeClass('error');
|
|
|
}); |
|
|
\ No newline at end of file |
...
|
...
|
|