UNPKG

@cainiaofe/cn-ui-m-lowcode

Version:
147 lines (145 loc) 4.2 kB
import { handleComponentTitle, handleI18nLabel } from '@/common/util/util'; import { getItemListByPosition } from '@/common/manager/filter-item'; import { getJSExpressionPrototype } from '@/common/manager/common-style'; import { DisplayPosition } from '@/type/display-position'; export function getDialogBasePrototype(config) { const { position } = config || {}; const titleSetter = [ { componentName: 'CnI18nSetter', title: '纯文本', }, { componentName: 'SelectSetter', props: () => { return { showSearch: true, options: getItemListByPosition({ position: DisplayPosition.dialogTitle, }), }; }, title: '选择业务组件', }, ]; if ([DisplayPosition.formDialog, DisplayPosition.dialog].includes(position)) { titleSetter.push(getJSExpressionPrototype({ type: 'formDialogTitle' })); } return [ { name: 'isCnDialog', title: 'cnDialog', initialValue: true, display: 'none', }, { name: 'dialogProps', title: '弹窗配置', type: 'group', display: 'accordion', items: [ { name: 'title', title: '弹窗标题', display: 'inline', setter: { componentName: 'MixedSetter', props: { setters: titleSetter, }, }, initialValue: '标题', // supportVariable: true, mutator(value) { let name = '弹窗'; const isCnFormDialog = this?.getNode?.().getPropValue?.('isCnFormDialog'); const title = handleI18nLabel(value || ''); if (isCnFormDialog) { name = '表单弹窗'; } this?.setExtraPropValue?.( 'title', `${name}_${handleComponentTitle(title)}`, ); }, }, { name: 'dialogMode', title: '展示样式', display: 'inline', initialValue: 'dialog', setter: { componentName: 'RadioGroupSetter', props: { options: [ { title: '弹窗', value: 'dialog', }, { title: '抽屉', value: 'drawer', }, ], }, }, // supportVariable: true, }, // { // name: 'size', // title: '弹窗大小', // display: 'inline', // initialValue: 'medium', // setter: { // componentName: 'RadioGroupSetter', // props: { // options: [ // { title: '大', value: 'large' }, // { title: '中', value: 'medium' }, // { title: '小', value: 'small' }, // ], // }, // }, // // supportVariable: true, // }, // { // name: 'hasMask', // title: '是否显示遮罩', // display: 'inline', // initialValue: true, // setter: 'BoolSetter', // }, // cn-ui-m层不支持 // { // name: 'closeMode', // tip: '不选就默认行为', // title: '关闭方式', // display: 'inline', // supportVariable: true, // setter: { // componentName: 'SelectSetter', // props: { // mode: 'multiple', // hasClear: true, // options: [ // { title: '遮罩层', value: 'mask' }, // { title: '关闭按钮', value: 'close' }, // { title: '只能按钮关闭(选了其他不生效)', value: 'cancel' }, // ], // }, // // supportVariable: true, // }, // mutator(value) { // if (isEmpty(value)) { // this?.setPropValue?.( // 'closeMode', // undefined, // ); // } // }, // }, ], }, ]; }