refactor(storage): 清理废弃组件与接口,统一筛选/排序参数并完善表单校验
- 包装耗材、包装供应商:移除未使用的搜索表单与废弃接口,去掉后端不支持的 顶层 page/pageSize 与 order 参数,列表统一使用 pagination;新增创建/更新时间列、 重量格式化与空值显示;编辑时被清空的数值字段显式提交 null,保留「未修改」语义 - 库存:删除已废弃的 InventoryStockPickerDialog、库存日志组件与 quickPutaway 接口; 列表与导出支持文档声明的排序白名单(id/stock_id/space_id/时间/数量); 库位关键字先解析为 space_id、stock_query 先解析为 stock_id 后再下发, 规避导出接口 Unknown column 报错;新增库存类型筛选与库位库存入口, 详情面板复用入库明细组件 - 入库:ScanBox 新增「快捷搜索」(quickWhere 直接传字符串), 列表与导出共用当前排序 - 出库:转单表单增加字段级校验与错误提示(收货人、手机/固话二选一、 省市区镇、详细地址) - 包装流程:运单号汇总优先取 expresses 并去重,按选中导出一致带上运单号与 当前排序,补充录像列表弹窗并调整详情面板布局
This commit is contained in:
parent
4008a28796
commit
4eb0282a6a
@ -93,19 +93,6 @@ export function packageMaterialGet(data?: PackageMaterialGetParams) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function packageMaterialList(data?: PackageMaterialGetParams) {
|
|
||||||
return request({
|
|
||||||
url: '/system',
|
|
||||||
method: 'post',
|
|
||||||
params: {
|
|
||||||
method: 'setting.packageMaterial.list',
|
|
||||||
v,
|
|
||||||
timestamp: new Date().getTime()
|
|
||||||
},
|
|
||||||
data: data || {}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
export type PackageMaterialSearchParams = {
|
export type PackageMaterialSearchParams = {
|
||||||
keyword?: string
|
keyword?: string
|
||||||
}
|
}
|
||||||
|
|||||||
@ -22,8 +22,6 @@ export type PackageSupplierCreatePayload = {
|
|||||||
|
|
||||||
export type PackageSupplierUpdatePayload = {
|
export type PackageSupplierUpdatePayload = {
|
||||||
id: number
|
id: number
|
||||||
supplier_id?: number
|
|
||||||
supplierId?: number
|
|
||||||
supplier_code?: string
|
supplier_code?: string
|
||||||
supplier_name?: string
|
supplier_name?: string
|
||||||
contact_name?: string
|
contact_name?: string
|
||||||
@ -82,16 +80,3 @@ export function packageSupplierGet(data?: PackageSupplierGetParams) {
|
|||||||
data: data || {}
|
data: data || {}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function packageSupplierList(data?: PackageSupplierGetParams) {
|
|
||||||
return request({
|
|
||||||
url: '/system',
|
|
||||||
method: 'post',
|
|
||||||
params: {
|
|
||||||
method: 'setting.packageSupplier.list',
|
|
||||||
v,
|
|
||||||
timestamp: new Date().getTime()
|
|
||||||
},
|
|
||||||
data: data || {}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
@ -193,24 +193,6 @@ export function updateInventoryExpiry(data: InventoryUpdateExpiryParams): Promis
|
|||||||
} as any)
|
} as any)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function quickPutaway(data: { receiving_id: number; id?: number }): Promise<any> {
|
|
||||||
const body: Record<string, unknown> = { ...data }
|
|
||||||
if (body.receiving_id === undefined && body.id != null) {
|
|
||||||
body.receiving_id = Number(body.id)
|
|
||||||
}
|
|
||||||
return request({
|
|
||||||
url: '/system',
|
|
||||||
method: 'post',
|
|
||||||
params: {
|
|
||||||
method: 'storage.inventory.quickPutaway',
|
|
||||||
v,
|
|
||||||
timestamp: new Date().getTime()
|
|
||||||
},
|
|
||||||
data: body,
|
|
||||||
isSystemApi: true
|
|
||||||
} as any)
|
|
||||||
}
|
|
||||||
|
|
||||||
export type MatchPutawayReceivingResult = {
|
export type MatchPutawayReceivingResult = {
|
||||||
receiving_id?: number
|
receiving_id?: number
|
||||||
storage_status?: 'all' | 'partial' | 'none' | string
|
storage_status?: 'all' | 'partial' | 'none' | string
|
||||||
|
|||||||
@ -120,11 +120,10 @@
|
|||||||
<div class="detail-header">
|
<div class="detail-header">
|
||||||
<el-tabs v-model="activeTab" class="detail-tab">
|
<el-tabs v-model="activeTab" class="detail-tab">
|
||||||
<el-tab-pane label="任务详情" name="detail" />
|
<el-tab-pane label="任务详情" name="detail" />
|
||||||
<!-- <el-tab-pane label="录像" name="videos" /> -->
|
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</div>
|
</div>
|
||||||
<div class="detail-container" v-loading="detailLoading">
|
<div class="detail-container" v-loading="detailLoading">
|
||||||
<div v-if="activeTab === 'detail'" class="detail-page detail-panel">
|
<div class="detail-page detail-panel">
|
||||||
<!-- 任务信息 -->
|
<!-- 任务信息 -->
|
||||||
<div class="section">
|
<div class="section">
|
||||||
<div class="section-title">任务信息</div>
|
<div class="section-title">任务信息</div>
|
||||||
@ -232,33 +231,6 @@
|
|||||||
</el-descriptions>
|
</el-descriptions>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-else-if="activeTab === 'videos'" class="detail-page">
|
|
||||||
<template v-if="currentVideos.length">
|
|
||||||
<div class="video-tab-list">
|
|
||||||
<div v-for="(v, i) in currentVideos" :key="i" class="video-tab-item">
|
|
||||||
<div class="video-tab-info">
|
|
||||||
<span class="video-tab-label">录像 #{{ i + 1 }}</span>
|
|
||||||
<span class="video-tab-camera">{{ v.camera_name || '—' }}</span>
|
|
||||||
<el-tag v-if="v.status" size="small" :type="v.status === 'completed' ? 'success' : 'danger'">
|
|
||||||
{{ v.status === 'completed' ? '已完成' : v.status === 'failed' ? '失败' : v.status }}
|
|
||||||
</el-tag>
|
|
||||||
</div>
|
|
||||||
<el-button
|
|
||||||
v-if="v.video_url"
|
|
||||||
link
|
|
||||||
type="primary"
|
|
||||||
size="small"
|
|
||||||
@click="handlePlayVideo(v)"
|
|
||||||
>
|
|
||||||
播放
|
|
||||||
</el-button>
|
|
||||||
<span v-else-if="v.status === 'failed'" class="video-tab-unavailable">录像不可用</span>
|
|
||||||
<span v-else class="video-tab-unplayable">不可播放</span>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
<el-empty v-else description="暂无录像" :image-size="60" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -271,7 +243,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- 录像列表弹窗(顶部任务信息 + 左侧可播放列表 + 右侧播放器) -->
|
<!-- 录像列表弹窗(内部自带播放器) -->
|
||||||
<VideoListDialog
|
<VideoListDialog
|
||||||
v-model:visible="videoListVisible"
|
v-model:visible="videoListVisible"
|
||||||
:videos="currentVideos"
|
:videos="currentVideos"
|
||||||
@ -279,12 +251,6 @@
|
|||||||
@force-record="handleVideoListForceRecord"
|
@force-record="handleVideoListForceRecord"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 录像播放弹窗 -->
|
|
||||||
<VideoPlayerDialog
|
|
||||||
v-model:visible="playerVisible"
|
|
||||||
:video="playingVideo"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<!-- 设置结束时间弹窗:面板结构 / 尺寸对齐「手工录入运单号」 -->
|
<!-- 设置结束时间弹窗:面板结构 / 尺寸对齐「手工录入运单号」 -->
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="setEndTimeVisible"
|
v-model="setEndTimeVisible"
|
||||||
@ -404,7 +370,6 @@ import { getStatusTextClass } from '@/utils/statusText'
|
|||||||
import WarehouseSelect from '@/components/WarehouseSelect.vue'
|
import WarehouseSelect from '@/components/WarehouseSelect.vue'
|
||||||
import VideoButton, { type VideoItem } from './components/VideoButton.vue'
|
import VideoButton, { type VideoItem } from './components/VideoButton.vue'
|
||||||
import VideoListDialog from './components/VideoListDialog.vue'
|
import VideoListDialog from './components/VideoListDialog.vue'
|
||||||
import VideoPlayerDialog from './components/VideoPlayerDialog.vue'
|
|
||||||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||||||
import { safeInvoke } from '@/utils/safe-invoke'
|
import { safeInvoke } from '@/utils/safe-invoke'
|
||||||
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
||||||
@ -539,6 +504,25 @@ function handleSelectionChange(rows: PackingTaskItem[]) {
|
|||||||
selectionRows.value = rows || []
|
selectionRows.value = rows || []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 汇总行上的运单号:
|
||||||
|
* 列表接口的顶层 `waybill_code` 经常为 null(实测 66 条中 49 条为空),真实运单在 `expresses[]`,
|
||||||
|
* 故优先从 expresses 取、顶层兼底,并去重(后端 where.waybill_code 会关联 expresses 匹配)。
|
||||||
|
*/
|
||||||
|
function collectRowWaybillCodes(rows: PackingTaskItem[]): string[] {
|
||||||
|
const codes = new Set<string>()
|
||||||
|
for (const row of rows || []) {
|
||||||
|
const expresses = Array.isArray(row?.expresses) ? row.expresses : []
|
||||||
|
for (const exp of expresses) {
|
||||||
|
const code = String((exp as any)?.waybill_code ?? '').trim()
|
||||||
|
if (code) codes.add(code)
|
||||||
|
}
|
||||||
|
const topCode = String(row?.waybill_code ?? '').trim()
|
||||||
|
if (topCode) codes.add(topCode)
|
||||||
|
}
|
||||||
|
return [...codes]
|
||||||
|
}
|
||||||
|
|
||||||
// ─── 导出处理(导出选中 / 导出全部)───────────────────────────────────────
|
// ─── 导出处理(导出选中 / 导出全部)───────────────────────────────────────
|
||||||
/**
|
/**
|
||||||
* 构建导出参数:where 语义与 order.packing.list 一致(warehouse_id 由服务端注入,禁止传)。
|
* 构建导出参数:where 语义与 order.packing.list 一致(warehouse_id 由服务端注入,禁止传)。
|
||||||
@ -553,9 +537,7 @@ function buildPackingExportPayload(selected: boolean): Record<string, any> {
|
|||||||
payload.where = { ...filterWhere }
|
payload.where = { ...filterWhere }
|
||||||
}
|
}
|
||||||
if (selected) {
|
if (selected) {
|
||||||
const waybillCodes = selectionRows.value
|
const waybillCodes = collectRowWaybillCodes(selectionRows.value)
|
||||||
.map((row) => row?.waybill_code)
|
|
||||||
.filter((v: any) => v !== undefined && v !== null && String(v).trim() !== '')
|
|
||||||
if (waybillCodes.length) {
|
if (waybillCodes.length) {
|
||||||
payload.where = {
|
payload.where = {
|
||||||
...(payload.where || {}),
|
...(payload.where || {}),
|
||||||
@ -566,7 +548,7 @@ function buildPackingExportPayload(selected: boolean): Record<string, any> {
|
|||||||
if (sortState.value?.sortField) {
|
if (sortState.value?.sortField) {
|
||||||
payload.sort = {
|
payload.sort = {
|
||||||
sortField: sortState.value.sortField,
|
sortField: sortState.value.sortField,
|
||||||
sortOrder: String(sortState.value.sortOrder || 'desc').toLowerCase()
|
sortOrder: sortState.value.sortOrder || 'desc'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return payload
|
return payload
|
||||||
@ -582,11 +564,9 @@ async function handleExportSelected() {
|
|||||||
resumeExportTaskFromStorage()
|
resumeExportTaskFromStorage()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const waybillCodes = selectionRows.value
|
const waybillCodes = collectRowWaybillCodes(selectionRows.value)
|
||||||
.map((row) => row?.waybill_code)
|
|
||||||
.filter((v: any) => v !== undefined && v !== null && String(v).trim() !== '')
|
|
||||||
if (!waybillCodes.length) {
|
if (!waybillCodes.length) {
|
||||||
ElMessage.warning('选中的记录无有效运单号')
|
ElMessage.warning(`已勾选 ${selectionRows.value.length} 条任务,但未取到运单号,无法按选中导出`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await submitExportTask(buildPackingExportPayload(true))
|
await submitExportTask(buildPackingExportPayload(true))
|
||||||
@ -644,12 +624,12 @@ async function loadData() {
|
|||||||
// ─── 排序状态 ──────────────────────────────────────────────────────────────
|
// ─── 排序状态 ──────────────────────────────────────────────────────────────
|
||||||
const sortState = ref<PackingListSort>({
|
const sortState = ref<PackingListSort>({
|
||||||
sortField: 'create_time',
|
sortField: 'create_time',
|
||||||
sortOrder: 'DESC'
|
sortOrder: 'desc'
|
||||||
})
|
})
|
||||||
|
|
||||||
function handleSortChange(sort: { prop: string; order: string }) {
|
function handleSortChange(sort: { prop: string; order: string }) {
|
||||||
if (!sort.order) {
|
if (!sort.order) {
|
||||||
sortState.value = { sortField: 'create_time', sortOrder: 'DESC' }
|
sortState.value = { sortField: 'create_time', sortOrder: 'desc' }
|
||||||
} else {
|
} else {
|
||||||
sortState.value = {
|
sortState.value = {
|
||||||
sortField: sort.prop,
|
sortField: sort.prop,
|
||||||
@ -724,12 +704,6 @@ function handleRowClick(row: PackingTaskItem | null) {
|
|||||||
void loadDetail(row)
|
void loadDetail(row)
|
||||||
}
|
}
|
||||||
|
|
||||||
function openDetail(row: PackingTaskItem | null) {
|
|
||||||
if (!row) return
|
|
||||||
selectedRow.value = row
|
|
||||||
void loadDetail(row)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadDetail(row: PackingTaskItem | null | undefined) {
|
async function loadDetail(row: PackingTaskItem | null | undefined) {
|
||||||
if (!row || row.id == null) return
|
if (!row || row.id == null) return
|
||||||
detailLoading.value = true
|
detailLoading.value = true
|
||||||
@ -755,27 +729,18 @@ async function loadDetail(row: PackingTaskItem | null | undefined) {
|
|||||||
|
|
||||||
// ─── 录像相关 ──────────────────────────────────────────────────────────────
|
// ─── 录像相关 ──────────────────────────────────────────────────────────────
|
||||||
const videoListVisible = ref(false)
|
const videoListVisible = ref(false)
|
||||||
const playerVisible = ref(false)
|
|
||||||
const currentVideos = ref<VideoItem[]>([])
|
const currentVideos = ref<VideoItem[]>([])
|
||||||
const playingVideo = ref<VideoItem | null>(null)
|
|
||||||
|
|
||||||
function openVideoList(row: PackingTaskItem) {
|
function openVideoList(row: PackingTaskItem) {
|
||||||
currentVideos.value = (row.videos as VideoItem[]) || []
|
currentVideos.value = (row.videos as VideoItem[]) || []
|
||||||
if (currentVideos.value.length === 0) return
|
if (currentVideos.value.length === 0) return
|
||||||
selectedRow.value = row
|
selectedRow.value = row
|
||||||
activeTab.value = 'videos'
|
|
||||||
if (!detailVisible.value) {
|
if (!detailVisible.value) {
|
||||||
detailVisible.value = true
|
detailVisible.value = true
|
||||||
}
|
}
|
||||||
videoListVisible.value = true
|
videoListVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
function handlePlayVideo(video: VideoItem) {
|
|
||||||
videoListVisible.value = false
|
|
||||||
playingVideo.value = video
|
|
||||||
playerVisible.value = true
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleVideoListForceRecord() {
|
function handleVideoListForceRecord() {
|
||||||
videoListVisible.value = false
|
videoListVisible.value = false
|
||||||
if (selectedRow.value) {
|
if (selectedRow.value) {
|
||||||
@ -893,6 +858,8 @@ async function doForceRecord() {
|
|||||||
// ─── 初始化 ────────────────────────────────────────────────────────────────
|
// ─── 初始化 ────────────────────────────────────────────────────────────────
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
loadData()
|
loadData()
|
||||||
|
// 刷新后恢复未完成的导出任务进度弹窗(与其他导出页一致)
|
||||||
|
resumeExportTaskFromStorage()
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@ -238,6 +238,16 @@ export const baseAvailableFields = [
|
|||||||
value: 'order_id',
|
value: 'order_id',
|
||||||
type: 'text' as const
|
type: 'text' as const
|
||||||
}),
|
}),
|
||||||
|
// 工作台ID(文档 order.packing.export 的 where 字段含 workbench_id,精确匹配)
|
||||||
|
packingScanField('basic', {
|
||||||
|
label: '工作台ID',
|
||||||
|
value: 'workbench_id',
|
||||||
|
type: 'number' as const,
|
||||||
|
placeholder: '工作台ID',
|
||||||
|
operators: ['eq'],
|
||||||
|
defaultOperator: 'eq',
|
||||||
|
hideOperator: true
|
||||||
|
}),
|
||||||
// 打包员(operator_text,任务主表展示文本列;默认模糊匹配,支持精确/包含)
|
// 打包员(operator_text,任务主表展示文本列;默认模糊匹配,支持精确/包含)
|
||||||
packingScanField('basic', {
|
packingScanField('basic', {
|
||||||
label: '打包员',
|
label: '打包员',
|
||||||
|
|||||||
@ -1,170 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-dialog
|
|
||||||
v-model="visible"
|
|
||||||
title="包材快速搜索"
|
|
||||||
width="860px"
|
|
||||||
align-center
|
|
||||||
destroy-on-close
|
|
||||||
:close-on-click-modal="!loading"
|
|
||||||
@closed="emit('closed')"
|
|
||||||
>
|
|
||||||
<!-- <el-alert
|
|
||||||
type="info"
|
|
||||||
:closable="false"
|
|
||||||
show-icon
|
|
||||||
class="search-alert"
|
|
||||||
title="setting.packageMaterial.search"
|
|
||||||
description="按包材编码/名称模糊匹配,最多返回 50 条启用中的包材;关键字为空时返回前 50 条。"
|
|
||||||
/> -->
|
|
||||||
|
|
||||||
<el-form :inline="true" size="small" class="search-form" @submit.prevent="handleSearch">
|
|
||||||
<el-form-item label="关键字">
|
|
||||||
<el-input
|
|
||||||
v-model="keyword"
|
|
||||||
clearable
|
|
||||||
placeholder="编码 / 名称"
|
|
||||||
style="width: 260px"
|
|
||||||
@keyup.enter="handleSearch"
|
|
||||||
/>
|
|
||||||
</el-form-item>
|
|
||||||
<el-form-item>
|
|
||||||
<el-button type="primary" :loading="loading" @click="handleSearch">搜索</el-button>
|
|
||||||
<el-button :disabled="loading" @click="handleReset">重置</el-button>
|
|
||||||
</el-form-item>
|
|
||||||
</el-form>
|
|
||||||
|
|
||||||
<div class="result-meta">
|
|
||||||
共 {{ list.length }} 条(最多 50 条)
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-table
|
|
||||||
:data="list"
|
|
||||||
border
|
|
||||||
size="small"
|
|
||||||
max-height="420"
|
|
||||||
v-loading="loading"
|
|
||||||
row-key="id"
|
|
||||||
empty-text="暂无包材"
|
|
||||||
highlight-current-row
|
|
||||||
@row-dblclick="handleSelect"
|
|
||||||
>
|
|
||||||
<el-table-column prop="id" label="ID" width="72" />
|
|
||||||
<el-table-column prop="material_code" label="包材编码" min-width="130" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="material_name" label="包材名称" min-width="150" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="material_type" label="类型" min-width="100" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="spec" label="规格" min-width="120" show-overflow-tooltip />
|
|
||||||
<el-table-column label="状态" width="88" align="center">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag :type="formatPackageMaterialStatus(row.status).type" size="small">
|
|
||||||
{{ formatPackageMaterialStatus(row.status).text }}
|
|
||||||
</el-tag>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
<el-table-column v-if="selectable" label="操作" width="80" fixed="right" align="center">
|
|
||||||
<template #default="{ row }">
|
|
||||||
<el-button link type="primary" size="small" @click="handleSelect(row)">选择</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<template #footer>
|
|
||||||
<el-button size="small" @click="visible = false">关闭</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { ref, watch } from 'vue'
|
|
||||||
import { ElMessage } from 'element-plus'
|
|
||||||
import { packageMaterialSearch, type PackageMaterialSearchItem } from '@/api/setting.packagematerial/packagematerial'
|
|
||||||
import {
|
|
||||||
formatPackageMaterialStatus,
|
|
||||||
isPackageMaterialApiSuccess,
|
|
||||||
parsePackageMaterialSearchResponse,
|
|
||||||
type PackageMaterialRecord
|
|
||||||
} from '../package-material-config'
|
|
||||||
|
|
||||||
const visible = defineModel<boolean>({ default: false })
|
|
||||||
|
|
||||||
const props = withDefaults(
|
|
||||||
defineProps<{
|
|
||||||
/** 是否显示「选择」操作列并 emit select */
|
|
||||||
selectable?: boolean
|
|
||||||
/** 打开时预填关键字 */
|
|
||||||
initialKeyword?: string
|
|
||||||
}>(),
|
|
||||||
{
|
|
||||||
selectable: false,
|
|
||||||
initialKeyword: ''
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
(e: 'closed'): void
|
|
||||||
(e: 'select', row: PackageMaterialSearchItem): void
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const loading = ref(false)
|
|
||||||
const keyword = ref('')
|
|
||||||
const list = ref<PackageMaterialRecord[]>([])
|
|
||||||
|
|
||||||
watch(
|
|
||||||
() => visible.value,
|
|
||||||
(open) => {
|
|
||||||
if (!open) return
|
|
||||||
keyword.value = String(props.initialKeyword || '').trim()
|
|
||||||
void loadList()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
|
|
||||||
async function loadList() {
|
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
const payload: { keyword?: string } = {}
|
|
||||||
const text = keyword.value.trim()
|
|
||||||
if (text) payload.keyword = text
|
|
||||||
const res = await packageMaterialSearch(payload)
|
|
||||||
if (!isPackageMaterialApiSuccess(res)) {
|
|
||||||
throw new Error((res as any)?.message || '包材搜索失败')
|
|
||||||
}
|
|
||||||
list.value = parsePackageMaterialSearchResponse(res)
|
|
||||||
} catch (error: any) {
|
|
||||||
list.value = []
|
|
||||||
ElMessage.error(error?.message || '包材搜索失败')
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSearch() {
|
|
||||||
void loadList()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleReset() {
|
|
||||||
keyword.value = ''
|
|
||||||
void loadList()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSelect(row: PackageMaterialRecord) {
|
|
||||||
emit('select', row)
|
|
||||||
if (props.selectable) {
|
|
||||||
visible.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss">
|
|
||||||
.search-alert {
|
|
||||||
margin-bottom: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.search-form {
|
|
||||||
margin-bottom: 8px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.result-meta {
|
|
||||||
margin-bottom: 8px;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #909399;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@ -50,7 +50,6 @@
|
|||||||
@current-change="handleRowClick"
|
@current-change="handleRowClick"
|
||||||
@page-change="handlePageChange"
|
@page-change="handlePageChange"
|
||||||
@page-size-change="handlePageSizeChange"
|
@page-size-change="handlePageSizeChange"
|
||||||
@sort-change="handleSortChange"
|
|
||||||
@refresh="loadList"
|
@refresh="loadList"
|
||||||
@selection-change="onSelectionChange"
|
@selection-change="onSelectionChange"
|
||||||
>
|
>
|
||||||
@ -59,7 +58,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #column-weight="{ row }">
|
<template #column-weight="{ row }">
|
||||||
{{ formatNumber(row.weight) ? formatNumber(row.weight) + 'g' : '--' }}
|
{{ formatPackageMaterialWeight(row.weight) }}
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #column-cost_price="{ row }">
|
<template #column-cost_price="{ row }">
|
||||||
@ -267,7 +266,6 @@
|
|||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
<BatchImportDialog v-model="batchImportVisible" @success="onBatchImportSuccess" />
|
<BatchImportDialog v-model="batchImportVisible" @success="onBatchImportSuccess" />
|
||||||
<PackageMaterialSearchForm v-model="searchFormVisible" />
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -283,14 +281,12 @@ import { getStatusTextClass } from '@/utils/statusText'
|
|||||||
import { safeInvoke } from '@/utils/safe-invoke'
|
import { safeInvoke } from '@/utils/safe-invoke'
|
||||||
import * as indexApi from '@/api/index/index'
|
import * as indexApi from '@/api/index/index'
|
||||||
import BatchImportDialog from './component/BatchImportDialog.vue'
|
import BatchImportDialog from './component/BatchImportDialog.vue'
|
||||||
import PackageMaterialSearchForm from './form/PackageMaterialSearchForm.vue'
|
|
||||||
import {
|
import {
|
||||||
packageMaterialCreate,
|
packageMaterialCreate,
|
||||||
packageMaterialDelete,
|
packageMaterialDelete,
|
||||||
packageMaterialGet,
|
packageMaterialGet,
|
||||||
packageMaterialUpdate
|
packageMaterialUpdate
|
||||||
} from '@/api/setting.packagematerial/packagematerial'
|
} from '@/api/setting.packagematerial/packagematerial'
|
||||||
import { useSettingsStore } from '@/stores/modules/settings'
|
|
||||||
import {
|
import {
|
||||||
buildPackageMaterialListPayload,
|
buildPackageMaterialListPayload,
|
||||||
parsePackageMaterialListResponse,
|
parsePackageMaterialListResponse,
|
||||||
@ -298,13 +294,13 @@ import {
|
|||||||
formatDimensions,
|
formatDimensions,
|
||||||
formatNumber,
|
formatNumber,
|
||||||
formatPackageMaterialStatus,
|
formatPackageMaterialStatus,
|
||||||
|
formatPackageMaterialWeight,
|
||||||
normalizePackageMaterialScanConditionToWhere,
|
normalizePackageMaterialScanConditionToWhere,
|
||||||
packageMaterialColumns,
|
packageMaterialColumns,
|
||||||
packageMaterialScanFields,
|
packageMaterialScanFields,
|
||||||
type PackageMaterialRecord
|
type PackageMaterialRecord
|
||||||
} from './package-material-config'
|
} from './package-material-config'
|
||||||
|
|
||||||
const settingsStore = useSettingsStore()
|
|
||||||
const scanBox = ref<any>(null)
|
const scanBox = ref<any>(null)
|
||||||
const upperTable = ref<any>(null)
|
const upperTable = ref<any>(null)
|
||||||
const splitStackRef = ref<HTMLElement | null>(null)
|
const splitStackRef = ref<HTMLElement | null>(null)
|
||||||
@ -374,14 +370,12 @@ function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
|||||||
const queryTime = ref(0)
|
const queryTime = ref(0)
|
||||||
const tableSize = ref<'small' | 'default' | 'large'>('small')
|
const tableSize = ref<'small' | 'default' | 'large'>('small')
|
||||||
const currentConditionRaw = ref<any>(null)
|
const currentConditionRaw = ref<any>(null)
|
||||||
const currentSort = reactive({ prop: '', order: '' })
|
|
||||||
|
|
||||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||||
|
|
||||||
const dialogVisible = ref(false)
|
const dialogVisible = ref(false)
|
||||||
const dialogMode = ref<'create' | 'edit'>('create')
|
const dialogMode = ref<'create' | 'edit'>('create')
|
||||||
const batchImportVisible = ref(false)
|
const batchImportVisible = ref(false)
|
||||||
const searchFormVisible = ref(false)
|
|
||||||
const formRef = ref<FormInstance>()
|
const formRef = ref<FormInstance>()
|
||||||
const formData = reactive({
|
const formData = reactive({
|
||||||
id: undefined as number | undefined,
|
id: undefined as number | undefined,
|
||||||
@ -402,13 +396,6 @@ const rules: FormRules = {
|
|||||||
material_name: [{ required: true, message: '请输入包材名称', trigger: 'blur' }]
|
material_name: [{ required: true, message: '请输入包材名称', trigger: 'blur' }]
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleSortChange({ prop, order }: any) {
|
|
||||||
currentSort.prop = prop
|
|
||||||
currentSort.order = order
|
|
||||||
pagination.currentPage = 1
|
|
||||||
loadList()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleRowClick(_row: any) {
|
function handleRowClick(_row: any) {
|
||||||
// 预留行点击事件,用于未来扩展详情面板
|
// 预留行点击事件,用于未来扩展详情面板
|
||||||
}
|
}
|
||||||
@ -426,10 +413,30 @@ function onSelectionChange(rows: PackageMaterialRecord[]) {
|
|||||||
.map((id) => Number(id))
|
.map((id) => Number(id))
|
||||||
}
|
}
|
||||||
|
|
||||||
function pickOptionalNumber(value: number | undefined) {
|
function pickOptionalNumber(value: number | undefined | null) {
|
||||||
return value === undefined || value === null ? undefined : value
|
return value === undefined || value === null ? undefined : value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 编辑前的行快照:用于区分「未修改」与「被清空」 */
|
||||||
|
const editingSnapshot = ref<PackageMaterialRecord | null>(null)
|
||||||
|
|
||||||
|
type NumericFieldKey = 'length' | 'width' | 'height' | 'weight' | 'cost_price'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编辑态数值字段取值:
|
||||||
|
* - 有值 → 直接下发
|
||||||
|
* - 被清空(undefined/null/NaN)且原值有值 → 显式下发 null(后端 update 支持 null 清空,实测)
|
||||||
|
* - 原本就为空 → 不下发(保持“未传=保持原值”)
|
||||||
|
*/
|
||||||
|
function pickUpdateNumber(key: NumericFieldKey): number | null | undefined {
|
||||||
|
const current = formData[key]
|
||||||
|
const isEmpty = current === undefined || current === null || (typeof current === 'number' && Number.isNaN(current))
|
||||||
|
if (!isEmpty) return current
|
||||||
|
const before = editingSnapshot.value?.[key]
|
||||||
|
const hadValue = before !== undefined && before !== null
|
||||||
|
return hadValue ? null : undefined
|
||||||
|
}
|
||||||
|
|
||||||
function buildCreatePayload() {
|
function buildCreatePayload() {
|
||||||
const payload: Record<string, unknown> = {
|
const payload: Record<string, unknown> = {
|
||||||
material_code: formData.material_code.trim(),
|
material_code: formData.material_code.trim(),
|
||||||
@ -462,11 +469,11 @@ function buildUpdatePayload() {
|
|||||||
const spec = formData.spec.trim()
|
const spec = formData.spec.trim()
|
||||||
payload.material_type = materialType || ''
|
payload.material_type = materialType || ''
|
||||||
payload.spec = spec || ''
|
payload.spec = spec || ''
|
||||||
const length = pickOptionalNumber(formData.length)
|
const length = pickUpdateNumber('length')
|
||||||
const width = pickOptionalNumber(formData.width)
|
const width = pickUpdateNumber('width')
|
||||||
const height = pickOptionalNumber(formData.height)
|
const height = pickUpdateNumber('height')
|
||||||
const weight = pickOptionalNumber(formData.weight)
|
const weight = pickUpdateNumber('weight')
|
||||||
const costPrice = pickOptionalNumber(formData.cost_price)
|
const costPrice = pickUpdateNumber('cost_price')
|
||||||
if (length !== undefined) payload.length = length
|
if (length !== undefined) payload.length = length
|
||||||
if (width !== undefined) payload.width = width
|
if (width !== undefined) payload.width = width
|
||||||
if (height !== undefined) payload.height = height
|
if (height !== undefined) payload.height = height
|
||||||
@ -482,13 +489,11 @@ async function loadList() {
|
|||||||
const start = Date.now()
|
const start = Date.now()
|
||||||
try {
|
try {
|
||||||
const where = normalizePackageMaterialScanConditionToWhere(currentConditionRaw.value)
|
const where = normalizePackageMaterialScanConditionToWhere(currentConditionRaw.value)
|
||||||
const order = currentSort.prop ? { [currentSort.prop]: currentSort.order === 'ascending' ? 'ASC' : 'DESC' } : undefined
|
|
||||||
const res: any = await packageMaterialGet(
|
const res: any = await packageMaterialGet(
|
||||||
buildPackageMaterialListPayload({
|
buildPackageMaterialListPayload({
|
||||||
page: pagination.currentPage,
|
page: pagination.currentPage,
|
||||||
pageSize: pagination.pageSize,
|
pageSize: pagination.pageSize,
|
||||||
where,
|
where
|
||||||
order
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
if (!isSuccess(res)) {
|
if (!isSuccess(res)) {
|
||||||
@ -563,6 +568,7 @@ function resetForm() {
|
|||||||
formData.weight = undefined
|
formData.weight = undefined
|
||||||
formData.cost_price = undefined
|
formData.cost_price = undefined
|
||||||
formData.status = 1
|
formData.status = 1
|
||||||
|
editingSnapshot.value = null
|
||||||
formRef.value?.clearValidate()
|
formRef.value?.clearValidate()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -576,16 +582,17 @@ function openEdit(row: PackageMaterialRecord) {
|
|||||||
if (!row.id) return
|
if (!row.id) return
|
||||||
dialogMode.value = 'edit'
|
dialogMode.value = 'edit'
|
||||||
dialogVisible.value = true
|
dialogVisible.value = true
|
||||||
|
editingSnapshot.value = { ...row }
|
||||||
formData.id = row.id
|
formData.id = row.id
|
||||||
formData.material_code = row.material_code || ''
|
formData.material_code = row.material_code || ''
|
||||||
formData.material_name = row.material_name || ''
|
formData.material_name = row.material_name || ''
|
||||||
formData.material_type = row.material_type || ''
|
formData.material_type = row.material_type || ''
|
||||||
formData.spec = row.spec || ''
|
formData.spec = row.spec || ''
|
||||||
formData.length = row.length
|
formData.length = row.length ?? undefined
|
||||||
formData.width = row.width
|
formData.width = row.width ?? undefined
|
||||||
formData.height = row.height
|
formData.height = row.height ?? undefined
|
||||||
formData.weight = row.weight
|
formData.weight = row.weight ?? undefined
|
||||||
formData.cost_price = row.cost_price
|
formData.cost_price = row.cost_price ?? undefined
|
||||||
formData.status = row.status === 0 ? 0 : 1
|
formData.status = row.status === 0 ? 0 : 1
|
||||||
formRef.value?.clearValidate()
|
formRef.value?.clearValidate()
|
||||||
}
|
}
|
||||||
|
|||||||
@ -57,6 +57,8 @@ export const packageMaterialColumns = [
|
|||||||
{ prop: 'weight', label: '重量(g)', width: '90' },
|
{ prop: 'weight', label: '重量(g)', width: '90' },
|
||||||
{ prop: 'cost_price', label: '成本价', width: '100' },
|
{ prop: 'cost_price', label: '成本价', width: '100' },
|
||||||
{ prop: 'status', label: '状态', width: '90' },
|
{ prop: 'status', label: '状态', width: '90' },
|
||||||
|
{ prop: 'created_at', label: '创建时间', width: '168', formatter: (row: PackageMaterialRecord) => formatDateTime(row.created_at) },
|
||||||
|
{ prop: 'updated_at', label: '更新时间', width: '168', formatter: (row: PackageMaterialRecord) => formatDateTime(row.updated_at) },
|
||||||
{ prop: 'actions', label: '操作', width: '150', fixed: 'right' }
|
{ prop: 'actions', label: '操作', width: '150', fixed: 'right' }
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -67,8 +69,11 @@ export const packageMaterialScanFields = [
|
|||||||
type: 'text',
|
type: 'text',
|
||||||
group: '基础信息',
|
group: '基础信息',
|
||||||
placeholder: '编码/名称/类型',
|
placeholder: '编码/名称/类型',
|
||||||
operators: ['eq','contains'],
|
// quickWhere 由 normalizePackageMaterialScanConditionToWhere 固定转成纯字符串(后端按模糊匹配处理),
|
||||||
defaultOperator: 'eq'
|
// 操作符实际不生效,故隐藏下拉避免“等于”误导
|
||||||
|
operators: ['contains'],
|
||||||
|
defaultOperator: 'contains',
|
||||||
|
hideOperator: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'material_code',
|
value: 'material_code',
|
||||||
@ -223,15 +228,30 @@ export function formatNumber(value: unknown, digits = 2): string {
|
|||||||
return Number.isInteger(num) ? String(num) : num.toFixed(digits)
|
return Number.isInteger(num) ? String(num) : num.toFixed(digits)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 重量展示:空值直接 --,有值补 g 单位(避免出现 `--g`) */
|
||||||
|
export function formatPackageMaterialWeight(value: unknown): string {
|
||||||
|
if (value === null || value === undefined || value === '') return '--'
|
||||||
|
const num = Number(value)
|
||||||
|
if (!Number.isFinite(num)) return String(value)
|
||||||
|
return `${formatNumber(num)}g`
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 时间展示:YYYY-MM-DD HH:mm:ss,空值/非法值回退 -- */
|
||||||
|
export function formatDateTime(value: unknown): string {
|
||||||
|
if (value === null || value === undefined || value === '') return '--'
|
||||||
|
const date = new Date(String(value))
|
||||||
|
if (Number.isNaN(date.getTime())) return String(value)
|
||||||
|
const pad = (n: number) => String(n).padStart(2, '0')
|
||||||
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`
|
||||||
|
}
|
||||||
|
|
||||||
export function buildPackageMaterialListPayload(options: {
|
export function buildPackageMaterialListPayload(options: {
|
||||||
page: number
|
page: number
|
||||||
pageSize: number
|
pageSize: number
|
||||||
where?: Record<string, unknown>
|
where?: Record<string, unknown>
|
||||||
order?: Record<string, string>
|
|
||||||
}) {
|
}) {
|
||||||
|
// 仅用文档声明的 pagination;顶层 page/pageSize 与后端的 order/sort 均未在文档中且实测被忽略
|
||||||
const payload: Record<string, unknown> = {
|
const payload: Record<string, unknown> = {
|
||||||
page: options.page,
|
|
||||||
pageSize: options.pageSize,
|
|
||||||
pagination: {
|
pagination: {
|
||||||
page: options.page,
|
page: options.page,
|
||||||
pageSize: options.pageSize
|
pageSize: options.pageSize
|
||||||
@ -240,9 +260,6 @@ export function buildPackageMaterialListPayload(options: {
|
|||||||
if (options.where && Object.keys(options.where).length) {
|
if (options.where && Object.keys(options.where).length) {
|
||||||
payload.where = options.where
|
payload.where = options.where
|
||||||
}
|
}
|
||||||
if (options.order && Object.keys(options.order).length) {
|
|
||||||
payload.order = options.order
|
|
||||||
}
|
|
||||||
return payload
|
return payload
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -50,7 +50,6 @@
|
|||||||
@current-change="handleRowClick"
|
@current-change="handleRowClick"
|
||||||
@page-change="handlePageChange"
|
@page-change="handlePageChange"
|
||||||
@page-size-change="handlePageSizeChange"
|
@page-size-change="handlePageSizeChange"
|
||||||
@sort-change="handleSortChange"
|
|
||||||
@refresh="loadList"
|
@refresh="loadList"
|
||||||
@selection-change="onSelectionChange"
|
@selection-change="onSelectionChange"
|
||||||
>
|
>
|
||||||
@ -192,7 +191,6 @@ import {
|
|||||||
packageSupplierGet,
|
packageSupplierGet,
|
||||||
packageSupplierUpdate
|
packageSupplierUpdate
|
||||||
} from '@/api/setting.packagesupplier/packagesupplier'
|
} from '@/api/setting.packagesupplier/packagesupplier'
|
||||||
import { useSettingsStore } from '@/stores/modules/settings'
|
|
||||||
import {
|
import {
|
||||||
buildPackageSupplierListPayload,
|
buildPackageSupplierListPayload,
|
||||||
parsePackageSupplierListResponse,
|
parsePackageSupplierListResponse,
|
||||||
@ -204,7 +202,6 @@ import {
|
|||||||
type PackageSupplierRecord
|
type PackageSupplierRecord
|
||||||
} from './package-supplier-config'
|
} from './package-supplier-config'
|
||||||
|
|
||||||
const settingsStore = useSettingsStore()
|
|
||||||
const scanBox = ref<any>(null)
|
const scanBox = ref<any>(null)
|
||||||
const upperTable = ref<any>(null)
|
const upperTable = ref<any>(null)
|
||||||
const splitStackRef = ref<HTMLElement | null>(null)
|
const splitStackRef = ref<HTMLElement | null>(null)
|
||||||
@ -273,7 +270,6 @@ function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
|||||||
const queryTime = ref(0)
|
const queryTime = ref(0)
|
||||||
const tableSize = ref<'small' | 'default' | 'large'>('small')
|
const tableSize = ref<'small' | 'default' | 'large'>('small')
|
||||||
const currentConditionRaw = ref<any>(null)
|
const currentConditionRaw = ref<any>(null)
|
||||||
const currentSort = reactive({ prop: '', order: '' })
|
|
||||||
|
|
||||||
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
const pagination = reactive({ currentPage: 1, pageSize: 20, total: 0 })
|
||||||
|
|
||||||
@ -296,13 +292,6 @@ const rules: FormRules = {
|
|||||||
|
|
||||||
const isSuccess = (res: any) => res && [0, 1, 200].includes(res.code)
|
const isSuccess = (res: any) => res && [0, 1, 200].includes(res.code)
|
||||||
|
|
||||||
function handleSortChange({ prop, order }: any) {
|
|
||||||
currentSort.prop = prop
|
|
||||||
currentSort.order = order
|
|
||||||
pagination.currentPage = 1
|
|
||||||
loadList()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleRowClick(_row: any) {
|
function handleRowClick(_row: any) {
|
||||||
// 预留行点击事件,用于未来扩展详情面板
|
// 预留行点击事件,用于未来扩展详情面板
|
||||||
}
|
}
|
||||||
@ -348,13 +337,11 @@ async function loadList() {
|
|||||||
const start = Date.now()
|
const start = Date.now()
|
||||||
try {
|
try {
|
||||||
const where = normalizePackageSupplierScanConditionToWhere(currentConditionRaw.value)
|
const where = normalizePackageSupplierScanConditionToWhere(currentConditionRaw.value)
|
||||||
const order = currentSort.prop ? { [currentSort.prop]: currentSort.order === 'ascending' ? 'ASC' : 'DESC' } : undefined
|
|
||||||
const res: any = await packageSupplierGet(
|
const res: any = await packageSupplierGet(
|
||||||
buildPackageSupplierListPayload({
|
buildPackageSupplierListPayload({
|
||||||
page: pagination.currentPage,
|
page: pagination.currentPage,
|
||||||
pageSize: pagination.pageSize,
|
pageSize: pagination.pageSize,
|
||||||
where,
|
where
|
||||||
order
|
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
if (!isSuccess(res)) {
|
if (!isSuccess(res)) {
|
||||||
|
|||||||
@ -39,9 +39,11 @@ export const packageSupplierColumns = [
|
|||||||
// { prop: 'id', label: 'ID', width: '80', sortable: true },
|
// { prop: 'id', label: 'ID', width: '80', sortable: true },
|
||||||
{ prop: 'supplier_code', label: '供应商编码', minWidth: '130', showOverflowTooltip: true },
|
{ prop: 'supplier_code', label: '供应商编码', minWidth: '130', showOverflowTooltip: true },
|
||||||
{ prop: 'supplier_name', label: '供应商名称', minWidth: '160', showOverflowTooltip: true },
|
{ prop: 'supplier_name', label: '供应商名称', minWidth: '160', showOverflowTooltip: true },
|
||||||
{ prop: 'contact_name', label: '联系人', minWidth: '120', showOverflowTooltip: true },
|
{ prop: 'contact_name', label: '联系人', minWidth: '120', showOverflowTooltip: true, formatter: (row: PackageSupplierRecord) => formatOptionalText(row.contact_name) },
|
||||||
{ prop: 'contact_phone', label: '联系电话', minWidth: '140', showOverflowTooltip: true },
|
{ prop: 'contact_phone', label: '联系电话', minWidth: '140', showOverflowTooltip: true, formatter: (row: PackageSupplierRecord) => formatOptionalText(row.contact_phone) },
|
||||||
{ prop: 'status', label: '状态', width: '90' },
|
{ prop: 'status', label: '状态', width: '90' },
|
||||||
|
{ prop: 'created_at', label: '创建时间', width: '168', formatter: (row: PackageSupplierRecord) => formatDateTime(row.created_at) },
|
||||||
|
{ prop: 'updated_at', label: '更新时间', width: '168', formatter: (row: PackageSupplierRecord) => formatDateTime(row.updated_at) },
|
||||||
{ prop: 'actions', label: '操作', width: '150', fixed: 'right' }
|
{ prop: 'actions', label: '操作', width: '150', fixed: 'right' }
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -52,8 +54,11 @@ export const packageSupplierScanFields = [
|
|||||||
type: 'text',
|
type: 'text',
|
||||||
group: '基础信息',
|
group: '基础信息',
|
||||||
placeholder: '编码/名称/联系人/电话',
|
placeholder: '编码/名称/联系人/电话',
|
||||||
operators: ['eq','contains'],
|
// quickWhere 由 normalizePackageSupplierScanConditionToWhere 固定转成纯字符串(后端按模糊匹配处理),
|
||||||
defaultOperator: 'eq'
|
// 操作符实际不生效,故隐藏下拉避免“等于”误导
|
||||||
|
operators: ['contains'],
|
||||||
|
defaultOperator: 'contains',
|
||||||
|
hideOperator: true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
value: 'supplier_code',
|
value: 'supplier_code',
|
||||||
@ -189,6 +194,21 @@ export function normalizePackageSupplierScanConditionToWhere(
|
|||||||
return where
|
return where
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 文本展示:空值 / 空串统一显示 -- */
|
||||||
|
export function formatOptionalText(value: unknown): string {
|
||||||
|
const text = String(value ?? '').trim()
|
||||||
|
return text || '--'
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 时间展示:YYYY-MM-DD HH:mm:ss,空值/非法值回退 -- */
|
||||||
|
export function formatDateTime(value: unknown): string {
|
||||||
|
if (value === null || value === undefined || value === '') return '--'
|
||||||
|
const date = new Date(String(value))
|
||||||
|
if (Number.isNaN(date.getTime())) return String(value)
|
||||||
|
const pad = (n: number) => String(n).padStart(2, '0')
|
||||||
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}:${pad(date.getSeconds())}`
|
||||||
|
}
|
||||||
|
|
||||||
export function formatPackageSupplierStatus(status: string | number | undefined) {
|
export function formatPackageSupplierStatus(status: string | number | undefined) {
|
||||||
const raw = String(status ?? '').trim()
|
const raw = String(status ?? '').trim()
|
||||||
if (!raw) return { text: '--', type: 'info' as const }
|
if (!raw) return { text: '--', type: 'info' as const }
|
||||||
@ -205,11 +225,9 @@ export function buildPackageSupplierListPayload(options: {
|
|||||||
page: number
|
page: number
|
||||||
pageSize: number
|
pageSize: number
|
||||||
where?: Record<string, unknown>
|
where?: Record<string, unknown>
|
||||||
order?: Record<string, string>
|
|
||||||
}) {
|
}) {
|
||||||
|
// 仅用文档声明的 pagination;顶层 page/pageSize 与后端的 order/sort 均未在文档中且实测被忽略
|
||||||
const payload: Record<string, unknown> = {
|
const payload: Record<string, unknown> = {
|
||||||
page: options.page,
|
|
||||||
pageSize: options.pageSize,
|
|
||||||
pagination: {
|
pagination: {
|
||||||
page: options.page,
|
page: options.page,
|
||||||
pageSize: options.pageSize
|
pageSize: options.pageSize
|
||||||
@ -218,9 +236,6 @@ export function buildPackageSupplierListPayload(options: {
|
|||||||
if (options.where && Object.keys(options.where).length) {
|
if (options.where && Object.keys(options.where).length) {
|
||||||
payload.where = options.where
|
payload.where = options.where
|
||||||
}
|
}
|
||||||
if (options.order && Object.keys(options.order).length) {
|
|
||||||
payload.order = options.order
|
|
||||||
}
|
|
||||||
return payload
|
return payload
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -93,6 +93,14 @@ export function translateEntryField(fieldValue: string, value: unknown): string
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const availableFields: EntryScanFieldConfig[] = [
|
export const availableFields: EntryScanFieldConfig[] = [
|
||||||
|
// 快捷搜索:对应 where.quickWhere(服务端在入库单号/采购单号/供应商/货主/仓库等字段 OR 模糊),直接传字符串
|
||||||
|
entryScanBasicField({
|
||||||
|
label: '快捷搜索',
|
||||||
|
value: 'quickWhere',
|
||||||
|
type: 'text',
|
||||||
|
placeholder: '入库单号/采购单号/供应商',
|
||||||
|
hideOperator: true,
|
||||||
|
}),
|
||||||
entryScanBasicField({
|
entryScanBasicField({
|
||||||
label: '入库单号',
|
label: '入库单号',
|
||||||
value: 'entry_order_code',
|
value: 'entry_order_code',
|
||||||
@ -1051,20 +1059,3 @@ export function buildReceivingCompareSummaryItems(
|
|||||||
|
|
||||||
return items
|
return items
|
||||||
}
|
}
|
||||||
|
|
||||||
export const addEntryFields = [
|
|
||||||
{ label: '业务类型', prop: 'order_type', type: 'select', options: [
|
|
||||||
{ label: '生产入库', value: 'SCRK' },
|
|
||||||
{ label: '领用入库', value: 'LYRK' },
|
|
||||||
{ label: '拆解入库', value: 'CCRK' },
|
|
||||||
{ label: '采购入库', value: 'CGRK' },
|
|
||||||
{ label: '调拨入库', value: 'DBRK' },
|
|
||||||
{ label: '其他入库', value: 'QTRK' },
|
|
||||||
{ label: 'B2B入库', value: 'B2BRK' },
|
|
||||||
{ label: '虚拟入库', value: 'XNRK' },
|
|
||||||
]},
|
|
||||||
{ label: '货主', prop: 'store_id', type: 'select', options: [] },
|
|
||||||
{ label: '入库单号', prop: 'entry_order_code' },
|
|
||||||
{ label: '采购单号', prop: 'purchase_order_code' },
|
|
||||||
{ label: '备注', prop: 'remark', type: 'textarea' }
|
|
||||||
]
|
|
||||||
|
|||||||
@ -230,33 +230,6 @@
|
|||||||
:receiving-bindings="receivingBindingsDialogData"
|
:receiving-bindings="receivingBindingsDialogData"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- 新建入库单对话框 -->
|
|
||||||
<el-dialog
|
|
||||||
v-model="createDialogVisible"
|
|
||||||
title="新建入库单"
|
|
||||||
width="600px"
|
|
||||||
align-center
|
|
||||||
@closed="handleCreateDialogClosed"
|
|
||||||
>
|
|
||||||
<el-form :model="createForm" label-width="100px" size="small">
|
|
||||||
<el-row :gutter="20">
|
|
||||||
<el-col v-for="field in addEntryFieldsRef" :key="field.prop" :span="field.type === 'textarea' ? 24 : 12">
|
|
||||||
<el-form-item :label="field.label">
|
|
||||||
<el-select v-if="field.type === 'select'" v-model="createForm[field.prop]" :placeholder="'请选择' + field.label" style="width: 100%" filterable>
|
|
||||||
<el-option v-for="opt in field.options" :key="opt.value" :label="opt.label" :value="opt.value" />
|
|
||||||
</el-select>
|
|
||||||
<el-input v-else-if="field.type === 'textarea'" v-model="createForm[field.prop]" type="textarea" :rows="3" :placeholder="'请输入' + field.label" />
|
|
||||||
<el-input v-else v-model="createForm[field.prop]" :placeholder="'请输入' + field.label" />
|
|
||||||
</el-form-item>
|
|
||||||
</el-col>
|
|
||||||
</el-row>
|
|
||||||
</el-form>
|
|
||||||
<template #footer>
|
|
||||||
<el-button size="small" @click="createDialogVisible = false">取消</el-button>
|
|
||||||
<el-button size="small" type="primary" :loading="createLoading" @click="submitCreateEntry">确定</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
|
|
||||||
<!-- 开始入库确认(面板结构参考「批量发货」) -->
|
<!-- 开始入库确认(面板结构参考「批量发货」) -->
|
||||||
<el-dialog
|
<el-dialog
|
||||||
v-model="reviewDialogVisible"
|
v-model="reviewDialogVisible"
|
||||||
@ -412,7 +385,6 @@ import type { StorageEntryListParams } from '@/api/storage.entry/entry'
|
|||||||
import {
|
import {
|
||||||
availableFields,
|
availableFields,
|
||||||
entryColums,
|
entryColums,
|
||||||
addEntryFields,
|
|
||||||
entryToolbarButtons,
|
entryToolbarButtons,
|
||||||
formatEntryOrderStatus,
|
formatEntryOrderStatus,
|
||||||
getEntryOrderStatusTagType,
|
getEntryOrderStatusTagType,
|
||||||
@ -497,7 +469,6 @@ const currentConditionRaw = ref<any>(null)
|
|||||||
|
|
||||||
const presetTree = ref<any[]>([])
|
const presetTree = ref<any[]>([])
|
||||||
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(availableFields)))
|
const availableFieldsRef = reactive(JSON.parse(JSON.stringify(availableFields)))
|
||||||
const addEntryFieldsRef = reactive(JSON.parse(JSON.stringify(addEntryFields)))
|
|
||||||
|
|
||||||
const activeTab = ref('details')
|
const activeTab = ref('details')
|
||||||
|
|
||||||
@ -582,15 +553,22 @@ function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
|||||||
safeInvoke(() => handler())
|
safeInvoke(() => handler())
|
||||||
}
|
}
|
||||||
|
|
||||||
const quickSearch = ref('')
|
|
||||||
const currentSort = reactive({ prop: '', order: '' })
|
const currentSort = reactive({ prop: '', order: '' })
|
||||||
|
|
||||||
// 导出相关 —— 使用异步任务模式
|
// 导出相关 —— 使用异步任务模式
|
||||||
function buildExportPayload() {
|
function buildExportPayload() {
|
||||||
if (currentCondition.value && currentCondition.value !== 'reset') {
|
const sort = currentSort.prop
|
||||||
return { where: normalizeToWhere(currentCondition.value) }
|
? {
|
||||||
}
|
sortField: currentSort.prop,
|
||||||
return { where: normalizeToWhere({}) }
|
sortOrder: currentSort.order === 'ascending' ? 'ASC' : 'DESC'
|
||||||
|
}
|
||||||
|
: undefined
|
||||||
|
const where =
|
||||||
|
currentCondition.value && currentCondition.value !== 'reset'
|
||||||
|
? normalizeToWhere(currentCondition.value)
|
||||||
|
: normalizeToWhere({})
|
||||||
|
// 导出接口(未文档化)实测接受 sort,与列表保持同序
|
||||||
|
return sort ? { where, sort } : { where }
|
||||||
}
|
}
|
||||||
|
|
||||||
function buildExportSelectedPayload() {
|
function buildExportSelectedPayload() {
|
||||||
@ -744,6 +722,17 @@ function formatTime(val: any) {
|
|||||||
* - 是简单值(string/number/array):包装为 { operator: 'eq', value: val }
|
* - 是简单值(string/number/array):包装为 { operator: 'eq', value: val }
|
||||||
* - 空或 undefined:忽略该字段
|
* - 空或 undefined:忽略该字段
|
||||||
*/
|
*/
|
||||||
|
/**
|
||||||
|
* quickWhere:项目惯例直接传字符串(服务端在入库单号/采购单号/供应商/货主/仓库等字段 OR 模糊),
|
||||||
|
* 不能包成 { operator, value } 对象
|
||||||
|
*/
|
||||||
|
function assignQuickWhere(source: any, where: Record<string, any>) {
|
||||||
|
const raw = source?.quickWhere
|
||||||
|
const text = raw && typeof raw === 'object' && 'value' in raw ? (raw as any).value : raw
|
||||||
|
if (text === undefined || text === null || String(text).trim() === '') return
|
||||||
|
where.quickWhere = String(text).trim()
|
||||||
|
}
|
||||||
|
|
||||||
// 将 scan-box 返回的条件标准化为后端推荐结构:{ operator, value, type }
|
// 将 scan-box 返回的条件标准化为后端推荐结构:{ operator, value, type }
|
||||||
function normalizeToWhere(condition: any) {
|
function normalizeToWhere(condition: any) {
|
||||||
if (!condition) return {}
|
if (!condition) return {}
|
||||||
@ -789,7 +778,9 @@ function normalizeToWhere(condition: any) {
|
|||||||
// 如果来自 ScanBox 的 preset(包含 conditions)
|
// 如果来自 ScanBox 的 preset(包含 conditions)
|
||||||
if (condition.conditions && typeof condition.conditions === 'object') {
|
if (condition.conditions && typeof condition.conditions === 'object') {
|
||||||
const where: any = {}
|
const where: any = {}
|
||||||
|
assignQuickWhere(condition.conditions, where)
|
||||||
Object.keys(condition.conditions).forEach(k => {
|
Object.keys(condition.conditions).forEach(k => {
|
||||||
|
if (k === 'quickWhere') return
|
||||||
const result = processConditionValue(k, condition.conditions[k])
|
const result = processConditionValue(k, condition.conditions[k])
|
||||||
if (result) where[k] = result
|
if (result) where[k] = result
|
||||||
})
|
})
|
||||||
@ -799,7 +790,9 @@ function normalizeToWhere(condition: any) {
|
|||||||
// 普通自定义条件对象
|
// 普通自定义条件对象
|
||||||
if (typeof condition === 'object') {
|
if (typeof condition === 'object') {
|
||||||
const where: any = {}
|
const where: any = {}
|
||||||
|
assignQuickWhere(condition, where)
|
||||||
Object.keys(condition).forEach(k => {
|
Object.keys(condition).forEach(k => {
|
||||||
|
if (k === 'quickWhere') return
|
||||||
const result = processConditionValue(k, condition[k])
|
const result = processConditionValue(k, condition[k])
|
||||||
if (result) where[k] = result
|
if (result) where[k] = result
|
||||||
})
|
})
|
||||||
@ -989,9 +982,6 @@ async function loadFilterData() {
|
|||||||
const stores = storesRes.stores || []
|
const stores = storesRes.stores || []
|
||||||
const f = availableFieldsRef.find((i: any) => i.value === 'store_id')
|
const f = availableFieldsRef.find((i: any) => i.value === 'store_id')
|
||||||
if (f) f.options = stores
|
if (f) f.options = stores
|
||||||
|
|
||||||
const af = addEntryFieldsRef.find((i: any) => i.prop === 'store_id')
|
|
||||||
if (af) af.options = stores
|
|
||||||
}
|
}
|
||||||
if (presetRes && presetRes.code === 200) {
|
if (presetRes && presetRes.code === 200) {
|
||||||
presetTree.value = presetRes.presetTree || []
|
presetTree.value = presetRes.presetTree || []
|
||||||
@ -1069,26 +1059,6 @@ function handlePageSizeChange(size: number) {
|
|||||||
loadData()
|
loadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
function onQuickSearch() {
|
|
||||||
pagination.currentPage = 1
|
|
||||||
loadData()
|
|
||||||
}
|
|
||||||
|
|
||||||
// 新建入库单相关
|
|
||||||
const createDialogVisible = ref(false)
|
|
||||||
const createLoading = ref(false)
|
|
||||||
const createForm = reactive<any>({
|
|
||||||
order_type: '',
|
|
||||||
store_id: '',
|
|
||||||
entry_order_code: '',
|
|
||||||
purchase_order_code: '',
|
|
||||||
remark: ''
|
|
||||||
})
|
|
||||||
|
|
||||||
function handleCreateEntry() {
|
|
||||||
ElMessage.warning('接口已下线:入库单不再支持手工新建,请使用快捷入库/匹配入库流程')
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 一键上架后是否通知货主:返回 0=通知、1=不通知;关闭/ESC 返回 null(取消) */
|
/** 一键上架后是否通知货主:返回 0=通知、1=不通知;关闭/ESC 返回 null(取消) */
|
||||||
async function askOwnerNotice(actionDesc: string): Promise<number | null> {
|
async function askOwnerNotice(actionDesc: string): Promise<number | null> {
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
@ -1231,13 +1201,6 @@ async function handleReviewConfirm() {
|
|||||||
reviewSubmitting.value = false
|
reviewSubmitting.value = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function handleCreateDialogClosed() {
|
|
||||||
Object.keys(createForm).forEach(key => createForm[key] = '')
|
|
||||||
}
|
|
||||||
|
|
||||||
async function submitCreateEntry() {
|
|
||||||
ElMessage.warning('接口已下线:storage.entry.create 不再对外开放')
|
|
||||||
}
|
|
||||||
|
|
||||||
async function confirmBatchCancel() {
|
async function confirmBatchCancel() {
|
||||||
if (!selectionRows.value.length) {
|
if (!selectionRows.value.length) {
|
||||||
|
|||||||
@ -1,534 +0,0 @@
|
|||||||
<template>
|
|
||||||
<el-dialog
|
|
||||||
v-model="visible"
|
|
||||||
title="按商品编码筛选"
|
|
||||||
width="720px"
|
|
||||||
align-center
|
|
||||||
append-to-body
|
|
||||||
destroy-on-close
|
|
||||||
@closed="handleClosed"
|
|
||||||
>
|
|
||||||
<div class="picker-meta">
|
|
||||||
<span v-if="storeId">货主 ID:{{ storeId }}</span>
|
|
||||||
<span v-else>全部货主</span>
|
|
||||||
<span>已选 {{ localSelectedItems.length }} 个商品</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="picker-toolbar">
|
|
||||||
<el-input
|
|
||||||
v-model="keyword"
|
|
||||||
placeholder="支持多个商品编码,逗号分隔"
|
|
||||||
clearable
|
|
||||||
size="small"
|
|
||||||
@keyup.enter="handleSearch"
|
|
||||||
/>
|
|
||||||
<el-button type="primary" size="small" :loading="loading" @click="handleSearch">
|
|
||||||
查询
|
|
||||||
</el-button>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<el-table
|
|
||||||
ref="tableRef"
|
|
||||||
:data="list"
|
|
||||||
border
|
|
||||||
size="small"
|
|
||||||
max-height="280"
|
|
||||||
v-loading="loading"
|
|
||||||
row-key="item_id"
|
|
||||||
empty-text="暂无商品"
|
|
||||||
@selection-change="handleSelectionChange"
|
|
||||||
>
|
|
||||||
<el-table-column type="selection" width="46" :reserve-selection="true" />
|
|
||||||
<el-table-column prop="item_id" label="商品ID" width="90" />
|
|
||||||
<el-table-column prop="item_code" label="商品编码" min-width="120" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="item_name" label="商品名称" min-width="130" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="barcode" label="条码" min-width="100" show-overflow-tooltip />
|
|
||||||
</el-table>
|
|
||||||
|
|
||||||
<div class="picker-pagination">
|
|
||||||
<el-pagination
|
|
||||||
background
|
|
||||||
small
|
|
||||||
layout="total, prev, pager, next"
|
|
||||||
:total="pagination.total"
|
|
||||||
:current-page="pagination.currentPage"
|
|
||||||
:page-size="pagination.pageSize"
|
|
||||||
@current-change="handlePageChange"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="selected-items-panel">
|
|
||||||
<div class="selected-items-title">已选商品(将写入左侧商品ID筛选)</div>
|
|
||||||
<el-table :data="localSelectedItems" border size="small" max-height="160" empty-text="未选择商品">
|
|
||||||
<el-table-column prop="item_id" label="商品ID" width="90" />
|
|
||||||
<el-table-column prop="item_code" label="编码" min-width="100" show-overflow-tooltip />
|
|
||||||
<el-table-column prop="item_name" label="名称" min-width="110" show-overflow-tooltip />
|
|
||||||
<el-table-column label="操作" width="60">
|
|
||||||
<template #default="{ row: item }">
|
|
||||||
<el-button type="danger" link size="small" @click="removeSelectedItem(item)">移除</el-button>
|
|
||||||
</template>
|
|
||||||
</el-table-column>
|
|
||||||
</el-table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<template #footer>
|
|
||||||
<el-button size="small" @click="visible = false">取消</el-button>
|
|
||||||
<el-button size="small" type="primary" @click="handleConfirm">确定筛选</el-button>
|
|
||||||
</template>
|
|
||||||
</el-dialog>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts">
|
|
||||||
import { nextTick, reactive, ref, watch } from 'vue'
|
|
||||||
import { ElMessage } from 'element-plus'
|
|
||||||
import { warehouseSearch } from '@/api/stock/stock'
|
|
||||||
|
|
||||||
export type InventoryStockPickerItem = {
|
|
||||||
item_id?: number
|
|
||||||
item_code: string
|
|
||||||
item_name: string
|
|
||||||
barcode: string
|
|
||||||
store_id?: number
|
|
||||||
}
|
|
||||||
|
|
||||||
const visible = defineModel<boolean>({ default: false })
|
|
||||||
|
|
||||||
const props = defineProps<{
|
|
||||||
storeId?: number
|
|
||||||
selectedItems?: InventoryStockPickerItem[]
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const emit = defineEmits<{
|
|
||||||
confirm: [items: InventoryStockPickerItem[]]
|
|
||||||
}>()
|
|
||||||
|
|
||||||
const loading = ref(false)
|
|
||||||
const keyword = ref('')
|
|
||||||
const allRows = ref<any[]>([])
|
|
||||||
const list = ref<any[]>([])
|
|
||||||
const syncingSelection = ref(false)
|
|
||||||
const tableRef = ref<any>(null)
|
|
||||||
const localSelectedItems = ref<InventoryStockPickerItem[]>([])
|
|
||||||
const pagination = reactive({
|
|
||||||
currentPage: 1,
|
|
||||||
pageSize: 20,
|
|
||||||
total: 0
|
|
||||||
})
|
|
||||||
|
|
||||||
watch(visible, (opened) => {
|
|
||||||
if (!opened) return
|
|
||||||
localSelectedItems.value = (props.selectedItems || []).map((item) => ({ ...item }))
|
|
||||||
keyword.value = ''
|
|
||||||
pagination.currentPage = 1
|
|
||||||
void initDialog()
|
|
||||||
})
|
|
||||||
|
|
||||||
function getSearchKeyword() {
|
|
||||||
return String(keyword.value || '')
|
|
||||||
.replace(/[\r\n]+/g, ',')
|
|
||||||
.replace(/[,;;、]/g, ',')
|
|
||||||
.split(',')
|
|
||||||
.map((s) => s.trim())
|
|
||||||
.filter((s) => s !== '')
|
|
||||||
.join(',')
|
|
||||||
}
|
|
||||||
|
|
||||||
async function initDialog() {
|
|
||||||
syncingSelection.value = true
|
|
||||||
try {
|
|
||||||
tableRef.value?.clearSelection?.()
|
|
||||||
await loadList()
|
|
||||||
await enrichLocalSelectedItems()
|
|
||||||
await syncSelectionFromLocal()
|
|
||||||
} finally {
|
|
||||||
await nextTick()
|
|
||||||
syncingSelection.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleClosed() {
|
|
||||||
keyword.value = ''
|
|
||||||
localSelectedItems.value = []
|
|
||||||
resetListState()
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetListState() {
|
|
||||||
allRows.value = []
|
|
||||||
list.value = []
|
|
||||||
pagination.currentPage = 1
|
|
||||||
pagination.total = 0
|
|
||||||
tableRef.value?.clearSelection?.()
|
|
||||||
}
|
|
||||||
|
|
||||||
function hasValidItemId(item: InventoryStockPickerItem) {
|
|
||||||
const itemId = Number(item.item_id)
|
|
||||||
return Number.isInteger(itemId) && itemId > 0
|
|
||||||
}
|
|
||||||
|
|
||||||
function getStockItemId(row: any): number | undefined {
|
|
||||||
const candidates = [
|
|
||||||
row?.item_id,
|
|
||||||
row?.id,
|
|
||||||
row?.store_stock?.item_id,
|
|
||||||
row?.store_stock?.id,
|
|
||||||
row?.stock?.item_id,
|
|
||||||
row?.stock?.id,
|
|
||||||
row?.goods?.item_id,
|
|
||||||
row?.goods?.id
|
|
||||||
]
|
|
||||||
for (const candidate of candidates) {
|
|
||||||
const itemId = Number(candidate)
|
|
||||||
if (Number.isInteger(itemId) && itemId > 0) return itemId
|
|
||||||
}
|
|
||||||
return undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
function getStockItemCode(row: any) {
|
|
||||||
const candidates = [
|
|
||||||
row?.item_code,
|
|
||||||
row?.goods_code,
|
|
||||||
row?.store_stock?.item_code,
|
|
||||||
row?.store_stock?.goods_code,
|
|
||||||
row?.stock?.item_code,
|
|
||||||
row?.stock?.goods_code,
|
|
||||||
row?.goods?.item_code,
|
|
||||||
row?.goods?.goods_code
|
|
||||||
]
|
|
||||||
for (const candidate of candidates) {
|
|
||||||
const text = String(candidate ?? '').trim()
|
|
||||||
if (text) return text
|
|
||||||
}
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
|
|
||||||
function getStockItemName(row: any) {
|
|
||||||
const candidates = [
|
|
||||||
row?.item_name,
|
|
||||||
row?.product_name,
|
|
||||||
row?.goods_name,
|
|
||||||
row?.name,
|
|
||||||
row?.store_stock?.item_name,
|
|
||||||
row?.store_stock?.product_name,
|
|
||||||
row?.stock?.item_name,
|
|
||||||
row?.goods?.item_name,
|
|
||||||
row?.goods?.product_name
|
|
||||||
]
|
|
||||||
for (const candidate of candidates) {
|
|
||||||
const text = String(candidate ?? '').trim()
|
|
||||||
if (text) return text
|
|
||||||
}
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
|
|
||||||
function getStockBarcode(row: any) {
|
|
||||||
const candidates = [
|
|
||||||
row?.barcode,
|
|
||||||
row?.store_stock?.barcode,
|
|
||||||
row?.stock?.barcode,
|
|
||||||
row?.goods?.barcode
|
|
||||||
]
|
|
||||||
for (const candidate of candidates) {
|
|
||||||
const text = String(candidate ?? '').trim()
|
|
||||||
if (text) return text
|
|
||||||
}
|
|
||||||
return ''
|
|
||||||
}
|
|
||||||
|
|
||||||
function getStockStoreId(row: any): number | undefined {
|
|
||||||
const storeId = Number(row?.store_stock?.store_id ?? row?.store_id)
|
|
||||||
return Number.isFinite(storeId) && storeId > 0 ? storeId : undefined
|
|
||||||
}
|
|
||||||
|
|
||||||
function mapStockPickerItem(row: any): InventoryStockPickerItem {
|
|
||||||
const itemId = getStockItemId(row)
|
|
||||||
return {
|
|
||||||
...row,
|
|
||||||
item_id: itemId,
|
|
||||||
item_code: getStockItemCode(row),
|
|
||||||
item_name: getStockItemName(row),
|
|
||||||
barcode: getStockBarcode(row),
|
|
||||||
store_id: getStockStoreId(row)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildSelectedItemFromStock(row: any): InventoryStockPickerItem | null {
|
|
||||||
const itemId = getStockItemId(row)
|
|
||||||
const itemCode = getStockItemCode(row)
|
|
||||||
if (!itemId || !itemCode) return null
|
|
||||||
return {
|
|
||||||
item_id: itemId,
|
|
||||||
item_code: itemCode,
|
|
||||||
item_name: getStockItemName(row),
|
|
||||||
barcode: getStockBarcode(row),
|
|
||||||
store_id: getStockStoreId(row)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function enrichSelectedItemFromStockRow(
|
|
||||||
item: InventoryStockPickerItem,
|
|
||||||
stockRow: any
|
|
||||||
): InventoryStockPickerItem {
|
|
||||||
return {
|
|
||||||
...item,
|
|
||||||
item_id: item.item_id || getStockItemId(stockRow),
|
|
||||||
item_code: item.item_code || getStockItemCode(stockRow),
|
|
||||||
item_name: String(item.item_name || '').trim() || getStockItemName(stockRow),
|
|
||||||
barcode: String(item.barcode || '').trim() || getStockBarcode(stockRow),
|
|
||||||
store_id: item.store_id || getStockStoreId(stockRow)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function enrichLocalSelectedItemsFromRows(rows: any[]) {
|
|
||||||
if (!localSelectedItems.value.length || !rows.length) return
|
|
||||||
|
|
||||||
const byId = new Map<number, any>()
|
|
||||||
const byCode = new Map<string, any>()
|
|
||||||
for (const row of rows) {
|
|
||||||
const itemId = getStockItemId(row)
|
|
||||||
const itemCode = getStockItemCode(row)
|
|
||||||
if (itemId) byId.set(itemId, row)
|
|
||||||
if (itemCode) byCode.set(itemCode, row)
|
|
||||||
}
|
|
||||||
|
|
||||||
localSelectedItems.value = localSelectedItems.value.map((item) => {
|
|
||||||
const stockRow =
|
|
||||||
(hasValidItemId(item) ? byId.get(Number(item.item_id)) : undefined)
|
|
||||||
|| (item.item_code ? byCode.get(item.item_code) : undefined)
|
|
||||||
if (!stockRow) return item
|
|
||||||
return enrichSelectedItemFromStockRow(item, stockRow)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async function fetchStockRowsForSelectedItems(items: InventoryStockPickerItem[]) {
|
|
||||||
const codes = Array.from(new Set(
|
|
||||||
items
|
|
||||||
.filter((item) => !String(item.item_name || '').trim() && String(item.item_code || '').trim())
|
|
||||||
.map((item) => String(item.item_code).trim())
|
|
||||||
))
|
|
||||||
if (!codes.length) return []
|
|
||||||
|
|
||||||
const requestData: { keyword?: string; store_id?: number } = {
|
|
||||||
keyword: codes.join(',')
|
|
||||||
}
|
|
||||||
if (props.storeId) {
|
|
||||||
requestData.store_id = props.storeId
|
|
||||||
}
|
|
||||||
|
|
||||||
const res: any = await warehouseSearch(requestData)
|
|
||||||
const ok = res && (res.code === 1 || res.code === 200 || res.flag === 'success')
|
|
||||||
if (!ok) return []
|
|
||||||
|
|
||||||
const rawList = Array.isArray(res?.data) ? res.data : []
|
|
||||||
return rawList.map(mapStockPickerItem).filter((item: InventoryStockPickerItem) => item.item_id)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function enrichLocalSelectedItems() {
|
|
||||||
enrichLocalSelectedItemsFromRows(allRows.value)
|
|
||||||
|
|
||||||
const needsFetch = localSelectedItems.value.some(
|
|
||||||
(item) => !String(item.item_name || '').trim() && String(item.item_code || '').trim()
|
|
||||||
)
|
|
||||||
if (!needsFetch) return
|
|
||||||
|
|
||||||
try {
|
|
||||||
const extraRows = await fetchStockRowsForSelectedItems(localSelectedItems.value)
|
|
||||||
enrichLocalSelectedItemsFromRows(extraRows)
|
|
||||||
} catch (error) {
|
|
||||||
console.error('enrich selected stock items failed:', error)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function applyPageSlice() {
|
|
||||||
const start = (pagination.currentPage - 1) * pagination.pageSize
|
|
||||||
const end = start + pagination.pageSize
|
|
||||||
list.value = allRows.value.slice(start, end)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadList() {
|
|
||||||
loading.value = true
|
|
||||||
try {
|
|
||||||
const requestData: { keyword?: string; store_id?: number } = {}
|
|
||||||
const normalizedKeyword = getSearchKeyword()
|
|
||||||
if (normalizedKeyword) {
|
|
||||||
requestData.keyword = normalizedKeyword
|
|
||||||
}
|
|
||||||
if (props.storeId) {
|
|
||||||
requestData.store_id = props.storeId
|
|
||||||
}
|
|
||||||
const res: any = await warehouseSearch(requestData)
|
|
||||||
const ok = res && (res.code === 1 || res.code === 200 || res.flag === 'success')
|
|
||||||
if (!ok) {
|
|
||||||
resetListState()
|
|
||||||
ElMessage.error(res?.message || '查询商品失败')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
const rawList = Array.isArray(res?.data) ? res.data : []
|
|
||||||
allRows.value = rawList.map(mapStockPickerItem).filter((item: InventoryStockPickerItem) => item.item_id)
|
|
||||||
pagination.total = allRows.value.length
|
|
||||||
const maxPage = Math.max(1, Math.ceil(pagination.total / pagination.pageSize))
|
|
||||||
if (pagination.currentPage > maxPage) {
|
|
||||||
pagination.currentPage = maxPage
|
|
||||||
}
|
|
||||||
applyPageSlice()
|
|
||||||
} catch (error) {
|
|
||||||
console.error('load inventory stock picker failed:', error)
|
|
||||||
resetListState()
|
|
||||||
ElMessage.error('查询商品失败')
|
|
||||||
} finally {
|
|
||||||
loading.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
async function syncSelectionFromLocal(releaseSync = true) {
|
|
||||||
await nextTick()
|
|
||||||
const table = tableRef.value
|
|
||||||
if (!table) return
|
|
||||||
|
|
||||||
syncingSelection.value = true
|
|
||||||
table.clearSelection?.()
|
|
||||||
await nextTick()
|
|
||||||
|
|
||||||
const selectedIdSet = new Set(
|
|
||||||
localSelectedItems.value.filter((item) => hasValidItemId(item)).map((item) => Number(item.item_id))
|
|
||||||
)
|
|
||||||
allRows.value
|
|
||||||
.filter((item) => selectedIdSet.has(Number(item.item_id)))
|
|
||||||
.forEach((item) => {
|
|
||||||
table.toggleRowSelection?.(item, true)
|
|
||||||
})
|
|
||||||
|
|
||||||
if (releaseSync) {
|
|
||||||
await nextTick()
|
|
||||||
syncingSelection.value = false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function applySelectedItems(selections: any[]) {
|
|
||||||
const loadedItemIds = new Set(
|
|
||||||
allRows.value.map((item) => getStockItemId(item)).filter((id): id is number => Boolean(id))
|
|
||||||
)
|
|
||||||
const selectedIdsInTable = new Set(
|
|
||||||
(selections || []).map((item) => getStockItemId(item)).filter((id): id is number => Boolean(id))
|
|
||||||
)
|
|
||||||
|
|
||||||
const keptItems = localSelectedItems.value.filter((item) => {
|
|
||||||
if (!hasValidItemId(item)) {
|
|
||||||
return String(item.item_code || '').trim() !== ''
|
|
||||||
}
|
|
||||||
if (!loadedItemIds.has(Number(item.item_id))) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return selectedIdsInTable.has(Number(item.item_id))
|
|
||||||
}).map((item) => {
|
|
||||||
if (!String(item.item_name || '').trim()) {
|
|
||||||
const stockRow = allRows.value.find((row) => {
|
|
||||||
const itemId = getStockItemId(row)
|
|
||||||
return (hasValidItemId(item) && itemId === Number(item.item_id))
|
|
||||||
|| (item.item_code && getStockItemCode(row) === item.item_code)
|
|
||||||
})
|
|
||||||
if (stockRow) {
|
|
||||||
return enrichSelectedItemFromStockRow(item, stockRow)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return item
|
|
||||||
})
|
|
||||||
|
|
||||||
const keptIdSet = new Set(
|
|
||||||
keptItems.filter((item) => hasValidItemId(item)).map((item) => Number(item.item_id))
|
|
||||||
)
|
|
||||||
|
|
||||||
for (const selected of selections || []) {
|
|
||||||
const nextItem = buildSelectedItemFromStock(selected)
|
|
||||||
if (!nextItem || keptIdSet.has(Number(nextItem.item_id))) continue
|
|
||||||
keptItems.push(nextItem)
|
|
||||||
keptIdSet.add(Number(nextItem.item_id))
|
|
||||||
}
|
|
||||||
|
|
||||||
localSelectedItems.value = keptItems
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSelectionChange(rows: any[]) {
|
|
||||||
if (syncingSelection.value) return
|
|
||||||
applySelectedItems(rows || [])
|
|
||||||
}
|
|
||||||
|
|
||||||
function removeSelectedItem(item: InventoryStockPickerItem) {
|
|
||||||
const itemId = Number(item.item_id)
|
|
||||||
localSelectedItems.value = localSelectedItems.value.filter((row) => {
|
|
||||||
if (hasValidItemId(item) && hasValidItemId(row)) {
|
|
||||||
return Number(row.item_id) !== itemId
|
|
||||||
}
|
|
||||||
return row.item_code !== item.item_code
|
|
||||||
})
|
|
||||||
syncingSelection.value = true
|
|
||||||
void syncSelectionFromLocal().finally(async () => {
|
|
||||||
await nextTick()
|
|
||||||
syncingSelection.value = false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleSearch() {
|
|
||||||
pagination.currentPage = 1
|
|
||||||
syncingSelection.value = true
|
|
||||||
void loadList()
|
|
||||||
.then(() => enrichLocalSelectedItems())
|
|
||||||
.then(() => syncSelectionFromLocal())
|
|
||||||
.finally(async () => {
|
|
||||||
await nextTick()
|
|
||||||
syncingSelection.value = false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function handlePageChange(page: number) {
|
|
||||||
pagination.currentPage = page
|
|
||||||
syncingSelection.value = true
|
|
||||||
applyPageSlice()
|
|
||||||
void syncSelectionFromLocal().finally(async () => {
|
|
||||||
await nextTick()
|
|
||||||
syncingSelection.value = false
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleConfirm() {
|
|
||||||
if (!localSelectedItems.value.length) {
|
|
||||||
ElMessage.warning('请至少选择 1 个商品')
|
|
||||||
return
|
|
||||||
}
|
|
||||||
emit('confirm', localSelectedItems.value.map((item) => ({ ...item })))
|
|
||||||
visible.value = false
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style scoped lang="scss">
|
|
||||||
.picker-meta {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #606266;
|
|
||||||
}
|
|
||||||
|
|
||||||
.picker-toolbar {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 8px;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.picker-pagination {
|
|
||||||
display: flex;
|
|
||||||
justify-content: flex-end;
|
|
||||||
margin-top: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.selected-items-panel {
|
|
||||||
margin-top: 12px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.selected-items-title {
|
|
||||||
margin-bottom: 8px;
|
|
||||||
font-size: 12px;
|
|
||||||
color: #606266;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="">
|
|
||||||
<h1>操作日志</h1>
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script setup lang="ts"></script>
|
|
||||||
|
|
||||||
<style lang="css" scoped></style>
|
|
||||||
@ -39,7 +39,7 @@
|
|||||||
<div class="upper-wrapper" :style="detailVisible ? upperPaneStyle : upperPaneFullStyle">
|
<div class="upper-wrapper" :style="detailVisible ? upperPaneStyle : upperPaneFullStyle">
|
||||||
<upper-table
|
<upper-table
|
||||||
ref="upperTable"
|
ref="upperTable"
|
||||||
title="入库单列表"
|
title="库存列表"
|
||||||
default-align="center"
|
default-align="center"
|
||||||
table-id="storage-inventory-list"
|
table-id="storage-inventory-list"
|
||||||
:enable-column-config="true"
|
:enable-column-config="true"
|
||||||
@ -55,6 +55,7 @@
|
|||||||
@current-change="handleRowClick"
|
@current-change="handleRowClick"
|
||||||
@page-change="handlePageChange"
|
@page-change="handlePageChange"
|
||||||
@page-size-change="handlePageSizeChange"
|
@page-size-change="handlePageSizeChange"
|
||||||
|
@sort-change="handleSortChange"
|
||||||
@refresh="loadData"
|
@refresh="loadData"
|
||||||
@selection-change="onSelectionChange"
|
@selection-change="onSelectionChange"
|
||||||
>
|
>
|
||||||
@ -113,7 +114,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #empty>
|
<template #empty>
|
||||||
<div class="empty-tip">暂无入库单</div>
|
<div class="empty-tip">暂无库存记录</div>
|
||||||
</template>
|
</template>
|
||||||
</upper-table>
|
</upper-table>
|
||||||
</div>
|
</div>
|
||||||
@ -128,7 +129,6 @@
|
|||||||
<div class="detail-header">
|
<div class="detail-header">
|
||||||
<el-tabs v-model="activeTab" class="detail-tab">
|
<el-tabs v-model="activeTab" class="detail-tab">
|
||||||
<el-tab-pane label="库存明细" name="details" />
|
<el-tab-pane label="库存明细" name="details" />
|
||||||
<!-- <el-tab-pane label="操作日志" name="logs" /> -->
|
|
||||||
</el-tabs>
|
</el-tabs>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -178,7 +178,7 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, reactive, onMounted, computed } from 'vue'
|
import { ref, reactive, onMounted, computed } from 'vue'
|
||||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import ScanBox from '@/components/ScanBox/index.vue'
|
import ScanBox from '@/components/ScanBox/index.vue'
|
||||||
import UpperTable from '@/components/UpperTable/index.vue'
|
import UpperTable from '@/components/UpperTable/index.vue'
|
||||||
import OrderToolbarButtonGroup from '@/components/ToolbarButtonGroup/index.vue'
|
import OrderToolbarButtonGroup from '@/components/ToolbarButtonGroup/index.vue'
|
||||||
@ -204,7 +204,6 @@ import {
|
|||||||
} from './inventory-config'
|
} from './inventory-config'
|
||||||
|
|
||||||
import entrydetail from './component/panelstockdetail.vue'
|
import entrydetail from './component/panelstockdetail.vue'
|
||||||
import log from './component/log.vue'
|
|
||||||
import SpaceStockDialog from './component/SpaceStockDialog.vue'
|
import SpaceStockDialog from './component/SpaceStockDialog.vue'
|
||||||
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
||||||
import { useSettingsStore } from '@/stores/modules/settings'
|
import { useSettingsStore } from '@/stores/modules/settings'
|
||||||
@ -359,9 +358,7 @@ const toolbarActionMap: Record<string, () => void> = {
|
|||||||
handleExportAll: () => { void handleExportAll() },
|
handleExportAll: () => { void handleExportAll() },
|
||||||
openColumnConfigPanel: () => openColumnConfigPanel(),
|
openColumnConfigPanel: () => openColumnConfigPanel(),
|
||||||
toggleDetailVisible: () => toggleDetailVisible(),
|
toggleDetailVisible: () => toggleDetailVisible(),
|
||||||
handleImport: () => handleImport(),
|
openSpaceStock: () => openSpaceStock()
|
||||||
openSpaceStock: () => openSpaceStock(),
|
|
||||||
confirmBatchCancel: () => { void confirmBatchCancel() }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
||||||
@ -370,8 +367,7 @@ function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
|||||||
safeInvoke(() => handler())
|
safeInvoke(() => handler())
|
||||||
}
|
}
|
||||||
const componentMap: Record<string, any> = {
|
const componentMap: Record<string, any> = {
|
||||||
details: entrydetail,
|
details: entrydetail
|
||||||
logs: log
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const activeComponent = computed(() => componentMap[activeTab.value] || componentMap.details)
|
const activeComponent = computed(() => componentMap[activeTab.value] || componentMap.details)
|
||||||
@ -388,46 +384,99 @@ onMounted(() => {
|
|||||||
resumeExportTaskFromStorage()
|
resumeExportTaskFromStorage()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** 当前排序(文档 sort 白名单:id/stock_id/space_id/created_at/updated_at/inbound_time/quantity) */
|
||||||
|
const currentSort = reactive({ prop: '', order: '' })
|
||||||
|
|
||||||
|
/** 组装接口 sort 参数(未排序时不下发,走后端默认 created_at DESC) */
|
||||||
|
function buildSortParam() {
|
||||||
|
if (!currentSort.prop) return undefined
|
||||||
|
return {
|
||||||
|
sortField: currentSort.prop,
|
||||||
|
sortOrder: currentSort.order === 'ascending' ? 'ASC' : 'DESC'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function handleSortChange({ prop, order }: any) {
|
||||||
|
currentSort.prop = order ? prop : ''
|
||||||
|
currentSort.order = order || ''
|
||||||
|
pagination.currentPage = 1
|
||||||
|
loadData()
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 解析库位关键字 → space_id(列表与导出共用):多库位传数组,未匹配传 -1 使结果为空 */
|
||||||
|
async function resolveSpaceKeyword(rawSpaceVal: any): Promise<number | number[] | null> {
|
||||||
|
const spaceKeyword = rawSpaceVal && typeof rawSpaceVal === 'object'
|
||||||
|
? String((rawSpaceVal as any).value ?? '').trim()
|
||||||
|
: String(rawSpaceVal ?? '').trim()
|
||||||
|
if (!spaceKeyword) return null
|
||||||
|
try {
|
||||||
|
const spaceRes: any = await indexApi.searchSpace({ keyword: spaceKeyword, page: 1, pageSize: 20 })
|
||||||
|
const spaceData = spaceRes && (spaceRes.data || spaceRes.list || spaceRes)
|
||||||
|
const spaceList = Array.isArray(spaceData?.list) ? spaceData.list : Array.isArray(spaceData) ? spaceData : []
|
||||||
|
const spaceIds = spaceList.map((s: any) => Number(s.id)).filter((id: number) => Number.isFinite(id) && id > 0)
|
||||||
|
if (!spaceIds.length) return -1
|
||||||
|
return spaceIds.length === 1 ? spaceIds[0] : spaceIds
|
||||||
|
} catch {
|
||||||
|
return -1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 组装 storage.inventory.list / export 共用的 where:
|
||||||
|
* - `space_keyword`(ScanBox 库位关键字)→ `space_id`:导出接口不认 `space_keyword`
|
||||||
|
* (实测任务失败 `Unknown column 'wms_storage.space_keyword'`),必须转换后再下发
|
||||||
|
* - `stock_query` 是列表专属虚拟字段(导出实测 `Unknown column 'wms_storage.stock_query'`),
|
||||||
|
* 导出时由 `resolveStockIdsByStockQuery` 先解析成 stock_id 列表
|
||||||
|
*/
|
||||||
|
async function buildInventoryWhere(options: { dropStockQuery?: boolean } = {}) {
|
||||||
|
const raw = scanBox.value?.getConditions?.() || {}
|
||||||
|
const where: Record<string, any> = { ...raw }
|
||||||
|
const rawSpaceVal = where.space_keyword
|
||||||
|
delete where.space_keyword
|
||||||
|
const spaceId = await resolveSpaceKeyword(rawSpaceVal)
|
||||||
|
if (spaceId !== null) where.space_id = spaceId
|
||||||
|
if (options.dropStockQuery) delete where.stock_query
|
||||||
|
return where
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 解析 stock_query 时每页条数与最大页数上限(防止异常条件下无限翻页) */
|
||||||
|
const STOCK_QUERY_RESOLVE_PAGE_SIZE = 200
|
||||||
|
const STOCK_QUERY_RESOLVE_MAX_PAGES = 50
|
||||||
|
|
||||||
|
/** 把列表专属的 stock_query 虚拟筛选解析成 stock_id 列表(导出接口不支持 stock_query) */
|
||||||
|
async function resolveStockIdsByStockQuery(stockQuery: any): Promise<number[]> {
|
||||||
|
const ids = new Set<number>()
|
||||||
|
for (let page = 1; page <= STOCK_QUERY_RESOLVE_MAX_PAGES; page += 1) {
|
||||||
|
const res: any = await inventoryApi.getInventoryList({
|
||||||
|
pagination: { page, pageSize: STOCK_QUERY_RESOLVE_PAGE_SIZE },
|
||||||
|
where: { stock_query: stockQuery },
|
||||||
|
group_by_batch: false
|
||||||
|
})
|
||||||
|
if (!(res && (res.code === 200 || res.code === 1 || res.flag === 'success'))) break
|
||||||
|
const data = res.data || res
|
||||||
|
const rows: any[] = Array.isArray(data.list) ? data.list : []
|
||||||
|
rows.forEach((row) => {
|
||||||
|
const stockId = Number(row?.stock_id)
|
||||||
|
if (Number.isFinite(stockId) && stockId > 0) ids.add(stockId)
|
||||||
|
})
|
||||||
|
if (rows.length < STOCK_QUERY_RESOLVE_PAGE_SIZE) break
|
||||||
|
}
|
||||||
|
return [...ids]
|
||||||
|
}
|
||||||
|
|
||||||
async function loadData() {
|
async function loadData() {
|
||||||
if (loading.value) return
|
if (loading.value) return
|
||||||
loading.value = true
|
loading.value = true
|
||||||
const start = Date.now()
|
const start = Date.now()
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const rawWhere = scanBox.value?.getConditions?.() || {}
|
const where = await buildInventoryWhere()
|
||||||
const where: Record<string, unknown> = { ...rawWhere }
|
|
||||||
|
|
||||||
// 解析库位关键字 → 库位ID
|
|
||||||
const rawSpaceVal = where.space_keyword
|
|
||||||
delete where.space_keyword
|
|
||||||
const spaceKeyword = rawSpaceVal && typeof rawSpaceVal === 'object'
|
|
||||||
? String((rawSpaceVal as any).value ?? '').trim()
|
|
||||||
: String(rawSpaceVal ?? '').trim()
|
|
||||||
if (spaceKeyword) {
|
|
||||||
try {
|
|
||||||
const spaceRes: any = await indexApi.searchSpace({ keyword: spaceKeyword, page: 1, pageSize: 20 })
|
|
||||||
const spaceData = spaceRes && (spaceRes.data || spaceRes.list || spaceRes)
|
|
||||||
const spaceList = Array.isArray(spaceData?.list) ? spaceData.list : Array.isArray(spaceData) ? spaceData : []
|
|
||||||
if (spaceList.length) {
|
|
||||||
const spaceIds = spaceList.map((s: any) => Number(s.id)).filter((id: number) => Number.isFinite(id) && id > 0)
|
|
||||||
if (spaceIds.length === 1) {
|
|
||||||
where.space_id = spaceIds[0]
|
|
||||||
} else if (spaceIds.length > 1) {
|
|
||||||
where.space_id = spaceIds
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// 未匹配到任何库位,设一个不可能的值使结果为空
|
|
||||||
where.space_id = -1
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
where.space_id = -1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const params: any = {
|
const params: any = {
|
||||||
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
|
pagination: { page: pagination.currentPage, pageSize: pagination.pageSize },
|
||||||
where,
|
where,
|
||||||
group_by_batch: groupByBatch.value
|
group_by_batch: groupByBatch.value,
|
||||||
|
sort: buildSortParam()
|
||||||
}
|
}
|
||||||
|
|
||||||
const res: any = await inventoryApi.getInventoryList(params)
|
const res: any = await inventoryApi.getInventoryList(params)
|
||||||
@ -554,7 +603,7 @@ async function loadFilterData() {
|
|||||||
try {
|
try {
|
||||||
const [storesRes, presetRes]: any = await Promise.all([
|
const [storesRes, presetRes]: any = await Promise.all([
|
||||||
indexApi.loadStores(),
|
indexApi.loadStores(),
|
||||||
indexApi.fastWhereTree('entry')
|
indexApi.fastWhereTree('stock')
|
||||||
])
|
])
|
||||||
if (storesRes && storesRes.code === 200) {
|
if (storesRes && storesRes.code === 200) {
|
||||||
const f = availableFieldsRef.find((i: any) => i.value === 'store_id')
|
const f = availableFieldsRef.find((i: any) => i.value === 'store_id')
|
||||||
@ -612,10 +661,6 @@ function handleGroupByBatchChange() {
|
|||||||
loadData()
|
loadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleCreateEntry() {
|
|
||||||
ElMessage.info('新建入库单')
|
|
||||||
}
|
|
||||||
|
|
||||||
// ── 库位商品查询(storage.inventory.listBySpaceId)──
|
// ── 库位商品查询(storage.inventory.listBySpaceId)──
|
||||||
const spaceStockVisible = ref(false)
|
const spaceStockVisible = ref(false)
|
||||||
const spaceStockSpaceId = ref<number | null>(null)
|
const spaceStockSpaceId = ref<number | null>(null)
|
||||||
@ -635,24 +680,26 @@ function openSpaceStock(row?: any) {
|
|||||||
spaceStockVisible.value = true
|
spaceStockVisible.value = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
async function confirmBatchCancel() {
|
* 导出参数:与列表共用同一套 where 组装,避免 `space_keyword` / `stock_query`
|
||||||
if (!selectionRows.value.length) {
|
* 这类列表专属字段直接下发到导出接口(后端会直接报 Unknown column)。
|
||||||
ElMessage.warning('请先选择要作废的入库单')
|
* 返回 null 表示筛选后无数据,不再提交导出任务。
|
||||||
return
|
*/
|
||||||
|
async function buildExportPayload(): Promise<AsyncExportPayload | null> {
|
||||||
|
const rawConditions = scanBox.value?.getConditions?.() || {}
|
||||||
|
const rawStockQuery = rawConditions.stock_query
|
||||||
|
const where = await buildInventoryWhere({ dropStockQuery: true })
|
||||||
|
if (rawStockQuery) {
|
||||||
|
const stockIds = await resolveStockIdsByStockQuery(rawStockQuery)
|
||||||
|
if (!stockIds.length) {
|
||||||
|
ElMessage.warning('当前「包含商品」条件未匹配到库存,已取消导出')
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
where.stock_id = stockIds.length === 1 ? stockIds[0] : stockIds
|
||||||
}
|
}
|
||||||
try {
|
|
||||||
await ElMessageBox.confirm(`确定要批量作废 ${selectionRows.value.length} 个入库单吗?`, '确认', { type: 'warning', buttonSize: 'small' })
|
|
||||||
// 调用作废 API
|
|
||||||
ElMessage.success('操作成功')
|
|
||||||
loadData()
|
|
||||||
} catch (e) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
function buildExportPayload(): AsyncExportPayload {
|
|
||||||
const rawWhere = scanBox.value?.getConditions?.() || {}
|
|
||||||
return {
|
return {
|
||||||
where: { ...rawWhere },
|
where,
|
||||||
|
sort: buildSortParam(),
|
||||||
group_by_batch: groupByBatch.value
|
group_by_batch: groupByBatch.value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -676,6 +723,7 @@ async function handleExportSelected() {
|
|||||||
}
|
}
|
||||||
await submitExportTask({
|
await submitExportTask({
|
||||||
where: { stock_id: stockIds.length === 1 ? stockIds[0] : stockIds },
|
where: { stock_id: stockIds.length === 1 ? stockIds[0] : stockIds },
|
||||||
|
sort: buildSortParam(),
|
||||||
group_by_batch: groupByBatch.value
|
group_by_batch: groupByBatch.value
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@ -690,7 +738,10 @@ async function handleExportAll() {
|
|||||||
resumeExportTaskFromStorage()
|
resumeExportTaskFromStorage()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
await submitExportTask(buildExportPayload())
|
if (exportLoading.value) return
|
||||||
|
const payload = await buildExportPayload()
|
||||||
|
if (!payload) return
|
||||||
|
await submitExportTask(payload)
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleExportAction(action: string) {
|
function handleExportAction(action: string) {
|
||||||
@ -701,10 +752,6 @@ function handleExportAction(action: string) {
|
|||||||
void handleExportSelected()
|
void handleExportSelected()
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleImport() {
|
|
||||||
ElMessage.info('导入功能')
|
|
||||||
}
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@ -31,13 +31,6 @@ export const inventoryToolbarButtons: ToolbarButtonConfig[] = [
|
|||||||
size: 'small',
|
size: 'small',
|
||||||
action: 'toggleDetailVisible'
|
action: 'toggleDetailVisible'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: 'import',
|
|
||||||
label: '导入',
|
|
||||||
category: 'action',
|
|
||||||
size: 'small',
|
|
||||||
action: 'handleImport'
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
key: 'spaceStock',
|
key: 'spaceStock',
|
||||||
label: '库位商品',
|
label: '库位商品',
|
||||||
@ -45,14 +38,6 @@ export const inventoryToolbarButtons: ToolbarButtonConfig[] = [
|
|||||||
size: 'small',
|
size: 'small',
|
||||||
action: 'openSpaceStock'
|
action: 'openSpaceStock'
|
||||||
},
|
},
|
||||||
{
|
|
||||||
key: 'batchCancel',
|
|
||||||
label: '批量作废',
|
|
||||||
category: 'cancel',
|
|
||||||
size: 'small',
|
|
||||||
disabledKey: 'hasNoSelection',
|
|
||||||
action: 'confirmBatchCancel'
|
|
||||||
},
|
|
||||||
]
|
]
|
||||||
|
|
||||||
/** ScanBox 基础信息分组(对齐收货单排版) */
|
/** ScanBox 基础信息分组(对齐收货单排版) */
|
||||||
@ -86,13 +71,6 @@ export function inventoryScanBasicField(field: Record<string, any>): InventorySc
|
|||||||
return { ...field, group: INVENTORY_SCAN_BASIC_INFO_GROUP } as InventoryScanFieldConfig
|
return { ...field, group: INVENTORY_SCAN_BASIC_INFO_GROUP } as InventoryScanFieldConfig
|
||||||
}
|
}
|
||||||
|
|
||||||
/** ScanBox 默认 props(与波次模块 scan-box 侧栏一致) */
|
|
||||||
export const inventoryScanBoxConfig = {
|
|
||||||
width: '220px',
|
|
||||||
treeProps: { children: 'children', label: 'label' } as const,
|
|
||||||
autoSubmit: false
|
|
||||||
}
|
|
||||||
|
|
||||||
export const availableFields: InventoryScanFieldConfig[] = [
|
export const availableFields: InventoryScanFieldConfig[] = [
|
||||||
inventoryScanBasicField({
|
inventoryScanBasicField({
|
||||||
...stockQueryScanField,
|
...stockQueryScanField,
|
||||||
@ -100,7 +78,33 @@ export const availableFields: InventoryScanFieldConfig[] = [
|
|||||||
}),
|
}),
|
||||||
inventoryScanBasicField({ label: '货主', value: 'store_id', type: 'select', multiple: true, options: [] }),
|
inventoryScanBasicField({ label: '货主', value: 'store_id', type: 'select', multiple: true, options: [] }),
|
||||||
inventoryScanBasicField({ label: '库位', value: 'space_keyword', type: 'text', placeholder: '库位名称或编码' }),
|
inventoryScanBasicField({ label: '库位', value: 'space_keyword', type: 'text', placeholder: '库位名称或编码' }),
|
||||||
|
// 以下字段对齐 storage.inventory.list 文档 where 能力
|
||||||
|
inventoryScanBasicField({
|
||||||
|
label: '库存类型',
|
||||||
|
value: 'inventory_type',
|
||||||
|
type: 'select',
|
||||||
|
options: [
|
||||||
|
{ label: '正品', value: 'ZP' },
|
||||||
|
{ label: '次品', value: 'CC' },
|
||||||
|
{ label: '机损', value: 'JS' },
|
||||||
|
{ label: '箱损', value: 'XS' },
|
||||||
|
{ label: '在途', value: 'ZT' },
|
||||||
|
{ label: '冻结', value: 'DJ' },
|
||||||
|
{ label: '分配', value: 'FP' }
|
||||||
|
]
|
||||||
|
}),
|
||||||
|
inventoryScanBasicField({ label: '批次号', value: 'batch_no', type: 'text', placeholder: '批次号' }),
|
||||||
|
inventoryScanBasicField({ label: '入库单号', value: 'inbound_order_no', type: 'text', placeholder: '入库单号' }),
|
||||||
|
inventoryScanBasicField({
|
||||||
|
label: '可用数量',
|
||||||
|
value: 'available_quantity',
|
||||||
|
type: 'number',
|
||||||
|
operators: ['gt', 'lt', 'ge', 'le', 'eq'],
|
||||||
|
defaultOperator: 'gt',
|
||||||
|
placeholder: '可用数量'
|
||||||
|
}),
|
||||||
inventoryScanBasicField({ label: '创建日期', value: 'created_at', type: 'daterange' }),
|
inventoryScanBasicField({ label: '创建日期', value: 'created_at', type: 'daterange' }),
|
||||||
|
inventoryScanBasicField({ label: '入库时间', value: 'inbound_time', type: 'daterange' }),
|
||||||
]
|
]
|
||||||
/** 库位展示名:优先 custom_name,其次 space_code */
|
/** 库位展示名:优先 custom_name,其次 space_code */
|
||||||
export function formatInventorySpaceLabel(space?: Record<string, any> | null, fallback = ''): string {
|
export function formatInventorySpaceLabel(space?: Record<string, any> | null, fallback = ''): string {
|
||||||
@ -163,26 +167,8 @@ const inventoryBarcodesColumn = {
|
|||||||
copyAction: 'copy' as const
|
copyAction: 'copy' as const
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 库存列表选中导出列 */
|
|
||||||
export const inventoryExportColumns = [
|
|
||||||
{ prop: 'store_name', label: '货主' },
|
|
||||||
{ prop: 'item_code', label: '商品编码' },
|
|
||||||
{ prop: 'item_name', label: '商品名称' },
|
|
||||||
{ ...inventoryBarcodesColumn },
|
|
||||||
{ prop: 'sku_property', label: '规格' },
|
|
||||||
{ prop: 'stock_unit', label: '单位' },
|
|
||||||
{ prop: 'quantity', label: '总数量' },
|
|
||||||
{ prop: 'available_quantity', label: '可用数量' },
|
|
||||||
{ prop: 'locked_quantity', label: '锁定数量' },
|
|
||||||
{ prop: 'batch_count', label: '批次数' },
|
|
||||||
{ prop: 'first_inbound_time', label: '首次入库时间' },
|
|
||||||
{ prop: 'last_inbound_time', label: '最后入库时间' },
|
|
||||||
{ prop: 'is_shelf_life_mgmt', label: '保质期管理' },
|
|
||||||
{ prop: 'remaining_threshold_days', label: '临期阈值(天)' }
|
|
||||||
]
|
|
||||||
|
|
||||||
export const productstockColums = [
|
export const productstockColums = [
|
||||||
{ prop: 'stock_id', label: '商品ID', width: '100', copyAction: 'copy' as const },
|
{ prop: 'stock_id', label: '商品ID', width: '100', copyAction: 'copy' as const, sortable: true },
|
||||||
{ prop: 'item_code', label: '商品编码', width: '150', copyAction: 'copy' as const },
|
{ prop: 'item_code', label: '商品编码', width: '150', copyAction: 'copy' as const },
|
||||||
{ prop: 'item_name', label: '商品名称', width: '200' },
|
{ prop: 'item_name', label: '商品名称', width: '200' },
|
||||||
{ ...inventoryBarcodesColumn },
|
{ ...inventoryBarcodesColumn },
|
||||||
@ -192,7 +178,7 @@ export const productstockColums = [
|
|||||||
{ prop: 'expiry_date', label: '到期日期', width: '120' },
|
{ prop: 'expiry_date', label: '到期日期', width: '120' },
|
||||||
{ prop: 'store_name', label: '货主', width: '120' },
|
{ prop: 'store_name', label: '货主', width: '120' },
|
||||||
{ prop: 'space_code', label: '库位', width: '120' },
|
{ prop: 'space_code', label: '库位', width: '120' },
|
||||||
{ prop: 'quantity', label: '总数量', width: '100' },
|
{ prop: 'quantity', label: '总数量', width: '100', sortable: true },
|
||||||
{ prop: 'available_quantity', label: '可用数量', width: '100' },
|
{ prop: 'available_quantity', label: '可用数量', width: '100' },
|
||||||
{ prop: 'locked_quantity', label: '锁定数量', width: '100' },
|
{ prop: 'locked_quantity', label: '锁定数量', width: '100' },
|
||||||
{ prop: 'is_shelf_life_mgmt', label: '保质期管理', width: '100' },
|
{ prop: 'is_shelf_life_mgmt', label: '保质期管理', width: '100' },
|
||||||
@ -220,20 +206,4 @@ export const spaceStockColumns = [
|
|||||||
{ prop: 'batch_count', label: '批次数', width: '80' },
|
{ prop: 'batch_count', label: '批次数', width: '80' },
|
||||||
{ prop: 'first_inbound_time', label: '最早入库时间', width: '160' },
|
{ prop: 'first_inbound_time', label: '最早入库时间', width: '160' },
|
||||||
{ prop: 'last_inbound_time', label: '最晚入库时间', width: '160' }
|
{ prop: 'last_inbound_time', label: '最晚入库时间', width: '160' }
|
||||||
]
|
|
||||||
|
|
||||||
export const productstockDetail = [
|
|
||||||
{ prop: 'id', label: 'ID', width: '80' },
|
|
||||||
{ prop: 'sku_code', label: '商品编码', width: '150' },
|
|
||||||
{ prop: 'barcode', label: '条码', width: '150' },
|
|
||||||
{ prop: 'product_name', label: '商品名称', width: '250' },
|
|
||||||
{ prop: 'spec_name', label: '规格', width: '120' },
|
|
||||||
{ prop: 'unit', label: '单位', width: '80' },
|
|
||||||
{ prop: 'actual_qty', label: '入库数量', width: '100' },
|
|
||||||
{ prop: 'available_qty', label: '可用库存', width: '100' },
|
|
||||||
{ prop: 'batch_no', label: '批次号', width: '120' },
|
|
||||||
{ prop: 'warehouse_name', label: '库房', width: '120' },
|
|
||||||
{ prop: 'area_name', label: '库区', width: '100' },
|
|
||||||
{ prop: 'location_name', label: '库位', width: '120' },
|
|
||||||
{ prop: 'inventory_status', label: '库存状态', width: '100' }
|
|
||||||
]
|
]
|
||||||
@ -192,23 +192,25 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="task-panel__grid">
|
<div class="task-panel__grid">
|
||||||
<div class="task-panel__field task-panel__field--input">
|
<div class="task-panel__field task-panel__field--input" :class="{ 'is-error': toOrderErrors.name }">
|
||||||
<span class="task-panel__field-label">收件人姓名</span>
|
<span class="task-panel__field-label is-required">收件人姓名</span>
|
||||||
<div class="task-panel__field-form">
|
<div class="task-panel__field-form">
|
||||||
<el-input v-model="toOrderForm.receiverInfo.name" size="default" placeholder="收件人姓名" clearable />
|
<el-input v-model="toOrderForm.receiverInfo.name" size="default" placeholder="收件人姓名" clearable />
|
||||||
|
<p v-if="toOrderErrors.name" class="task-panel__field-error">{{ toOrderErrors.name }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="task-panel__field task-panel__field--input">
|
<div class="task-panel__field task-panel__field--input" :class="{ 'is-error': toOrderErrors.mobile }">
|
||||||
<span class="task-panel__field-label">手机号</span>
|
<span class="task-panel__field-label">手机号</span>
|
||||||
<div class="task-panel__field-form">
|
<div class="task-panel__field-form">
|
||||||
<el-input v-model="toOrderForm.receiverInfo.mobile" size="default" placeholder="手机号" clearable />
|
<el-input v-model="toOrderForm.receiverInfo.mobile" size="default" placeholder="手机号(与电话二选一)" clearable />
|
||||||
|
<p v-if="toOrderErrors.mobile" class="task-panel__field-error">{{ toOrderErrors.mobile }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="task-panel__field task-panel__field--input">
|
<div class="task-panel__field task-panel__field--input">
|
||||||
<span class="task-panel__field-label">电话</span>
|
<span class="task-panel__field-label">电话</span>
|
||||||
<div class="task-panel__field-form">
|
<div class="task-panel__field-form">
|
||||||
<el-input v-model="toOrderForm.receiverInfo.tel" size="default" placeholder="固定电话(可选)" clearable />
|
<el-input v-model="toOrderForm.receiverInfo.tel" size="default" placeholder="固定电话(与手机号二选一)" clearable />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="task-panel__field task-panel__field--input">
|
<div class="task-panel__field task-panel__field--input">
|
||||||
@ -218,34 +220,38 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="task-panel__field task-panel__field--input">
|
<div class="task-panel__field task-panel__field--input" :class="{ 'is-error': toOrderErrors.province }">
|
||||||
<span class="task-panel__field-label">省份</span>
|
<span class="task-panel__field-label is-required">省份</span>
|
||||||
<div class="task-panel__field-form">
|
<div class="task-panel__field-form">
|
||||||
<el-input v-model="toOrderForm.receiverInfo.province" size="default" placeholder="省份" clearable />
|
<el-input v-model="toOrderForm.receiverInfo.province" size="default" placeholder="省份" clearable />
|
||||||
|
<p v-if="toOrderErrors.province" class="task-panel__field-error">{{ toOrderErrors.province }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="task-panel__field task-panel__field--input">
|
<div class="task-panel__field task-panel__field--input" :class="{ 'is-error': toOrderErrors.city }">
|
||||||
<span class="task-panel__field-label">城市</span>
|
<span class="task-panel__field-label is-required">城市</span>
|
||||||
<div class="task-panel__field-form">
|
<div class="task-panel__field-form">
|
||||||
<el-input v-model="toOrderForm.receiverInfo.city" size="default" placeholder="城市" clearable />
|
<el-input v-model="toOrderForm.receiverInfo.city" size="default" placeholder="城市" clearable />
|
||||||
|
<p v-if="toOrderErrors.city" class="task-panel__field-error">{{ toOrderErrors.city }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="task-panel__field task-panel__field--input">
|
<div class="task-panel__field task-panel__field--input" :class="{ 'is-error': toOrderErrors.area }">
|
||||||
<span class="task-panel__field-label">区县</span>
|
<span class="task-panel__field-label is-required">区县</span>
|
||||||
<div class="task-panel__field-form">
|
<div class="task-panel__field-form">
|
||||||
<el-input v-model="toOrderForm.receiverInfo.area" size="default" placeholder="区县" clearable />
|
<el-input v-model="toOrderForm.receiverInfo.area" size="default" placeholder="区县" clearable />
|
||||||
|
<p v-if="toOrderErrors.area" class="task-panel__field-error">{{ toOrderErrors.area }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="task-panel__field task-panel__field--input">
|
<div class="task-panel__field task-panel__field--input" :class="{ 'is-error': toOrderErrors.town }">
|
||||||
<span class="task-panel__field-label">乡镇</span>
|
<span class="task-panel__field-label is-required">乡镇</span>
|
||||||
<div class="task-panel__field-form">
|
<div class="task-panel__field-form">
|
||||||
<el-input v-model="toOrderForm.receiverInfo.town" size="default" placeholder="乡镇(可选)" clearable />
|
<el-input v-model="toOrderForm.receiverInfo.town" size="default" placeholder="乡镇" clearable />
|
||||||
|
<p v-if="toOrderErrors.town" class="task-panel__field-error">{{ toOrderErrors.town }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="task-panel__field task-panel__field--input task-panel__field--textarea task-panel__field--full">
|
<div class="task-panel__field task-panel__field--input task-panel__field--textarea task-panel__field--full" :class="{ 'is-error': toOrderErrors.detailAddress }">
|
||||||
<span class="task-panel__field-label">详细地址</span>
|
<span class="task-panel__field-label is-required">详细地址</span>
|
||||||
<div class="task-panel__field-form">
|
<div class="task-panel__field-form">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="toOrderForm.receiverInfo.detailAddress"
|
v-model="toOrderForm.receiverInfo.detailAddress"
|
||||||
@ -253,16 +259,17 @@
|
|||||||
:rows="2"
|
:rows="2"
|
||||||
resize="none"
|
resize="none"
|
||||||
size="default"
|
size="default"
|
||||||
placeholder="详细地址(可选)"
|
placeholder="详细地址"
|
||||||
clearable
|
clearable
|
||||||
/>
|
/>
|
||||||
|
<p v-if="toOrderErrors.detailAddress" class="task-panel__field-error">{{ toOrderErrors.detailAddress }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
|
|
||||||
<p class="task-panel__form-tip">
|
<p class="task-panel__form-tip">
|
||||||
收件人信息均为选填,不会影响转单;新订单号留空时自动生成(SK 前缀),原出库单在转单成功后作废。
|
收件人姓名、手机号/电话(至少一项)、省市区镇与详细地址为必填项,缺失将无法转单;新订单号留空时自动生成(SK 前缀),原出库单在转单成功后作废。
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -680,6 +687,43 @@ const toOrderForm = reactive({
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** 转单表单校验错误:key 与 receiverInfo 字段一致,值为提示文案 */
|
||||||
|
const toOrderErrors = reactive<Record<string, string>>({})
|
||||||
|
|
||||||
|
function clearToOrderErrors() {
|
||||||
|
Object.keys(toOrderErrors).forEach((k) => delete toOrderErrors[k])
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 按 storage.stockout.toOrder 文档校验必填项:
|
||||||
|
* 收货信息 name、(tel/mobile) 至少一项、省市区镇与详细地址,缺失后端会直接拒绝转单。
|
||||||
|
* 表单已用出库单现有收件人信息回填,因此这里校验的即是最终会提交的内容。
|
||||||
|
*/
|
||||||
|
function validateToOrderForm(): boolean {
|
||||||
|
clearToOrderErrors()
|
||||||
|
const r = toOrderForm.receiverInfo
|
||||||
|
const val = (v: unknown) => String(v ?? '').trim()
|
||||||
|
|
||||||
|
if (!val(r.name)) toOrderErrors.name = '请填写收件人姓名'
|
||||||
|
if (!val(r.mobile) && !val(r.tel)) toOrderErrors.mobile = '手机号与电话至少填一项'
|
||||||
|
if (!val(r.province)) toOrderErrors.province = '请填写省份'
|
||||||
|
if (!val(r.city)) toOrderErrors.city = '请填写城市'
|
||||||
|
if (!val(r.area)) toOrderErrors.area = '请填写区县'
|
||||||
|
if (!val(r.town)) toOrderErrors.town = '请填写乡镇'
|
||||||
|
if (!val(r.detailAddress)) toOrderErrors.detailAddress = '请填写详细地址'
|
||||||
|
|
||||||
|
return Object.keys(toOrderErrors).length === 0
|
||||||
|
}
|
||||||
|
|
||||||
|
// 已提示错误时随输入实时重算,避免红框与提示滞留
|
||||||
|
watch(
|
||||||
|
() => toOrderForm.receiverInfo,
|
||||||
|
() => {
|
||||||
|
if (Object.keys(toOrderErrors).length) validateToOrderForm()
|
||||||
|
},
|
||||||
|
{ deep: true }
|
||||||
|
)
|
||||||
|
|
||||||
function resetToOrderForm() {
|
function resetToOrderForm() {
|
||||||
toOrderForm.delivery_order_code = ''
|
toOrderForm.delivery_order_code = ''
|
||||||
toOrderForm.receiverInfo = {
|
toOrderForm.receiverInfo = {
|
||||||
@ -693,6 +737,7 @@ function resetToOrderForm() {
|
|||||||
detailAddress: '',
|
detailAddress: '',
|
||||||
zipCode: ''
|
zipCode: ''
|
||||||
}
|
}
|
||||||
|
clearToOrderErrors()
|
||||||
}
|
}
|
||||||
|
|
||||||
function openToOrderDialog(row: any) {
|
function openToOrderDialog(row: any) {
|
||||||
@ -715,6 +760,12 @@ async function handleToOrderSubmit() {
|
|||||||
const row = toOrderTargetRow.value
|
const row = toOrderTargetRow.value
|
||||||
if (!row) return
|
if (!row) return
|
||||||
|
|
||||||
|
// 必填校验:不通过不发请求(后端同样会拒绝,提前拦截可避免无谓请求与整块报错文案)
|
||||||
|
if (!validateToOrderForm()) {
|
||||||
|
ElMessage.warning('请先补全收货信息后再提交转单')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
const receiverInfo = toOrderForm.receiverInfo
|
const receiverInfo = toOrderForm.receiverInfo
|
||||||
const hasReceiver = Object.values(receiverInfo).some((v) => String(v || '').trim() !== '')
|
const hasReceiver = Object.values(receiverInfo).some((v) => String(v || '').trim() !== '')
|
||||||
const payload: StockoutToOrderParams = { id: row.id }
|
const payload: StockoutToOrderParams = { id: row.id }
|
||||||
@ -1048,7 +1099,6 @@ function handleToolbarButtonClick(action: ToolbarButtonConfig['action']) {
|
|||||||
safeInvoke(() => handler())
|
safeInvoke(() => handler())
|
||||||
}
|
}
|
||||||
|
|
||||||
const quickSearch = ref('')
|
|
||||||
const currentSort = reactive({ prop: '', order: '' })
|
const currentSort = reactive({ prop: '', order: '' })
|
||||||
const currentCondition = ref<any>(null)
|
const currentCondition = ref<any>(null)
|
||||||
|
|
||||||
@ -1100,10 +1150,6 @@ async function loadData() {
|
|||||||
sort: currentSort.prop ? { sortField: currentSort.prop, sortOrder: currentSort.order === 'ascending' ? 'ASC' : 'DESC' } : undefined
|
sort: currentSort.prop ? { sortField: currentSort.prop, sortOrder: currentSort.order === 'ascending' ? 'ASC' : 'DESC' } : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
if (quickSearch.value) {
|
|
||||||
params.where = { ...(params.where || {}), delivery_order_code: quickSearch.value }
|
|
||||||
}
|
|
||||||
|
|
||||||
const res: any = await stockoutApi.stockoutList(params)
|
const res: any = await stockoutApi.stockoutList(params)
|
||||||
if (res && (res.code === 200 || res.code === 1 || res.flag === 'success')) {
|
if (res && (res.code === 200 || res.code === 1 || res.flag === 'success')) {
|
||||||
const data = res.data || res
|
const data = res.data || res
|
||||||
@ -1382,11 +1428,6 @@ function handlePageSizeChange(size: number) {
|
|||||||
loadData()
|
loadData()
|
||||||
}
|
}
|
||||||
|
|
||||||
function onQuickSearch() {
|
|
||||||
pagination.currentPage = 1
|
|
||||||
loadData()
|
|
||||||
}
|
|
||||||
|
|
||||||
function handleCreateStockout() {
|
function handleCreateStockout() {
|
||||||
ElMessage.info('新建出库单功能')
|
ElMessage.info('新建出库单功能')
|
||||||
}
|
}
|
||||||
@ -1754,6 +1795,36 @@ function handleImport() {
|
|||||||
color: #606266;
|
color: #606266;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|
||||||
|
/* 必填星号:放在标签左侧预留的 10px 内边距里 */
|
||||||
|
&.is-required::before {
|
||||||
|
content: '*';
|
||||||
|
position: absolute;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
font-family: SimSun, sans-serif;
|
||||||
|
line-height: 20px;
|
||||||
|
color: #f56c6c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 校验失败:标签文字与输入框描边变红 */
|
||||||
|
&__field.is-error {
|
||||||
|
.task-panel__field-label {
|
||||||
|
color: #f56c6c;
|
||||||
|
}
|
||||||
|
|
||||||
|
:deep(.el-input__wrapper),
|
||||||
|
:deep(.el-textarea__inner) {
|
||||||
|
box-shadow: 0 0 0 1px #f56c6c inset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
&__field-error {
|
||||||
|
margin: 2px 0 0;
|
||||||
|
font-size: 12px;
|
||||||
|
line-height: 16px;
|
||||||
|
color: #f56c6c;
|
||||||
}
|
}
|
||||||
|
|
||||||
&__field-value {
|
&__field-value {
|
||||||
|
|||||||
@ -320,6 +320,15 @@ export const availableFields: StockoutScanFieldConfig[] = [
|
|||||||
{ label: '奇门', value: 'QM' }
|
{ label: '奇门', value: 'QM' }
|
||||||
]
|
]
|
||||||
}),
|
}),
|
||||||
|
// 备注(storage.stockout.list 的 where.remark,文档「常用字段」已声明;默认模糊匹配)
|
||||||
|
stockoutScanBasicField({
|
||||||
|
value: 'remark',
|
||||||
|
label: '备注',
|
||||||
|
type: 'text',
|
||||||
|
placeholder: '备注关键词',
|
||||||
|
operators: ['like', 'eq', 'notlike'],
|
||||||
|
defaultOperator: 'like'
|
||||||
|
}),
|
||||||
|
|
||||||
// ===== 流程状态 =====
|
// ===== 流程状态 =====
|
||||||
stockoutScanWorkflowField({
|
stockoutScanWorkflowField({
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user