1
This commit is contained in:
parent
82c280e0dc
commit
072f4dd833
@ -532,6 +532,18 @@ export type ReturnUnpackDetailParams = {
|
|||||||
id: number
|
id: number
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** returnUnpack.detail 响应 */
|
||||||
|
export type ReturnUnpackDetailResponse = {
|
||||||
|
/** 主表完整记录(含 details 明细、videos 视频、returnReceived 退回收到单关联与格式化时间字段;videos 的 video_url 自动拼接 CDN 域名前缀 http://w{warehouseId}-c{recordingComputerId}.o.gztbyc.com{path}) */
|
||||||
|
record: ReturnUnpackRecord
|
||||||
|
/** 关联信息对象 */
|
||||||
|
related?: {
|
||||||
|
/** 原订单详情(含 items 明细,仅原单退回时返回,非原单为 null) */
|
||||||
|
order?: ReturnUnpackOriginalOrder | null
|
||||||
|
[key: string]: any
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** returnUnpack.detail:拆包单详情(主表 + 明细 + 视频副表 + 退回收到单) */
|
/** returnUnpack.detail:拆包单详情(主表 + 明细 + 视频副表 + 退回收到单) */
|
||||||
export function returnUnpackDetail(data: ReturnUnpackDetailParams): Promise<any> {
|
export function returnUnpackDetail(data: ReturnUnpackDetailParams): Promise<any> {
|
||||||
return request({
|
return request({
|
||||||
|
|||||||
@ -532,7 +532,13 @@ export type ReceivingCompareResponse = {
|
|||||||
message?: string
|
message?: string
|
||||||
entry_order_id?: number
|
entry_order_id?: number
|
||||||
entry_order_code?: string
|
entry_order_code?: string
|
||||||
/** 各收货单对照结果列表 */
|
/** 合并后的逐行对照列表(多个收货单明细先合并,再与入库单对照;以入库单明细为主,每个入库明细仅一行,含匹配状态 matched/entry_only、合并收货数量与各收货单来源明细) */
|
||||||
|
comparison?: ReceivingCompareRow[]
|
||||||
|
/** 仅收货单有的商品列表(合并后仍未匹配到任何入库明细,按商品合并) */
|
||||||
|
receiving_only?: ReceivingCompareRow[]
|
||||||
|
/** 合并对照汇总统计,含 total_entry_items/matched_items/entry_only_items/receiving_only_items */
|
||||||
|
summary?: ReceivingCompareSummary
|
||||||
|
/** 各收货单对照结果列表(兼容旧结构) */
|
||||||
comparisons?: ReceivingCompareItem[]
|
comparisons?: ReceivingCompareItem[]
|
||||||
/** 校验失败的收货单列表 */
|
/** 校验失败的收货单列表 */
|
||||||
errors?: Array<{ receiving_id?: number; message?: string; [key: string]: unknown }>
|
errors?: Array<{ receiving_id?: number; message?: string; [key: string]: unknown }>
|
||||||
|
|||||||
@ -69,8 +69,44 @@ export const stockoutListItems = (data: StockoutListItemsParams) => {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/** 占位扩展接口,参数预留;与文档 storage.stockout.toOrder 对齐 */
|
// ── storage.stockout.toOrder ──
|
||||||
export const stockoutToOrder = (data?: { id?: number; delivery_order_code?: string }) => {
|
|
||||||
|
export type StockoutToOrderReceiverInfo = {
|
||||||
|
name?: string
|
||||||
|
mobile?: string
|
||||||
|
tel?: string
|
||||||
|
province?: string
|
||||||
|
city?: string
|
||||||
|
area?: string
|
||||||
|
town?: string
|
||||||
|
detailAddress?: string
|
||||||
|
zipCode?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type StockoutToOrderParams = {
|
||||||
|
/** 出库单ID(必填) */
|
||||||
|
id: number
|
||||||
|
/** 新订单号,不传自动生成(SK 前缀) */
|
||||||
|
delivery_order_code?: string
|
||||||
|
/** 收件人信息,不传时新订单收货信息为空 */
|
||||||
|
receiverInfo?: StockoutToOrderReceiverInfo
|
||||||
|
}
|
||||||
|
|
||||||
|
export type StockoutToOrderResponse = {
|
||||||
|
/** 出库单ID */
|
||||||
|
id: number
|
||||||
|
/** 出库单号 */
|
||||||
|
stockout_order_code: string
|
||||||
|
/** 新订单ID */
|
||||||
|
order_id: number
|
||||||
|
/** 新订单号 */
|
||||||
|
delivery_order_code: string
|
||||||
|
/** 订单步骤(0=待审核,1=待处理) */
|
||||||
|
step?: number
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 将非订单出库单转为正式销售订单:新订单 create_channel 固定为 STOCKOUT;转单成功后原出库单置为 CANCELLED(幂等,重复调用返回原订单信息)。仅 CREATED / PENDING 状态允许转单 */
|
||||||
|
export const stockoutToOrder = (data: StockoutToOrderParams): Promise<StockoutToOrderResponse> => {
|
||||||
return request({
|
return request({
|
||||||
url: `/system`,
|
url: `/system`,
|
||||||
method: 'post',
|
method: 'post',
|
||||||
@ -79,7 +115,7 @@ export const stockoutToOrder = (data?: { id?: number; delivery_order_code?: stri
|
|||||||
v,
|
v,
|
||||||
timestamp: new Date().getTime()
|
timestamp: new Date().getTime()
|
||||||
},
|
},
|
||||||
data: data || {}
|
data: data
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -404,6 +404,44 @@ export function storeWarehouseOpenAccount(data: {
|
|||||||
} as any)
|
} as any)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** storeWarehouse.store.createUser 响应 */
|
||||||
|
export type StoreWarehouseCreateUserResponse = {
|
||||||
|
/** 账号ID */
|
||||||
|
account_id: number
|
||||||
|
/** 用户名 */
|
||||||
|
username: string
|
||||||
|
/** 货主ID */
|
||||||
|
store_id: number
|
||||||
|
/** 是否本次新建账号;false 表示账号已存在仅完成授权 */
|
||||||
|
created: boolean
|
||||||
|
/** 仅 created=true 时返回:随机生成的初始明文密码(12 位,随机大小写字母/数字) */
|
||||||
|
password?: string
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* storeWarehouse.store.createUser:为货主创建用户。
|
||||||
|
* 按用户名查询平台账号,不存在则自动注册并随机生成 12 位密码返回;
|
||||||
|
* 两种情况统一完成货主工号绑定并授予货主管理员角色(wms_role.id=5),幂等。
|
||||||
|
*/
|
||||||
|
export function storeWarehouseCreateUser(data: {
|
||||||
|
/** 用户名,3-50 位字母、数字或下划线,全局唯一 */
|
||||||
|
username: string
|
||||||
|
/** 货主ID */
|
||||||
|
store_id: number
|
||||||
|
}): Promise<StoreWarehouseCreateUserResponse> {
|
||||||
|
return request({
|
||||||
|
url: '/system',
|
||||||
|
method: 'post',
|
||||||
|
params: {
|
||||||
|
method: 'storeWarehouse.store.createUser',
|
||||||
|
v,
|
||||||
|
timestamp: new Date().getTime()
|
||||||
|
},
|
||||||
|
data,
|
||||||
|
isSystemApi: true
|
||||||
|
} as any)
|
||||||
|
}
|
||||||
|
|
||||||
/** 提交面单余额变更日志导出任务 */
|
/** 提交面单余额变更日志导出任务 */
|
||||||
export function storeWarehouseExportPrintQuantityLogs(data: {
|
export function storeWarehouseExportPrintQuantityLogs(data: {
|
||||||
store_id: number | string
|
store_id: number | string
|
||||||
|
|||||||
@ -471,7 +471,7 @@ const props = defineProps({
|
|||||||
// 分页每页显示个数选择器的选项设置
|
// 分页每页显示个数选择器的选项设置
|
||||||
pageSizes: {
|
pageSizes: {
|
||||||
type: Array as any,
|
type: Array as any,
|
||||||
default: () => [10, 20, 50, 100, 200, 500],
|
default: () => [10, 20, 50, 100, 200, 500, 1000],
|
||||||
},
|
},
|
||||||
// 分页布局
|
// 分页布局
|
||||||
paginationLayout: {
|
paginationLayout: {
|
||||||
@ -580,6 +580,7 @@ const draggingProp = ref<string>('')
|
|||||||
const dragOverProp = ref<string>('')
|
const dragOverProp = ref<string>('')
|
||||||
const tableContainer = ref<HTMLElement | null>(null)
|
const tableContainer = ref<HTMLElement | null>(null)
|
||||||
const bodyScrollEl = ref<HTMLElement | null>(null)
|
const bodyScrollEl = ref<HTMLElement | null>(null)
|
||||||
|
let scrollRaf: number | null = null
|
||||||
const columnConfigListRef = ref<HTMLElement | null>(null)
|
const columnConfigListRef = ref<HTMLElement | null>(null)
|
||||||
const virtualScrollTop = ref(0)
|
const virtualScrollTop = ref(0)
|
||||||
const virtualViewportHeight = ref(0)
|
const virtualViewportHeight = ref(0)
|
||||||
@ -729,7 +730,7 @@ const virtualVisibleCount = computed(() => {
|
|||||||
const bufferRows = props.virtualBufferRows
|
const bufferRows = props.virtualBufferRows
|
||||||
const viewportCount = virtualViewportHeight.value
|
const viewportCount = virtualViewportHeight.value
|
||||||
? Math.ceil(virtualViewportHeight.value / virtualRowHeight.value) + bufferRows * 2
|
? Math.ceil(virtualViewportHeight.value / virtualRowHeight.value) + bufferRows * 2
|
||||||
: (props.pagination.pageSize || 20)
|
: 30
|
||||||
if (props.virtualMaxVisibleRows > 0) {
|
if (props.virtualMaxVisibleRows > 0) {
|
||||||
return Math.min(props.virtualMaxVisibleRows, viewportCount)
|
return Math.min(props.virtualMaxVisibleRows, viewportCount)
|
||||||
}
|
}
|
||||||
@ -811,7 +812,7 @@ watch(() => props.data, () => {
|
|||||||
clearSelection()
|
clearSelection()
|
||||||
expandedMultiCopyCells.value = new Set()
|
expandedMultiCopyCells.value = new Set()
|
||||||
syncVirtualViewport()
|
syncVirtualViewport()
|
||||||
}, { deep: true })
|
})
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
[() => props.columns, () => props.enableColumnConfig, () => props.tableId, () => userStore.roleId, () => userStore.user],
|
[() => props.columns, () => props.enableColumnConfig, () => props.tableId, () => userStore.roleId, () => userStore.user],
|
||||||
@ -1568,12 +1569,23 @@ function getRowStyle({ row }: { row: any }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleBodyScroll() {
|
function handleBodyScroll() {
|
||||||
if (!bodyScrollEl.value) return
|
if (scrollRaf !== null) return
|
||||||
virtualScrollTop.value = bodyScrollEl.value.scrollTop || 0
|
scrollRaf = requestAnimationFrame(() => {
|
||||||
virtualViewportHeight.value = bodyScrollEl.value.clientHeight || 0
|
scrollRaf = null
|
||||||
|
if (!bodyScrollEl.value) return
|
||||||
|
const top = bodyScrollEl.value.scrollTop || 0
|
||||||
|
const height = bodyScrollEl.value.clientHeight || 0
|
||||||
|
// 仅在值变化时更新,避免滚动过程中无谓的 computed 重算与表格重渲染
|
||||||
|
if (top !== virtualScrollTop.value) virtualScrollTop.value = top
|
||||||
|
if (height !== virtualViewportHeight.value) virtualViewportHeight.value = height
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function unbindBodyScroll() {
|
function unbindBodyScroll() {
|
||||||
|
if (scrollRaf !== null) {
|
||||||
|
cancelAnimationFrame(scrollRaf)
|
||||||
|
scrollRaf = null
|
||||||
|
}
|
||||||
if (!bodyScrollEl.value) return
|
if (!bodyScrollEl.value) return
|
||||||
bodyScrollEl.value.removeEventListener('scroll', handleBodyScroll)
|
bodyScrollEl.value.removeEventListener('scroll', handleBodyScroll)
|
||||||
}
|
}
|
||||||
@ -1593,8 +1605,10 @@ function bindBodyScroll() {
|
|||||||
|
|
||||||
function syncVirtualViewport() {
|
function syncVirtualViewport() {
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
if (!shouldUseVirtual.value) {
|
// 数据源变化(翻页/新数据)时重置滚动位置,避免虚拟滚动窗口错位
|
||||||
virtualScrollTop.value = 0
|
virtualScrollTop.value = 0
|
||||||
|
if (bodyScrollEl.value) {
|
||||||
|
bodyScrollEl.value.scrollTop = 0
|
||||||
}
|
}
|
||||||
bindBodyScroll()
|
bindBodyScroll()
|
||||||
})
|
})
|
||||||
|
|||||||
@ -16,6 +16,9 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="item_code" label="商品编码" min-width="120" show-overflow-tooltip />
|
<el-table-column prop="item_code" label="商品编码" min-width="120" show-overflow-tooltip />
|
||||||
<el-table-column prop="item_name" label="商品名称" min-width="140" show-overflow-tooltip />
|
<el-table-column prop="item_name" label="商品名称" min-width="140" show-overflow-tooltip />
|
||||||
|
<el-table-column label="规格" min-width="100" show-overflow-tooltip>
|
||||||
|
<template #default="{ row }">{{ row.spec || row.stock?.sku_property || row.stockWarehouse?.sku_property || '-' }}</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="SKU" min-width="110" show-overflow-tooltip>
|
<el-table-column label="SKU" min-width="110" show-overflow-tooltip>
|
||||||
<template #default="{ row }">{{ stockSku(row) }}</template>
|
<template #default="{ row }">{{ stockSku(row) }}</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -45,6 +48,9 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column prop="quantity" label="数量" width="70" />
|
<el-table-column prop="quantity" label="数量" width="70" />
|
||||||
<el-table-column prop="remark" label="备注" min-width="120" show-overflow-tooltip />
|
<el-table-column prop="remark" label="备注" min-width="120" show-overflow-tooltip />
|
||||||
|
<el-table-column label="录入时间" min-width="150">
|
||||||
|
<template #default="{ row }">{{ formatDetailTime(row.created_at) }}</template>
|
||||||
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -70,6 +76,12 @@ function stockBarcodes(row: any): string {
|
|||||||
}
|
}
|
||||||
return row?.barcode || '-'
|
return row?.barcode || '-'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 明细录入时间展示(ISO → YYYY-MM-DD HH:mm:ss,容错) */
|
||||||
|
function formatDetailTime(v: any): string {
|
||||||
|
if (v === null || v === undefined || v === '') return '-'
|
||||||
|
return String(v).replace('T', ' ').slice(0, 19)
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
|
|||||||
@ -127,6 +127,7 @@
|
|||||||
<!-- 主表信息 -->
|
<!-- 主表信息 -->
|
||||||
<el-descriptions title="拆包单信息" :column="3" border size="small" class="detail-section">
|
<el-descriptions title="拆包单信息" :column="3" border size="small" class="detail-section">
|
||||||
<el-descriptions-item label="拆包单ID">{{ detailRecord.id ?? '-' }}</el-descriptions-item>
|
<el-descriptions-item label="拆包单ID">{{ detailRecord.id ?? '-' }}</el-descriptions-item>
|
||||||
|
<el-descriptions-item label="仓库ID">{{ detailRecord.warehouse_id ?? '-' }}</el-descriptions-item>
|
||||||
<el-descriptions-item label="拆包单号">
|
<el-descriptions-item label="拆包单号">
|
||||||
<span
|
<span
|
||||||
v-if="detailRecord.unpack_no"
|
v-if="detailRecord.unpack_no"
|
||||||
|
|||||||
@ -71,7 +71,12 @@ export const returnUnpackColumns = [
|
|||||||
{ prop: 'total_quantity', label: '总数量', width: '90' },
|
{ prop: 'total_quantity', label: '总数量', width: '90' },
|
||||||
{ prop: 'unpacker_name', label: '拆包人', minWidth: '100', showOverflowTooltip: true },
|
{ prop: 'unpacker_name', label: '拆包人', minWidth: '100', showOverflowTooltip: true },
|
||||||
{ prop: 'unpack_date', label: '拆包日期', width: '130' },
|
{ prop: 'unpack_date', label: '拆包日期', width: '130' },
|
||||||
|
{ prop: 'start_time', label: '拆包开始时间', width: '160' },
|
||||||
|
{ prop: 'end_time', label: '拆包结束时间', width: '160' },
|
||||||
{ prop: 'shop_name', label: '货主/店铺', minWidth: '120', showOverflowTooltip: true },
|
{ prop: 'shop_name', label: '货主/店铺', minWidth: '120', showOverflowTooltip: true },
|
||||||
|
{ prop: 'source_order_codes', label: '平台交易单号', minWidth: '140', showOverflowTooltip: true },
|
||||||
|
{ prop: 'remark', label: '备注', minWidth: '140', showOverflowTooltip: true },
|
||||||
|
{ prop: 'camera_ids', label: '摄像头', width: '110', formatter: (row: any) => Array.isArray(row.camera_ids) && row.camera_ids.length ? row.camera_ids.join(',') : '--' },
|
||||||
{ prop: 'is_original_return', label: '原单退回', width: '100' },
|
{ prop: 'is_original_return', label: '原单退回', width: '100' },
|
||||||
{ prop: 'has_video', label: '视频', width: '90' },
|
{ prop: 'has_video', label: '视频', width: '90' },
|
||||||
{ prop: 'video_enable', label: '视频可用', width: '100' },
|
{ prop: 'video_enable', label: '视频可用', width: '100' },
|
||||||
|
|||||||
@ -223,7 +223,7 @@ function formatStatusLabel(status: any): string {
|
|||||||
|
|
||||||
async function parseExcelFile(file: File) {
|
async function parseExcelFile(file: File) {
|
||||||
const buffer = await file.arrayBuffer()
|
const buffer = await file.arrayBuffer()
|
||||||
const workbook = XLSX.read(buffer, { type: 'array' })
|
const workbook = XLSX.read(buffer, { type: 'array', dense: true })
|
||||||
const sheetName = workbook.SheetNames[0]
|
const sheetName = workbook.SheetNames[0]
|
||||||
if (!sheetName) {
|
if (!sheetName) {
|
||||||
ElMessage.warning('Excel 中没有可读取的工作表')
|
ElMessage.warning('Excel 中没有可读取的工作表')
|
||||||
@ -341,6 +341,20 @@ async function importSingleRow(row: ImportPreviewRow): Promise<boolean> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function runWithConcurrency<T>(items: T[], limit: number, worker: (item: T) => Promise<void>): Promise<void> {
|
||||||
|
if (!items.length) return
|
||||||
|
let cursor = 0
|
||||||
|
const runners = Math.min(limit, items.length)
|
||||||
|
await Promise.all(
|
||||||
|
Array.from({ length: runners }, async () => {
|
||||||
|
while (cursor < items.length) {
|
||||||
|
const item = items[cursor++] as T
|
||||||
|
await worker(item)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
async function submitBatchImport() {
|
async function submitBatchImport() {
|
||||||
if (!previewRows.value.length) {
|
if (!previewRows.value.length) {
|
||||||
ElMessage.warning('请先选择 Excel 文件')
|
ElMessage.warning('请先选择 Excel 文件')
|
||||||
@ -363,10 +377,10 @@ async function submitBatchImport() {
|
|||||||
importLoading.value = true
|
importLoading.value = true
|
||||||
let successCount = 0
|
let successCount = 0
|
||||||
try {
|
try {
|
||||||
for (const row of pendingRows) {
|
await runWithConcurrency(pendingRows, 8, async (row) => {
|
||||||
const ok = await importSingleRow(row)
|
const ok = await importSingleRow(row)
|
||||||
if (ok) successCount += 1
|
if (ok) successCount += 1
|
||||||
}
|
})
|
||||||
ElMessage.success(`导入完成:成功 ${successCount} 条,共 ${pendingRows.length} 条`)
|
ElMessage.success(`导入完成:成功 ${successCount} 条,共 ${pendingRows.length} 条`)
|
||||||
if (successCount > 0) {
|
if (successCount > 0) {
|
||||||
emit('success')
|
emit('success')
|
||||||
@ -386,10 +400,10 @@ async function retryFailedRows() {
|
|||||||
retryLoading.value = true
|
retryLoading.value = true
|
||||||
let successCount = 0
|
let successCount = 0
|
||||||
try {
|
try {
|
||||||
for (const row of failedRows) {
|
await runWithConcurrency(failedRows, 8, async (row) => {
|
||||||
const ok = await importSingleRow(row)
|
const ok = await importSingleRow(row)
|
||||||
if (ok) successCount += 1
|
if (ok) successCount += 1
|
||||||
}
|
})
|
||||||
ElMessage.success(`重试完成:成功 ${successCount} 条,共 ${failedRows.length} 条`)
|
ElMessage.success(`重试完成:成功 ${successCount} 条,共 ${failedRows.length} 条`)
|
||||||
if (successCount > 0) {
|
if (successCount > 0) {
|
||||||
emit('success')
|
emit('success')
|
||||||
|
|||||||
@ -1591,7 +1591,7 @@ async function parseImportPreviewFromFile(file: File) {
|
|||||||
clearPreviewRowSelection()
|
clearPreviewRowSelection()
|
||||||
try {
|
try {
|
||||||
const buffer = await file.arrayBuffer()
|
const buffer = await file.arrayBuffer()
|
||||||
const workbook = XLSX.read(buffer, { type: 'array' })
|
const workbook = XLSX.read(buffer, { type: 'array', dense: true })
|
||||||
const sheetName = workbook.SheetNames[0]
|
const sheetName = workbook.SheetNames[0]
|
||||||
if (!sheetName) {
|
if (!sheetName) {
|
||||||
ElMessage.warning('Excel 中没有可读取的工作表')
|
ElMessage.warning('Excel 中没有可读取的工作表')
|
||||||
@ -1606,10 +1606,6 @@ async function parseImportPreviewFromFile(file: File) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const rawRows = XLSX.utils.sheet_to_json<Record<string, any>>(sheet, { defval: '' })
|
const rawRows = XLSX.utils.sheet_to_json<Record<string, any>>(sheet, { defval: '' })
|
||||||
console.log('【Excel导入】原始行数据(前3行):', rawRows.slice(0, 3).map((r: any) => {
|
|
||||||
const keys = Object.keys(r)
|
|
||||||
return { keys, sample: keys.slice(0, 8).map(k => `${k}=${r[k]}`) }
|
|
||||||
}))
|
|
||||||
const previewRows: ImportPreviewRow[] = []
|
const previewRows: ImportPreviewRow[] = []
|
||||||
for (let index = 0; index < rawRows.length; index += 1) {
|
for (let index = 0; index < rawRows.length; index += 1) {
|
||||||
const previewRow = buildPreviewRow(rawRows[index] || {}, index + 1)
|
const previewRow = buildPreviewRow(rawRows[index] || {}, index + 1)
|
||||||
@ -1674,6 +1670,30 @@ async function parseImportPreviewFromFile(file: File) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 自动匹配商品(按 item_code 查询并填充 item_id,组合商品自动展开)
|
// 自动匹配商品(按 item_code 查询并填充 item_id,组合商品自动展开)
|
||||||
|
// 先收集需要查询的任务并去重,受控并发查询,避免逐商品串行请求
|
||||||
|
const matchTasks: Array<{ storeId: number; itemCode: string }> = []
|
||||||
|
const matchCache = new Map<string, any[]>()
|
||||||
|
for (const row of mergedRows) {
|
||||||
|
const storeId = Number(row.store_id)
|
||||||
|
if (!Number.isFinite(storeId) || storeId <= 0) continue
|
||||||
|
for (const item of row.selected_items) {
|
||||||
|
if (hasValidSelectedItemId(item)) continue
|
||||||
|
const itemCode = String(item.item_code || '').trim()
|
||||||
|
if (!itemCode) continue
|
||||||
|
const cacheKey = `${storeId}::${itemCode}`
|
||||||
|
if (matchCache.has(cacheKey)) continue
|
||||||
|
matchCache.set(cacheKey, [])
|
||||||
|
matchTasks.push({ storeId, itemCode })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await runWithConcurrency(matchTasks, 6, async (task) => {
|
||||||
|
const cacheKey = `${task.storeId}::${task.itemCode}`
|
||||||
|
try {
|
||||||
|
matchCache.set(cacheKey, await lookupStockItemByCode(task.storeId, task.itemCode))
|
||||||
|
} catch {
|
||||||
|
matchCache.set(cacheKey, [])
|
||||||
|
}
|
||||||
|
})
|
||||||
for (const row of mergedRows) {
|
for (const row of mergedRows) {
|
||||||
const storeId = Number(row.store_id)
|
const storeId = Number(row.store_id)
|
||||||
if (!Number.isFinite(storeId) || storeId <= 0) continue
|
if (!Number.isFinite(storeId) || storeId <= 0) continue
|
||||||
@ -1688,29 +1708,25 @@ async function parseImportPreviewFromFile(file: File) {
|
|||||||
newItems.push(item)
|
newItems.push(item)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
try {
|
const matchedItems = matchCache.get(`${storeId}::${itemCode}`) || []
|
||||||
const matchedItems = await lookupStockItemByCode(storeId, itemCode)
|
if (!matchedItems.length) {
|
||||||
if (!matchedItems.length) {
|
|
||||||
newItems.push(item)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
// 统一展开:使用匹配结果中的编码和名称
|
|
||||||
const planQty = String(item.plan_qty || '1').trim()
|
|
||||||
matchedItems.forEach((subItem) => {
|
|
||||||
newItems.push({
|
|
||||||
item_id: subItem.item_id,
|
|
||||||
item_code: subItem.item_code,
|
|
||||||
item_name: subItem.item_name,
|
|
||||||
barcode: subItem.barcode,
|
|
||||||
plan_qty: planQty,
|
|
||||||
store_id: subItem.store_id,
|
|
||||||
is_combo: false,
|
|
||||||
combo_id: undefined
|
|
||||||
})
|
|
||||||
})
|
|
||||||
} catch {
|
|
||||||
newItems.push(item)
|
newItems.push(item)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
// 统一展开:使用匹配结果中的编码和名称
|
||||||
|
const planQty = String(item.plan_qty || '1').trim()
|
||||||
|
matchedItems.forEach((subItem) => {
|
||||||
|
newItems.push({
|
||||||
|
item_id: subItem.item_id,
|
||||||
|
item_code: subItem.item_code,
|
||||||
|
item_name: subItem.item_name,
|
||||||
|
barcode: subItem.barcode,
|
||||||
|
plan_qty: planQty,
|
||||||
|
store_id: subItem.store_id,
|
||||||
|
is_combo: false,
|
||||||
|
combo_id: undefined
|
||||||
|
})
|
||||||
|
})
|
||||||
}
|
}
|
||||||
row.selected_items = newItems
|
row.selected_items = newItems
|
||||||
}
|
}
|
||||||
@ -1745,6 +1761,20 @@ async function handleImportFileChange(event: Event) {
|
|||||||
await parseImportPreviewFromFile(file)
|
await parseImportPreviewFromFile(file)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function runWithConcurrency<T>(items: T[], limit: number, worker: (item: T) => Promise<void>): Promise<void> {
|
||||||
|
if (!items.length) return
|
||||||
|
let cursor = 0
|
||||||
|
const runners = Math.min(limit, items.length)
|
||||||
|
await Promise.all(
|
||||||
|
Array.from({ length: runners }, async () => {
|
||||||
|
while (cursor < items.length) {
|
||||||
|
const item = items[cursor++] as T
|
||||||
|
await worker(item)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
function groupPendingRowsByOrder() {
|
function groupPendingRowsByOrder() {
|
||||||
const map = new Map<string, ImportPreviewRow[]>()
|
const map = new Map<string, ImportPreviewRow[]>()
|
||||||
for (const row of importPreviewRows.value) {
|
for (const row of importPreviewRows.value) {
|
||||||
@ -2021,7 +2051,7 @@ async function submitImportOrders() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
for (const [, rows] of groups) {
|
await runWithConcurrency([...groups.values()], 4, async (rows) => {
|
||||||
const orderLabel = String(rows[0]?.delivery_order_code || '').trim() || `第 ${rows[0]?.row_no} 行`
|
const orderLabel = String(rows[0]?.delivery_order_code || '').trim() || `第 ${rows[0]?.row_no} 行`
|
||||||
try {
|
try {
|
||||||
const payload = buildCreateOrderPayload(rows)
|
const payload = buildCreateOrderPayload(rows)
|
||||||
@ -2033,7 +2063,7 @@ async function submitImportOrders() {
|
|||||||
result.fail_count += 1
|
result.fail_count += 1
|
||||||
result.fail_orders.push({ delivery_order_code: orderLabel, error: message })
|
result.fail_orders.push({ delivery_order_code: orderLabel, error: message })
|
||||||
applyOrderGroupResult(rows, false, { message })
|
applyOrderGroupResult(rows, false, { message })
|
||||||
continue
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = res?.data || {}
|
const data = res?.data || {}
|
||||||
@ -2051,7 +2081,7 @@ async function submitImportOrders() {
|
|||||||
result.fail_orders.push({ delivery_order_code: orderLabel, error: message })
|
result.fail_orders.push({ delivery_order_code: orderLabel, error: message })
|
||||||
applyOrderGroupResult(rows, false, { message })
|
applyOrderGroupResult(rows, false, { message })
|
||||||
}
|
}
|
||||||
}
|
})
|
||||||
|
|
||||||
importOrderResult.value = result
|
importOrderResult.value = result
|
||||||
ElMessage.success(`批量创建完成:成功 ${result.success_count} 个,失败 ${result.fail_count} 个`)
|
ElMessage.success(`批量创建完成:成功 ${result.success_count} 个,失败 ${result.fail_count} 个`)
|
||||||
|
|||||||
@ -38,7 +38,7 @@
|
|||||||
<div class="create-order-body">
|
<div class="create-order-body">
|
||||||
<div class="create-order-left">
|
<div class="create-order-left">
|
||||||
<div class="preview-table-wrap">
|
<div class="preview-table-wrap">
|
||||||
<el-table :data="importRows" border size="small" height="100%" @selection-change="onSelectionChange">
|
<el-table :data="pagedRows" border size="small" height="100%" @selection-change="onSelectionChange">
|
||||||
<el-table-column type="selection" width="40" fixed="left" />
|
<el-table-column type="selection" width="40" fixed="left" />
|
||||||
<el-table-column label="SKU" min-width="140" fixed="left">
|
<el-table-column label="SKU" min-width="140" fixed="left">
|
||||||
<template #header>
|
<template #header>
|
||||||
@ -98,6 +98,9 @@
|
|||||||
<el-table-column label="零售价" min-width="120">
|
<el-table-column label="零售价" min-width="120">
|
||||||
<template #default="{ row }"><el-input v-model="row.retailPrice" size="small" clearable /></template>
|
<template #default="{ row }"><el-input v-model="row.retailPrice" size="small" clearable /></template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
|
<el-table-column label="复核" min-width="120">
|
||||||
|
<template #default="{ row }"><el-input v-model="row.needRecheck" size="small" clearable /></template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="货主" min-width="160" fixed="left">
|
<el-table-column label="货主" min-width="160" fixed="left">
|
||||||
<template #default="{ row }">
|
<template #default="{ row }">
|
||||||
<div :class="{ 'cell-required-empty': !row.sku.trim() && !row.storeName.trim() }">
|
<div :class="{ 'cell-required-empty': !row.sku.trim() && !row.storeName.trim() }">
|
||||||
@ -140,6 +143,19 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="preview-pagination">
|
||||||
|
<el-pagination
|
||||||
|
v-model:current-page="page"
|
||||||
|
:page-size="pageSize"
|
||||||
|
:total="importRows.length"
|
||||||
|
:page-sizes="[50, 100, 200, 500, 1000]"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
small
|
||||||
|
background
|
||||||
|
@current-change="onPageChange"
|
||||||
|
@size-change="onPageSizeChange"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@ -156,7 +172,7 @@ import * as XLSX from 'xlsx'
|
|||||||
import * as stockApi from '@/api/stock/stock'
|
import * as stockApi from '@/api/stock/stock'
|
||||||
import * as indexApi from '@/api/index/index'
|
import * as indexApi from '@/api/index/index'
|
||||||
|
|
||||||
const IMPORT_MAX_ROWS = 1000
|
const IMPORT_MAX_ROWS = 20000
|
||||||
|
|
||||||
type ImportRow = {
|
type ImportRow = {
|
||||||
sku: string
|
sku: string
|
||||||
@ -171,6 +187,7 @@ type ImportRow = {
|
|||||||
tagPrice: string
|
tagPrice: string
|
||||||
retailPrice: string
|
retailPrice: string
|
||||||
storeName: string
|
storeName: string
|
||||||
|
needRecheck: string
|
||||||
status: string
|
status: string
|
||||||
errorMsg: string
|
errorMsg: string
|
||||||
missingFields: string
|
missingFields: string
|
||||||
@ -178,7 +195,7 @@ type ImportRow = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function createEmptyImportRow(): ImportRow {
|
function createEmptyImportRow(): ImportRow {
|
||||||
return { sku: '', itemCode: '', itemName: '', cargoCode: '', barcode: '', skuSpec: '', stockUnit: '', brand: '', grossWeight: '', tagPrice: '', retailPrice: '', storeName: '', status: '', errorMsg: '', missingFields: '', storeError: '' }
|
return { sku: '', itemCode: '', itemName: '', cargoCode: '', barcode: '', skuSpec: '', stockUnit: '', brand: '', grossWeight: '', tagPrice: '', retailPrice: '', storeName: '', needRecheck: '', status: '', errorMsg: '', missingFields: '', storeError: '' }
|
||||||
}
|
}
|
||||||
|
|
||||||
const props = defineProps<{ modelValue: boolean }>()
|
const props = defineProps<{ modelValue: boolean }>()
|
||||||
@ -197,8 +214,37 @@ const importRows = ref<ImportRow[]>([])
|
|||||||
const selectedRows = ref<ImportRow[]>([])
|
const selectedRows = ref<ImportRow[]>([])
|
||||||
const hasSelection = computed(() => selectedRows.value.length > 0)
|
const hasSelection = computed(() => selectedRows.value.length > 0)
|
||||||
|
|
||||||
|
// 参与“是否为空行”判断的数据字段(不含 status/errorMsg 等内部状态字段)
|
||||||
|
const DATA_KEYS: Array<keyof ImportRow> = ['sku', 'itemCode', 'itemName', 'cargoCode', 'barcode', 'skuSpec', 'stockUnit', 'brand', 'grossWeight', 'tagPrice', 'retailPrice', 'storeName']
|
||||||
|
|
||||||
|
/** 判断一行是否包含有效数据(仅遍历数据字段,避免 Object.values 全字段扫描带来的额外分配) */
|
||||||
|
function hasData(r: ImportRow): boolean {
|
||||||
|
for (const k of DATA_KEYS) {
|
||||||
|
if (String(r[k] ?? '').trim() !== '') return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 分页渲染:只渲染当前页,避免大量 el-input 组件同时挂载导致 DOM 开销过大
|
||||||
|
const page = ref(1)
|
||||||
|
const pageSize = ref(100)
|
||||||
|
const pagedRows = computed(() => {
|
||||||
|
const start = (page.value - 1) * pageSize.value
|
||||||
|
return importRows.value.slice(start, start + pageSize.value)
|
||||||
|
})
|
||||||
|
|
||||||
|
function onPageChange() {
|
||||||
|
selectedRows.value = []
|
||||||
|
}
|
||||||
|
|
||||||
|
function onPageSizeChange(size: number) {
|
||||||
|
pageSize.value = size
|
||||||
|
page.value = 1
|
||||||
|
selectedRows.value = []
|
||||||
|
}
|
||||||
|
|
||||||
const importSummary = computed(() => {
|
const importSummary = computed(() => {
|
||||||
const nonEmpty = importRows.value.filter(r => Object.values(r).some(v => String(v || '').trim() !== ''))
|
const nonEmpty = importRows.value.filter(hasData)
|
||||||
const updateCount = nonEmpty.filter(r => String(r.sku || '').trim() !== '').length
|
const updateCount = nonEmpty.filter(r => String(r.sku || '').trim() !== '').length
|
||||||
return { total: nonEmpty.length, addCount: nonEmpty.length - updateCount, updateCount }
|
return { total: nonEmpty.length, addCount: nonEmpty.length - updateCount, updateCount }
|
||||||
})
|
})
|
||||||
@ -210,7 +256,7 @@ const handleBeforeClose: DialogBeforeCloseFn = (done) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function handleCloseAttempt(): Promise<boolean> {
|
async function handleCloseAttempt(): Promise<boolean> {
|
||||||
const nonEmpty = importRows.value.filter(r => Object.values(r).some(v => String(v || '').trim() !== '' && v !== r.status && v !== r.errorMsg))
|
const nonEmpty = importRows.value.filter(hasData)
|
||||||
if (!nonEmpty.length) {
|
if (!nonEmpty.length) {
|
||||||
doClose()
|
doClose()
|
||||||
return true
|
return true
|
||||||
@ -242,6 +288,7 @@ function clearData() {
|
|||||||
|
|
||||||
function addRow() {
|
function addRow() {
|
||||||
importRows.value.push(createEmptyImportRow())
|
importRows.value.push(createEmptyImportRow())
|
||||||
|
page.value = Math.max(1, Math.ceil(importRows.value.length / pageSize.value))
|
||||||
}
|
}
|
||||||
|
|
||||||
function onSelectionChange(rows: ImportRow[]) {
|
function onSelectionChange(rows: ImportRow[]) {
|
||||||
@ -252,6 +299,8 @@ function deleteSelectedRows() {
|
|||||||
const ids = new Set(selectedRows.value)
|
const ids = new Set(selectedRows.value)
|
||||||
importRows.value = importRows.value.filter(r => !ids.has(r))
|
importRows.value = importRows.value.filter(r => !ids.has(r))
|
||||||
selectedRows.value = []
|
selectedRows.value = []
|
||||||
|
const maxPage = Math.max(1, Math.ceil(importRows.value.length / pageSize.value))
|
||||||
|
if (page.value > maxPage) page.value = maxPage
|
||||||
}
|
}
|
||||||
|
|
||||||
function copyError(msg: string) {
|
function copyError(msg: string) {
|
||||||
@ -272,7 +321,7 @@ function validateRow(r: ImportRow): string[] {
|
|||||||
|
|
||||||
/** 重新校验单行并更新状态 */
|
/** 重新校验单行并更新状态 */
|
||||||
function revalidateRow(r: ImportRow) {
|
function revalidateRow(r: ImportRow) {
|
||||||
if (!Object.values(r).some(v => String(v || '').trim() !== '' && v !== r.status && v !== r.errorMsg && v !== r.missingFields && v !== r.storeError)) {
|
if (!hasData(r)) {
|
||||||
r.status = ''; r.missingFields = ''; r.storeError = ''
|
r.status = ''; r.missingFields = ''; r.storeError = ''
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -292,7 +341,7 @@ function revalidateRow(r: ImportRow) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function downloadTemplate() {
|
function downloadTemplate() {
|
||||||
const headers = ['SKU', '商品编码', '商品名称', '货物编码', '条码', 'SKU规格', '库存单位', '品牌', '毛重', '标价', '零售价', '货主']
|
const headers = ['SKU', '商品编码', '商品名称', '货物编码', '条码', 'SKU规格', '库存单位', '品牌', '毛重', '标价', '零售价', '是否需要复核', '货主']
|
||||||
const ws = XLSX.utils.aoa_to_sheet([headers])
|
const ws = XLSX.utils.aoa_to_sheet([headers])
|
||||||
ws['!cols'] = headers.map(() => ({ wch: 20 }))
|
ws['!cols'] = headers.map(() => ({ wch: 20 }))
|
||||||
const wb = XLSX.utils.book_new()
|
const wb = XLSX.utils.book_new()
|
||||||
@ -352,6 +401,7 @@ function mapRow(row: Record<string, any>): ImportRow {
|
|||||||
tagPrice: pickCell(row, ['标价', 'tag_price', 'tagPrice']),
|
tagPrice: pickCell(row, ['标价', 'tag_price', 'tagPrice']),
|
||||||
retailPrice: pickCell(row, ['零售价', 'retail_price', 'retailPrice']),
|
retailPrice: pickCell(row, ['零售价', 'retail_price', 'retailPrice']),
|
||||||
storeName: pickCell(row, ['货主', 'store_name', 'storeName', '店铺']),
|
storeName: pickCell(row, ['货主', 'store_name', 'storeName', '店铺']),
|
||||||
|
needRecheck: pickCell(row, ['是否需要复核', '复核', 'need_recheck', 'needRecheck']),
|
||||||
status: '',
|
status: '',
|
||||||
errorMsg: '',
|
errorMsg: '',
|
||||||
missingFields: '',
|
missingFields: '',
|
||||||
@ -363,7 +413,7 @@ function validateAllRows(): number {
|
|||||||
const storeList = stores.value
|
const storeList = stores.value
|
||||||
let invalidCount = 0
|
let invalidCount = 0
|
||||||
for (const r of importRows.value) {
|
for (const r of importRows.value) {
|
||||||
if (!Object.values(r).some(v => String(v || '').trim() !== '' && v !== r.status && v !== r.errorMsg && v !== r.missingFields && v !== r.storeError)) continue
|
if (!hasData(r)) continue
|
||||||
r.status = ''; r.errorMsg = ''; r.missingFields = ''; r.storeError = ''
|
r.status = ''; r.errorMsg = ''; r.missingFields = ''; r.storeError = ''
|
||||||
const missing = validateRow(r)
|
const missing = validateRow(r)
|
||||||
if (missing.length) {
|
if (missing.length) {
|
||||||
@ -385,11 +435,11 @@ function validateAllRows(): number {
|
|||||||
async function parseExcel(file: File) {
|
async function parseExcel(file: File) {
|
||||||
try {
|
try {
|
||||||
const buf = await file.arrayBuffer()
|
const buf = await file.arrayBuffer()
|
||||||
const wb = XLSX.read(buf, { type: 'array' })
|
const wb = XLSX.read(buf, { type: 'array', dense: true })
|
||||||
const ws = wb.Sheets[wb.SheetNames?.[0] || '']
|
const ws = wb.Sheets[wb.SheetNames?.[0] || '']
|
||||||
if (!ws) { ElMessage.error('未读取到工作表'); return }
|
if (!ws) { ElMessage.error('未读取到工作表'); return }
|
||||||
const rawRows = XLSX.utils.sheet_to_json<Record<string, any>>(ws, { defval: '' })
|
const rawRows = XLSX.utils.sheet_to_json<Record<string, any>>(ws, { defval: '' })
|
||||||
const mapped = rawRows.map(mapRow).filter(r => Object.values(r).some(v => v !== ''))
|
const mapped = rawRows.map(mapRow).filter(hasData)
|
||||||
if (mapped.length > IMPORT_MAX_ROWS) { ElMessage.error(`不超过 ${IMPORT_MAX_ROWS} 行`); return }
|
if (mapped.length > IMPORT_MAX_ROWS) { ElMessage.error(`不超过 ${IMPORT_MAX_ROWS} 行`); return }
|
||||||
importRows.value = mapped.length ? mapped : []
|
importRows.value = mapped.length ? mapped : []
|
||||||
selectedRows.value = []
|
selectedRows.value = []
|
||||||
@ -410,9 +460,11 @@ async function handleSubmit() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const payload = importRows.value
|
// 构造待提交项,并记录其在 importRows 中的原始下标,便于失败行精确回写
|
||||||
.filter(r => Object.values(r).some(v => String(v || '').trim() !== ''))
|
const items = importRows.value
|
||||||
.map(r => {
|
.map((r, rowIndex) => ({ r, rowIndex }))
|
||||||
|
.filter(({ r }) => hasData(r))
|
||||||
|
.map(({ r, rowIndex }) => {
|
||||||
const sku = String(r.sku || '').trim()
|
const sku = String(r.sku || '').trim()
|
||||||
const storeName = r.storeName.trim()
|
const storeName = r.storeName.trim()
|
||||||
let storeId: number | undefined
|
let storeId: number | undefined
|
||||||
@ -421,57 +473,65 @@ async function handleSubmit() {
|
|||||||
if (match) storeId = Number(match.value)
|
if (match) storeId = Number(match.value)
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
stock_id: sku || undefined,
|
rowIndex,
|
||||||
item_code: r.itemCode.trim(),
|
data: {
|
||||||
item_name: r.itemName.trim(),
|
stock_id: sku || undefined,
|
||||||
cargo_code: r.cargoCode.trim(),
|
item_code: r.itemCode.trim(),
|
||||||
barcode: r.barcode.trim(),
|
item_name: r.itemName.trim(),
|
||||||
sku_property: r.skuSpec.trim(),
|
cargo_code: r.cargoCode.trim(),
|
||||||
stock_unit: r.stockUnit.trim(),
|
barcode: r.barcode.trim(),
|
||||||
brand_name: r.brand.trim(),
|
sku_property: r.skuSpec.trim(),
|
||||||
gross_weight: r.grossWeight.trim(),
|
stock_unit: r.stockUnit.trim(),
|
||||||
tag_price: r.tagPrice.trim(),
|
brand_name: r.brand.trim(),
|
||||||
retail_price: r.retailPrice.trim(),
|
gross_weight: r.grossWeight.trim(),
|
||||||
store_id: storeId,
|
tag_price: r.tagPrice.trim(),
|
||||||
action: sku ? 'update' : 'add'
|
retail_price: r.retailPrice.trim(),
|
||||||
|
need_recheck: r.needRecheck.trim() || undefined,
|
||||||
|
store_id: storeId,
|
||||||
|
action: sku ? 'update' : 'add'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
if (!payload.length) { ElMessage.warning('没有可提交的数据'); return }
|
|
||||||
|
if (!items.length) { ElMessage.warning('没有可提交的数据'); return }
|
||||||
|
|
||||||
|
const BATCH_SIZE = 1000
|
||||||
|
const totals = { total: 0, created: 0, updated: 0, fail: 0 }
|
||||||
|
const failItems: Array<{ index: number; error: string }> = []
|
||||||
|
|
||||||
submitting.value = true
|
submitting.value = true
|
||||||
try {
|
try {
|
||||||
importRows.value.forEach(r => { r.status = ''; r.errorMsg = '' })
|
// 分批提交,避免一次性请求体过大
|
||||||
const res: any = await stockApi.importStockWarehouse(payload)
|
for (let start = 0; start < items.length; start += BATCH_SIZE) {
|
||||||
const total = Number(res?.total_count ?? payload.length)
|
const batch = items.slice(start, start + BATCH_SIZE)
|
||||||
const created = Number(res?.created_count ?? 0)
|
const res: any = await stockApi.importStockWarehouse(batch.map(b => b.data))
|
||||||
const updated = Number(res?.updated_count ?? 0)
|
totals.total += Number(res?.total_count ?? batch.length)
|
||||||
const fail = Number(res?.fail_count ?? 0)
|
totals.created += Number(res?.created_count ?? 0)
|
||||||
const failItems: Array<{ index: number; error: string }> = res?.fail_items || []
|
totals.updated += Number(res?.updated_count ?? 0)
|
||||||
|
totals.fail += Number(res?.fail_count ?? 0)
|
||||||
|
for (const f of res?.fail_items || []) {
|
||||||
|
const item = batch[f.index]
|
||||||
|
failItems.push({ index: item ? item.rowIndex : -1, error: f.error || '导入失败' })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 精确回写:只标记已提交的行(跳过被过滤掉的空行)
|
||||||
const failIdxSet = new Set(failItems.map(f => f.index))
|
const failIdxSet = new Set(failItems.map(f => f.index))
|
||||||
for (let i = 0; i < importRows.value.length; i++) {
|
for (const item of items) {
|
||||||
const row = importRows.value[i]
|
const row = importRows.value[item.rowIndex]
|
||||||
if (row && !failIdxSet.has(i)) {
|
if (row && !failIdxSet.has(item.rowIndex)) row.status = 'success'
|
||||||
row.status = 'success'
|
}
|
||||||
}
|
for (const f of failItems) {
|
||||||
|
if (f.index < 0) continue
|
||||||
|
const row = importRows.value[f.index]
|
||||||
|
if (row) { row.status = 'error'; row.errorMsg = f.error }
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const item of failItems) {
|
if (totals.fail === 0) {
|
||||||
const idx = item.index
|
ElMessage.success(`导入完成:总数 ${totals.total},新增 ${totals.created},更新 ${totals.updated}`)
|
||||||
if (idx >= 0 && idx < importRows.value.length) {
|
|
||||||
const row = importRows.value[idx]
|
|
||||||
if (row) {
|
|
||||||
row.status = 'error'
|
|
||||||
row.errorMsg = item.error || '导入失败'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fail === 0) {
|
|
||||||
ElMessage.success(`导入完成:总数 ${total},新增 ${created},更新 ${updated}`)
|
|
||||||
emit('success')
|
emit('success')
|
||||||
} else {
|
} else {
|
||||||
ElMessage.warning(`导入完成:总数 ${total},成功 ${total - fail},失败 ${fail},请查看失败行`)
|
ElMessage.warning(`导入完成:总数 ${totals.total},成功 ${totals.total - totals.fail},失败 ${totals.fail},请查看失败行`)
|
||||||
}
|
}
|
||||||
} catch (e: any) { ElMessage.error(e?.message || '导入提交失败') }
|
} catch (e: any) { ElMessage.error(e?.message || '导入提交失败') }
|
||||||
finally { submitting.value = false }
|
finally { submitting.value = false }
|
||||||
@ -546,6 +606,13 @@ async function handleSubmit() {
|
|||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.preview-pagination {
|
||||||
|
display: flex;
|
||||||
|
justify-content: flex-end;
|
||||||
|
padding: 8px 4px 0;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
.field-tip {
|
.field-tip {
|
||||||
color: #909399;
|
color: #909399;
|
||||||
font-size: 11px;
|
font-size: 11px;
|
||||||
|
|||||||
@ -116,7 +116,7 @@
|
|||||||
|
|
||||||
<el-table
|
<el-table
|
||||||
v-if="parsedRows.length"
|
v-if="parsedRows.length"
|
||||||
:data="parsedRows"
|
:data="pagedParsedRows"
|
||||||
border
|
border
|
||||||
size="small"
|
size="small"
|
||||||
max-height="360"
|
max-height="360"
|
||||||
@ -167,11 +167,22 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="操作" width="64" align="center" fixed="right">
|
<el-table-column label="操作" width="64" align="center" fixed="right">
|
||||||
<template #default="{ $index }">
|
<template #default="{ row }">
|
||||||
<el-button link type="danger" size="small" @click="removeParsedRow($index)">删除</el-button>
|
<el-button link type="danger" size="small" @click="removeParsedRow(row)">删除</el-button>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
</el-table>
|
</el-table>
|
||||||
|
<div style="display:flex;justify-content:flex-end;padding:8px 4px 0;">
|
||||||
|
<el-pagination
|
||||||
|
v-model:current-page="parsedPage"
|
||||||
|
:page-size="parsedPageSize"
|
||||||
|
:total="parsedRows.length"
|
||||||
|
:page-sizes="[50, 100, 200, 500, 1000]"
|
||||||
|
layout="total, sizes, prev, pager, next, jumper"
|
||||||
|
small
|
||||||
|
background
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -294,6 +305,12 @@ const singleFormRef = ref<FormInstance>()
|
|||||||
const singleTarget = ref<DirectInboundImportRow | null>(null)
|
const singleTarget = ref<DirectInboundImportRow | null>(null)
|
||||||
const importFileName = ref('')
|
const importFileName = ref('')
|
||||||
const parsedRows = ref<ParsedDirectInboundImportRow[]>([])
|
const parsedRows = ref<ParsedDirectInboundImportRow[]>([])
|
||||||
|
const parsedPage = ref(1)
|
||||||
|
const parsedPageSize = ref(100)
|
||||||
|
const pagedParsedRows = computed(() => {
|
||||||
|
const start = (parsedPage.value - 1) * parsedPageSize.value
|
||||||
|
return parsedRows.value.slice(start, start + parsedPageSize.value)
|
||||||
|
})
|
||||||
|
|
||||||
const singleForm = reactive({
|
const singleForm = reactive({
|
||||||
quantity: 1,
|
quantity: 1,
|
||||||
@ -455,6 +472,7 @@ const spaceResolveCache = new Map<string, Promise<{ id?: number; displayName?: s
|
|||||||
function resetBatchState() {
|
function resetBatchState() {
|
||||||
importFileName.value = ''
|
importFileName.value = ''
|
||||||
parsedRows.value = []
|
parsedRows.value = []
|
||||||
|
parsedPage.value = 1
|
||||||
spaceResolveCache.clear()
|
spaceResolveCache.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -468,8 +486,12 @@ function getBatchRowMaxQuantity(row: ParsedDirectInboundImportRow): number {
|
|||||||
return Number.isFinite(remaining) && remaining > 0 ? remaining : Number.MAX_SAFE_INTEGER
|
return Number.isFinite(remaining) && remaining > 0 ? remaining : Number.MAX_SAFE_INTEGER
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeParsedRow(index: number) {
|
function removeParsedRow(row: ParsedDirectInboundImportRow) {
|
||||||
|
const index = parsedRows.value.indexOf(row)
|
||||||
|
if (index < 0) return
|
||||||
parsedRows.value.splice(index, 1)
|
parsedRows.value.splice(index, 1)
|
||||||
|
const maxPage = Math.max(1, Math.ceil(parsedRows.value.length / parsedPageSize.value))
|
||||||
|
if (parsedPage.value > maxPage) parsedPage.value = maxPage
|
||||||
}
|
}
|
||||||
|
|
||||||
function openSpacePicker(target: 'single' | 'batch') {
|
function openSpacePicker(target: 'single' | 'batch') {
|
||||||
|
|||||||
@ -1090,12 +1090,16 @@ async function handleReviewEntry(row: any) {
|
|||||||
})
|
})
|
||||||
const payload = (res.data && typeof res.data === 'object' ? { ...res, ...res.data } : res) as any
|
const payload = (res.data && typeof res.data === 'object' ? { ...res, ...res.data } : res) as any
|
||||||
const allRecords: any[] = []
|
const allRecords: any[] = []
|
||||||
for (const item of (payload.comparisons ?? [])) {
|
if (Array.isArray(payload.comparison)) {
|
||||||
const records = [
|
// 最新结构:合并后的逐行对照 + 合并后仍未匹配的收货商品
|
||||||
...(Array.isArray(item.comparison) ? item.comparison : []),
|
allRecords.push(...payload.comparison)
|
||||||
...(Array.isArray(item.receiving_only) ? item.receiving_only : []),
|
if (Array.isArray(payload.receiving_only)) allRecords.push(...payload.receiving_only)
|
||||||
]
|
} else {
|
||||||
allRecords.push(...records)
|
// 兼容旧结构:各收货单各自对照
|
||||||
|
for (const item of (payload.comparisons ?? [])) {
|
||||||
|
allRecords.push(...(Array.isArray(item.comparison) ? item.comparison : []))
|
||||||
|
allRecords.push(...(Array.isArray(item.receiving_only) ? item.receiving_only : []))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
reviewCompareRows.value = allRecords.map(buildReviewCompareRow)
|
reviewCompareRows.value = allRecords.map(buildReviewCompareRow)
|
||||||
}
|
}
|
||||||
|
|||||||
@ -293,7 +293,7 @@ export function parseDirectInboundXlsxRows(
|
|||||||
|
|
||||||
export async function readDirectInboundXlsxFile(file: File): Promise<Record<string, unknown>[]> {
|
export async function readDirectInboundXlsxFile(file: File): Promise<Record<string, unknown>[]> {
|
||||||
const buffer = await file.arrayBuffer()
|
const buffer = await file.arrayBuffer()
|
||||||
const workbook = XLSX.read(buffer, { type: 'array' })
|
const workbook = XLSX.read(buffer, { type: 'array', dense: true })
|
||||||
const sheetName = workbook.SheetNames[0]
|
const sheetName = workbook.SheetNames[0]
|
||||||
if (!sheetName) return []
|
if (!sheetName) return []
|
||||||
const worksheet = workbook.Sheets[sheetName]
|
const worksheet = workbook.Sheets[sheetName]
|
||||||
|
|||||||
@ -1566,7 +1566,7 @@ const generateBatchImportList = async () => {
|
|||||||
batchImportLoading.value = true
|
batchImportLoading.value = true
|
||||||
try {
|
try {
|
||||||
const buffer = await batchImportSourceFile.value.arrayBuffer()
|
const buffer = await batchImportSourceFile.value.arrayBuffer()
|
||||||
const wb = XLSX.read(buffer, { type: 'array' })
|
const wb = XLSX.read(buffer, { type: 'array', dense: true })
|
||||||
const firstName = wb.SheetNames[0]
|
const firstName = wb.SheetNames[0]
|
||||||
if (!firstName) {
|
if (!firstName) {
|
||||||
ElMessage.warning('Excel中没有可读取的工作表')
|
ElMessage.warning('Excel中没有可读取的工作表')
|
||||||
@ -1797,6 +1797,20 @@ const resolveSpaceByKeyword = async (keyword: string): Promise<{ id?: number; di
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const runWithConcurrency = async <T>(items: T[], limit: number, worker: (item: T) => Promise<void>): Promise<void> => {
|
||||||
|
if (!items.length) return
|
||||||
|
let cursor = 0
|
||||||
|
const runners = Math.min(limit, items.length)
|
||||||
|
await Promise.all(
|
||||||
|
Array.from({ length: runners }, async () => {
|
||||||
|
while (cursor < items.length) {
|
||||||
|
const item = items[cursor++] as T
|
||||||
|
await worker(item)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
const submitBatchImportCreate = async () => {
|
const submitBatchImportCreate = async () => {
|
||||||
const receivingId = Number(props.id ?? props.row?.id)
|
const receivingId = Number(props.id ?? props.row?.id)
|
||||||
if (!Number.isFinite(receivingId) || receivingId <= 0) {
|
if (!Number.isFinite(receivingId) || receivingId <= 0) {
|
||||||
@ -1811,10 +1825,10 @@ const submitBatchImportCreate = async () => {
|
|||||||
batchImportLoading.value = true
|
batchImportLoading.value = true
|
||||||
let successCount = 0
|
let successCount = 0
|
||||||
try {
|
try {
|
||||||
for (const row of batchImportPreviewRows.value) {
|
await runWithConcurrency(batchImportPreviewRows.value, 8, async (row) => {
|
||||||
const ok = await importSingleBatchRow(row, receivingId)
|
const ok = await importSingleBatchRow(row, receivingId)
|
||||||
if (ok) successCount += 1
|
if (ok) successCount += 1
|
||||||
}
|
})
|
||||||
|
|
||||||
ElMessage.success(`导入完成:成功 ${successCount} 条,共 ${batchImportPreviewRows.value.length} 条`)
|
ElMessage.success(`导入完成:成功 ${successCount} 条,共 ${batchImportPreviewRows.value.length} 条`)
|
||||||
if (successCount > 0) {
|
if (successCount > 0) {
|
||||||
@ -1897,10 +1911,10 @@ const retryFailedBatchRows = async () => {
|
|||||||
batchRetryFailedLoading.value = true
|
batchRetryFailedLoading.value = true
|
||||||
let successCount = 0
|
let successCount = 0
|
||||||
try {
|
try {
|
||||||
for (const row of failedRows) {
|
await runWithConcurrency(failedRows, 8, async (row) => {
|
||||||
const ok = await importSingleBatchRow(row, receivingId)
|
const ok = await importSingleBatchRow(row, receivingId)
|
||||||
if (ok) successCount += 1
|
if (ok) successCount += 1
|
||||||
}
|
})
|
||||||
ElMessage.success(`重试完成:成功 ${successCount} 条,共 ${failedRows.length} 条`)
|
ElMessage.success(`重试完成:成功 ${successCount} 条,共 ${failedRows.length} 条`)
|
||||||
if (successCount > 0) {
|
if (successCount > 0) {
|
||||||
loadProductData()
|
loadProductData()
|
||||||
|
|||||||
@ -76,6 +76,15 @@
|
|||||||
>
|
>
|
||||||
一键出库
|
一键出库
|
||||||
</el-button>
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
v-if="row.order_status === 'CREATED' || row.order_status === 'PENDING'"
|
||||||
|
type="primary"
|
||||||
|
link
|
||||||
|
size="small"
|
||||||
|
@click.stop="openToOrderDialog(row)"
|
||||||
|
>
|
||||||
|
转销售订单
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<template #empty>
|
<template #empty>
|
||||||
@ -129,6 +138,93 @@
|
|||||||
document-label="出库单"
|
document-label="出库单"
|
||||||
:fetch-print-data="fetchPrintData"
|
:fetch-print-data="fetchPrintData"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<el-dialog
|
||||||
|
v-model="toOrderDialogVisible"
|
||||||
|
title="转为销售订单"
|
||||||
|
width="640px"
|
||||||
|
align-center
|
||||||
|
append-to-body
|
||||||
|
destroy-on-close
|
||||||
|
:close-on-click-modal="false"
|
||||||
|
>
|
||||||
|
<div class="to-order-dialog">
|
||||||
|
<el-alert
|
||||||
|
type="info"
|
||||||
|
:closable="false"
|
||||||
|
show-icon
|
||||||
|
:title="`将出库单「${toOrderTargetRow?.stockout_order_code || toOrderTargetRow?.id || ''}」转为正式销售订单,转单成功后原出库单将置为已作废。`"
|
||||||
|
style="margin-bottom: 16px;"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<el-form :model="toOrderForm" label-width="110px">
|
||||||
|
<el-form-item label="新订单号">
|
||||||
|
<el-input v-model="toOrderForm.delivery_order_code" placeholder="不填自动生成(SK 前缀)" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-divider content-position="left">收件人信息(可选)</el-divider>
|
||||||
|
|
||||||
|
<el-row :gutter="12">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="姓名">
|
||||||
|
<el-input v-model="toOrderForm.receiverInfo.name" placeholder="收件人姓名" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="手机号">
|
||||||
|
<el-input v-model="toOrderForm.receiverInfo.mobile" placeholder="手机号" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row :gutter="12">
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="电话">
|
||||||
|
<el-input v-model="toOrderForm.receiverInfo.tel" placeholder="固定电话(可选)" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="12">
|
||||||
|
<el-form-item label="邮编">
|
||||||
|
<el-input v-model="toOrderForm.receiverInfo.zipCode" placeholder="邮编(可选)" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-row :gutter="12">
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="省份">
|
||||||
|
<el-input v-model="toOrderForm.receiverInfo.province" placeholder="省份" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="城市">
|
||||||
|
<el-input v-model="toOrderForm.receiverInfo.city" placeholder="城市" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
<el-col :span="8">
|
||||||
|
<el-form-item label="区县">
|
||||||
|
<el-input v-model="toOrderForm.receiverInfo.area" placeholder="区县" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
<el-form-item label="乡镇">
|
||||||
|
<el-input v-model="toOrderForm.receiverInfo.town" placeholder="乡镇(可选)" clearable />
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="详细地址">
|
||||||
|
<el-input
|
||||||
|
v-model="toOrderForm.receiverInfo.detailAddress"
|
||||||
|
type="textarea"
|
||||||
|
:rows="2"
|
||||||
|
placeholder="详细地址(可选)"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-form>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<template #footer>
|
||||||
|
<el-button @click="toOrderDialogVisible = false">取消</el-button>
|
||||||
|
<el-button type="primary" :loading="toOrderLoading" @click="handleToOrderSubmit">确认转单</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@ -144,8 +240,8 @@ import type { ToolbarButtonConfig } from '@/views/order/orderManagement/config/o
|
|||||||
import { safeInvoke } from '@/utils/safe-invoke'
|
import { safeInvoke } from '@/utils/safe-invoke'
|
||||||
import * as XLSX from 'xlsx'
|
import * as XLSX from 'xlsx'
|
||||||
import * as indexApi from '@/api/index/index'
|
import * as indexApi from '@/api/index/index'
|
||||||
import * as stockoutApi from '@/api/storage.stockout/stockout' //现有的对应 API
|
import * as stockoutApi from '@/api/storage.stockout/stockout' //现有的对应API
|
||||||
|
import type { StockoutToOrderParams } from '@/api/storage.stockout/stockout'
|
||||||
import {
|
import {
|
||||||
availableFields,
|
availableFields,
|
||||||
entryColums,
|
entryColums,
|
||||||
@ -221,6 +317,83 @@ const hasSelection = ref(false)
|
|||||||
const selectedStockoutId = ref<number | string | null>(null)
|
const selectedStockoutId = ref<number | string | null>(null)
|
||||||
const printDialogVisible = ref(false)
|
const printDialogVisible = ref(false)
|
||||||
|
|
||||||
|
// ── 转销售订单(storage.stockout.toOrder)──
|
||||||
|
const toOrderDialogVisible = ref(false)
|
||||||
|
const toOrderLoading = ref(false)
|
||||||
|
const toOrderTargetRow = ref<any>(null)
|
||||||
|
const toOrderForm = reactive({
|
||||||
|
delivery_order_code: '',
|
||||||
|
receiverInfo: {
|
||||||
|
name: '',
|
||||||
|
mobile: '',
|
||||||
|
tel: '',
|
||||||
|
province: '',
|
||||||
|
city: '',
|
||||||
|
area: '',
|
||||||
|
town: '',
|
||||||
|
detailAddress: '',
|
||||||
|
zipCode: ''
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
function resetToOrderForm() {
|
||||||
|
toOrderForm.delivery_order_code = ''
|
||||||
|
toOrderForm.receiverInfo = {
|
||||||
|
name: '',
|
||||||
|
mobile: '',
|
||||||
|
tel: '',
|
||||||
|
province: '',
|
||||||
|
city: '',
|
||||||
|
area: '',
|
||||||
|
town: '',
|
||||||
|
detailAddress: '',
|
||||||
|
zipCode: ''
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function openToOrderDialog(row: any) {
|
||||||
|
toOrderTargetRow.value = row
|
||||||
|
resetToOrderForm()
|
||||||
|
toOrderDialogVisible.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function handleToOrderSubmit() {
|
||||||
|
const row = toOrderTargetRow.value
|
||||||
|
if (!row) return
|
||||||
|
|
||||||
|
const receiverInfo = toOrderForm.receiverInfo
|
||||||
|
const hasReceiver = Object.values(receiverInfo).some((v) => String(v || '').trim() !== '')
|
||||||
|
const payload: StockoutToOrderParams = { id: row.id }
|
||||||
|
const orderCode = toOrderForm.delivery_order_code.trim()
|
||||||
|
if (orderCode) payload.delivery_order_code = orderCode
|
||||||
|
if (hasReceiver) {
|
||||||
|
payload.receiverInfo = {}
|
||||||
|
for (const [k, v] of Object.entries(receiverInfo)) {
|
||||||
|
if (String(v || '').trim() !== '') {
|
||||||
|
;(payload.receiverInfo as Record<string, string>)[k] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
toOrderLoading.value = true
|
||||||
|
try {
|
||||||
|
const res: any = await stockoutApi.stockoutToOrder(payload)
|
||||||
|
if (res && (res.code === 1 || res.code === 200 || res.code === 20000 || res.flag === 'success')) {
|
||||||
|
const data = res?.data || res
|
||||||
|
const orderCodeText = data?.delivery_order_code || payload.delivery_order_code || ''
|
||||||
|
ElMessage.success(orderCodeText ? `转单成功,新订单号:${orderCodeText}` : '转单成功')
|
||||||
|
toOrderDialogVisible.value = false
|
||||||
|
loadData()
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res?.message || '转单失败')
|
||||||
|
}
|
||||||
|
} catch (e: any) {
|
||||||
|
ElMessage.error(e?.message || '转单失败')
|
||||||
|
} finally {
|
||||||
|
toOrderLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ── 工具栏状态 ──
|
// ── 工具栏状态 ──
|
||||||
const buttonLoadingMap = computed(() => ({
|
const buttonLoadingMap = computed(() => ({
|
||||||
loading: loading.value,
|
loading: loading.value,
|
||||||
|
|||||||
@ -166,7 +166,7 @@ export const entryColums = [
|
|||||||
{ prop: 'order_create_time', label: '下单时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.order_create_time) },
|
{ 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: '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: 'updated_at', label: '更新时间', width: '160', sortable: true, formatter: (row: any) => formatDateTime(row.updated_at) },
|
||||||
{ prop: 'actions', label: '操作', width: '120', fixed: 'right' }
|
{ prop: 'actions', label: '操作', width: '180', fixed: 'right' }
|
||||||
]
|
]
|
||||||
|
|
||||||
export const availableFields: StockoutScanFieldConfig[] = [
|
export const availableFields: StockoutScanFieldConfig[] = [
|
||||||
|
|||||||
@ -126,6 +126,12 @@
|
|||||||
link
|
link
|
||||||
@click.stop="openAdjustBalanceDialog(row)"
|
@click.stop="openAdjustBalanceDialog(row)"
|
||||||
>调整余额</el-button>
|
>调整余额</el-button>
|
||||||
|
<el-button
|
||||||
|
size="small"
|
||||||
|
type="primary"
|
||||||
|
link
|
||||||
|
@click.stop="openCreateUserDialog(row)"
|
||||||
|
>创建用户</el-button>
|
||||||
<el-button
|
<el-button
|
||||||
v-if="row.use_status === 1"
|
v-if="row.use_status === 1"
|
||||||
size="small"
|
size="small"
|
||||||
@ -344,13 +350,13 @@
|
|||||||
<el-icon style="margin-left:4px;cursor:pointer;color:#999;vertical-align:middle"><QuestionFilled /></el-icon>
|
<el-icon style="margin-left:4px;cursor:pointer;color:#999;vertical-align:middle"><QuestionFilled /></el-icon>
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</template>
|
</template>
|
||||||
<!-- 默认快递:使用快递接口列表 -->
|
<!-- 快递类字段(默认快递 / 出库单默认快递等):使用快递接口列表,后端返回哪个菜单项就显示哪个 -->
|
||||||
<el-select
|
<el-select
|
||||||
v-if="field.key === 'default_express_code'"
|
v-if="isExpressSelectField(field)"
|
||||||
v-model="policyDialog.formData[field.key]"
|
v-model="policyDialog.formData[field.key]"
|
||||||
clearable
|
clearable
|
||||||
filterable
|
filterable
|
||||||
placeholder="请选择默认快递"
|
:placeholder="field.placeholder || '请选择默认快递'"
|
||||||
style="width:220px"
|
style="width:220px"
|
||||||
>
|
>
|
||||||
<el-option
|
<el-option
|
||||||
@ -929,6 +935,48 @@
|
|||||||
</template>
|
</template>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
|
|
||||||
|
<!-- 创建用户弹窗(storeWarehouse.store.createUser) -->
|
||||||
|
<el-dialog
|
||||||
|
v-model="createUserDialog.visible"
|
||||||
|
title="创建用户"
|
||||||
|
width="480px"
|
||||||
|
destroy-on-close
|
||||||
|
align-center
|
||||||
|
@close="resetCreateUserDialog"
|
||||||
|
>
|
||||||
|
<el-form
|
||||||
|
ref="createUserFormRef"
|
||||||
|
:model="createUserForm"
|
||||||
|
:rules="createUserFormRules"
|
||||||
|
label-width="80px"
|
||||||
|
size="small"
|
||||||
|
>
|
||||||
|
<el-row :gutter="20">
|
||||||
|
<el-col v-for="item in createUserFormItems" :key="item.prop" :span="item.span ?? 24">
|
||||||
|
<el-form-item :label="item.label" :prop="item.prop">
|
||||||
|
<el-input
|
||||||
|
v-if="item.type === 'display'"
|
||||||
|
:model-value="createUserForm[item.prop]"
|
||||||
|
readonly
|
||||||
|
/>
|
||||||
|
<el-input
|
||||||
|
v-else
|
||||||
|
v-model="createUserForm[item.prop]"
|
||||||
|
:placeholder="item.placeholder"
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
</el-col>
|
||||||
|
</el-row>
|
||||||
|
</el-form>
|
||||||
|
<template #footer>
|
||||||
|
<el-button size="small" @click="createUserDialog.visible = false">取消</el-button>
|
||||||
|
<el-button size="small" type="primary" :loading="createUserDialog.loading" @click="submitCreateUser">
|
||||||
|
确认创建
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-dialog>
|
||||||
|
|
||||||
<!-- 余额变动导出进度弹窗 -->
|
<!-- 余额变动导出进度弹窗 -->
|
||||||
<AsyncExportProgressDialog
|
<AsyncExportProgressDialog
|
||||||
:visible="exportDialogVisible"
|
:visible="exportDialogVisible"
|
||||||
@ -986,7 +1034,8 @@ import { storeWarehouseList, storeWarehouseUnbind,
|
|||||||
storeWarehouseAdjustPrintQuantity, storeWarehouseQueryPrintQuantityLogs, listApiConfig,
|
storeWarehouseAdjustPrintQuantity, storeWarehouseQueryPrintQuantityLogs, listApiConfig,
|
||||||
storeWarehouseOpenAccount, storeWarehouseConfirmSign,
|
storeWarehouseOpenAccount, storeWarehouseConfirmSign,
|
||||||
storeWarehouseExportPrintQuantityLogs,
|
storeWarehouseExportPrintQuantityLogs,
|
||||||
storeWarehouseExportPrintQuantityLogsTaskProgress
|
storeWarehouseExportPrintQuantityLogsTaskProgress,
|
||||||
|
storeWarehouseCreateUser
|
||||||
} from '@/api/storewarehouse.store/storeWarehouse'
|
} from '@/api/storewarehouse.store/storeWarehouse'
|
||||||
import { listInterfaceTypes, getExpressList, getPlatformList, getQimenAppList, loadStores } from '@/api/index/index'
|
import { listInterfaceTypes, getExpressList, getPlatformList, getQimenAppList, loadStores } from '@/api/index/index'
|
||||||
import ScanBox from '@/components/ScanBox/index.vue'
|
import ScanBox from '@/components/ScanBox/index.vue'
|
||||||
@ -1001,7 +1050,7 @@ import { useVerticalSplitPane } from '@/composables/useVerticalSplitPane'
|
|||||||
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
import { useAsyncExportTask } from '@/composables/useAsyncExportTask'
|
||||||
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
|
import AsyncExportProgressDialog from '@/components/AsyncExportProgressDialog.vue'
|
||||||
import { safeInvoke } from '@/utils/safe-invoke'
|
import { safeInvoke } from '@/utils/safe-invoke'
|
||||||
import { columns as defaultColumns, availableFields as defaultAvailableFields, presetTree as defaultPresetTree, qimenFormDefault, qimenFormItems, qimenTableColumns, adjustBalanceDialogDefault, adjustBalanceFormDefault, adjustBalanceFormItems, openAccountDialogDefault, openAccountFormDefault, openAccountFormItems, storeToolbarButtons } from './store-config.ts'
|
import { columns as defaultColumns, availableFields as defaultAvailableFields, presetTree as defaultPresetTree, qimenFormDefault, qimenFormItems, qimenTableColumns, adjustBalanceDialogDefault, adjustBalanceFormDefault, adjustBalanceFormItems, openAccountDialogDefault, openAccountFormDefault, openAccountFormItems, createUserDialogDefault, createUserFormDefault, createUserFormItems, storeToolbarButtons } from './store-config.ts'
|
||||||
import { inboxBindCode } from '@/api/inbox/inbox'
|
import { inboxBindCode } from '@/api/inbox/inbox'
|
||||||
|
|
||||||
// ─── 列表 ───────────────────────────────────────────────────────────────────
|
// ─── 列表 ───────────────────────────────────────────────────────────────────
|
||||||
@ -1685,6 +1734,16 @@ function normalizeOptionText(value: unknown) {
|
|||||||
return String(value ?? '').trim()
|
return String(value ?? '').trim()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 判断是否为“快递编码”类下拉字段(默认快递 / 出库单默认快递等),使用快递接口列表作为选项 */
|
||||||
|
function isExpressSelectField(field: any) {
|
||||||
|
if (!field) return false
|
||||||
|
const key = String(field.key || '').trim()
|
||||||
|
if (key === 'default_express_code') return true
|
||||||
|
const name = String(field.name || field.label || '').trim()
|
||||||
|
// 兼容后端动态字段:名称同时包含“出库单”与“快递”(如“出库单默认快递”),避免误伤 flag 类快递开关字段
|
||||||
|
return name.includes('出库单') && name.includes('快递')
|
||||||
|
}
|
||||||
|
|
||||||
function mapPolicyExpressOptions(rawList: any[]) {
|
function mapPolicyExpressOptions(rawList: any[]) {
|
||||||
const result: Array<{ label: string; value: string }> = []
|
const result: Array<{ label: string; value: string }> = []
|
||||||
const seen = new Set<string>()
|
const seen = new Set<string>()
|
||||||
@ -2086,6 +2145,81 @@ async function submitOpenAccount() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ─── 创建用户(storeWarehouse.store.createUser) ──────────────────────────────
|
||||||
|
const createUserDialog = reactive({ ...createUserDialogDefault })
|
||||||
|
const createUserForm = reactive<Record<string, any>>({ ...createUserFormDefault })
|
||||||
|
const createUserFormRef = ref<any>(null)
|
||||||
|
|
||||||
|
const createUserFormRules: Record<string, any> = {
|
||||||
|
username: [
|
||||||
|
{ required: true, message: '请输入用户名', trigger: 'blur' },
|
||||||
|
{
|
||||||
|
pattern: /^[a-zA-Z0-9_]{3,50}$/,
|
||||||
|
message: '用户名需为3-50位字母、数字或下划线',
|
||||||
|
trigger: 'blur'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
function openCreateUserDialog(row: any) {
|
||||||
|
resetCreateUserDialog()
|
||||||
|
createUserForm.store_id = Number(row.store_id ?? row.counterparty_id)
|
||||||
|
createUserForm.store_label = String(row.counterparty_name ?? row.remask ?? '') || `货主 ${row.store_id}`
|
||||||
|
createUserDialog.visible = true
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetCreateUserDialog() {
|
||||||
|
Object.assign(createUserDialog, createUserDialogDefault)
|
||||||
|
Object.assign(createUserForm, createUserFormDefault)
|
||||||
|
createUserFormRef.value?.clearValidate?.()
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitCreateUser() {
|
||||||
|
if (!createUserFormRef.value) return
|
||||||
|
try {
|
||||||
|
await createUserFormRef.value.validate()
|
||||||
|
} catch {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const storeId = Number(createUserForm.store_id)
|
||||||
|
if (!Number.isFinite(storeId) || storeId <= 0) {
|
||||||
|
ElMessage.warning('缺少货主信息,无法创建用户')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
createUserDialog.loading = true
|
||||||
|
try {
|
||||||
|
const res: any = await storeWarehouseCreateUser({
|
||||||
|
username: String(createUserForm.username ?? '').trim(),
|
||||||
|
store_id: storeId
|
||||||
|
})
|
||||||
|
const data = res?.data ?? res
|
||||||
|
if (res?.flag === 'success' || res?.code === 200 || res?.code === 1) {
|
||||||
|
const created = Boolean(data?.created)
|
||||||
|
const password = data?.password
|
||||||
|
createUserDialog.visible = false
|
||||||
|
if (created && password) {
|
||||||
|
// 仅本次新建账号时返回初始明文密码
|
||||||
|
ElMessageBox.alert(
|
||||||
|
`用户名:${data?.username ?? createUserForm.username}\n初始密码:${password}`,
|
||||||
|
'创建成功',
|
||||||
|
{ confirmButtonText: '复制密码并关闭', type: 'success' }
|
||||||
|
).then(() => {
|
||||||
|
navigator.clipboard?.writeText(password).catch(() => {})
|
||||||
|
}).catch(() => {})
|
||||||
|
} else {
|
||||||
|
ElMessage.success(created ? '创建成功' : '账号已存在,已为货主授权')
|
||||||
|
}
|
||||||
|
loadList()
|
||||||
|
} else {
|
||||||
|
ElMessage.error(res?.message || '创建用户失败')
|
||||||
|
}
|
||||||
|
} catch (e: any) {
|
||||||
|
ElMessage.error(e?.message || '创建用户失败')
|
||||||
|
} finally {
|
||||||
|
createUserDialog.loading = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function openQimenDialog(row: any) {
|
function openQimenDialog(row: any) {
|
||||||
qimenDialog.contractRow = row
|
qimenDialog.contractRow = row
|
||||||
qimenDialog.formVisible = false
|
qimenDialog.formVisible = false
|
||||||
|
|||||||
@ -124,6 +124,25 @@ export const openAccountFormItems = [
|
|||||||
{ label: '仓库备注名', prop: 'warehouse_remask', placeholder: '最长50字符' }
|
{ label: '仓库备注名', prop: 'warehouse_remask', placeholder: '最长50字符' }
|
||||||
]
|
]
|
||||||
|
|
||||||
|
// 创建用户(storeWarehouse.store.createUser)弹窗默认配置
|
||||||
|
export const createUserDialogDefault = {
|
||||||
|
visible: false,
|
||||||
|
loading: false
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建用户表单默认配置
|
||||||
|
export const createUserFormDefault = {
|
||||||
|
username: '',
|
||||||
|
store_id: undefined as number | undefined,
|
||||||
|
store_label: ''
|
||||||
|
}
|
||||||
|
|
||||||
|
// 创建用户表单项配置
|
||||||
|
export const createUserFormItems = [
|
||||||
|
{ label: '货主', prop: 'store_label', type: 'display', span: 24 },
|
||||||
|
{ label: '用户名', prop: 'username', required: true, placeholder: '3-50位字母/数字/下划线,全局唯一', span: 24 }
|
||||||
|
]
|
||||||
|
|
||||||
// 面单余额调整表单项配置
|
// 面单余额调整表单项配置
|
||||||
export const adjustBalanceFormItems = [
|
export const adjustBalanceFormItems = [
|
||||||
{
|
{
|
||||||
@ -179,7 +198,7 @@ export const columns = [
|
|||||||
{ prop: 'use_status', label: '使用状态', width: 90 },
|
{ prop: 'use_status', label: '使用状态', width: 90 },
|
||||||
{ prop: 'print_quantity', label: '面单余额', width: 100 },
|
{ prop: 'print_quantity', label: '面单余额', width: 100 },
|
||||||
{ prop: 'has_qimen_config', label: '奇门配置', width: 100 },
|
{ prop: 'has_qimen_config', label: '奇门配置', width: 100 },
|
||||||
{ prop: 'actions', label: '操作', width: 280, fixed: 'right' }
|
{ prop: 'actions', label: '操作', width: 340, fixed: 'right' }
|
||||||
]
|
]
|
||||||
|
|
||||||
export const availableFields = [
|
export const availableFields = [
|
||||||
|
|||||||
@ -179,7 +179,7 @@ async function onFileChange(e: Event) {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const arr = await file.arrayBuffer()
|
const arr = await file.arrayBuffer()
|
||||||
const wb = XLSX.read(arr, { type: 'array' })
|
const wb = XLSX.read(arr, { type: 'array', dense: true })
|
||||||
const sheetName = Array.isArray(wb.SheetNames) && wb.SheetNames.length ? wb.SheetNames[0] : undefined
|
const sheetName = Array.isArray(wb.SheetNames) && wb.SheetNames.length ? wb.SheetNames[0] : undefined
|
||||||
if (!sheetName) {
|
if (!sheetName) {
|
||||||
ElMessage.error('Excel 文件不包含工作表')
|
ElMessage.error('Excel 文件不包含工作表')
|
||||||
@ -210,16 +210,6 @@ async function onFileChange(e: Event) {
|
|||||||
}
|
}
|
||||||
return obj
|
return obj
|
||||||
})
|
})
|
||||||
// 打印调试信息,便于排查列映射问题(只打印前几行)
|
|
||||||
try {
|
|
||||||
console.log('RackBulkModifyDialog headerRow:', headerRow)
|
|
||||||
console.log('RackBulkModifyDialog matrix sample:', matrix.slice(0, Math.min(5, matrix.length)))
|
|
||||||
console.log('RackBulkModifyDialog dataRows sample:', dataRows.slice(0, Math.min(5, dataRows.length)))
|
|
||||||
console.log('RackBulkModifyDialog parsed rows sample:', rows.slice(0, Math.min(5, rows.length)))
|
|
||||||
console.log('RackBulkModifyDialog locationTypes:', locationTypes.value)
|
|
||||||
} catch (e) {
|
|
||||||
// ignore
|
|
||||||
}
|
|
||||||
// pass both rows objects and original matrix rows so parser can force A 列为 space_code
|
// pass both rows objects and original matrix rows so parser can force A 列为 space_code
|
||||||
parseRowsToItems(rows, headerRow as string[])
|
parseRowsToItems(rows, headerRow as string[])
|
||||||
input.value = ''
|
input.value = ''
|
||||||
@ -267,10 +257,6 @@ function parseRowsToItems(rows: any[], headerOrder?: string[]) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
console.log('RackBulkModifyDialog headerMap:', headerMap, 'headerKeys:', headerKeys)
|
|
||||||
} catch (e) {}
|
|
||||||
|
|
||||||
// fallback: if no space_code mapped, pick header with most non-empty values (excluding barcode-like headers)
|
// fallback: if no space_code mapped, pick header with most non-empty values (excluding barcode-like headers)
|
||||||
if (!Object.values(headerMap).includes('space_code')) {
|
if (!Object.values(headerMap).includes('space_code')) {
|
||||||
let bestHeader: string | null = null
|
let bestHeader: string | null = null
|
||||||
@ -483,9 +469,28 @@ async function validateAll() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function validateRow(index: number) {
|
function validateRow(index: number) {
|
||||||
// re-run validateAll for simplicity
|
const r = items.value[index]
|
||||||
await validateAll()
|
if (!r) return
|
||||||
|
delete errors[index]
|
||||||
|
const code = String(getRowValue(r, 'space_code') ?? '').trim()
|
||||||
|
if (!code) {
|
||||||
|
errors[index] = '缺失仓位编码'
|
||||||
|
}
|
||||||
|
const pickVal = getRowValue(r, 'pick_sequence')
|
||||||
|
if (pickVal !== null && pickVal !== undefined && pickVal !== '') {
|
||||||
|
const n = Number(pickVal)
|
||||||
|
if (isNaN(n) || n < 0 || !Number.isInteger(n)) {
|
||||||
|
errors[index] = (errors[index] ? errors[index] + ';' : '') + '拣货顺序必须为非负整数'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
const locVal = getRowValue(r, 'location_type_name')
|
||||||
|
if (locVal !== null && locVal !== undefined && String(locVal).trim() !== '') {
|
||||||
|
const ok = locationTypes.value.some((lt) => lt.id === locVal || String(lt.id) === String(locVal))
|
||||||
|
if (!ok) {
|
||||||
|
errors[index] = (errors[index] ? errors[index] + ';' : '') + '库位类型无效'
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function submit() {
|
async function submit() {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user