import $dialog from "../$dialog"; import ImageSelector, {iImageSelectOption} from "../ImageSelector"; import {iDialogServiceOption} from "../useDialog/dialog.service.utils"; import $message from "../$message"; import i18n from "../i18n"; export const $imageSelector = ( { selectOptions, selectValue, dialogServiceOption, handleConfirm, title, aspectRatio, imageFit, imagePosition, }: { title?: string, selectOptions: iImageSelectOption[], selectValue?: any, dialogServiceOption?: iDialogServiceOption, handleConfirm?: (selectValue: string, selectOption: iImageSelectOption) => void | boolean | Promise, aspectRatio?: string, imageFit?: string, imagePosition?: string, } ) => { const _handleConfirm = async () => { if (!selectValue) { $message.error(i18n.$it('base.pleaseSelect').d('请选择')); return false; } const flag = await handleConfirm?.(selectValue, selectOptions.find(i => i.val === selectValue)!); if (flag !== false) {close();} }; const close = $dialog({ title, width: 800, render: () => selectValue = val} selectOptions={selectOptions} aspectRatio={aspectRatio} onDoubleClickOption={() => {_handleConfirm();}} />, confirmButton: true, cancelButton: true, handleConfirm: () => { _handleConfirm(); return false; }, ...dialogServiceOption, }); };