vxe-design
Version:
A PC-based visual designer based on Vxe UI, used for building zero-code and low-code platforms
60 lines (59 loc) • 2.3 kB
JavaScript
import { h, inject } from 'vue';
import { defineVxeComponent } from '../../ui/src/comp';
import { VxeUI } from '@vxe-ui/core';
import { useWidgetName } from '../../form-design/src/use';
export const WidgetVxeUploadImageViewComponent = defineVxeComponent({
props: {
renderOpts: {
type: Object,
default: () => ({})
},
renderParams: {
type: Object,
default: () => ({})
}
},
emits: [],
setup(props) {
const VxeUIFormItemComponent = VxeUI.getComponent('vxe-form-item');
const VxeUIUploadComponent = VxeUI.getComponent('vxe-upload');
const $xeFormView = inject('$xeFormView', null);
const { computeKebabCaseName } = 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 h(VxeUIFormItemComponent, {
class: ['vxe-form-design--widget-render-form-item', `widget-${kebabCaseName}`],
title: widget.title,
field: widget.field,
itemRender: {}
}, {
default() {
return h(VxeUIUploadComponent, {
modelValue: $xeFormView ? $xeFormView.getItemValue(widget) : null,
mode: 'image',
multiple: options.multiple,
limitCount: options.limitCount,
limitSize: options.limitSize,
onChange: changeEvent,
'onUpdate:modelValue'(val) {
if ($xeFormView) {
$xeFormView.setItemValue(widget, val);
}
}
});
}
});
};
}
});