diff --git a/src/views/formula/formulaLibrary/components/FormulaLibraryDetailTabs.vue b/src/views/formula/formulaLibrary/components/FormulaLibraryDetailTabs.vue index cac74e44..fbb014b3 100644 --- a/src/views/formula/formulaLibrary/components/FormulaLibraryDetailTabs.vue +++ b/src/views/formula/formulaLibrary/components/FormulaLibraryDetailTabs.vue @@ -205,6 +205,23 @@ const buildQueryParams = () => { } } +const refreshManual = async () => { + if (!props.recipeId) { + list.value = [] + total.value = 0 + return + } + loading.value = true + try { + await ensureUnitList() + const data = await RecipePointRecordApi.getRecipePointRecordPage(buildQueryParams()) + list.value = data.list + total.value = data.total + } finally { + loading.value = false + } +} + const getList = async () => { if (!props.recipeId) { list.value = [] @@ -256,4 +273,6 @@ watch( getList() } ) + +defineExpose({ refreshManual }) diff --git a/src/views/formula/formulaLibrary/components/FormulaLibraryReadDialog.vue b/src/views/formula/formulaLibrary/components/FormulaLibraryReadDialog.vue index 375ea5f5..a22b6af5 100644 --- a/src/views/formula/formulaLibrary/components/FormulaLibraryReadDialog.vue +++ b/src/views/formula/formulaLibrary/components/FormulaLibraryReadDialog.vue @@ -84,10 +84,10 @@ @@ -107,6 +107,7 @@ type PageResult = { list: T[]; total: number } const visible = ref(false) const title = ref('') const loading = ref(false) +const submitLoading = ref(false) const hasExistingRecords = ref(false) const recipeId = ref(undefined) @@ -115,6 +116,9 @@ const total = ref(0) const { t } = useI18n() // 国际化 const message = useMessage() // 消息弹窗 +const emit = defineEmits<{ + (e: 'success'): void +}>() const unitList = ref([]) @@ -193,12 +197,19 @@ const open = async (options: { defineExpose({ open }) -const submitForm = async() => { +const submitForm = async () => { + if (submitLoading.value) return + submitLoading.value = true console.log(list.value) - await RecipePointRecordApi.createRecipePointRecordBatch(list.value as unknown as RecipePointRecordVO[]) - await RecipeDeviceRecordApi.createRecipeDeviceRecordBatch(formulaLibraryId.value) - visible.value = false - message.success(t('common.createSuccess')) + try { + await RecipePointRecordApi.createRecipePointRecordBatch(list.value as unknown as RecipePointRecordVO[]) + await RecipeDeviceRecordApi.createRecipeDeviceRecordBatch(formulaLibraryId.value) + visible.value = false + message.success(t('common.createSuccess')) + emit('success') + } finally { + submitLoading.value = false + } } diff --git a/src/views/formula/formulaLibrary/index.vue b/src/views/formula/formulaLibrary/index.vue index eda13f80..a353aea0 100644 --- a/src/views/formula/formulaLibrary/index.vue +++ b/src/views/formula/formulaLibrary/index.vue @@ -102,10 +102,10 @@ v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" ro - + - + >() +const detailTabsRef = ref>() + +const handleReadSuccess = async () => { + await detailTabsRef.value?.refreshManual?.() +} const checkRecipeRecords = async (recipeId: string | number) => { const params = { @@ -380,6 +385,7 @@ const handleRead = async (row: RecipePlanDetailVO) => { if (id != null) { await RecipeDeviceRecordApi.createRecipeDeviceRecordBatch(id) message.success(t('common.createSuccess')) + await handleReadSuccess() return } }