From a49845f424ae5b1e43e391837a55c43ce07ea62d Mon Sep 17 00:00:00 2001
From: zhou zhou <3272660260@qq.com>
Date: 星期三, 01 四月 2026 15:02:47 +0800
Subject: [PATCH] #前端
---
rsf-design/src/views/basic-info/loc/index.vue | 213 ++++++++++++++++------------------------------------
1 files changed, 66 insertions(+), 147 deletions(-)
diff --git a/rsf-design/src/views/basic-info/loc/index.vue b/rsf-design/src/views/basic-info/loc/index.vue
index c4287c6..8e69d59 100644
--- a/rsf-design/src/views/basic-info/loc/index.vue
+++ b/rsf-design/src/views/basic-info/loc/index.vue
@@ -103,6 +103,7 @@
buildLocSavePayload,
buildLocSearchParams,
createLocSearchState,
+ filterLocAreaOptionsByWarehouse,
getLocPaginationKey,
getLocStatusOptions,
getLocUseStatusOptions,
@@ -130,141 +131,74 @@
const reportTitle = LOC_REPORT_TITLE
const reportQueryParams = computed(() => buildLocSearchParams(searchForm.value))
+ const filteredSearchAreaOptions = computed(() =>
+ filterLocAreaOptionsByWarehouse(areaOptions.value, searchForm.value.warehouseId)
+ )
- const searchItems = computed(() => [
- {
- label: '鍏抽敭瀛�',
- key: 'condition',
+ function createInputSearchItem(label, key, placeholder) {
+ return {
+ label,
+ key,
type: 'input',
props: {
clearable: true,
- placeholder: '璇疯緭鍏ュ簱浣嶅彿/瀹瑰櫒缂栫爜/澶囨敞'
- }
- },
- {
- label: '浠撳簱',
- key: 'warehouseId',
- type: 'select',
- props: {
- clearable: true,
- filterable: true,
- options: warehouseOptions.value
- }
- },
- {
- label: '搴撳尯',
- key: 'areaId',
- type: 'select',
- props: {
- clearable: true,
- filterable: true,
- options: areaOptions.value.filter((item) => {
- if (!searchForm.value.warehouseId) {
- return true
- }
- if (item?.warehouseId === undefined || item?.warehouseId === null) {
- return true
- }
- return Number(item.warehouseId) === Number(searchForm.value.warehouseId)
- })
- }
- },
- {
- label: '搴撲綅鍙�',
- key: 'code',
- type: 'input',
- props: {
- clearable: true,
- placeholder: '璇疯緭鍏ュ簱浣嶅彿'
- }
- },
- {
- label: '浣跨敤鐘舵��',
- key: 'useStatus',
- type: 'select',
- props: {
- clearable: true,
- filterable: true,
- options: getLocUseStatusOptions()
- }
- },
- {
- label: '鎺�',
- key: 'row',
- type: 'number',
- props: {
- min: 0,
- controlsPosition: 'right',
- placeholder: '璇疯緭鍏ユ帓'
- }
- },
- {
- label: '鍒�',
- key: 'col',
- type: 'number',
- props: {
- min: 0,
- controlsPosition: 'right',
- placeholder: '璇疯緭鍏ュ垪'
- }
- },
- {
- label: '灞�',
- key: 'lev',
- type: 'number',
- props: {
- min: 0,
- controlsPosition: 'right',
- placeholder: '璇疯緭鍏ュ眰'
- }
- },
- {
- label: '宸烽亾',
- key: 'channel',
- type: 'number',
- props: {
- min: 0,
- controlsPosition: 'right',
- placeholder: '璇疯緭鍏ュ贩閬�'
- }
- },
- {
- label: '鐘舵��',
- key: 'status',
- type: 'select',
- props: {
- clearable: true,
- options: getLocStatusOptions()
- }
- },
- {
- label: '瀹瑰櫒缂栫爜',
- key: 'barcode',
- type: 'input',
- props: {
- clearable: true,
- placeholder: '璇疯緭鍏ュ鍣ㄧ紪鐮�'
- }
- },
- {
- label: '澶囨敞',
- key: 'memo',
- type: 'input',
- props: {
- clearable: true,
- placeholder: '璇疯緭鍏ュ娉�'
+ placeholder
}
}
+ }
+
+ function createNumberSearchItem(label, key, placeholder) {
+ return {
+ label,
+ key,
+ type: 'number',
+ props: {
+ min: 0,
+ controlsPosition: 'right',
+ placeholder
+ }
+ }
+ }
+
+ function createSelectSearchItem(label, key, options, extraProps = {}) {
+ return {
+ label,
+ key,
+ type: 'select',
+ props: {
+ clearable: true,
+ ...extraProps,
+ options
+ }
+ }
+ }
+
+ const searchItems = computed(() => [
+ createInputSearchItem('鍏抽敭瀛�', 'condition', '璇疯緭鍏ュ簱浣嶅彿/瀹瑰櫒缂栫爜/澶囨敞'),
+ createSelectSearchItem('浠撳簱', 'warehouseId', warehouseOptions.value, { filterable: true }),
+ createSelectSearchItem('搴撳尯', 'areaId', filteredSearchAreaOptions.value, { filterable: true }),
+ createInputSearchItem('搴撲綅鍙�', 'code', '璇疯緭鍏ュ簱浣嶅彿'),
+ createSelectSearchItem('浣跨敤鐘舵��', 'useStatus', getLocUseStatusOptions(), { filterable: true }),
+ createNumberSearchItem('鎺�', 'row', '璇疯緭鍏ユ帓'),
+ createNumberSearchItem('鍒�', 'col', '璇疯緭鍏ュ垪'),
+ createNumberSearchItem('灞�', 'lev', '璇疯緭鍏ュ眰'),
+ createNumberSearchItem('宸烽亾', 'channel', '璇疯緭鍏ュ贩閬�'),
+ createSelectSearchItem('鐘舵��', 'status', getLocStatusOptions()),
+ createInputSearchItem('瀹瑰櫒缂栫爜', 'barcode', '璇疯緭鍏ュ鍣ㄧ紪鐮�'),
+ createInputSearchItem('澶囨敞', 'memo', '璇疯緭鍏ュ娉�')
])
+
+ async function fetchLocDetailById(id) {
+ return guardRequestWithMessage(fetchGetLocDetail(id), {}, {
+ timeoutMessage: '搴撲綅璇︽儏鍔犺浇瓒呮椂锛屽凡鍋滄绛夊緟'
+ })
+ }
async function openDetail(row) {
detailDrawerVisible.value = true
detailLoading.value = true
try {
- const detail = await guardRequestWithMessage(fetchGetLocDetail(row.id), {}, {
- timeoutMessage: '搴撲綅璇︽儏鍔犺浇瓒呮椂锛屽凡鍋滄绛夊緟'
- })
- detailData.value = normalizeLocListRow(detail)
+ detailData.value = normalizeLocListRow(await fetchLocDetailById(row.id))
} catch (error) {
detailDrawerVisible.value = false
detailData.value = {}
@@ -276,10 +210,7 @@
async function openEditDialog(row) {
try {
- const detail = await guardRequestWithMessage(fetchGetLocDetail(row.id), {}, {
- timeoutMessage: '搴撲綅璇︽儏鍔犺浇瓒呮椂锛屽凡鍋滄绛夊緟'
- })
- showDialog('edit', detail)
+ showDialog('edit', await fetchLocDetailById(row.id))
} catch (error) {
ElMessage.error(error?.message || '鑾峰彇搴撲綅璇︽儏澶辫触')
}
@@ -400,25 +331,9 @@
})
)
- async function loadWarehouseOptions() {
- const response = await guardRequestWithMessage(fetchWarehouseList(), [], {
- timeoutMessage: '浠撳簱閫夐」鍔犺浇瓒呮椂锛屽凡鍋滄绛夊緟'
- })
- warehouseOptions.value = resolveLocWarehouseOptions(defaultResponseAdapter(response).records)
- }
-
- async function loadAreaOptions() {
- const response = await guardRequestWithMessage(fetchWarehouseAreasList(), [], {
- timeoutMessage: '搴撳尯閫夐」鍔犺浇瓒呮椂锛屽凡鍋滄绛夊緟'
- })
- areaOptions.value = resolveLocAreaOptions(defaultResponseAdapter(response).records)
- }
-
- async function loadLocTypeOptions() {
- const response = await guardRequestWithMessage(fetchLocTypeList(), [], {
- timeoutMessage: '搴撲綅绫诲瀷閫夐」鍔犺浇瓒呮椂锛屽凡鍋滄绛夊緟'
- })
- locTypeOptions.value = resolveLocTypeOptions(defaultResponseAdapter(response).records)
+ async function loadOptions(requestFn, resolver, targetRef, timeoutMessage) {
+ const response = await guardRequestWithMessage(requestFn(), [], { timeoutMessage })
+ targetRef.value = resolver(defaultResponseAdapter(response).records)
}
function handleSearch(params) {
@@ -432,6 +347,10 @@
}
onMounted(async () => {
- await Promise.all([loadWarehouseOptions(), loadAreaOptions(), loadLocTypeOptions()])
+ await Promise.all([
+ loadOptions(fetchWarehouseList, resolveLocWarehouseOptions, warehouseOptions, '浠撳簱閫夐」鍔犺浇瓒呮椂锛屽凡鍋滄绛夊緟'),
+ loadOptions(fetchWarehouseAreasList, resolveLocAreaOptions, areaOptions, '搴撳尯閫夐」鍔犺浇瓒呮椂锛屽凡鍋滄绛夊緟'),
+ loadOptions(fetchLocTypeList, resolveLocTypeOptions, locTypeOptions, '搴撲綅绫诲瀷閫夐」鍔犺浇瓒呮椂锛屽凡鍋滄绛夊緟')
+ ])
})
</script>
--
Gitblit v1.9.1