nimble-ui
Version:
107 lines (105 loc) • 3.35 kB
JavaScript
import { callFn, extend } from 'nimble-lib';
import { PopupBase } from '../popup/PopupBase';
import Service from '../services';
export class Keyboard extends Service {
name = 'Keyboard';
constructor(Vue, options) {
super(options);
let _that = this;
_that.setDefaultOptions(options);
_that._popup = new PopupBase(Vue, _that.defaultOption);
_that._popup._getParent = () => {
return _that._getParent && _that._getParent();
};
}
/**
* 车型keyboard弹框
* @param {Object} params 键盘选项
* @param {Object} options 弹框选项
* @returns {*}
*/
carKeyboard(params, options) {
let _that = this;
params = params || {};
let param = [
['港', '澳', '学', '警', '领'],
{
list: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'],
className: 'nus_keyboard-split'
},
['Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O'],
['A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'P'],
['Z', 'X', 'C', 'V', 'B', 'N', 'M', 'L', {
isDel: true,
isPopUnable: true,
text: '\ue617',
styleName: {fontSize: '25px'}
}]
];
if (params.type === 'pre') { // 前缀
param = [
['京', '沪', '浙', '苏', '粤', '鲁', '晋', '冀', '豫'],
['川', '渝', '辽', '吉', '黑', '皖', '鄂', '湘', '赣'],
['闽', '陕', '甘', '宁', '蒙', '津', '贵', '云', '桂'],
['琼', '青', '新', '藏', '港', '澳']
];
}
return _that.keyboard(extend({
list: param,
themeType: 'confirmbars'
}, params), options);
}
/**
* keyboard弹框
* @param {Object} param 键盘参数
* @param {Object} options 弹框选项
* @returns {*}
*/
keyboard(param, options) {
let _that = this;
_that.inputBlur();
let _options = _that.getOptions({
key: 'Keyboard',
// wrapCla: '', // 最外层追加的Class名
alignCla: 'bottom', // ''|'bottom'|'top'|'fullScreen'|'centerMiddle',
transitionCls: 'toUp', // ''|toUp|scale|toBottom|toLeft;
maskCloseFlag: 0,
maskFlag: -1
}, options, {
props: param
});
_options.wrapCla = (_options.wrapCla || '') + ' nu_Keyboard';
if (param.type === 'close') {
_that._popup.closePopup(_options.key);
return;
}
return _that._popup.popupData(() => {
return callFn(_options.getComponent, ['keyboard']);
}, _options);
}
/**
* 安装
*
* @param {Vue} Vue Vue
* @param {Object} options 选项
* @memberof Service
* @returns {Object}
*/
install(Vue, options) {
let _that = this;
super.install(Vue, options);
_that._popup && _that._popup._setSPopup(Vue);
return _that;
}
}
/**
*
* 实例化工厂方法
* @export
* @param {Vue} Vue vue
* @param {any} options 配置选项
* @returns {keyboardFactory}
*/
export default function keyboardFactory(Vue, options) {
return new Keyboard(Vue, options);
}