diff --git a/src/utils/search-range.js b/src/utils/search-range.js index e5723cd..34865bb 100644 --- a/src/utils/search-range.js +++ b/src/utils/search-range.js @@ -1,3 +1,35 @@ +/** + * 合并列表搜索条件:新条件覆盖旧条件,本次显式清空的字段从查询中移除。 + */ +export const applyIncomingSearch = (current = {}, incoming = {}) => { + const merged = { ...current, ...incoming }; + Object.keys(incoming || {}).forEach(key => { + const value = incoming[key]; + if ( + value === '' || + value === null || + value === undefined || + (Array.isArray(value) && value.length === 0) + ) { + delete merged[key]; + } + }); + return merged; +}; + +/** + * 启停状态下拉「全部」在数字类型下会被转成 0/-1,不能当作查询条件。 + * 状态 0 表示草稿等有效值的页面不要调用。 + */ +export const omitInvalidListStatus = (params = {}) => { + const values = { ...params }; + const status = values.status; + if (status === 0 || status === '0' || status === -1 || status === '-1') { + delete values.status; + } + return values; +}; + export const normalizeSearchRangeParams = (params = {}, rangeMap = {}) => { const values = { ...params }; diff --git a/src/views/base/airport-master.vue b/src/views/base/airport-master.vue index 3c94260..9969378 100644 --- a/src/views/base/airport-master.vue +++ b/src/views/base/airport-master.vue @@ -150,6 +150,7 @@ import { mapGetters } from 'vuex'; import { downloadXls } from '@/utils/util'; import { openImportDialog } from '@/utils/import-excel'; import { formatUpdateUserName } from '@/utils/audit'; +import { omitInvalidListStatus } from '@/utils/search-range'; import { getToken, isAdministrator } from '@/utils/auth'; import { getCoordinateValidationMessage, normalizeCoordinateInput } from '@/utils/coordinate'; import AddressMapPicker from '@/components/address-map-picker/main.vue'; @@ -1182,7 +1183,7 @@ export default { }, onLoad(page, params = {}) { this.loading = true; - getList(page.currentPage, page.pageSize, { ...params, ...this.query }) + getList(page.currentPage, page.pageSize, omitInvalidListStatus({ ...params, ...this.query })) .then(res => { const data = res.data.data; this.page.total = data.total; diff --git a/src/views/base/currency.vue b/src/views/base/currency.vue index 0ad39fe..903fae0 100644 --- a/src/views/base/currency.vue +++ b/src/views/base/currency.vue @@ -104,6 +104,7 @@ import { mapGetters } from 'vuex'; import { downloadXls } from '@/utils/util'; import { openImportDialog } from '@/utils/import-excel'; import { formatUpdateUserName } from '@/utils/audit'; +import { omitInvalidListStatus } from '@/utils/search-range'; import { getToken } from '@/utils/auth'; import NProgress from 'nprogress'; import 'nprogress/nprogress.css'; @@ -507,7 +508,7 @@ export default { this.onLoad(this.page, this.query); }, buildQuery(params = {}) { - const values = { ...params, ...this.query }; + const values = omitInvalidListStatus({ ...params, ...this.query }); const rangeMap = { effectiveDateRange: ['effectiveDateStart', 'effectiveDateEnd'], expiryDateRange: ['expiryDateStart', 'expiryDateEnd'], diff --git a/src/views/base/customer-type.vue b/src/views/base/customer-type.vue index fb68968..6653a85 100644 --- a/src/views/base/customer-type.vue +++ b/src/views/base/customer-type.vue @@ -63,6 +63,7 @@