vxe-design
Version:
A PC-based visual designer based on Vxe UI, used for building zero-code and low-code platforms
79 lines (78 loc) • 2.28 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.WidgetVxeTreeSelectViewComponent = void 0;
var _vue = require("vue");
var _comp = require("../../ui/src/comp");
var _core = require("@vxe-ui/core");
var _use = require("../src/use");
const WidgetVxeTreeSelectViewComponent = exports.WidgetVxeTreeSelectViewComponent = (0, _comp.defineVxeComponent)({
props: {
renderOpts: {
type: Object,
default: () => ({})
},
renderParams: {
type: Object,
default: () => ({})
}
},
emits: [],
setup(props) {
const VxeUIFormItemComponent = _core.VxeUI.getComponent('vxe-form-item');
const VxeUITreeSelectComponent = _core.VxeUI.getComponent('vxe-tree-select');
const $xeFormView = (0, _vue.inject)('$xeFormView', null);
const {
computeKebabCaseName
} = (0, _use.useWidgetName)(props);
const changeEvent = () => {
const {
renderParams
} = props;
const {
widget
} = renderParams;
if ($xeFormView) {
const itemValue = $xeFormView ? $xeFormView.getItemValue(widget) : null;
$xeFormView.updateWidgetStatus(widget, itemValue);
}
};
return () => {
const {
renderParams
} = props;
const {
widget
} = renderParams;
const {
options
} = widget;
const kebabCaseName = computeKebabCaseName.value;
return (0, _vue.h)(VxeUIFormItemComponent, {
class: ['vxe-form-design--widget-render-form-item', `widget-${kebabCaseName}`],
title: widget.title,
field: widget.field,
itemRender: {}
}, {
default() {
return (0, _vue.h)(VxeUITreeSelectComponent, {
modelValue: $xeFormView ? $xeFormView.getItemValue(widget) : null,
placeholder: options.placeholder || (0, _core.getI18n)('vxe.base.pleaseSelect'),
options: options.options,
optionProps: {
label: 'value',
value: 'value'
},
onChange: changeEvent,
'onUpdate:modelValue'(val) {
if ($xeFormView) {
$xeFormView.setItemValue(widget, val);
}
}
});
}
});
};
}
});