diff --git a/frontend/src/components/right/DataMapping.vue b/frontend/src/components/right/DataMapping.vue index 3930255..bbe937b 100644 --- a/frontend/src/components/right/DataMapping.vue +++ b/frontend/src/components/right/DataMapping.vue @@ -18,28 +18,29 @@ -
+
-
+
ソース
-
+
目標
- - +
+ キー +
- +
-
+
-
+
+
+ + +
+ +
+ +
@@ -100,12 +107,19 @@ type Props = { } } }; + +type Value = { + data: ValueType[]; + createWithNull: boolean; +} + type ValueType = { id: string; from: object; to: typeof IAppFields & { isDialogVisible: boolean; }; + isKey: boolean; } @@ -132,7 +146,7 @@ export default defineComponent({ default: '', }, modelValue: { - type: Object as () => ValueType[], + type: Object as () => Value, }, placeholder: { type: String, @@ -161,7 +175,9 @@ export default defineComponent({ ); } - const mappingProps = computed(() => props.modelValue ?? []); + const mappingProps = computed(() => props.modelValue?.data ?? []); + + const createWithNull = computed(() => props.modelValue?.createWithNull) watch(() => sourceAppId.value, async (newId, oldId) => { if (!newId) return; @@ -180,23 +196,28 @@ export default defineComponent({ app: sourceApp.value, fields: [f], isDialogVisible: false - } + }, + isKey: true } }) }) - const modelValue = props.modelValue ?? []; + const modelValueData = props.modelValue?.data ?? []; - if (modelValue.length === 0 || newId !== oldId) { - emit('update:modelValue', a); + const createWithNull = props.modelValue?.createWithNull ?? false + + if (modelValueData.length === 0 || newId !== oldId) { + // emit('update:modelValue', a); + emit('update:modelValue', { data: a, createWithNull: createWithNull }); return; } - const modelValueFieldNames = modelValue.map(item => item.to.fields[0].name); + const modelValueFieldNames = modelValueData.map(item => item.to.fields[0].name); const newFields = a.filter(field => !modelValueFieldNames.includes(field.to.fields[0].name)); - const updatedModelValue = [...modelValue, ...newFields]; + const updatedModelValue = [...modelValueData, ...newFields]; - emit('update:modelValue', updatedModelValue); + emit('update:modelValue', { data: updatedModelValue, createWithNull: createWithNull }); + // emit('update:modelValue', updatedModelValue); }) console.log(mappingProps.value); @@ -231,6 +252,7 @@ export default defineComponent({ toDgIsShow: ref(false), closeToDg, mappingProps, + createWithNull, // addMappingObject: () => mappingProps.push(defaultMappingProp()), // deleteMappingObject, mappingObjectsInputDisplay, @@ -240,7 +262,7 @@ export default defineComponent({ config: { canInput: false, buttonsConfig: [ - { label: '変数', color: 'green', type: 'VariableAdd',editable:false }, + { label: '変数', color: 'green', type: 'VariableAdd', editable: false }, ] } };