UNPKG

nsn-comp

Version:

NSN核心组件

64 lines (56 loc) 2.08 kB
import "antd/es/input/style"; import _Input from "antd/es/input"; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } import { debounce } from "lodash"; import { NConst } from 'nsn-const'; import { NStr } from "nsn-util"; import React from 'react'; /** * 拼音首字母填充 */ var FormItemPinyinFirstLetters = function FormItemPinyinFirstLetters(props) { var config = props.config, form = props.form, dataIndex = props.item.dataIndex, defaultValue = props.defaultValue, _props$allowClear = props.allowClear, allowClear = _props$allowClear === void 0 ? true : _props$allowClear, _props$style = props.style, style = _props$style === void 0 ? { width: '100%' } : _props$style, comp = props.comp, targetDataIndex = props.targetDataIndex; return React.createElement(_Input, Object.assign({}, { allowClear: allowClear, style: style }, { defaultValue: NStr.isTrimEmpty("".concat(defaultValue)) ? undefined : defaultValue, value: config.value, onChange: function onChange(event) { var value = event.currentTarget.value; if (dataIndex) { form.setFieldsValue(_defineProperty({}, "".concat(dataIndex), value)); } debounce(function () { var dispatch = comp.props.dispatch; if (dispatch) { dispatch({ type: 'common/pinyin_first_letters', payload: { chinese: value !== null && value !== void 0 ? value : NConst.EMPTY }, callback: function callback(_ref) { var success = _ref.success, data = _ref.data; if (success) { form === null || form === void 0 ? void 0 : form.setFieldsValue(_defineProperty({}, targetDataIndex, data)); } } }); } }, 500)(); } })); }; export default FormItemPinyinFirstLetters;