feat(phase3): complete loading workbenches
This commit is contained in:
@@ -58,13 +58,11 @@ const viewPermission = computed(() => isPreload.value ? 'platform:firstleg:prelo
|
||||
const canList = computed(() => access.can(listPermission.value))
|
||||
const canView = computed(() => access.can(viewPermission.value))
|
||||
const canEdit = computed(() => isPreload.value && access.can('platform:firstleg:preload:edit'))
|
||||
const hasWarehouse = computed(() => Boolean(String(query.warehouseId || '').trim()))
|
||||
|
||||
const fields = computed<QueryField[]>(() => [
|
||||
{
|
||||
key: 'warehouseId', type: 'select', label: '仓库', placeholder: loadingWarehouses.value ? '仓库加载中' : '请选择仓库(必选)', width: 220,
|
||||
key: 'warehouseId', type: 'select', label: '仓库', placeholder: loadingWarehouses.value ? '仓库加载中' : '全部仓库', width: 220,
|
||||
options: warehouses.value.map((warehouse) => ({ label: warehouse.name, value: warehouse.id })),
|
||||
props: { loading: loadingWarehouses.value, 'aria-label': '仓库(必选)' },
|
||||
props: { loading: loadingWarehouses.value, clearable: true, 'aria-label': '仓库' },
|
||||
},
|
||||
{ key: 'keyword', type: 'input', label: '关键词', placeholder: isPreload.value ? '预装单号/集装箱号/柜号' : '装柜清单号/集装箱号/柜号', width: 250 },
|
||||
{ key: 'createdRange', type: 'daterange', label: '创建日期', width: 260 },
|
||||
@@ -117,14 +115,13 @@ function formatNumber(value?: number | null, digits = 3) {
|
||||
return Number(value).toLocaleString('zh-CN', { maximumFractionDigits: digits })
|
||||
}
|
||||
|
||||
function toQuery(): LoadingListQuery | null {
|
||||
function toQuery(): LoadingListQuery {
|
||||
const warehouseId = String(query.warehouseId || '').trim()
|
||||
if (!warehouseId) return null
|
||||
const range = Array.isArray(query.createdRange) ? query.createdRange.map(String) : []
|
||||
return {
|
||||
page: page.value,
|
||||
size: pageSize.value,
|
||||
warehouseId,
|
||||
warehouseId: warehouseId || undefined,
|
||||
keyword: String(query.keyword || '').trim() || undefined,
|
||||
createdFrom: range[0] ? `${range[0]}T00:00:00` : undefined,
|
||||
createdTo: range[1] ? `${range[1]}T23:59:59` : undefined,
|
||||
@@ -146,12 +143,6 @@ async function loadWarehouses() {
|
||||
async function load() {
|
||||
if (!canList.value) return
|
||||
const request = toQuery()
|
||||
if (!request) {
|
||||
rows.value = []
|
||||
total.value = 0
|
||||
error.value = null
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
error.value = null
|
||||
try {
|
||||
@@ -166,21 +157,13 @@ async function load() {
|
||||
}
|
||||
|
||||
function search() {
|
||||
if (!hasWarehouse.value) {
|
||||
rows.value = []
|
||||
total.value = 0
|
||||
ElMessage.warning('请先选择仓库')
|
||||
return
|
||||
}
|
||||
if (page.value !== 1) page.value = 1
|
||||
else void load()
|
||||
}
|
||||
|
||||
function reset() {
|
||||
page.value = 1
|
||||
rows.value = []
|
||||
total.value = 0
|
||||
error.value = null
|
||||
void load()
|
||||
}
|
||||
|
||||
async function loadDetail() {
|
||||
@@ -240,8 +223,11 @@ async function saveTransport() {
|
||||
}
|
||||
}
|
||||
|
||||
watch([page, pageSize], () => { if (hasWarehouse.value) void load() })
|
||||
onMounted(() => void loadWarehouses())
|
||||
watch([page, pageSize], () => void load())
|
||||
onMounted(() => {
|
||||
void loadWarehouses()
|
||||
void load()
|
||||
})
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -277,7 +263,7 @@ onMounted(() => void loadWarehouses())
|
||||
:total="total"
|
||||
:preference-key="`loading-lists-${mode}`"
|
||||
row-key="planId"
|
||||
:empty-text="hasWarehouse ? `暂无符合筛选条件的${title}` : '请先选择仓库后查询'"
|
||||
:empty-text="`暂无符合筛选条件的${title}`"
|
||||
:aria-label="title"
|
||||
>
|
||||
<template #actions="{ row }"><el-button v-if="canView" link type="primary" @click="openDetail(row)"><Eye :size="15" />查看</el-button></template>
|
||||
|
||||
Reference in New Issue
Block a user