收货和商品的优化
This commit is contained in:
parent
baff37ad45
commit
4afce2376d
@ -398,3 +398,69 @@ export function stockStockWarehouse(data: { pagination?: any; where?: any }) {
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
export function exportStockWarehouse(data: { where?: Record<string, any>; group_by_batch?: boolean; sort?: Record<string, any> }) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'stock.warehouse.export',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data: data || {},
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
export function getExportTaskProgress(data: { task_id?: string; taskId?: string }) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'stock.warehouse.exportTaskProgress',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
export type StockWarehouseImportItem = {
|
||||
stock_id?: string | number
|
||||
sku?: string
|
||||
item_code?: string
|
||||
cargo_code?: string
|
||||
sku_property?: string
|
||||
stock_unit?: string
|
||||
brand_name?: string
|
||||
gross_weight?: string | number
|
||||
tag_price?: string | number
|
||||
retail_price?: string | number
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export type StockWarehouseImportPayload =
|
||||
| StockWarehouseImportItem[]
|
||||
| {
|
||||
items?: StockWarehouseImportItem[]
|
||||
rows?: StockWarehouseImportItem[]
|
||||
list?: StockWarehouseImportItem[]
|
||||
data?: StockWarehouseImportItem[]
|
||||
[key: string]: any
|
||||
}
|
||||
|
||||
export function importStockWarehouse(data: StockWarehouseImportPayload) {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'stock.warehouse.import',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data,
|
||||
isSystemApi: true
|
||||
} as any)
|
||||
}
|
||||
|
||||
@ -294,6 +294,32 @@ export function detailChange(data: any): Promise<any> {
|
||||
})
|
||||
}
|
||||
|
||||
export function addDetail(data: any): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.receiving.addDetail',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function deleteDetail(data: any): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
method: 'post',
|
||||
params: {
|
||||
method: 'storage.receiving.deleteDetail',
|
||||
v,
|
||||
timestamp: new Date().getTime()
|
||||
},
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
export function save(data: any): Promise<any> {
|
||||
return request({
|
||||
url: '/system',
|
||||
|
||||
@ -77,11 +77,22 @@
|
||||
:icon="Download"
|
||||
@click="handleExport"
|
||||
title="导出"
|
||||
:loading="loading"
|
||||
:loading="exportLoading"
|
||||
>
|
||||
导出
|
||||
</el-button>
|
||||
|
||||
<el-button
|
||||
size="small"
|
||||
type="primary"
|
||||
plain
|
||||
:icon="Upload"
|
||||
@click="openImportDialog"
|
||||
title="导入"
|
||||
>
|
||||
导入
|
||||
</el-button>
|
||||
|
||||
<el-button
|
||||
size="small"
|
||||
@click="openColumnConfigPanel"
|
||||
@ -239,14 +250,102 @@
|
||||
<el-drawer v-model="showRecycle" :with-header="false" direction="rtl" size="800px">
|
||||
<Recycle :drawer-visible="showRecycle" />
|
||||
</el-drawer>
|
||||
|
||||
<el-dialog
|
||||
v-model="exportDialogVisible"
|
||||
title="商品导出进度"
|
||||
width="min(520px, 92vw)"
|
||||
append-to-body
|
||||
align-center
|
||||
:show-close="false"
|
||||
:close-on-click-modal="false"
|
||||
:close-on-press-escape="false"
|
||||
>
|
||||
<div class="export-progress-panel">
|
||||
<div class="export-progress-panel__header">
|
||||
<span class="export-progress-panel__meta">任务ID:{{ exportTaskProgress.taskId || '—' }}</span>
|
||||
</div>
|
||||
<el-progress :percentage="exportProgressPercent" :status="exportProgressBarStatus" :stroke-width="16" />
|
||||
<div class="export-progress-panel__info">
|
||||
<span>状态:{{ exportStatusText }}</span>
|
||||
<span>进度:{{ exportProgressPercent }}%</span>
|
||||
<span v-if="exportTaskProgress.updateTime">更新时间:{{ formatDateTime(exportTaskProgress.updateTime) }}</span>
|
||||
</div>
|
||||
<div v-if="exportTaskProgress.message || exportTaskProgress.error" class="export-progress-panel__message">
|
||||
{{ exportTaskProgress.error || exportTaskProgress.message }}
|
||||
</div>
|
||||
</div>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog
|
||||
v-model="importDialogVisible"
|
||||
title="商品导入"
|
||||
width="80vw"
|
||||
align-center
|
||||
class="import-dialog"
|
||||
>
|
||||
<div class="import-dialog-body">
|
||||
<div class="import-toolbar">
|
||||
<input
|
||||
ref="importFileInputRef"
|
||||
type="file"
|
||||
class="hidden-file-input"
|
||||
@change="handleImportFileChange"
|
||||
/>
|
||||
<el-button size="small" type="primary" @click="triggerImportFileSelect">选择文件</el-button>
|
||||
<span class="import-file-name">{{ selectedImportFileName || '未选择文件' }}</span>
|
||||
</div>
|
||||
<div class="import-summary">
|
||||
汇总:共 {{ importSummary.total }} 条,新增 {{ importSummary.addCount }} 条,修改 {{ importSummary.updateCount }} 条
|
||||
</div>
|
||||
|
||||
<div class="import-table-wrap">
|
||||
<el-table :data="importRows" border size="small" height="100%">
|
||||
<el-table-column label="SKU" min-width="140">
|
||||
<template #default="{ row }"><el-input v-model="row.sku" size="small" readonly /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="商品编码" min-width="140">
|
||||
<template #default="{ row }"><el-input v-model="row.itemCode" size="small" clearable /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="货物编码" min-width="140">
|
||||
<template #default="{ row }"><el-input v-model="row.cargoCode" size="small" clearable /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="SKU规格" min-width="140">
|
||||
<template #default="{ row }"><el-input v-model="row.skuSpec" size="small" clearable /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="库存单位" min-width="120">
|
||||
<template #default="{ row }"><el-input v-model="row.stockUnit" size="small" clearable /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="品牌" min-width="120">
|
||||
<template #default="{ row }"><el-input v-model="row.brand" size="small" clearable /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="毛重" min-width="120">
|
||||
<template #default="{ row }"><el-input v-model="row.grossWeight" size="small" clearable /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="标价" min-width="120">
|
||||
<template #default="{ row }"><el-input v-model="row.tagPrice" size="small" clearable /></template>
|
||||
</el-table-column>
|
||||
<el-table-column label="零售价" min-width="120">
|
||||
<template #default="{ row }"><el-input v-model="row.retailPrice" size="small" clearable /></template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<template #footer>
|
||||
<el-button type="primary" :loading="importSubmitting" @click="handleImportSubmit">提交</el-button>
|
||||
<el-button @click="closeImportDialog">关闭</el-button>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ref, reactive, computed, onMounted, onBeforeUnmount, shallowRef, markRaw } from 'vue'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import * as XLSX from 'xlsx'
|
||||
import {
|
||||
Refresh, Plus, Delete, DeleteFilled, Edit, Download,
|
||||
Refresh, Plus, Delete, DeleteFilled, Edit, Download, Upload,
|
||||
ArrowDown, User, InfoFilled
|
||||
} from '@element-plus/icons-vue'
|
||||
|
||||
@ -288,6 +387,7 @@ const showBatchDialog = ref(false)
|
||||
const batchDialogOptions = ref<any[]>([])
|
||||
const batchDialogValue = ref<any>(null)
|
||||
const batchDialogCommand = ref('')
|
||||
const importFileInputRef = ref<HTMLInputElement | null>(null)
|
||||
|
||||
// State
|
||||
const drawer = ref(false)
|
||||
@ -295,6 +395,7 @@ const showRecycle = ref(false)
|
||||
const activeTab = ref('info')
|
||||
const detailVisible = ref(true)
|
||||
const loading = ref(false)
|
||||
const exportLoading = ref(false)
|
||||
const showSelection = ref(true)
|
||||
const queryTime = ref(0)
|
||||
const selectionIds = ref<any[]>([])
|
||||
@ -311,6 +412,66 @@ const pagination = reactive({
|
||||
})
|
||||
|
||||
const batchConfig = reactive(JSON.parse(JSON.stringify(stockBatchConfig)))
|
||||
const exportDialogVisible = ref(false)
|
||||
const importDialogVisible = ref(false)
|
||||
const selectedImportFileName = ref('')
|
||||
const importSubmitting = ref(false)
|
||||
const IMPORT_MAX_ROWS = 1000
|
||||
|
||||
type ImportRow = {
|
||||
sku: string
|
||||
itemCode: string
|
||||
cargoCode: string
|
||||
skuSpec: string
|
||||
stockUnit: string
|
||||
brand: string
|
||||
grossWeight: string
|
||||
tagPrice: string
|
||||
retailPrice: string
|
||||
}
|
||||
|
||||
function createEmptyImportRow(): ImportRow {
|
||||
return {
|
||||
sku: '',
|
||||
itemCode: '',
|
||||
cargoCode: '',
|
||||
skuSpec: '',
|
||||
stockUnit: '',
|
||||
brand: '',
|
||||
grossWeight: '',
|
||||
tagPrice: '',
|
||||
retailPrice: ''
|
||||
}
|
||||
}
|
||||
|
||||
const importRows = ref<ImportRow[]>([
|
||||
createEmptyImportRow(),
|
||||
createEmptyImportRow(),
|
||||
createEmptyImportRow(),
|
||||
createEmptyImportRow(),
|
||||
createEmptyImportRow()
|
||||
])
|
||||
|
||||
const importSummary = computed(() => {
|
||||
const nonEmptyRows = importRows.value.filter((row) => Object.values(row).some((v) => String(v || '').trim() !== ''))
|
||||
const updateCount = nonEmptyRows.filter((row) => String(row.sku || '').trim() !== '').length
|
||||
const addCount = nonEmptyRows.length - updateCount
|
||||
return {
|
||||
total: nonEmptyRows.length,
|
||||
addCount,
|
||||
updateCount
|
||||
}
|
||||
})
|
||||
const exportTaskProgress = reactive({
|
||||
taskId: '',
|
||||
status: 'submitted' as 'submitted' | 'running' | 'success' | 'failed' | 'not_found',
|
||||
progress: 0,
|
||||
message: '',
|
||||
error: '',
|
||||
downloadUrl: '',
|
||||
updateTime: 0
|
||||
})
|
||||
let exportPollingTimer: number | null = null
|
||||
|
||||
const tableSize = ref('small')
|
||||
const { splitStackRef, beginSplitDrag, lowerPaneStyle, upperPaneStyle } = useVerticalSplitPane({
|
||||
@ -556,13 +717,151 @@ const confirmBatchDialog = async () => {
|
||||
}
|
||||
|
||||
const handleExport = () => {
|
||||
ElMessage.info('导出功能待后端接口确认')
|
||||
if (exportLoading.value) return
|
||||
void submitExportTask()
|
||||
}
|
||||
|
||||
const handleTabChange = () => {
|
||||
//
|
||||
}
|
||||
|
||||
const openImportDialog = () => {
|
||||
importDialogVisible.value = true
|
||||
}
|
||||
|
||||
const closeImportDialog = () => {
|
||||
importDialogVisible.value = false
|
||||
}
|
||||
|
||||
const triggerImportFileSelect = () => {
|
||||
importFileInputRef.value?.click()
|
||||
}
|
||||
|
||||
const handleImportFileChange = (event: Event) => {
|
||||
const target = event.target as HTMLInputElement
|
||||
const file = target?.files?.[0]
|
||||
selectedImportFileName.value = file?.name || ''
|
||||
if (file) {
|
||||
void parseImportExcel(file)
|
||||
}
|
||||
}
|
||||
|
||||
function pickExcelCellValue(row: Record<string, any>, aliases: string[]) {
|
||||
for (const key of aliases) {
|
||||
if (!Object.prototype.hasOwnProperty.call(row, key)) continue
|
||||
const val = row[key]
|
||||
if (val === null || val === undefined) continue
|
||||
const text = String(val).trim()
|
||||
if (text !== '') return text
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
function mapExcelRowToImportRow(row: Record<string, any>): ImportRow {
|
||||
return {
|
||||
sku: pickExcelCellValue(row, ['SKU', '商品ID', '商品id', 'sku', 'Sku']),
|
||||
itemCode: pickExcelCellValue(row, ['商品编码', 'item_code', 'itemCode']),
|
||||
cargoCode: pickExcelCellValue(row, ['货物编码', '货品编码', 'cargo_code', 'cargoCode', '货号']),
|
||||
skuSpec: pickExcelCellValue(row, ['SKU规格', 'sku规格', 'sku_property', 'skuSpec', '规格']),
|
||||
stockUnit: pickExcelCellValue(row, ['库存单位', 'stock_unit', 'stockUnit', '单位']),
|
||||
brand: pickExcelCellValue(row, ['品牌', 'brand_name', 'brand']),
|
||||
grossWeight: pickExcelCellValue(row, ['毛重', 'gross_weight', 'grossWeight']),
|
||||
tagPrice: pickExcelCellValue(row, ['标价', 'tag_price', 'tagPrice']),
|
||||
retailPrice: pickExcelCellValue(row, ['零售价', 'retail_price', 'retailPrice'])
|
||||
}
|
||||
}
|
||||
|
||||
async function parseImportExcel(file: File) {
|
||||
try {
|
||||
const buf = await file.arrayBuffer()
|
||||
const wb = XLSX.read(buf, { type: 'array' })
|
||||
const firstSheetName = wb.SheetNames?.[0]
|
||||
if (!firstSheetName) {
|
||||
ElMessage.error('未读取到工作表')
|
||||
return
|
||||
}
|
||||
const ws = wb.Sheets[firstSheetName]
|
||||
if (!ws) {
|
||||
ElMessage.error('未读取到工作表内容')
|
||||
return
|
||||
}
|
||||
const rawRows = XLSX.utils.sheet_to_json<Record<string, any>>(ws, { defval: '' })
|
||||
const mappedRows = rawRows
|
||||
.map(mapExcelRowToImportRow)
|
||||
.filter((row) => Object.values(row).some((v) => String(v || '').trim() !== ''))
|
||||
|
||||
if (mappedRows.length > IMPORT_MAX_ROWS) {
|
||||
ElMessage.error(`导入数据不能超过 ${IMPORT_MAX_ROWS} 行`)
|
||||
return
|
||||
}
|
||||
|
||||
importRows.value = mappedRows.length ? mappedRows : [createEmptyImportRow()]
|
||||
ElMessage.success(`已读取 ${mappedRows.length} 条数据`)
|
||||
} catch (error) {
|
||||
console.error('解析导入模板失败:', error)
|
||||
ElMessage.error('解析 Excel 失败,请检查模板格式')
|
||||
}
|
||||
}
|
||||
|
||||
function buildImportPayload() {
|
||||
return importRows.value
|
||||
.filter((row) => Object.values(row).some((v) => String(v || '').trim() !== ''))
|
||||
.map((row) => {
|
||||
const sku = String(row.sku || '').trim()
|
||||
return {
|
||||
stock_id: sku || undefined,
|
||||
item_code: String(row.itemCode || '').trim(),
|
||||
cargo_code: String(row.cargoCode || '').trim(),
|
||||
sku_property: String(row.skuSpec || '').trim(),
|
||||
stock_unit: String(row.stockUnit || '').trim(),
|
||||
brand_name: String(row.brand || '').trim(),
|
||||
gross_weight: String(row.grossWeight || '').trim(),
|
||||
tag_price: String(row.tagPrice || '').trim(),
|
||||
retail_price: String(row.retailPrice || '').trim(),
|
||||
action: sku ? 'update' : 'add'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
async function handleImportSubmit() {
|
||||
const payload = buildImportPayload()
|
||||
if (!payload.length) {
|
||||
ElMessage.warning('没有可提交的导入数据')
|
||||
return
|
||||
}
|
||||
if (payload.length > IMPORT_MAX_ROWS) {
|
||||
ElMessage.error(`导入数据不能超过 ${IMPORT_MAX_ROWS} 行`)
|
||||
return
|
||||
}
|
||||
|
||||
importSubmitting.value = true
|
||||
try {
|
||||
const res: any = await stockApi.importStockWarehouse(payload)
|
||||
const totalCount = Number(res?.total_count ?? payload.length)
|
||||
const createdCount = Number(res?.created_count ?? 0)
|
||||
const updatedCount = Number(res?.updated_count ?? 0)
|
||||
const failCount = Number(res?.fail_count ?? 0)
|
||||
const failItems = Array.isArray(res?.fail_items) ? res.fail_items : []
|
||||
|
||||
ElMessage.success(`导入完成:总数 ${totalCount},新增 ${createdCount},更新 ${updatedCount},失败 ${failCount}`)
|
||||
|
||||
if (failItems.length > 0) {
|
||||
console.log('stockImportFailItems', failItems)
|
||||
ElMessage.warning(`存在 ${failItems.length} 条失败明细,已输出到控制台`)
|
||||
}
|
||||
|
||||
if (failCount === 0) {
|
||||
closeImportDialog()
|
||||
loadData()
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('stockImportError', error)
|
||||
ElMessage.error(error?.message || '导入提交失败')
|
||||
} finally {
|
||||
importSubmitting.value = false
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(async () => {
|
||||
// Load stores, prohibited types etc.
|
||||
try {
|
||||
@ -590,6 +889,10 @@ onMounted(async () => {
|
||||
loadStockUnits()
|
||||
})
|
||||
|
||||
onBeforeUnmount(() => {
|
||||
stopExportPolling()
|
||||
})
|
||||
|
||||
const loadStockUnits = async () => {
|
||||
try {
|
||||
const res = await stockApi.getStockUnits()
|
||||
@ -614,6 +917,177 @@ const loadStockUnits = async () => {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
function resetExportProgress() {
|
||||
exportTaskProgress.taskId = ''
|
||||
exportTaskProgress.status = 'submitted'
|
||||
exportTaskProgress.progress = 0
|
||||
exportTaskProgress.message = ''
|
||||
exportTaskProgress.error = ''
|
||||
exportTaskProgress.downloadUrl = ''
|
||||
exportTaskProgress.updateTime = 0
|
||||
}
|
||||
|
||||
function stopExportPolling() {
|
||||
if (exportPollingTimer) {
|
||||
window.clearTimeout(exportPollingTimer)
|
||||
exportPollingTimer = null
|
||||
}
|
||||
}
|
||||
|
||||
function scheduleExportPolling(delay = 1500) {
|
||||
stopExportPolling()
|
||||
exportPollingTimer = window.setTimeout(() => {
|
||||
void refreshExportTaskProgress()
|
||||
}, delay)
|
||||
}
|
||||
|
||||
function normalizeDownloadUrl(fileUrl: string) {
|
||||
if (!fileUrl) return ''
|
||||
if (/^https?:\/\//i.test(fileUrl)) return fileUrl
|
||||
const normalizedPath = fileUrl.startsWith('/') ? fileUrl : `/${fileUrl}`
|
||||
const baseApi = String(import.meta.env.VITE_APP_BASE_API || '')
|
||||
const normalizedBase = baseApi.endsWith('/') ? baseApi.slice(0, -1) : baseApi
|
||||
if (normalizedBase.startsWith('/')) {
|
||||
return `${window.location.origin}${normalizedBase}${normalizedPath}`
|
||||
}
|
||||
return `${window.location.origin}${normalizedPath}`
|
||||
}
|
||||
|
||||
function downloadFile(url: string) {
|
||||
const finalUrl = normalizeDownloadUrl(url)
|
||||
if (!finalUrl) {
|
||||
throw new Error('导出文件地址为空')
|
||||
}
|
||||
const link = document.createElement('a')
|
||||
link.href = finalUrl
|
||||
link.target = '_blank'
|
||||
document.body.appendChild(link)
|
||||
link.click()
|
||||
link.remove()
|
||||
}
|
||||
|
||||
function buildExportPayload() {
|
||||
return {
|
||||
where: buildStockQuery(currentConditions.value)
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshExportTaskProgress() {
|
||||
if (!exportTaskProgress.taskId) return
|
||||
try {
|
||||
const res: any = await stockApi.getExportTaskProgress({ taskId: exportTaskProgress.taskId })
|
||||
if (!res) {
|
||||
scheduleExportPolling()
|
||||
return
|
||||
}
|
||||
exportTaskProgress.status = res.status || exportTaskProgress.status
|
||||
exportTaskProgress.progress = Number.isFinite(Number(res.progress)) ? Number(res.progress) : exportTaskProgress.progress
|
||||
exportTaskProgress.message = res.message || ''
|
||||
exportTaskProgress.error = res.error || ''
|
||||
exportTaskProgress.downloadUrl = res.download_url || ''
|
||||
exportTaskProgress.updateTime = Number(res.update_time || 0)
|
||||
|
||||
if (exportTaskProgress.status === 'success') {
|
||||
stopExportPolling()
|
||||
exportLoading.value = false
|
||||
try {
|
||||
if (exportTaskProgress.downloadUrl) {
|
||||
downloadFile(exportTaskProgress.downloadUrl)
|
||||
ElMessage.success(exportTaskProgress.message || '导出完成,文件已开始下载')
|
||||
} else {
|
||||
ElMessage.warning(exportTaskProgress.message || '导出完成,但未返回下载地址')
|
||||
}
|
||||
} finally {
|
||||
setTimeout(() => {
|
||||
exportDialogVisible.value = false
|
||||
resetExportProgress()
|
||||
}, 1200)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if (exportTaskProgress.status === 'failed' || exportTaskProgress.status === 'not_found') {
|
||||
stopExportPolling()
|
||||
exportLoading.value = false
|
||||
ElMessage.error(exportTaskProgress.error || exportTaskProgress.message || '导出任务失败')
|
||||
return
|
||||
}
|
||||
|
||||
scheduleExportPolling()
|
||||
} catch (error) {
|
||||
console.error('查询商品导出进度失败:', error)
|
||||
scheduleExportPolling(2000)
|
||||
}
|
||||
}
|
||||
|
||||
async function submitExportTask() {
|
||||
exportLoading.value = true
|
||||
resetExportProgress()
|
||||
exportDialogVisible.value = true
|
||||
try {
|
||||
const res: any = await stockApi.exportStockWarehouse(buildExportPayload())
|
||||
if (!res || !res.task_id) {
|
||||
throw new Error(res?.message || '导出任务提交失败')
|
||||
}
|
||||
exportTaskProgress.taskId = res.task_id
|
||||
exportTaskProgress.status = res.status || 'submitted'
|
||||
exportTaskProgress.progress = Number.isFinite(Number(res.progress)) ? Number(res.progress) : 0
|
||||
exportTaskProgress.message = res.message || '任务已受理'
|
||||
exportTaskProgress.error = res.error || ''
|
||||
exportTaskProgress.updateTime = Number(res.update_time || 0)
|
||||
scheduleExportPolling(800)
|
||||
} catch (error: any) {
|
||||
exportLoading.value = false
|
||||
exportDialogVisible.value = false
|
||||
resetExportProgress()
|
||||
ElMessage.error(error?.message || '导出任务提交失败')
|
||||
}
|
||||
}
|
||||
|
||||
const exportProgressPercent = computed(() => {
|
||||
const value = Number(exportTaskProgress.progress || 0)
|
||||
if (!Number.isFinite(value)) return 0
|
||||
return Math.min(100, Math.max(0, Math.round(value)))
|
||||
})
|
||||
|
||||
const exportProgressBarStatus = computed(() => {
|
||||
if (exportTaskProgress.status === 'failed' || exportTaskProgress.status === 'not_found') return 'exception'
|
||||
if (exportTaskProgress.status === 'success' || exportProgressPercent.value >= 100) return 'success'
|
||||
return undefined
|
||||
})
|
||||
|
||||
const exportStatusText = computed(() => {
|
||||
const map: Record<string, string> = {
|
||||
submitted: '已受理',
|
||||
running: '进行中',
|
||||
success: '成功',
|
||||
failed: '失败',
|
||||
not_found: '未找到'
|
||||
}
|
||||
return map[exportTaskProgress.status] || exportTaskProgress.status || '—'
|
||||
})
|
||||
|
||||
function formatDateTime(value: string | number | null | undefined) {
|
||||
if (!value) return '—'
|
||||
let normalizedValue: string | number = value
|
||||
if (typeof value === 'string' && /^\d+$/.test(value.trim())) {
|
||||
const numericValue = Number(value.trim())
|
||||
normalizedValue = value.trim().length <= 10 ? numericValue * 1000 : numericValue
|
||||
} else if (typeof value === 'number' && Number.isFinite(value) && value > 0 && value < 1000000000000) {
|
||||
normalizedValue = value * 1000
|
||||
}
|
||||
|
||||
const date = new Date(normalizedValue)
|
||||
if (Number.isNaN(date.getTime())) return String(value)
|
||||
const y = date.getFullYear()
|
||||
const m = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const d = String(date.getDate()).padStart(2, '0')
|
||||
const hh = String(date.getHours()).padStart(2, '0')
|
||||
const mm = String(date.getMinutes()).padStart(2, '0')
|
||||
const ss = String(date.getSeconds()).padStart(2, '0')
|
||||
return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
|
||||
}
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
@ -748,4 +1222,58 @@ const loadStockUnits = async () => {
|
||||
.batch-dialog :deep(.el-dialog__footer) {
|
||||
padding: 10px 20px;
|
||||
}
|
||||
|
||||
.hidden-file-input {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:deep(.import-dialog.el-dialog) {
|
||||
max-width: none;
|
||||
height: 80vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
:deep(.import-dialog .el-dialog__body) {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
padding: 12px 16px;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.import-dialog-body {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.import-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.import-file-name {
|
||||
color: #606266;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.import-summary {
|
||||
color: #606266;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.import-table-wrap {
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.import-table-wrap :deep(.el-table) {
|
||||
height: 100%;
|
||||
}
|
||||
</style>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@ -9,7 +9,7 @@
|
||||
<div class="toolbar">
|
||||
<div class="toolbar-left">
|
||||
<el-button size="small" type="primary" @click="loadData">刷新</el-button>
|
||||
<!-- <el-button size="small" @click="handleCreateReceiving">新建收货单</el-button> -->
|
||||
<el-button size="small" type="primary" @click="handleCreateReceiving">添加收货单</el-button>
|
||||
<!-- <el-button type="success" size="small" icon="el-icon-delete" @click="confirmcomplete" title="入库单入库"
|
||||
:disabled="!hasSelection" class="toolbar-btn">
|
||||
入库单入库
|
||||
@ -759,12 +759,42 @@ async function submitCreateReceiving() {
|
||||
}
|
||||
}
|
||||
|
||||
const payload: any = {
|
||||
delivery_method: String(createForm.delivery_method || '').trim(),
|
||||
loading_method: String(createForm.loading_method || '').trim()
|
||||
}
|
||||
|
||||
const storeId = Number(createForm.store_id)
|
||||
if (Number.isFinite(storeId) && storeId > 0) {
|
||||
payload.store_id = storeId
|
||||
}
|
||||
|
||||
const totalBoxes = Number(createForm.total_boxes)
|
||||
if (String(createForm.total_boxes || '').trim() !== '' && Number.isFinite(totalBoxes)) {
|
||||
payload.total_boxes = totalBoxes
|
||||
}
|
||||
|
||||
const totalPallets = Number(createForm.total_pallets)
|
||||
if (String(createForm.total_pallets || '').trim() !== '' && Number.isFinite(totalPallets)) {
|
||||
payload.total_pallets = totalPallets
|
||||
}
|
||||
|
||||
const licensePlate = String(createForm.license_plate || '').trim()
|
||||
if (licensePlate) payload.license_plate = licensePlate
|
||||
|
||||
const trackingNumber = String(createForm.tracking_number || '').trim()
|
||||
if (trackingNumber) payload.tracking_number = trackingNumber
|
||||
|
||||
const remark = String(createForm.remark || '').trim()
|
||||
if (remark) payload.remark = remark
|
||||
|
||||
createLoading.value = true
|
||||
try {
|
||||
const res: any = await receivingApi.createReceiving(createForm)
|
||||
const res: any = await receivingApi.createReceiving(payload)
|
||||
// console.log('新建收货单返回结果:', res)
|
||||
if (res && res.code === 200) {
|
||||
ElMessage.success('新建收货单成功')
|
||||
const receivingNumber = res?.data?.receiving_number || res?.data?.receivingNumber || ''
|
||||
ElMessage.success(receivingNumber ? `新建收货单成功:${receivingNumber}` : '新建收货单成功')
|
||||
createDialogVisible.value = false
|
||||
loadData()
|
||||
} else {
|
||||
|
||||
@ -342,7 +342,7 @@ export const productquick = [
|
||||
{ prop: 'storage_status', label: '入库', width: '80', align: 'center' },
|
||||
{ prop: 'space_id', label: '库位', width: '120' },
|
||||
{ prop: 'remark', label: '备注', minWidth: '150' },
|
||||
{ prop: 'actions', label: '操作', width: '160', align: 'center', fixed: 'right' },
|
||||
{ prop: 'actions', label: '操作', width: '280', align: 'center', fixed: 'right' },
|
||||
]
|
||||
|
||||
|
||||
|
||||
@ -138,7 +138,7 @@
|
||||
type="warning"
|
||||
link
|
||||
@click.stop="openQimenDialog(row)"
|
||||
>奇门配置</el-button>
|
||||
>接口配置</el-button>
|
||||
</template>
|
||||
</upper-table>
|
||||
</div>
|
||||
@ -365,14 +365,8 @@
|
||||
<div v-loading="policyDialog.loading">
|
||||
<!-- 签约基本信息 -->
|
||||
<el-descriptions :column="2" size="small" border style="margin-bottom:16px">
|
||||
<el-descriptions-item label="签约ID">{{ policyDialog.contractRow?.id }}</el-descriptions-item>
|
||||
<el-descriptions-item label="当前角色">
|
||||
<el-tag size="small" :type="policyDialog.contractRow?.current_subject_role === 'warehouse' ? 'primary' : 'warning'" effect="light">
|
||||
{{ policyDialog.contractRow?.current_subject_role === 'warehouse' ? '仓库方' : '货主方' }}
|
||||
</el-tag>
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="货主">{{ policyDialog.contractRow?.store_name }}</el-descriptions-item>
|
||||
<el-descriptions-item label="仓库">{{ policyDialog.contractRow?.warehouse_name }}</el-descriptions-item>
|
||||
|
||||
<el-descriptions-item label="面单余额">
|
||||
<span :style="{ color: (policyDialog.contractRow?.print_quantity ?? 0) <= 0 ? '#f56c6c' : '' }">
|
||||
{{ policyDialog.contractRow?.print_quantity ?? '—' }}
|
||||
|
||||
BIN
仓库商品导出_20260517 (3).xlsx
Normal file
BIN
仓库商品导出_20260517 (3).xlsx
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user