nsn-comp
Version:
NSN核心组件
87 lines (72 loc) • 3.99 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
require("antd/lib/tree-select/style");
var _treeSelect = _interopRequireDefault(require("antd/lib/tree-select"));
var _nsnUtil = require("nsn-util");
var _react = _interopRequireDefault(require("react"));
var _util = require("./_util");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
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; }
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
var FormItemTreeSelect = function FormItemTreeSelect(props) {
var config = props.config,
dataIndex = props.item.dataIndex,
form = props.form,
defaultValue = props.defaultValue,
treeDataSimpleMode = props.treeDataSimpleMode,
_props$showSearch = props.showSearch,
showSearch = _props$showSearch === void 0 ? true : _props$showSearch,
_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,
_props$dropdownStyle = props.dropdownStyle,
dropdownStyle = _props$dropdownStyle === void 0 ? {
maxHeight: 400,
overflow: 'auto'
} : _props$dropdownStyle,
_props$treeDefaultExp = props.treeDefaultExpandAll,
treeDefaultExpandAll = _props$treeDefaultExp === void 0 ? false : _props$treeDefaultExp,
_props$placeholder = props.placeholder,
placeholder = _props$placeholder === void 0 ? _nsnUtil.NLocale.getText('common.placeholder.select') : _props$placeholder,
restProps = _objectWithoutProperties(props, ["config", "item", "form", "defaultValue", "treeDataSimpleMode", "showSearch", "allowClear", "style", "dropdownStyle", "treeDefaultExpandAll", "placeholder"]);
var records = restProps.records;
var treeData = treeDataSimpleMode ? (0, _util.transformData)(restProps) : records;
return _react.default.createElement(_treeSelect.default, Object.assign({}, {
showSearch: showSearch,
style: style,
dropdownStyle: dropdownStyle,
allowClear: allowClear,
treeDefaultExpandAll: treeDefaultExpandAll,
placeholder: placeholder
}, {
defaultValue: _nsnUtil.NStr.isTrimEmpty("".concat(defaultValue)) ? undefined : defaultValue,
value: _nsnUtil.NStr.isTrimEmpty(config.value) ? undefined : config.value,
onChange: function onChange(value) {
var _config$onChange;
if (dataIndex) {
form.setFieldsValue(_defineProperty({}, "".concat(dataIndex), value));
}
(_config$onChange = config.onChange) === null || _config$onChange === void 0 ? void 0 : _config$onChange.call(config, value);
},
treeLine: true,
treeIcon: false,
suffixIcon: false,
treeNodeFilterProp: "title",
treeNodeLabelProp: "title",
treeDataSimpleMode: treeDataSimpleMode || {
id: 'id',
pId: 'parentId'
}
}, {
treeData: treeData
}));
};
var _default = FormItemTreeSelect;
exports.default = _default;