Skip to content

Commit

Permalink
fix(editor): 修复新增第一个显示条件时会重置表单状态
Browse files Browse the repository at this point in the history
  • Loading branch information
roymondchen committed Jul 4, 2024
1 parent 1e93e9b commit eb376b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
14 changes: 12 additions & 2 deletions packages/editor/src/fields/DisplayConds.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
:last-values="lastValues"
:prop="prop"
:size="size"
@change="changeHandler"
></MGroupList>
</template>

Expand All @@ -22,6 +23,7 @@ import {
type GroupListConfig,
MGroupList,
} from '@tmagic/form';
import type { DisplayCond } from '@tmagic/schema';
import type { Services } from '@editor/type';
import { getCascaderOptionsFromFields } from '@editor/utils';
Expand All @@ -30,6 +32,10 @@ defineOptions({
name: 'm-fields-display-conds',
});
const emit = defineEmits<{
change: [value: DisplayCond[]];
}>();
const props = withDefaults(
defineProps<
FieldProps<{
Expand Down Expand Up @@ -93,12 +99,12 @@ const config = computed<GroupListConfig>(() => ({
type: 'cond-op-select',
parentFields: parentFields.value,
label: '条件',
width: 100,
width: 160,
name: 'op',
},
{
label: '',
width: 100,
width: 160,
items: [
{
name: 'value',
Expand Down Expand Up @@ -142,4 +148,8 @@ const config = computed<GroupListConfig>(() => ({
},
],
}));
const changeHandler = (v: DisplayCond[]) => {
emit('change', v);
};
</script>
4 changes: 2 additions & 2 deletions packages/editor/src/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -774,7 +774,7 @@ export type PropsFormValueFunction = (data: { editorService: EditorService }) =>
export type PartSortableOptions = Omit<Options, 'onStart' | 'onUpdate'>;
export interface PageBarSortOptions extends PartSortableOptions {
/** 在onUpdate之后调用 */
afterUpdate?: (event: SortableEvent, sortable: Sortable) => void;
afterUpdate?: (event: SortableEvent, sortable: Sortable) => void | Promise<void>;
/** 在onStart之前调用 */
beforeStart?: (event: SortableEvent, sortable: Sortable) => void;
beforeStart?: (event: SortableEvent, sortable: Sortable) => void | Promise<void>;
}

0 comments on commit eb376b2

Please sign in to comment.