Authored by liuyue

代销变价,限售商品

... ... @@ -37,193 +37,196 @@ var toast = function(options, ok, cancel) {
return new toast.prototype.init(options);
}
toast.list = {};
toast.prototype.constructor = toast,
toast.prototype.closed = true;
toast.prototype.constructor = toast;
toast.prototype.closed = true;
toast.prototype.destroyed = true;
toast.prototype.current = true;
toast.prototype.init = function(options) {
var __self = this,
_o = options;
__self.options = options;
__self.closed = false;
__self.destroyed = false;
console.log(options);
var __self = this,
_o = options;
__self.options = options;
__self.closed = false;
__self.destroyed = false;
var wrap = $('<div />')
.css({
display: 'none'
})
.addClass('modal')
.html(_o.template)
.appendTo('body');
__self.dom = __self.dom || __self.__dom(wrap, _o.className);
__self.dom.backdrop = $('<div />').addClass(_o.className + "backdrop");
__self.dom.backdrop.insertAfter(__self.dom.wrap);
__self
.button(_o.button)
.title(_o.title)
.content(_o.content)
.addclass(_o.addClass)
.show();
var wrap = $('<div />')
.css({
display: 'none'
})
.addClass('modal')
.html(_o.template)
.appendTo('body');
__self.dom = __self.dom || __self.__dom(wrap, _o.className);
//<div class="modal-backdrop fade in"></div>
__self.dom.backdrop = $('<div />').addClass(_o.className + "backdrop");
__self.dom.backdrop.insertAfter(__self.dom.wrap);
__self
.button(_o.button)
.title(_o.title)
.content(_o.content)
.addclass(_o.addClass)
.show();
if (__self.dom.close) {
__self.dom.close[_o.show === false ? 'hide' : 'show']().attr('title', _o.cancelValue)
.on('click', function(event) {
__self._trigger('cancel');
event.preventDefault();
});
__self.dom.wrap.on('click', '[data-id]', function(event) {
var $this = $(this);
if (!$this.attr('disabled')) {
__self._trigger($this.data('id'));
}
event.preventDefault();
});
return __self;
},
toast.prototype.addclass = function(css) {
var __self = this,
_o = __self.options;
__self.dom.wrap.addClass(css);
return __self;
},
toast.prototype.content = function(html) {
var __self = this,
_o = __self.options;
if (!__self.dom.body) {
return __self;
}
__self.dom.body.empty('')[typeof html === 'object' ? 'append' : 'html'](typeof html === 'object' ? html.innerHTML : html);
}
return __self;
},
toast.prototype.title = function(text) {
var __self = this,
_o = __self.options;
if (!__self.dom.title) {
return __self;
}
__self.dom.title.html(text);
__self.dom.title[text ? 'show' : 'hide']();
return __self;
},
toast.prototype.button = function() {
var __self = this,
_o = __self.options;
var html = '',
args = _o.button;
__self.callbacks = {};
if (!__self.dom.button) {
return this;
__self.dom.wrap.on('click', '[data-id]', function(event) {
var $this = $(this);
if (!$this.attr('disabled')) {
__self._trigger($this.data('id'));
}
if (typeof args === 'string') {
html = args;
} else {
$.each(args, function(i, val) {
val.id = val.id || val.value;
__self.callbacks[val.id] = val.callback;
html +=
'<button' + ' type="button"' + ' data-id="' + val.id + '"' + ' class="' + (_o.className + val.id) + ' btn ' + (val.css ? val.css : 'btn-default') + '"' + '>' + val.value + '</button>';
});
}
if ($.trim(html) == "")
__self.dom.button.hide();
else
__self.dom.button.html(html).show();
return __self;
},
toast.prototype.time = function(second) {
var __self = this,
_o = __self.options;
var cancel = _o.cancelValue,
timer = __self._timer;
timer && clearTimeout(timer);
if (second) {
__self._timer = setTimeout(function() {
__self._click(cancel);
}, 1000 * second);
};
event.preventDefault();
});
return __self;
};
toast.prototype.addclass = function(css) {
var __self = this,
_o = __self.options;
__self.dom.wrap.addClass(css);
return __self;
};
toast.prototype.content = function(html) {
var __self = this,
_o = __self.options;
if (!__self.dom.body) {
return __self;
},
toast.prototype.show = function() {
var __self = this,
_o = __self.options;
if (__self.destroyed) {
return this;
}
__self.dom.wrap.show().addClass("fade in");
__self.dom.backdrop.show().addClass("fade in");
__self.open = true;
}
__self.dom.body.empty('')[typeof html === 'object' ? 'append' : 'html'](typeof html === 'object' ? html.innerHTML : html);
return __self;
};
toast.prototype.title = function(text) {
var __self = this,
_o = __self.options;
if (!__self.dom.title) {
return __self;
},
toast.prototype.close = function() {
var __self = this,
_o = __self.options;
if (!__self.destroyed && __self.open) {
__self.dom.wrap.removeClass('in');
setTimeout(function() {
__self.dom.wrap.hide();
__self.dom.backdrop.hide();
__self.remove();
__self.open = false;
}, 200);
}
}
__self.dom.title.html(text);
__self.dom.title[text ? 'show' : 'hide']();
return __self;
};
toast.prototype.button = function() {
var __self = this,
_o = __self.options;
var html = '',
args = _o.button;
__self.callbacks = {};
if (!__self.dom.button) {
return this;
},
toast.prototype.remove = function() {
var __self = this,
_o = __self.options;
if (__self.destroyed) {
return g;
}
if (__self.current === this)
__self.current = null;
__self.dom.wrap.remove();
__self.dom.backdrop.remove();
for (var i in __self) {
delete this[i];
}
}
if (typeof args === 'string') {
html = args;
} else {
$.each(args, function(i, val) {
val.id = val.id || val.value;
__self.callbacks[val.id] = val.callback;
html +=
'<button' + ' type="button"' + ' data-id="' + val.id + '"' + ' class="' + (_o.className + val.id) + ' btn ' + (val.css ? val.css : 'btn-default') + '"' + '>' + val.value + '</button>';
});
}
if ($.trim(html) == "")
__self.dom.button.hide();
else
__self.dom.button.html(html).show();
return __self;
};
toast.prototype.time = function(second) {
var __self = this,
_o = __self.options;
var cancel = _o.cancelValue,
timer = __self._timer;
timer && clearTimeout(timer);
if (second) {
__self._timer = setTimeout(function() {
__self._click(cancel);
}, 1000 * second);
};
return __self;
};
toast.prototype.show = function() {
var __self = this,
_o = __self.options;
if (__self.destroyed) {
return this;
},
toast.prototype._trigger = function(id) {
var __self = this,
_o = __self.options;
var fn = __self.callbacks[id];
return typeof fn !== 'function' || fn.call(__self) !== false ?
__self.close() : __self;
},
toast.prototype._click = function(name) {
var __self = this,
_o = __self.options;
var fn = __self.callbacks[name];
return typeof fn !== 'function' || fn.call(__self, window) !== false ?
__self.close() : __self;
},
toast.prototype.__dom = function($select, classCss) {
var wrap = $select;
var name, DOM = {
wrap: $(wrap)
},
els = wrap[0].getElementsByTagName("*"),
elsLen = els.length;
for (var i = 0; i < elsLen; i++) {
name = els[i].className;
if (name.indexOf(classCss) > -1) {
name = name.split(classCss)[1];
}
if (name) {
DOM[name] = $(els[i], wrap)
}
}
return DOM
},
}
__self.dom.wrap.show().addClass("fade in");
__self.dom.backdrop.show().addClass("fade in");
__self.open = true;
return __self;
};
toast.prototype.close = function() {
var __self = this,
_o = __self.options;
toast._through = function() {
var __self = this,
_o = __self.options;
var api = new toast(arguments[0]);
return api;
if (!__self.destroyed && __self.open) {
__self.dom.wrap.removeClass('in');
setTimeout(function() {
__self.dom.wrap.hide();
__self.dom.backdrop.hide();
__self.remove();
__self.open = false;
}, 200);
}
return this;
};
toast.prototype.remove = function() {
var __self = this,
_o = __self.options;
if (__self.destroyed) {
return g;
}
if (__self.current === this)
__self.current = null;
__self.dom.wrap.remove();
__self.dom.backdrop.remove();
for (var i in __self) {
delete this[i];
}
return this;
};
toast.prototype._trigger = function(id) {
var __self = this,
_o = __self.options;
var fn = __self.callbacks[id];
return typeof fn !== 'function' || fn.call(__self) !== false ?
__self.close() : __self;
};
toast.prototype._click = function(name) {
var __self = this,
_o = __self.options;
var fn = __self.callbacks[name];
return typeof fn !== 'function' || fn.call(__self, window) !== false ?
__self.close() : __self;
};
toast.prototype.__dom = function($select, classCss) {
var wrap = $select;
var name, DOM = {
wrap: $(wrap)
},
els = wrap[0].getElementsByTagName("*"),
elsLen = els.length;
for (var i = 0; i < elsLen; i++) {
name = els[i].className;
if (name.indexOf(classCss) > -1) {
name = name.split(classCss)[1];
}
if (name) {
DOM[name] = $(els[i], wrap)
}
}
return DOM
};
toast._through = function() {
var __self = this,
_o = __self.options;
var api = new toast(arguments[0]);
return api;
};
toast.alert = function(content, callback) {
var __self = this,
_o = __self.options;
... ... @@ -236,7 +239,7 @@ toast.alert = function(content, callback) {
content: content,
ok: callback || true
});
}
};
toast.confirm = function(title, content, yes, no) {
var __self = this,
_o = __self.options;
... ... @@ -258,8 +261,10 @@ toast.confirm = function(title, content, yes, no) {
toast.load = function() {
var __self = this,
_o = __self.options;
return __self._through({
addClass: 'load'
addClass: 'load',
template: ''
});
};
toast.tip = function(content, time) {
... ... @@ -275,9 +280,10 @@ toast.tip = function(content, time) {
}
toast.close = function() {
// var __self = this, _o = __self.options;
// var _api = __self.top().me.get(window.frameElement.name);
// _api.close();
/*var __self = this,
_o = __self.options;
var _api = __self.top().me.get(window.frameElement.name);
_api.close();*/
}
toast.defaults = {
init: null,
... ...
... ... @@ -283,7 +283,7 @@ grid.prototype = {
} else {
content = value;
}
if (content || content == 0) {
if (content || typeof(content) == 'number') {
return content;
} else {
return '';
... ...
var $=require('jquery');
var $ = require('jquery');
$.fn.ajaxfileupload = function(options) {
var settings = {
params: {},
action: '',
onStart: function() { },
onComplete: function(response) { },
onCancel: function() { },
validate_extensions : true,
valid_extensions : ['gif','png','jpg','jpeg'],
submit_button : null
};
var settings = {
params: {},
action: '',
onStart: function() {},
onComplete: function(response) {},
onCancel: function() {},
validate_extensions: true,
valid_extensions: ['gif', 'png', 'jpg', 'jpeg'],
submit_button: null
};
var uploading_file = false;
var uploading_file = false;
if ( options ) {
$.extend( settings, options );
}
if (options) {
$.extend(settings, options);
}
return this.each(function() {
var $element = $(this);
if($element.data('ajaxUploader-setup') === true) return;
return this.each(function() {
var $element = $(this);
if ($element.data('ajaxUploader-setup') === true) return;
//
var ext=$element.attr("extend")
if(ext){
settings.valid_extensions=ext.split(',');
}
console.log(settings);
$element.change(function()
{
uploading_file = false;
if (settings.submit_button == null)
{
upload_file();
}
});
//
var ext = $element.attr("extend")
if (ext) {
settings.valid_extensions = ext.split(',');
}
$element.change(function() {
uploading_file = false;
if (settings.submit_button == null) {
upload_file();
}
});
if (settings.submit_button == null)
{
} else
{
settings.submit_button.click(function(e)
{
e.preventDefault();
if (!uploading_file)
{
upload_file();
}
});
}
if (settings.submit_button == null) {} else {
settings.submit_button.click(function(e) {
e.preventDefault();
if (!uploading_file) {
upload_file();
}
});
}
var upload_file = function()
{
if($element.val() == '') return settings.onCancel.apply($element, [settings.params]);
var upload_file = function() {
if ($element.val() == '') return settings.onCancel.apply($element, [settings.params]);
var ext = $element.val().split('.').pop().toLowerCase();
console.log(settings.validate_extensions);
if(true === settings.validate_extensions && $.inArray(ext, settings.valid_extensions) == -1)
{
settings.onComplete.apply($element, [{status: false, message: '文件类型无效.只支持'+settings.valid_extensions.join(',')}, settings.params]);
} else
{
uploading_file = true;
wrapElement($element);
var ret = settings.onStart.apply($element, [settings.params]);
if(ret !== false)
{
$element.parent('form').submit(function(e) { e.stopPropagation(); }).submit();
}
}
};
$element.data('ajaxUploader-setup', true);
var handleResponse = function(loadedFrame, element) {
var response, responseStr = $(loadedFrame).contents().text();
try {
response = JSON.parse(responseStr);
} catch(e) {
response = responseStr;
}
element.siblings().remove();
element.unwrap();
var ext = $element.val().split('.').pop().toLowerCase();
console.log(settings.validate_extensions);
if (true === settings.validate_extensions && $.inArray(ext, settings.valid_extensions) == -1) {
settings.onComplete.apply($element, [{
status: false,
message: '文件类型无效.只支持' + settings.valid_extensions.join(',')
}, settings.params]);
} else {
uploading_file = true;
wrapElement($element);
var ret = settings.onStart.apply($element, [settings.params]);
if (ret !== false) {
$element.parent('form').submit(function(e) {
e.stopPropagation();
}).submit();
}
}
};
$element.data('ajaxUploader-setup', true);
var handleResponse = function(loadedFrame, element) {
var response, responseStr = $(loadedFrame).contents().text();
try {
response = JSON.parse(responseStr);
} catch (e) {
response = responseStr;
}
element.siblings().remove();
element.unwrap();
uploading_file = false;
uploading_file = false;
settings.onComplete.apply(element, [response, settings.params]);
var _$element=$element.clone();
var _$parent=$element.parent();
$element.remove();
_$parent.append(_$element);
_$element.ajaxfileupload(settings);
};
var wrapElement = function(element) {
var frame_id = 'ajaxUploader-iframe-' + Math.round(new Date().getTime() / 1000)
$('body').after('<iframe width="0" height="0" style="display:none;" name="'+frame_id+'" id="'+frame_id+'"/>');
$('#'+frame_id).get(0).onload = function() {
handleResponse(this, element);
};
element.wrap(function() {
return '<form action="' + settings.action + '" method="POST" enctype="multipart/form-data" target="'+frame_id+'" />'
})
.before(function() {
var key, html = '';
for(key in settings.params) {
var paramVal = settings.params[key];
if (typeof paramVal === 'function') {
paramVal = paramVal();
}
html += '<input type="hidden" name="' + key + '" value="' + paramVal + '" />';
}
html+='<input type="hidden" name="filename" value="' + $element.attr("name") + '" />'
return html;
});
settings.onComplete.apply(element, [response, settings.params]);
var _$element = $element.clone();
var _$parent = $element.parent();
$element.remove();
_$parent.append(_$element);
_$element.ajaxfileupload(settings);
};
var wrapElement = function(element) {
var frame_id = 'ajaxUploader-iframe-' + Math.round(new Date().getTime() / 1000)
$('body').after('<iframe width="0" height="0" style="display:none;" name="' + frame_id + '" id="' + frame_id + '"/>');
$('#' + frame_id).get(0).onload = function() {
handleResponse(this, element);
};
element.wrap(function() {
return '<form action="' + settings.action + '" method="POST" enctype="multipart/form-data" target="' + frame_id + '" />'
})
.before(function() {
var key, html = '';
for (key in settings.params) {
var paramVal = settings.params[key];
if (typeof paramVal === 'function') {
paramVal = paramVal();
}
html += '<input type="hidden" name="' + key + '" value="' + paramVal + '" />';
}
html += '<input type="hidden" name="filename" value="' + $element.attr("name") + '" />'
return html;
});
}
}
});
}
module.exports=$;
\ No newline at end of file
module.exports = $;
\ No newline at end of file
... ...
... ... @@ -56,6 +56,8 @@ var g = new common.grid({
var html = '';
if (item.updateUserName) {
html += '<p>' + item.updateUserName + '</p>';
} else if (item.addUserName) {
html += '<p>' + item.addUserName + '</p>';
}
if (item.updateTime) {
... ... @@ -108,6 +110,7 @@ $('#basicTable').on('click', '.cooperate-type', function() {
});
});
//筛选
$("#filter-btn").click(function() {
g.reload(1);
... ... @@ -138,21 +141,19 @@ $('#import-btn').on('click', function() {
$(' #sure-change, .priceTable-wrap').hide();
/*common.dialog.load();*/
$('#upload-input').after('<div class="file-name btn btn-default">请选择文件</div>');
var loadModal = null;
common.edit.ajaxfileupload("#upload-input", {
params: {
type: "brandCooperation",
__type: "batch-import"
},
onStart: function() {
$('.load-modal').show();
loadModal = common.dialog.load();
$('.file-name').text($('#upload-input').val().replace("C:\\fakepath\\", ""));
},
onComplete: function(response) {
console.log(response);
$('.load-modal').hide();
loadModal.close();
if (response.code == 200) {
var li = '';
... ...
... ... @@ -132,6 +132,7 @@ var g = new common.grid({
g.init($("#gridurl").val());
//单个变价
$('#basicTable').on('click', '.modify-btn', function() {
var skn = $(this).data('skn'),
that = this;
... ... @@ -151,7 +152,6 @@ $('#basicTable').on('click', '.modify-btn', function() {
}).then(function(res) {
var data = res.data.data;
$(that).data('detail', true).parents('tr')
.after($(common.util.__template($("#template").html(), data)))
.next('.product-detail').find('.skn-value').text(skn);
... ... @@ -169,41 +169,24 @@ $('#basicTable').on('click', '.modify-btn', function() {
function vipPrice() {
var price = $price.val(),
vipPrice = {
vip1: price * 0.95,
vip2: price * 0.9,
vip3: price * 0.88,
},
selectVal = $select.val();
if (selectVal == 5) {
vipPrice = $vipPrice.val(),
selectVal = $select.val() - 1,
priceArr = [];
priceArr.push([vipPrice * 0.95, vipPrice * 0.9, vipPrice * 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);
$vip2Price.attr('disabled', true);
$vip3Price.attr('disabled', true);
}
if (selectVal == 1) {
$vip1Price.val(vipPrice.vip1.toFixed(2));
$vip2Price.val(vipPrice.vip2.toFixed(2));
$vip3Price.val(vipPrice.vip3.toFixed(2));
} else if (selectVal == 2) {
$vip1Price.val(price * 0.95);
$vip2Price.val(price * 0.95);
$vip3Price.val(price * 0.95);
} else if (selectVal == 3) {
$vip1Price.val($price.val());
$vip2Price.val($price.val());
$vip3Price.val($price.val());
} else if (selectVal == 4) {
$vip1Price.val($vipPrice.val());
$vip2Price.val($vipPrice.val());
$vip3Price.val($vipPrice.val());
$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));
}
}
vipPrice();
... ... @@ -262,15 +245,15 @@ $("#all-btn").click(function() {
//批量导入按钮点击事件
$('#import-btn').on('click', function() {
if ($('#basicTable').css('display') == 'none') {
g.reload();
location.reload();
}
$('#basicTable, .bulk-import').toggle();
});
//upload-input
//批量导入
var successList = null,
$error = $('#error-msg');
$error = $('#error-msg'),
loadModal = null;
$('#upload-input').after('<div class="file-name btn btn-default">请选择文件</div>');
common.edit.ajaxfileupload("#upload-input", {
params: {
... ... @@ -278,12 +261,12 @@ common.edit.ajaxfileupload("#upload-input", {
__type: "batch-import"
},
onStart: function() {
$('.load-modal').show();
loadModal = common.dialog.load();
$('.file-name').text($('#upload-input').val().replace("C:\\fakepath\\", ""));
},
onComplete: function(response) {
console.log(response);
$('.load-modal').hide();
loadModal.close();
if (response.code == 200) {
var data = response.data,
li = '';
... ... @@ -402,6 +385,7 @@ var p = new common.grid({
}]
});
//全部删除按钮
$('#delete-all').on('click', function() {
$('#priceTable').empty();
$error.empty();
... ... @@ -419,7 +403,8 @@ $('#priceTable').on('click', '.delete-btn', function() {
});
var path = '';
//确定变价
var path = ''; //确定变价后返回的excel名
$('#sure-change').on('click', function() {
var arr = [],
data = '';
... ... @@ -441,24 +426,12 @@ $('#sure-change').on('click', function() {
batchList: data
}
}, function(res) {
console.log(res);
$('#priceTable').hide();
$('.success-wrap').show();
path = res.data;
//$('#download-btn').attr('href', )
});
});
$('#download-btn').on('click', function() {
console.log(path);
/*common.util.__ajax({
url:'/goods/batch/download',
data:{
path: path
}
},function(res){
console.log(res);
//$('#download-btn').attr('href', )
});*/
location.href = $(this).data('domain') + '/batch/download?path=' + path;
});
\ No newline at end of file
... ...
... ... @@ -137,15 +137,21 @@ $('.limit-add-btn').click(function(option) {
}*/
option.data.saleTime = saleTime.getTime() / 1000;
console.log(option.data);
option.beforeSend = function() {
$('#limit-add-btn').addClass('disabled');
};
option.success = function(res) {
res = res.data;
if (res.code == "200") {
e.$tip('提交成功', function() {
location.href = "/limit/product/index";
}, 'growl-success');
} else {
$('#limit-add-btn').removeClass('disabled');
e.$tip(res.message);
}
return false;
}
option.error = function(res) {
... ...
... ... @@ -164,16 +164,8 @@
background: url(../images/excel.png) no-repeat left center;
}
.load-modal {
display: none;
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
.load {
background-image: url(../images/loading.gif);
background-color: rgba(0,0,0,0.4);
background-repeat: no-repeat;
background-position: center center;
z-index: 999;
}
\ No newline at end of file
... ...
... ... @@ -13,7 +13,7 @@ var config = {
redis: null,
apiKey: 'sd4H1ecAqlp',
domain: 'http://192.168.102.202:8088/platform',
domain: 'http://192.168.102.214:8081/platform',
loggers: {
api: {
level: 'verbose',
... ...
exports.domain = require('../config/common.js').domain;
// exports.domain = 'http://192.168.102.218:8088/platform'; //变价
//exports.domain = 'http://192.168.102.218:8088/platform'; //变价
//exports.domain = 'http://172.16.6.162:8088/platform'; //品牌合作
//商品管理路由配置
... ...
... ... @@ -194,8 +194,6 @@
</div>
</div>
<div class="load-modal"></div>
<input type="hidden" id="btnAuthority" value="{{bottons}}">
<input type="hidden" id="gridurl" value="{{gridurl}}">
... ...