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

main
黄伟杰 2 days ago
parent d9a1b07f07
commit 156e532b14

@ -12,8 +12,8 @@
<el-form ref="queryFormRef" :model="queryParams" :inline="true" class="-mb-15px mt-16px">
<el-form-item prop="keyword">
<el-input v-model="queryParams.keyword" :placeholder="t('MoldManagement.MoldBrandPage.placeholderKeyword')"
clearable class="!w-240px" @keyup.enter="handleQuery" />
<el-input v-model="inputKeyword" :placeholder="t('MoldManagement.MoldBrandPage.placeholderKeyword')"
clearable class="!w-240px" @keyup.enter="handleQuery" @clear="onKeywordClear" />
</el-form-item>
<el-form-item prop="status">
<el-select v-model="queryParams.status" :placeholder="t('MoldManagement.MoldBrandPage.placeholderStatus')"
@ -182,7 +182,6 @@ const counters = reactive({
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
keyword: undefined as string | undefined,
code: undefined as string | undefined,
name: undefined as string | undefined,
productIds: [] as number[],
@ -207,6 +206,18 @@ const moldOperateViewRef = ref()
const maintainFormVisible = ref(false)
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(() => [
{ key: 'all', label: t('MoldManagement.MoldBrandPage.all'), value: counters.allCount, status: undefined },
{ 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 }
])
const parseKeyword = () => {
const keyword = queryParams.keyword?.trim()
queryParams.code = keyword || undefined
queryParams.name = keyword || undefined
}
const getImageList = (images?: string) => {
if (!images) return []
return String(images)
@ -243,9 +248,10 @@ const normalizePageResult = (data: any) => {
const getList = async () => {
loading.value = true
try {
parseKeyword()
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({
...queryParams,
currentDevice: queryParams.currentDevice
@ -263,6 +269,7 @@ const handleQuery = () => {
const resetQuery = () => {
queryFormRef.value?.resetFields()
inputKeyword.value = ''
currentStatusKey.value = 'all'
queryParams.status = undefined
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
currentMold.value = row
operateFormVisible.value = true
await nextTick()
moldOperateViewRef.value?.open()
}
// operateFormVisible + moldOperateViewRef open
watch([operateFormVisible, moldOperateViewRef], ([visible, ref]) => {
if (visible && ref) {
ref.open()
}
})
const closeOperateForm = () => {
operateFormVisible.value = false
currentMold.value = null
@ -349,13 +361,18 @@ const onOperateSuccess = () => {
}
//
const openMaintainForm = async (row: MoldBrandVO) => {
const openMaintainForm = (row: MoldBrandVO) => {
currentMold.value = row
maintainFormVisible.value = true
await nextTick()
moldMaintainViewRef.value?.open()
}
// maintainFormVisible + moldMaintainViewRef open
watch([maintainFormVisible, moldMaintainViewRef], ([visible, ref]) => {
if (visible && ref) {
ref.open()
}
})
const closeMaintainForm = () => {
maintainFormVisible.value = false
currentMold.value = null

Loading…
Cancel
Save