tplus-pos
Version:
pos module
98 lines (86 loc) • 4.16 kB
JavaScript
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.formatNumber = undefined;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _tplusComponentsTouch = require('tplus-components-touch');
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var defaultImgURL = 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9Ii0xMS41IC0xMC4yMzE3NCAyMyAyMC40NjM0OCI+CiAgPHRpdGxlPlJlYWN0IExvZ288L3RpdGxlPgogIDxjaXJjbGUgY3g9IjAiIGN5PSIwIiByPSIyLjA1IiBmaWxsPSIjNjFkYWZiIi8+CiAgPGcgc3Ryb2tlPSIjNjFkYWZiIiBzdHJva2Utd2lkdGg9IjEiIGZpbGw9Im5vbmUiPgogICAgPGVsbGlwc2Ugcng9IjExIiByeT0iNC4yIi8+CiAgICA8ZWxsaXBzZSByeD0iMTEiIHJ5PSI0LjIiIHRyYW5zZm9ybT0icm90YXRlKDYwKSIvPgogICAgPGVsbGlwc2Ugcng9IjExIiByeT0iNC4yIiB0cmFuc2Zvcm09InJvdGF0ZSgxMjApIi8+CiAgPC9nPgo8L3N2Zz4K';
var formatNumber = exports.formatNumber = function formatNumber(number, length) {
if (number === '' || number === undefined || number === null) {
number = 0;
}
number += '';
if (length == 0) {
return parseInt(number);
}
if (number.indexOf('.') > 0) {
number += '0000000000';
} else {
number += '.0000000000';
}
return number.substring(0, number.indexOf(".") + +length + 1);
};
exports.default = function (_ref) {
var item = _ref.item,
click = _ref.click,
_ref$type = _ref.type,
type = _ref$type === undefined ? 'small' : _ref$type,
_ref$configure = _ref.configure,
configure = _ref$configure === undefined ? { img: true, name: true, code: true, price: true } : _ref$configure,
pricePrecision = _ref.pricePrecision;
var imgSuffix = {
small: '?x-oss-process=image/resize,l_76',
middle: '?x-oss-process=image/resize,l_96',
big: '?x-oss-process=image/resize,l_150'
};
click = click || function () {};
var imgUrl = item.ImageFile || '';
imgUrl = imgUrl.split(';')[0] ? imgUrl.split(';')[0] : '';
var defaultDom = document.createElement("div");
defaultDom.style.background = "#FF595E";
return _react2.default.createElement(
'div',
{ className: 'detail ' + ('detail-' + type), onClick: function onClick(e) {
var dom = imgUrl ? e.currentTarget.children[0] : defaultDom;
var isDefault = imgUrl ? false : true;
click(item, e.clientX, e.clientY, dom, isDefault);
}, key: item.Id },
configure.img ? imgUrl ? _react2.default.createElement('div', { className: 'detail-img', style: { backgroundImage: 'url(' + imgUrl + imgSuffix[type] + ')',
backgroundSize: 'contain',
backgroundPosition: 'center',
backgroundColor: 'rgba(200,200,200,.1)',
backgroundRepeat: 'no-repeat' } }) : _react2.default.createElement(
'div',
{ className: 'detail-img', style: { backgroundColor: 'rgba(255,140,37,.2)' } },
_react2.default.createElement(_tplusComponentsTouch.Ticon, { type: 'tupian', style: { color: 'rgba(254,194,145)' }, className: 'default-img' })
) : null,
_react2.default.createElement(
'div',
{ className: '' + (configure.img ? '' : 'detail-content-box') },
configure.name ? _react2.default.createElement(
'div',
{ className: 'detail-name text-2line-overflow ' + (configure.img ? 'marginTop10' : '') },
item.Name
) : null,
configure.code ? _react2.default.createElement(
'div',
{ className: 'detail-code text-1line-overflow' },
item.Code
) : null,
configure.specification ? _react2.default.createElement(
'div',
{ className: 'detail-specification ' + (type == 'big' ? 'text-1line-overflow detail-specification-big' : 'text-2line-overflow detail-specification-small') + ' ' + (configure.img ? 'detail-specification-withimg' : '') },
item.Specification
) : null,
configure.price ? _react2.default.createElement(
'div',
{ className: 'detail-price text-1line-overflow' },
pricePrecision && item.RetailPrice ? formatNumber(item.RetailPrice, pricePrecision) : item.RetailPrice
) : null
)
);
};
//# sourceMappingURL=detail.js.map