fix(amis-editor): 容器类组件/定位模式切换成特殊布局后设置默认层级,避免被遮挡导致不能选中

This commit is contained in:
wibetter 2023-11-03 17:06:18 +08:00
parent 87d365fab2
commit 5510ac89a2

View File

@ -53,20 +53,22 @@ setSchemaTpl(
pipeOut: config?.pipeOut,
onChange: (value: string, oldValue: string, model: any, form: any) => {
if (value === 'static') {
form.setValueByName('style.inset', undefined);
form.setValueByName('style.zIndex', undefined);
form.setValueByName('originPosition', undefined);
form.deleteValueByName('style.inset');
form.deleteValueByName('style.zIndex');
form.deleteValueByName('originPosition');
} else if (value === 'fixed' || value === 'absolute') {
// 默认使用右下角进行相对定位
form.setValueByName('style.zIndex', 1); // 避免被页面其他内容元素遮挡(导致不能选中)
form.setValueByName('style.inset', 'auto 50px 50px auto');
// 默认使用右下角进行相对定位
form.setValueByName('originPosition', 'right-bottom');
} else if (value === 'relative') {
form.setValueByName('style.zIndex', 1);
form.setValueByName('style.inset', 'auto');
form.setValueByName('originPosition', undefined);
form.deleteValueByName('originPosition');
}
if (value !== 'sticky') {
// 非滚动吸附定位
form.setValueByName('stickyStatus', undefined);
form.deleteValueByName('stickyStatus');
}
},
options: [
@ -273,10 +275,10 @@ setSchemaTpl(
pipeOut: config?.pipeOut,
onChange: (value: string, oldValue: string, model: any, form: any) => {
if (value !== 'flex' && value !== 'inline-flex') {
form.setValueByName('style.flexDirection', undefined);
form.setValueByName('style.justifyContent', undefined);
form.setValueByName('style.alignItems', undefined);
form.setValueByName('style.flexWrap', undefined);
form.deleteValueByName('style.flexDirection');
form.deleteValueByName('style.justifyContent');
form.deleteValueByName('style.alignItems');
form.deleteValueByName('style.flexWrap');
}
}
};
@ -582,33 +584,33 @@ setSchemaTpl(
// 弹性
if (config?.isFlexColumnItem) {
// form.setValueByName('style.overflowY', 'auto');
form.setValueByName('style.height', undefined);
form.deleteValueByName('style.height');
} else {
// form.setValueByName('style.overflowX', 'auto');
form.setValueByName('style.width', undefined);
form.deleteValueByName('style.width');
}
} else if (value === '0 0 150px') {
// 固定
form.setValueByName('style.flexGrow', undefined);
form.deleteValueByName('style.flexGrow');
form.setValueByName('style.flexBasis', '150px');
if (config?.isFlexColumnItem) {
form.setValueByName('style.height', undefined);
form.deleteValueByName('style.height');
} else {
form.setValueByName('style.width', undefined);
form.deleteValueByName('style.width');
}
} else if (value === '0 0 auto') {
// 适配
form.setValueByName('style.flexGrow', undefined);
form.setValueByName('style.flexBasis', undefined);
form.setValueByName('style.overflowX', undefined);
form.setValueByName('style.overflowY', undefined);
form.setValueByName('style.overflow', undefined);
form.deleteValueByName('style.flexGrow');
form.deleteValueByName('style.flexBasis');
form.deleteValueByName('style.overflowX');
form.deleteValueByName('style.overflowY');
form.deleteValueByName('style.overflow');
if (config?.isFlexColumnItem) {
form.setValueByName('style.height', undefined);
form.deleteValueByName('style.height');
} else {
form.setValueByName('style.width', undefined);
form.deleteValueByName('style.width');
}
}
}
@ -719,11 +721,11 @@ setSchemaTpl(
onChange: (value: boolean, oldValue: boolean, model: any, form: any) => {
if (value) {
// 固定宽度时,剔除最大宽度、最小宽度
form.setValueByName('style.maxWidth', undefined);
form.setValueByName('style.minWidth', undefined);
form.deleteValueByName('style.maxWidth');
form.deleteValueByName('style.minWidth');
} else {
// 非固定宽度时,剔除宽度数值
form.setValueByName('style.width', undefined);
form.deleteValueByName('style.width');
}
if (config?.onChange) {
config.onChange(value);
@ -959,11 +961,11 @@ setSchemaTpl(
onChange: (value: boolean, oldValue: boolean, model: any, form: any) => {
if (value) {
// 固定高度时,剔除最大高度、最小高度
form.setValueByName('style.maxHeight', undefined);
form.setValueByName('style.minHeight', undefined);
form.deleteValueByName('style.maxHeight');
form.deleteValueByName('style.minHeight');
} else {
// 非固定高度时,剔除高度数值
form.setValueByName('style.height', undefined);
form.deleteValueByName('style.height');
}
if (config?.onChange) {
config.onChange(value);
@ -1199,7 +1201,7 @@ setSchemaTpl(
} else {
form.setValueByName('style.inset', 'auto 0px auto auto');
}
form.setValueByName('style.transform', undefined);
form.deleteValueByName('style.transform');
} else {
// 靠左
if (form.data?.sorptionPosition === 'top') {
@ -1211,11 +1213,11 @@ setSchemaTpl(
} else {
form.setValueByName('style.inset', 'auto auto auto 0px');
}
form.setValueByName('style.transform', undefined);
form.deleteValueByName('style.transform');
}
} else {
// 靠左
form.setValueByName('style.transform', undefined);
form.deleteValueByName('style.transform');
}
}
};
@ -1342,8 +1344,8 @@ setSchemaTpl('layout:sticky', {
form.setValueByName('style.zIndex', 10);
} else {
form.setValueByName('style.position', 'static');
form.setValueByName('style.inset', undefined);
form.setValueByName('style.zIndex', undefined);
form.deleteValueByName('style.inset');
form.deleteValueByName('style.zIndex');
}
}
});