fix:模具组-修复第一次进入上模/下模页面没调用接口bug

main
黄伟杰 1 week ago
parent d9a1b07f07
commit 156e532b14

@ -12,8 +12,8 @@
<el-form ref="queryFormRef" :model="queryParams" :inline="true" class="-mb-15px mt-16px"> <el-form ref="queryFormRef" :model="queryParams" :inline="true" class="-mb-15px mt-16px">
<el-form-item prop="keyword"> <el-form-item prop="keyword">
<el-input v-model="queryParams.keyword" :placeholder="t('MoldManagement.MoldBrandPage.placeholderKeyword')" <el-input v-model="inputKeyword" :placeholder="t('MoldManagement.MoldBrandPage.placeholderKeyword')"
clearable class="!w-240px" @keyup.enter="handleQuery" /> clearable class="!w-240px" @keyup.enter="handleQuery" @clear="onKeywordClear" />
</el-form-item> </el-form-item>
<el-form-item prop="status"> <el-form-item prop="status">
<el-select v-model="queryParams.status" :placeholder="t('MoldManagement.MoldBrandPage.placeholderStatus')" <el-select v-model="queryParams.status" :placeholder="t('MoldManagement.MoldBrandPage.placeholderStatus')"
@ -182,7 +182,6 @@ const counters = reactive({
const queryParams = reactive({ const queryParams = reactive({
pageNo: 1, pageNo: 1,
pageSize: 10, pageSize: 10,
keyword: undefined as string | undefined,
code: undefined as string | undefined, code: undefined as string | undefined,
name: undefined as string | undefined, name: undefined as string | undefined,
productIds: [] as number[], productIds: [] as number[],
@ -207,6 +206,18 @@ const moldOperateViewRef = ref()
const maintainFormVisible = ref(false) const maintainFormVisible = ref(false)
const moldMaintainViewRef = ref() const moldMaintainViewRef = ref()
const inputKeyword = ref('')
watch(inputKeyword, (val) => {
const v = val?.trim() || undefined
queryParams.code = v
queryParams.name = v
queryParams.productName = v
})
const onKeywordClear = () => {
inputKeyword.value = ''
}
const statusCards = computed(() => [ const statusCards = computed(() => [
{ key: 'all', label: t('MoldManagement.MoldBrandPage.all'), value: counters.allCount, status: undefined }, { key: 'all', label: t('MoldManagement.MoldBrandPage.all'), value: counters.allCount, status: undefined },
{ key: 'onMachine', label: t('MoldManagement.MoldBrandPage.onMachine'), value: counters.onMachineCount, status: 1 }, { key: 'onMachine', label: t('MoldManagement.MoldBrandPage.onMachine'), value: counters.onMachineCount, status: 1 },
@ -215,12 +226,6 @@ const statusCards = computed(() => [
{ key: 'scrapped', label: t('MoldManagement.MoldBrandPage.scrapped'), value: counters.scrappedCount, status: 3 } { key: 'scrapped', label: t('MoldManagement.MoldBrandPage.scrapped'), value: counters.scrappedCount, status: 3 }
]) ])
const parseKeyword = () => {
const keyword = queryParams.keyword?.trim()
queryParams.code = keyword || undefined
queryParams.name = keyword || undefined
}
const getImageList = (images?: string) => { const getImageList = (images?: string) => {
if (!images) return [] if (!images) return []
return String(images) return String(images)
@ -243,9 +248,10 @@ const normalizePageResult = (data: any) => {
const getList = async () => { const getList = async () => {
loading.value = true loading.value = true
try { try {
parseKeyword()
const selected = productOptions.value.filter((item) => (queryParams.productIds || []).includes(item.id)) const selected = productOptions.value.filter((item) => (queryParams.productIds || []).includes(item.id))
queryParams.productName = selected.map((p) => p.name).join(',') if (selected.length > 0) {
queryParams.productName = selected.map((p) => p.name).join(',')
}
const data = await MoldBrandApi.getMoldBrandPage({ const data = await MoldBrandApi.getMoldBrandPage({
...queryParams, ...queryParams,
currentDevice: queryParams.currentDevice currentDevice: queryParams.currentDevice
@ -263,6 +269,7 @@ const handleQuery = () => {
const resetQuery = () => { const resetQuery = () => {
queryFormRef.value?.resetFields() queryFormRef.value?.resetFields()
inputKeyword.value = ''
currentStatusKey.value = 'all' currentStatusKey.value = 'all'
queryParams.status = undefined queryParams.status = undefined
queryParams.productIds = [] queryParams.productIds = []
@ -331,14 +338,19 @@ const openDetail = (id: number) => {
} }
// //
const openOperateForm = async (type: number, row: MoldBrandVO) => { const openOperateForm = (type: number, row: MoldBrandVO) => {
operateType.value = type operateType.value = type
currentMold.value = row currentMold.value = row
operateFormVisible.value = true operateFormVisible.value = true
await nextTick()
moldOperateViewRef.value?.open()
} }
// operateFormVisible + moldOperateViewRef open
watch([operateFormVisible, moldOperateViewRef], ([visible, ref]) => {
if (visible && ref) {
ref.open()
}
})
const closeOperateForm = () => { const closeOperateForm = () => {
operateFormVisible.value = false operateFormVisible.value = false
currentMold.value = null currentMold.value = null
@ -349,13 +361,18 @@ const onOperateSuccess = () => {
} }
// //
const openMaintainForm = async (row: MoldBrandVO) => { const openMaintainForm = (row: MoldBrandVO) => {
currentMold.value = row currentMold.value = row
maintainFormVisible.value = true maintainFormVisible.value = true
await nextTick()
moldMaintainViewRef.value?.open()
} }
// maintainFormVisible + moldMaintainViewRef open
watch([maintainFormVisible, moldMaintainViewRef], ([visible, ref]) => {
if (visible && ref) {
ref.open()
}
})
const closeMaintainForm = () => { const closeMaintainForm = () => {
maintainFormVisible.value = false maintainFormVisible.value = false
currentMold.value = null currentMold.value = null

Loading…
Cancel
Save