update app edit

This commit is contained in:
yumaojun03 2025-08-24 09:27:02 +08:00
parent 55bd699475
commit 56caa73209
2 changed files with 22 additions and 12 deletions

View File

@ -51,8 +51,7 @@
</a-table-column> </a-table-column>
</template> </template>
</a-table> </a-table>
<AppFormModel v-model:visible="formVisible" @update:visible="(v) => console.log(v)" :appData="currentApp" <AppFormModel v-model:visible="formVisible" :appData="currentApp" @submit="fetchAppList" />
@submit="fetchAppList" />
</a-card> </a-card>
</div> </div>
</template> </template>

View File

@ -119,13 +119,15 @@ onMounted(() => {
}); });
// 3. watchresetForm // 3. watchresetForm
watch(() => props.appData, (newVal) => { watch(() => props.visible, (newVal) => {
if (newVal) { if (props.appData) {
form.value = { ...newVal }; if (newVal) {
} else { form.value = { ...props.appData };
resetForm(); } else {
resetForm();
}
} }
}, { immediate: true }); }, { immediate: true, });
// , // ,
@ -141,10 +143,19 @@ const handleBeforeOk = async () => {
createAppLoading.value = true createAppLoading.value = true
try { try {
createAppLoading.value = true createAppLoading.value = true
await API.mpaas.AppCreate({
...form.value, if (editMode.value) {
name: form.value.name.trim() await API.mpaas.AppUpdate(props.appData.id, {
}); ...form.value,
name: form.value.name.trim()
});
return true
} else {
await API.mpaas.AppCreate({
...form.value,
name: form.value.name.trim()
});
}
return true return true
} catch (error) { } catch (error) {
console.error('Error creating app:', error); console.error('Error creating app:', error);