1
This commit is contained in:
parent
5211f818fc
commit
3ef327e0b8
@ -182,3 +182,56 @@ export const stockoutUpdateExpress = (data: StockoutUpdateExpressParams) => {
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
// ── storage.stockout.listLogs ──
|
||||
|
||||
export type StockoutLogItem = {
|
||||
id: number
|
||||
/** 操作编码(STOCKOUT_TO_ORDER / STOCKOUT_CONFIRM / STOCKOUT_CANCEL / STOCKOUT_UPDATE_INFO 等) */
|
||||
operation_code: string
|
||||
/** 操作名称(后端按编码解析) */
|
||||
operation_name?: string
|
||||
/** 操作人姓名 */
|
||||
operator_name?: string
|
||||
/** 格式化后的操作时间 */
|
||||
created_at: string
|
||||
platform_code?: string
|
||||
platform_name?: string
|
||||
/** 日志内容 */
|
||||
message?: string
|
||||
}
|
||||
|
||||
export type StockoutListLogsParams = {
|
||||
/** 出库单ID(与 stockout_order_code 至少传一个) */
|
||||
id?: number
|
||||
/** 出库单号 */
|
||||
stockout_order_code?: string
|
||||
/** 页码(也支持 pagination.page) */
|
||||
page?: number
|
||||
/** 每页数量 */
|
||||
pageSize?: number
|
||||
}
|
||||
|
||||
export type StockoutListLogsResponse = {
|
||||
list: StockoutLogItem[]
|
||||
pagination: {
|
||||
page: number
|
||||
pageSize: number
|
||||
total: number
|
||||
totalPages: number
|
||||
}
|
||||
}
|
||||
|
||||
/** 查询出库单操作日志(business_type=stockout),按创建时间倒序分页 */
|
||||
export const stockoutListLogs = (data: StockoutListLogsParams) => {
|
||||
return request({
|
||||
url: `/system`,
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.stockout.listLogs',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: data
|
||||
})
|
||||
}
|
||||
|
||||
@ -61,30 +61,32 @@
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { ref, reactive, computed, watch } from 'vue'
|
||||
import UpperTable from '@/components/UpperTable/index.vue'
|
||||
import * as indexApi from '@/api/index/index'
|
||||
import { getSpaceInfo } from '@/api/warehouse/warehouse'
|
||||
|
||||
type SpaceValue = number | string | null
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
modelValue?: string
|
||||
/** 库位ID(保存值),外部回显时按 ID 查询展示名 */
|
||||
modelValue?: SpaceValue
|
||||
placeholder?: string
|
||||
warehouseId?: number | string
|
||||
multiple?: boolean
|
||||
}>(), {
|
||||
modelValue: '',
|
||||
placeholder: '请选择库位',
|
||||
multiple: false
|
||||
modelValue: null,
|
||||
placeholder: '请选择库位'
|
||||
})
|
||||
|
||||
const emit = defineEmits<{
|
||||
(e: 'update:modelValue', value: string): void
|
||||
(e: 'change', value: string): void
|
||||
(e: 'update:modelValue', value: SpaceValue): void
|
||||
(e: 'change', value: SpaceValue): void
|
||||
}>()
|
||||
|
||||
const spaceColumns = [
|
||||
{ prop: 'id', label: '库位ID', width: 100 },
|
||||
{ prop: 'display_name', label: '显示名称', minWidth: 200 },
|
||||
{ prop: 'space_name', label: '默认名称', minWidth: 200 },
|
||||
{ prop: 'custom_name', label: '自定义名称', minWidth: 140 },
|
||||
{ prop: 'custom_code', label: '自定义编码', minWidth: 140 },
|
||||
{ prop: 'space_code', label: '库位编码', width: 160 }
|
||||
]
|
||||
|
||||
@ -95,11 +97,67 @@ const list = ref<any[]>([])
|
||||
const selectedItem = ref<any>(null)
|
||||
const pagination = reactive({ page: 1, pageSize: 20, total: 0 })
|
||||
|
||||
/** 当前选中的库位行(用于回显展示名) */
|
||||
const pickedItem = ref<any>(null)
|
||||
/** 外部赋值且暂时无法解析时的兜底文案 */
|
||||
const fallbackText = ref('')
|
||||
|
||||
function normalizeValue(value: unknown): SpaceValue {
|
||||
if (value === null || value === undefined || value === '') return null
|
||||
return value as SpaceValue
|
||||
}
|
||||
|
||||
/** 展示名兜底:自定义名称 → 自定义编码 → 库位编码 → ID */
|
||||
function spaceFallbackText(item: any): string {
|
||||
if (!item || typeof item !== 'object') return ''
|
||||
const customName = String(item?.custom_name ?? item?.customName ?? '').trim()
|
||||
if (customName) return customName
|
||||
const customCode = String(item?.custom_code ?? item?.customCode ?? item?.custom_barcode ?? '').trim()
|
||||
if (customCode) return customCode
|
||||
const code = String(item?.space_code ?? '').trim()
|
||||
if (code) return code
|
||||
const id = item?.id ?? item?.space_id
|
||||
return id === null || id === undefined || id === '' ? '' : `ID ${id}`
|
||||
}
|
||||
|
||||
const displayText = computed(() => {
|
||||
if (!props.modelValue) return ''
|
||||
return props.modelValue
|
||||
if (pickedItem.value) return spaceFallbackText(pickedItem.value)
|
||||
return fallbackText.value
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.modelValue,
|
||||
async (value) => {
|
||||
const normalized = normalizeValue(value)
|
||||
if (normalized === null) {
|
||||
pickedItem.value = null
|
||||
fallbackText.value = ''
|
||||
return
|
||||
}
|
||||
if (pickedItem.value && String(pickedItem.value.id) === String(normalized)) return
|
||||
const fromList = list.value.find((item: any) => String(item?.id) === String(normalized))
|
||||
if (fromList) {
|
||||
pickedItem.value = fromList
|
||||
fallbackText.value = ''
|
||||
return
|
||||
}
|
||||
// 外部回显:按 ID 查询库位信息解析展示名,失败则展示 ID 兜底
|
||||
fallbackText.value = `ID ${normalized}`
|
||||
pickedItem.value = null
|
||||
try {
|
||||
const info: any = await getSpaceInfo(Number(normalized))
|
||||
const direct = info?.data || info
|
||||
if (direct && String(direct?.id ?? direct?.space_id) === String(normalized)) {
|
||||
pickedItem.value = direct
|
||||
fallbackText.value = ''
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('按ID获取库位信息失败', e)
|
||||
}
|
||||
},
|
||||
{ immediate: true }
|
||||
)
|
||||
|
||||
function openPicker() {
|
||||
dialogVisible.value = true
|
||||
if (list.value.length === 0) {
|
||||
@ -108,17 +166,10 @@ function openPicker() {
|
||||
}
|
||||
|
||||
function handleClear() {
|
||||
emit('update:modelValue', '')
|
||||
emit('change', '')
|
||||
}
|
||||
|
||||
function getSpaceDisplayName(item: any): string {
|
||||
const parts = [
|
||||
String(item?.warehouse_name || item?.warehouseName || '').trim(),
|
||||
String(item?.area_name || item?.areaName || '').trim(),
|
||||
String(item?.space_name || item?.name || item?.space_code || '').trim()
|
||||
].filter(Boolean)
|
||||
return parts.join(' - ') || String(item?.space_code || item?.id || '')
|
||||
pickedItem.value = null
|
||||
fallbackText.value = ''
|
||||
emit('update:modelValue', null)
|
||||
emit('change', null)
|
||||
}
|
||||
|
||||
async function loadData(page = 1) {
|
||||
@ -131,10 +182,18 @@ async function loadData(page = 1) {
|
||||
const rawList = Array.isArray(data?.list) ? data.list : Array.isArray(data) ? data : []
|
||||
list.value = rawList.map((item: any) => ({
|
||||
...item,
|
||||
display_name: getSpaceDisplayName(item),
|
||||
space_name: item.space_name || item.name || item.space_code || ''
|
||||
custom_name: String(item?.custom_name ?? item?.customName ?? '').trim(),
|
||||
custom_code: String(item?.custom_code ?? item?.customCode ?? item?.custom_barcode ?? '').trim(),
|
||||
space_code: String(item?.space_code ?? '').trim()
|
||||
}))
|
||||
pagination.total = data?.pagination?.total || data?.total || list.value.length
|
||||
|
||||
// 列表加载后尝试用当前值命中回显
|
||||
const normalized = normalizeValue(props.modelValue)
|
||||
if (normalized !== null && !pickedItem.value) {
|
||||
const matched = list.value.find((item: any) => String(item?.id) === String(normalized))
|
||||
if (matched) pickedItem.value = matched
|
||||
}
|
||||
} catch {
|
||||
list.value = []
|
||||
pagination.total = 0
|
||||
@ -159,9 +218,11 @@ function handlePageSizeChange(size: number) {
|
||||
|
||||
function applySelection() {
|
||||
if (!selectedItem.value) return
|
||||
const value = String(selectedItem.value.display_name || selectedItem.value.space_code || selectedItem.value.id || '')
|
||||
emit('update:modelValue', value)
|
||||
emit('change', value)
|
||||
const id = selectedItem.value?.id ?? selectedItem.value?.space_id ?? null
|
||||
pickedItem.value = selectedItem.value
|
||||
fallbackText.value = ''
|
||||
emit('update:modelValue', id)
|
||||
emit('change', id)
|
||||
dialogVisible.value = false
|
||||
}
|
||||
</script>
|
||||
@ -172,11 +233,20 @@ function applySelection() {
|
||||
}
|
||||
|
||||
.space-picker-dialog {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
|
||||
.picker-toolbar {
|
||||
margin-bottom: 12px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.picker-table-wrap {
|
||||
min-height: 200px;
|
||||
/* 参考项目内其它库位选择弹窗样式,固定表格高度,避免弹窗过高看不到底部按钮 */
|
||||
height: 440px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
1
src/views/storage/receiving/2
Normal file
1
src/views/storage/receiving/2
Normal file
File diff suppressed because one or more lines are too long
@ -1,58 +1,81 @@
|
||||
<template>
|
||||
<div class="stockout-log-container">
|
||||
<div v-loading="loading" class="stockout-log-container">
|
||||
<el-timeline v-if="logs.length">
|
||||
<el-timeline-item
|
||||
v-for="(log, index) in logs"
|
||||
:key="index"
|
||||
:key="log.id ?? index"
|
||||
:timestamp="log.created_at"
|
||||
:type="log.type"
|
||||
:color="log.color"
|
||||
size="large"
|
||||
>
|
||||
<div class="log-content">
|
||||
<span class="operator">{{ log.operator_name }}</span>
|
||||
<span class="action">{{ log.action }}</span>
|
||||
<el-tag v-if="log.platform_name" size="small" type="info" class="platform">
|
||||
{{ log.platform_name }}
|
||||
</el-tag>
|
||||
<p v-if="log.remark" class="remark">{{ log.remark }}</p>
|
||||
</div>
|
||||
</el-timeline-item>
|
||||
</el-timeline>
|
||||
<el-empty v-else description="暂无操作日志" />
|
||||
<el-empty v-else-if="!loading" description="暂无操作日志" />
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, onMounted, watch } from 'vue'
|
||||
import { ref, watch, onActivated } from 'vue'
|
||||
import { stockoutListLogs } from '@/api/storage.stockout/stockout'
|
||||
|
||||
const props = defineProps<{
|
||||
id: string | number
|
||||
}>()
|
||||
|
||||
const logs = ref<any[]>([])
|
||||
const loading = ref(false)
|
||||
|
||||
// 操作编码 → 时间线节点颜色
|
||||
const OPERATION_COLOR_MAP: Record<string, string> = {
|
||||
STOCKOUT_CONFIRM: 'success',
|
||||
STOCKOUT_TO_ORDER: 'warning',
|
||||
STOCKOUT_CANCEL: 'danger',
|
||||
STOCKOUT_UPDATE_INFO: 'info'
|
||||
}
|
||||
|
||||
const normalizeLog = (item: any, index: number) => ({
|
||||
id: item.id ?? index,
|
||||
created_at: item.created_at || '',
|
||||
operator_name: item.operator_name || '—',
|
||||
action: item.operation_name || item.operation_code || '',
|
||||
remark: item.message || '',
|
||||
platform_name: item.platform_name || '',
|
||||
type: OPERATION_COLOR_MAP[item.operation_code] || 'primary'
|
||||
})
|
||||
|
||||
const loadLogs = async () => {
|
||||
if (!props.id) return
|
||||
// 模拟日志数据
|
||||
logs.value = [
|
||||
{
|
||||
created_at: '2026-03-27 10:00:00',
|
||||
operator_name: '管理员',
|
||||
action: '创建出库单',
|
||||
type: 'primary',
|
||||
remark: '系统自动创建'
|
||||
},
|
||||
{
|
||||
created_at: '2026-03-27 10:05:00',
|
||||
operator_name: '仓库员',
|
||||
action: '确认出库',
|
||||
type: 'success',
|
||||
remark: '已拣货并打包'
|
||||
}
|
||||
]
|
||||
if (!props.id) {
|
||||
logs.value = []
|
||||
return
|
||||
}
|
||||
loading.value = true
|
||||
try {
|
||||
const res: any = await stockoutListLogs({ id: Number(props.id), page: 1, pageSize: 50 })
|
||||
// 兼容 { data: { list } } 与 { list } 两种包装
|
||||
const data =
|
||||
res?.data && typeof res.data === 'object' && Array.isArray(res.data.list) ? res.data : res
|
||||
const list = Array.isArray(data?.list) ? data.list : []
|
||||
logs.value = list.map(normalizeLog)
|
||||
} catch (e) {
|
||||
console.error('加载出库单操作日志失败', e)
|
||||
logs.value = []
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
watch(() => props.id, loadLogs, { immediate: true })
|
||||
|
||||
onMounted(loadLogs)
|
||||
// KeepAlive 缓存下重新进入 tab 时刷新日志
|
||||
onActivated(loadLogs)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@ -69,6 +92,9 @@ onMounted(loadLogs)
|
||||
.action {
|
||||
color: #409eff;
|
||||
}
|
||||
.platform {
|
||||
margin-left: 10px;
|
||||
}
|
||||
.remark {
|
||||
margin-top: 5px;
|
||||
color: #909399;
|
||||
|
||||
@ -149,6 +149,26 @@ export function formatDateTime(dateStr: string): string {
|
||||
}
|
||||
}
|
||||
|
||||
// 运单号列:express_codes 为空时回退 waybill_code / waybill_codes(数组或分隔字符串),去重后展示
|
||||
export function formatExpressCodes(row: any): string {
|
||||
const flatten = (v: any): string[] => {
|
||||
if (v === null || v === undefined || v === '') return []
|
||||
if (Array.isArray(v)) {
|
||||
return v.map(item => String(item).trim()).filter(Boolean)
|
||||
}
|
||||
return String(v)
|
||||
.split(/[,;,;\n]+/)
|
||||
.map(s => s.trim())
|
||||
.filter(Boolean)
|
||||
}
|
||||
const codes = [...flatten(row?.express_codes), ...flatten(row?.waybill_code), ...flatten(row?.waybill_codes)]
|
||||
const unique = [...new Set(codes)]
|
||||
if (!unique.length) return '--'
|
||||
const escapeHtml = (s: string) =>
|
||||
s.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"')
|
||||
return unique.map(escapeHtml).join('<br/>')
|
||||
}
|
||||
|
||||
export const entryColums = [
|
||||
{ prop: 'stockout_order_code', label: '出库单号', width: '220', fixed: 'left', copyAction: 'copy' as const },
|
||||
{ prop: 'order_status', label: '出库状态', width: '100' },
|
||||
@ -158,7 +178,7 @@ export const entryColums = [
|
||||
{ prop: 'source_type', label: '来源类型', width: '100' },
|
||||
{ prop: 'qimen_owner_code', label: '奇门货主编码', width: '140' },
|
||||
{ prop: 'qimen_warehouse_code', label: '奇门仓库编码', width: '140' },
|
||||
{ prop: 'express_codes', label: '运单号', width: '140' },
|
||||
{ prop: 'express_codes', label: '运单号', width: '140', formatter: (row: any) => formatExpressCodes(row) },
|
||||
{ prop: 'express_code', label: '快递编码', width: '110' },
|
||||
{ prop: 'express_name', label: '快递名称', width: '110' },
|
||||
{ prop: 'total_order_lines', label: '订单行数', width: '90' },
|
||||
@ -166,7 +186,7 @@ export const entryColums = [
|
||||
{ prop: 'order_create_time', label: '下单时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.order_create_time) },
|
||||
{ prop: 'created_at', label: '创建时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.created_at) },
|
||||
{ prop: 'updated_at', label: '更新时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.updated_at) },
|
||||
{ prop: 'actions', label: '操作', width: '180', fixed: 'right' }
|
||||
{ prop: 'actions', label: '操作', width: '220', fixed: 'right' }
|
||||
]
|
||||
|
||||
export const availableFields: StockoutScanFieldConfig[] = [
|
||||
|
||||
@ -218,6 +218,13 @@
|
||||
<span v-if="itemKey.description" class="object-editor__desc">{{ itemKey.description }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<SpacePicker
|
||||
v-else-if="field.type === 'location'"
|
||||
:model-value="locationFieldValue(field.key)"
|
||||
class="field-control"
|
||||
placeholder="请选择库位"
|
||||
@update:model-value="onLocationFieldChange(field.key, $event)"
|
||||
/>
|
||||
<el-input
|
||||
v-else
|
||||
v-model="subjectConfig[field.key] as string"
|
||||
@ -283,6 +290,7 @@
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { ElMessage } from 'element-plus'
|
||||
import ApiOpenInterface from './ApiOpenInterface.vue'
|
||||
import SpacePicker from '@/components/SpacePicker/index.vue'
|
||||
import {
|
||||
settingWarehouseGetSettings,
|
||||
settingWarehouseGetFieldMeta,
|
||||
@ -301,7 +309,7 @@ const PREDEFINED_COLORS = ['#ff4d4f', '#ff7a45', '#faad14', '#fadb14', '#95de64'
|
||||
type NormalizedField = {
|
||||
key: string
|
||||
label: string
|
||||
type: 'number' | 'string' | 'boolean' | 'select' | 'array' | 'string_array' | 'color' | 'object'
|
||||
type: 'number' | 'string' | 'boolean' | 'select' | 'array' | 'string_array' | 'color' | 'object' | 'location'
|
||||
description?: string
|
||||
required?: boolean
|
||||
min?: number
|
||||
@ -462,6 +470,8 @@ function normalizeFieldMetaItem(raw: Record<string, unknown>): NormalizedField |
|
||||
type = rawType === 'string_array' ? 'string_array' : 'array'
|
||||
} else if (rawType.includes('object')) {
|
||||
type = 'object'
|
||||
} else if (rawType.includes('location')) {
|
||||
type = 'location'
|
||||
} else if (rawType === 'select' || rawType === 'enum' || options.length > 0) {
|
||||
type = 'select'
|
||||
}
|
||||
@ -575,6 +585,8 @@ function ensureFieldDefaults(target: Record<string, unknown>, fields: Normalized
|
||||
/* 不写入 key,便于 el-input-number 展示为空 */
|
||||
} else if (f.type === 'select') {
|
||||
/* 不默认选中,避免误保存 */
|
||||
} else if (f.type === 'location') {
|
||||
/* 不默认写入库位,避免误保存空值 */
|
||||
} else target[f.key] = ''
|
||||
}
|
||||
}
|
||||
@ -716,6 +728,17 @@ function onObjectFieldChange(fieldKey: string, subKey: string, value: unknown) {
|
||||
subjectConfig[fieldKey] = obj
|
||||
}
|
||||
|
||||
/** location 类型字段:取库位 ID 作为值(空值归一为 null) */
|
||||
function locationFieldValue(key: string): number | string | null {
|
||||
const value = subjectConfig[key]
|
||||
if (value === null || value === undefined || value === '') return null
|
||||
return value as number | string
|
||||
}
|
||||
|
||||
function onLocationFieldChange(key: string, value: number | string | null) {
|
||||
subjectConfig[key] = value
|
||||
}
|
||||
|
||||
function applySettingsPayload(settingsRes: SettingWarehouseSettingsPayload | Record<string, unknown>) {
|
||||
const normalized = normalizeGetSettingsPayload(settingsRes as Record<string, unknown>)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user