UNPKG

tplus-pos

Version:

pos module

161 lines (138 loc) 5.68 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck'); var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); var _createClass2 = require('babel-runtime/helpers/createClass'); var _createClass3 = _interopRequireDefault(_createClass2); var _tplusPoslogin = require('tplus-poslogin'); var _tplusComponentsTouch = require('tplus-components-touch'); var _tools = require('./tools.js'); var _tools2 = _interopRequireDefault(_tools); var _Enum = require('../commom/Enum'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } var activeEl_global; var Common = function () { function Common() { (0, _classCallCheck3.default)(this, Common); } (0, _createClass3.default)(Common, null, [{ key: 'getIsTakeTheir', //获取是否自提状态 value: function getIsTakeTheir(dataModel) { var isPickUp = false; var dto = dataModel; if (dto.DistributionMode && _Enum.DistributionMode.Code_02 == dto.DistributionMode.Id + '') { isPickUp = true; } return isPickUp; } //获取是否有更新quantity的权限 }, { key: 'getIsModifyQuantityAuth', value: function getIsModifyQuantityAuth() { var functionAuth = (0, _tplusPoslogin.PosInitData)("FunctionAuth"); var isModifyQuantity = true; if (Array.isArray(functionAuth)) { isModifyQuantity = functionAuth.includes('UpdateQuantity'); } return isModifyQuantity; } //input 输入长度,位数,限制 }, { key: 'getInputLimit', value: function getInputLimit(key) { var maxLength = 8, precisionLength = 2; switch (key) { case "amount": maxLength = (0, _tplusPoslogin.PosInitData)("AmountMaxLength"); precisionLength = (0, _tplusPoslogin.PosInitData)("AmountPrecision"); break; case 'discount': maxLength = (0, _tplusPoslogin.PosInitData)("DiscountMaxLength"); precisionLength = (0, _tplusPoslogin.PosInitData)("DiscountPrecision"); break; case 'price': maxLength = (0, _tplusPoslogin.PosInitData)("PriceMaxLength"); precisionLength = (0, _tplusPoslogin.PosInitData)("PricePrecision"); break; case 'quantity': maxLength = (0, _tplusPoslogin.PosInitData)("QuantityMaxLength"); precisionLength = (0, _tplusPoslogin.PosInitData)("QuantityPrecision"); break; } return { maxLength: maxLength, precisionLength: precisionLength }; } //是否退货 }, { key: 'getIsReturn', value: function getIsReturn(dataModal) { return dataModal.IdbusiType === 35; } //打印权限 }, { key: 'getRepeatPrint', value: function getRepeatPrint() { var functionAuth = (0, _tplusPoslogin.PosInitData)('FunctionAuth'); if (Array.isArray(functionAuth)) { return functionAuth.includes('RepeatPrint'); } return true; } //dto明细 format }, { key: 'formatValue', value: function formatValue(field, value) { if (_tools2.default.isNull(value) || _tools2.default.isNull(field)) { return null; } if ('Format' in field && field.Format == 'Percent') { var key = field.Format; if (key !== null) value = value * 100 + "%"; } if (field['Precision'] && field.Precision) { var _key = field.Precision; if (_key !== null) value = _tools2.default.formatPrecision(value, _key); } if ('Format' in field && field.FieldType == 'date') { var dateFormat = field.Format; if (value instanceof String) { value = String.StringToDate(value); } if (value && value.Format) { return value.Format(dateFormat); } else { return _tplusComponentsTouch.tools.dateFormat(value, dateFormat); } } return value; } }, { key: 'activeEl', value: function activeEl(e) { // if(e.srcTargetE) console.log('elclick.e', e); if (e.srcElement.tagName == 'INPUT') return; console.log('el.click======start'); console.log('activeObject_document.activeElement:', document.activeElement); if (!activeEl_global) activeEl_global = document.querySelector(".active-el"); if (document.activeElement == activeEl_global) return; activeEl_global.focus(); console.log('activeObject', activeEl_global); console.log('activeObject_document.activeElement2:', document.activeElement); console.log('el.click======end'); } }, { key: 'setFocus', value: function setFocus(activeEl) { activeEl = activeEl || document.querySelector(".active-el"); activeEl.focus(); activeEl_global = activeEl; } }]); return Common; }(); exports.default = Common; //# sourceMappingURL=common.js.map