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 () => { const getList = async () => {
if (!props.recipeId) { if (!props.recipeId) {
list.value = [] list.value = []
@ -256,4 +273,6 @@ watch(
getList() getList()
} }
) )
defineExpose({ refreshManual })
</script> </script>

@ -84,10 +84,10 @@
</div> </div>
<template #footer> <template #footer>
<el-button @click="submitForm" type="primary"> <el-button @click="submitForm" type="primary" :loading="submitLoading" :disabled="submitLoading">
{{ t('RecipeManagement.RecipeLibrary.readDialogSubmitButtonText') }} {{ t('RecipeManagement.RecipeLibrary.readDialogSubmitButtonText') }}
</el-button> </el-button>
<el-button @click="visible = false"> <el-button @click="visible = false" :disabled="submitLoading">
{{ t('RecipeManagement.RecipeLibrary.readDialogCancelButton') }} {{ t('RecipeManagement.RecipeLibrary.readDialogCancelButton') }}
</el-button> </el-button>
</template> </template>
@ -107,6 +107,7 @@ type PageResult<T> = { list: T[]; total: number }
const visible = ref(false) const visible = ref(false)
const title = ref('') const title = ref('')
const loading = ref(false) const loading = ref(false)
const submitLoading = ref(false)
const hasExistingRecords = ref(false) const hasExistingRecords = ref(false)
const recipeId = ref<string | number | undefined>(undefined) const recipeId = ref<string | number | undefined>(undefined)
@ -115,6 +116,9 @@ const total = ref(0)
const { t } = useI18n() // const { t } = useI18n() //
const message = useMessage() // const message = useMessage() //
const emit = defineEmits<{
(e: 'success'): void
}>()
const unitList = ref<ProductUnitVO[]>([]) const unitList = ref<ProductUnitVO[]>([])
@ -193,12 +197,19 @@ const open = async (options: {
defineExpose({ open }) defineExpose({ open })
const submitForm = async() => { const submitForm = async () => {
if (submitLoading.value) return
submitLoading.value = true
console.log(list.value) console.log(list.value)
try {
await RecipePointRecordApi.createRecipePointRecordBatch(list.value as unknown as RecipePointRecordVO[]) await RecipePointRecordApi.createRecipePointRecordBatch(list.value as unknown as RecipePointRecordVO[])
await RecipeDeviceRecordApi.createRecipeDeviceRecordBatch(formulaLibraryId.value) await RecipeDeviceRecordApi.createRecipeDeviceRecordBatch(formulaLibraryId.value)
visible.value = false visible.value = false
message.success(t('common.createSuccess')) 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>
<ContentWrap v-if="detailVisible"> <ContentWrap v-if="detailVisible">
<FormulaLibraryDetailTabs :recipe-id="detailRecipeId" /> <FormulaLibraryDetailTabs ref="detailTabsRef" :recipe-id="detailRecipeId" />
</ContentWrap> </ContentWrap>
<FormulaLibraryReadDialog ref="readDialogRef" /> <FormulaLibraryReadDialog ref="readDialogRef" @success="handleReadSuccess" />
<Dialog :title="dialogTitle" v-model="dialogVisible" width="720px"> <Dialog :title="dialogTitle" v-model="dialogVisible" width="720px">
<el-form <el-form
@ -339,6 +339,11 @@ const openDialog = async (type: 'create' | 'update', row?: RecipePlanDetailVO) =
} }
const readDialogRef = ref<InstanceType<typeof FormulaLibraryReadDialog>>() 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 checkRecipeRecords = async (recipeId: string | number) => {
const params = { const params = {
@ -380,6 +385,7 @@ const handleRead = async (row: RecipePlanDetailVO) => {
if (id != null) { if (id != null) {
await RecipeDeviceRecordApi.createRecipeDeviceRecordBatch(id) await RecipeDeviceRecordApi.createRecipeDeviceRecordBatch(id)
message.success(t('common.createSuccess')) message.success(t('common.createSuccess'))
await handleReadSuccess()
return return
} }
} }

Loading…
Cancel
Save