mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2025-04-06 03:57:56 +08:00
fix(editor): 绑定关系组件增加option来源的默认逻辑
This commit is contained in:
parent
8b9ac826fc
commit
ddd22ff486
@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="m-fields-code-select">
|
||||
<m-fields-select
|
||||
:config="config.selectConfig"
|
||||
:config="selectConfig"
|
||||
:model="model"
|
||||
:prop="prop"
|
||||
:name="name"
|
||||
@ -20,8 +20,9 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { defineEmits, defineProps, inject } from 'vue';
|
||||
import { computed, defineEmits, defineProps, inject } from 'vue';
|
||||
import { View } from '@element-plus/icons-vue';
|
||||
import { map } from 'lodash-es';
|
||||
|
||||
import { SelectConfig } from '@tmagic/form';
|
||||
|
||||
@ -41,6 +42,27 @@ const props = defineProps<{
|
||||
size: string;
|
||||
}>();
|
||||
|
||||
const selectConfig = computed(() => {
|
||||
const defaultConfig = {
|
||||
multiple: true,
|
||||
options: async () => {
|
||||
const codeDsl = await services?.codeBlockService.getCodeDsl();
|
||||
if (codeDsl) {
|
||||
return map(codeDsl, (value, key) => ({
|
||||
text: `${value.name}(${key})`,
|
||||
label: `${value.name}(${key})`,
|
||||
value: key,
|
||||
}));
|
||||
}
|
||||
return [];
|
||||
},
|
||||
};
|
||||
return {
|
||||
...defaultConfig,
|
||||
...props.config.selectConfig,
|
||||
};
|
||||
});
|
||||
|
||||
const changeHandler = async (value: any) => {
|
||||
// 记录组件与代码块的绑定关系
|
||||
const { id = '' } = services?.editorService.get('node') || {};
|
||||
|
@ -16,11 +16,8 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { map } from 'lodash-es';
|
||||
|
||||
import { FormConfig, FormState } from '@tmagic/form';
|
||||
|
||||
import codeBlockService from '../services/codeBlock';
|
||||
import editorService from '../services/editor';
|
||||
import eventsService from '../services/events';
|
||||
|
||||
@ -231,20 +228,6 @@ export const fillConfig = (config: FormConfig = []) => [
|
||||
text: 'created',
|
||||
type: 'code-select',
|
||||
labelWidth: '100px',
|
||||
selectConfig: {
|
||||
multiple: true,
|
||||
options: async () => {
|
||||
const codeDsl = await codeBlockService.getCodeDsl();
|
||||
if (codeDsl) {
|
||||
return map(codeDsl, (value, key) => ({
|
||||
text: `${value.name}(${key})`,
|
||||
label: `${value.name}(${key})`,
|
||||
value: key,
|
||||
}));
|
||||
}
|
||||
return [];
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user