style:配方库-读取添加loading、读取结束后刷新手动录入参数列表

main
黄伟杰 2 weeks ago
parent 410e5d644a
commit 82c10b98f1

@ -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 })
</script>

@ -84,10 +84,10 @@
</div>
<template #footer>
<el-button @click="submitForm" type="primary">
<el-button @click="submitForm" type="primary" :loading="submitLoading" :disabled="submitLoading">
{{ t('RecipeManagement.RecipeLibrary.readDialogSubmitButtonText') }}
</el-button>
<el-button @click="visible = false">
<el-button @click="visible = false" :disabled="submitLoading">
{{ t('RecipeManagement.RecipeLibrary.readDialogCancelButton') }}
</el-button>
</template>
@ -107,6 +107,7 @@ type PageResult<T> = { 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<string | number | undefined>(undefined)
@ -115,6 +116,9 @@ const total = ref(0)
const { t } = useI18n() //
const message = useMessage() //
const emit = defineEmits<{
(e: 'success'): void
}>()
const unitList = ref<ProductUnitVO[]>([])
@ -194,11 +198,18 @@ defineExpose({ open })
const submitForm = async () => {
if (submitLoading.value) return
submitLoading.value = true
console.log(list.value)
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
}
}

@ -102,10 +102,10 @@ v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true" ro
</ContentWrap>
<ContentWrap v-if="detailVisible">
<FormulaLibraryDetailTabs :recipe-id="detailRecipeId" />
<FormulaLibraryDetailTabs ref="detailTabsRef" :recipe-id="detailRecipeId" />
</ContentWrap>
<FormulaLibraryReadDialog ref="readDialogRef" />
<FormulaLibraryReadDialog ref="readDialogRef" @success="handleReadSuccess" />
<Dialog :title="dialogTitle" v-model="dialogVisible" width="720px">
<el-form
@ -339,6 +339,11 @@ const openDialog = async (type: 'create' | 'update', row?: RecipePlanDetailVO) =
}
const readDialogRef = ref<InstanceType<typeof FormulaLibraryReadDialog>>()
const detailTabsRef = ref<InstanceType<typeof FormulaLibraryDetailTabs>>()
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
}
}

Loading…
Cancel
Save