mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 18:29:20 +08:00
refactor(order-import): 重构订单导入为向导模式,优化页面布局
This commit is contained in:
+329
-194
@@ -58,22 +58,18 @@ interface StatusMappingItem {
|
||||
mappedStatusId: number;
|
||||
}
|
||||
|
||||
defineOptions({ name: 'CreateImportTaskModal' });
|
||||
defineOptions({ name: 'ImportTaskWizard' });
|
||||
|
||||
// 创建 vben modal
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[800px]',
|
||||
showCancelButton: false,
|
||||
showConfirmButton: false,
|
||||
onCancel() {
|
||||
handleCancel();
|
||||
},
|
||||
});
|
||||
const emit = defineEmits<{
|
||||
success: [];
|
||||
}>();
|
||||
|
||||
// 响应式数据
|
||||
const currentStep = ref(0);
|
||||
const loading = ref(false);
|
||||
/** 拉取订单字段定义(勿用整页 Spin 包住可滚动区,会破坏 overflow-y 滚轮) */
|
||||
const fieldDefsLoading = ref(false);
|
||||
/** 创建导入任务提交中(与 message.loading 配合,仅按钮 loading) */
|
||||
const createTaskSubmitting = ref(false);
|
||||
const csvHeaders = ref<string[]>([]);
|
||||
const csvData = ref<any[]>([]);
|
||||
const selectedFile = ref<File | null>(null);
|
||||
@@ -91,7 +87,7 @@ const editableMissingSpecCodeRows = ref<MissingSpecCodeRow[]>([]);
|
||||
const specCodePrechecked = ref(false);
|
||||
const hasPatchedFile = ref(false);
|
||||
|
||||
// 第一步:店铺选择
|
||||
// 店铺选择(在最终「确认信息」步骤内)
|
||||
const shopList = ref<ShopVO.Info[]>([]);
|
||||
const selectedShopId = ref<number | undefined>();
|
||||
const shopLoading = ref(false);
|
||||
@@ -100,7 +96,7 @@ const shopPageSize = ref(20);
|
||||
const shopHasMore = ref(true);
|
||||
const shopSearchValue = ref('');
|
||||
|
||||
// 第二步:字段映射
|
||||
// 字段映射(向导第一步)
|
||||
const fieldDefs = ref<ImportFieldDefVO.ImportFieldDefInfoVO[]>([]);
|
||||
const fieldMappings = ref<
|
||||
Record<
|
||||
@@ -124,7 +120,7 @@ const savingFieldToTemplate = ref<null | number>(null);
|
||||
// 当前模板的原始映射数据(用于对比哪些字段是模板的)
|
||||
const currentTemplateMappings = ref<FieldMappingItem[]>([]);
|
||||
|
||||
// 第三步:订单状态映射
|
||||
// 订单状态映射(向导第二步)
|
||||
const statusMappings = ref<Record<string, number>>({});
|
||||
const uniqueStatusValues = ref<string[]>([]);
|
||||
const statusMappingTemplates = ref<ImportMappingVO.ImportMappingInfoVO[]>([]);
|
||||
@@ -256,23 +252,19 @@ const [FixSpecCodeModal, fixSpecCodeModalApi] = useVbenModal({
|
||||
// 导入任务store
|
||||
const importTaskStore = useImportTaskStore();
|
||||
|
||||
// 计算属性:必填字段是否都已绑定
|
||||
// 计算属性:「下一步」是否可点(仅第 0、1 步有下一步;第 2 步直接点创建任务)
|
||||
const canGoToNextStep = computed(() => {
|
||||
if (currentStep.value === 0) {
|
||||
return selectedShopId.value !== undefined;
|
||||
}
|
||||
if (currentStep.value === 1) {
|
||||
const requiredFields = fieldDefs.value.filter((f) => f.required);
|
||||
return requiredFields.every((field) => {
|
||||
const mapping = fieldMappings.value[field.id];
|
||||
return mapping && mapping.mappedHeader;
|
||||
});
|
||||
}
|
||||
if (currentStep.value === 2) {
|
||||
// 订单状态映射步骤:允许不映射,所以总是返回 true
|
||||
if (currentStep.value === 1) {
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
return false;
|
||||
});
|
||||
|
||||
/** 当前 CSV 中仍存在的、需提示「系统状态已删除」的项(排序后用于文案展示) */
|
||||
@@ -436,7 +428,7 @@ const handleShopScroll = (e: any) => {
|
||||
// 获取字段定义
|
||||
const fetchFieldDefs = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
fieldDefsLoading.value = true;
|
||||
const result = await getFieldDefsByTypeApi('order');
|
||||
fieldDefs.value = result || [];
|
||||
initFieldMappings();
|
||||
@@ -444,7 +436,7 @@ const fetchFieldDefs = async () => {
|
||||
console.error('获取字段定义失败:', error);
|
||||
message.error('获取字段定义失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
fieldDefsLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1132,39 +1124,10 @@ async function handleConfirmFixSpecCode() {
|
||||
}
|
||||
}
|
||||
|
||||
// 下一步
|
||||
// 下一步(顺序:字段映射 → 订单状态映射 → 确认信息含选店铺)
|
||||
const handleNext = async () => {
|
||||
switch (currentStep.value) {
|
||||
case 0: {
|
||||
if (!selectedShopId.value) {
|
||||
message.warning('请选择店铺');
|
||||
return;
|
||||
}
|
||||
currentStep.value = 1;
|
||||
// 确保字段定义加载完成后,再加载模板(模板自动选中依赖 fieldDefs)
|
||||
if (fieldDefs.value.length === 0) {
|
||||
await fetchFieldDefs();
|
||||
}
|
||||
// 加载映射模板列表
|
||||
if (mappingTemplates.value.length === 0) {
|
||||
await fetchMappingTemplates();
|
||||
} else if (selectedTemplateId.value) {
|
||||
// 模板已选中但可能是重新进入,需要重新应用模板映射
|
||||
await handleSelectTemplate(selectedTemplateId.value);
|
||||
} else {
|
||||
// 第二次创建:列表仍在内存中,但创建成功后会清空 selectedTemplateId,
|
||||
// 此时不会走 fetchMappingTemplates,需再次默认选中并应用第一个模板
|
||||
const firstTemplate = mappingTemplates.value[0];
|
||||
if (firstTemplate?.id) {
|
||||
selectedTemplateId.value = firstTemplate.id;
|
||||
await handleSelectTemplate(firstTemplate.id);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
// 验证必填字段
|
||||
const requiredFields = fieldDefs.value.filter((f) => f.required);
|
||||
const unMappedFields = requiredFields.filter((field) => {
|
||||
const mapping = fieldMappings.value[field.id];
|
||||
@@ -1177,29 +1140,24 @@ const handleNext = async () => {
|
||||
return;
|
||||
}
|
||||
|
||||
// 规格编码缺失预检(用于第4步提示与补录)
|
||||
runMissingSpecCodePrecheck();
|
||||
if (missingSpecCodeCount.value > 0) {
|
||||
message.warning(
|
||||
`检测到 ${missingSpecCodeCount.value} 行规格编码为空,可在第4步补充后再创建任务`,
|
||||
`检测到 ${missingSpecCodeCount.value} 行规格编码为空,可在确认步骤补充后再创建任务`,
|
||||
);
|
||||
}
|
||||
|
||||
// 在进入订单状态映射步骤前,解析所有订单状态
|
||||
parseOrderStatuses();
|
||||
|
||||
// 加载订单状态列表
|
||||
if (orderStatusList.value.length === 0) {
|
||||
await fetchOrderStatusList();
|
||||
} else {
|
||||
mergeObsoleteSystemTargetRemind(pruneInvalidStatusMappings());
|
||||
}
|
||||
|
||||
// 加载订单状态映射模板列表
|
||||
if (statusMappingTemplates.value.length === 0) {
|
||||
await fetchStatusMappingTemplates();
|
||||
} else if (selectedStatusTemplateId.value) {
|
||||
// 模板已选中但可能是重新进入,需要重新应用模板映射
|
||||
await handleSelectStatusTemplate(selectedStatusTemplateId.value);
|
||||
} else {
|
||||
const firstStatusTemplate = statusMappingTemplates.value[0];
|
||||
@@ -1209,20 +1167,22 @@ const handleNext = async () => {
|
||||
}
|
||||
}
|
||||
|
||||
currentStep.value = 2;
|
||||
|
||||
currentStep.value = 1;
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
// 未重选系统状态、保持留空的行视为接受自动匹配,不再提示
|
||||
case 1: {
|
||||
for (const csv of [...csvStatusesObsoleteSystemTarget.value]) {
|
||||
if (statusMappings.value[csv] === undefined) {
|
||||
removeObsoleteSystemTargetRemind(csv);
|
||||
}
|
||||
}
|
||||
// 订单状态映射是可选的,可以直接进入下一步
|
||||
currentStep.value = 3;
|
||||
|
||||
if (shopList.value.length === 0) {
|
||||
shopSearchValue.value = '';
|
||||
shopPage.value = 1;
|
||||
shopHasMore.value = true;
|
||||
await fetchShopList(true);
|
||||
}
|
||||
currentStep.value = 2;
|
||||
break;
|
||||
}
|
||||
// No default
|
||||
@@ -1236,10 +1196,9 @@ const handlePrev = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 取消
|
||||
// 取消:回到第一步(不清空已选店铺与映射,与原先关闭弹窗行为一致)
|
||||
const handleCancel = () => {
|
||||
// 保持所有状态:步骤、店铺选择、字段映射
|
||||
modalApi.close();
|
||||
currentStep.value = 0;
|
||||
};
|
||||
|
||||
// 创建导入任务
|
||||
@@ -1248,9 +1207,13 @@ const handleCreateTask = async () => {
|
||||
message.error('文件信息丢失,请重新上传');
|
||||
return;
|
||||
}
|
||||
if (selectedShopId.value === undefined) {
|
||||
message.warning('请选择店铺');
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
loading.value = true;
|
||||
createTaskSubmitting.value = true;
|
||||
|
||||
// 先上传文件到 OSS(使用统一文件系统)
|
||||
message.loading('正在上传文件...', 0);
|
||||
@@ -1321,18 +1284,18 @@ const handleCreateTask = async () => {
|
||||
selectedTemplateId.value = undefined;
|
||||
selectedStatusTemplateId.value = undefined;
|
||||
clearObsoleteSystemTargetRemind();
|
||||
modalApi.close();
|
||||
emit('success');
|
||||
} catch (error: any) {
|
||||
message.destroy();
|
||||
console.error('创建导入任务失败:', error);
|
||||
message.error(error?.message || '创建导入任务失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
createTaskSubmitting.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 暴露给父组件的方法
|
||||
function open(headers: string[], file?: File, data?: any[]) {
|
||||
// 暴露给父组件的方法(第一步为字段映射,需预拉字段定义与映射模板)
|
||||
async function open(headers: string[], file?: File, data?: any[]) {
|
||||
const headersChanged =
|
||||
JSON.stringify(csvHeaders.value) !== JSON.stringify(headers);
|
||||
|
||||
@@ -1344,9 +1307,7 @@ function open(headers: string[], file?: File, data?: any[]) {
|
||||
editableMissingSpecCodeRows.value = [];
|
||||
specCodePrechecked.value = false;
|
||||
hasPatchedFile.value = false;
|
||||
// 步骤保持不变,不清空
|
||||
|
||||
// 如果 CSV 表头变化了,需要重新初始化字段映射
|
||||
if (headersChanged) {
|
||||
fieldMappings.value = {};
|
||||
statusMappings.value = {};
|
||||
@@ -1357,29 +1318,61 @@ function open(headers: string[], file?: File, data?: any[]) {
|
||||
editableMissingSpecCodeRows.value = [];
|
||||
specCodePrechecked.value = false;
|
||||
hasPatchedFile.value = false;
|
||||
// 如果已有字段定义,重新初始化映射
|
||||
if (fieldDefs.value.length > 0) {
|
||||
initFieldMappings();
|
||||
}
|
||||
// 表头变化时,重置到第一步
|
||||
currentStep.value = 0;
|
||||
}
|
||||
|
||||
// 店铺选择保持不变,不清空
|
||||
// 只在首次打开或列表为空时加载店铺列表
|
||||
if (shopList.value.length === 0) {
|
||||
shopSearchValue.value = '';
|
||||
shopPage.value = 1;
|
||||
shopHasMore.value = true;
|
||||
fetchShopList(true);
|
||||
void fetchShopList(true);
|
||||
}
|
||||
|
||||
modalApi.open();
|
||||
if (fieldDefs.value.length === 0) {
|
||||
await fetchFieldDefs();
|
||||
} else if (headersChanged) {
|
||||
initFieldMappings();
|
||||
}
|
||||
|
||||
if (mappingTemplates.value.length === 0) {
|
||||
await fetchMappingTemplates();
|
||||
} else if (headersChanged) {
|
||||
if (selectedTemplateId.value) {
|
||||
await handleSelectTemplate(selectedTemplateId.value);
|
||||
} else {
|
||||
const firstTemplate = mappingTemplates.value[0];
|
||||
if (firstTemplate?.id) {
|
||||
selectedTemplateId.value = firstTemplate.id;
|
||||
await handleSelectTemplate(firstTemplate.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** 清空向导状态(父级清空表格时调用) */
|
||||
function reset() {
|
||||
currentStep.value = 0;
|
||||
selectedShopId.value = undefined;
|
||||
fieldMappings.value = {};
|
||||
statusMappings.value = {};
|
||||
uniqueStatusValues.value = [];
|
||||
missingSpecCodeCount.value = 0;
|
||||
missingSpecCodeRows.value = [];
|
||||
editableMissingSpecCodeRows.value = [];
|
||||
specCodePrechecked.value = false;
|
||||
hasPatchedFile.value = false;
|
||||
csvHeaders.value = [];
|
||||
csvData.value = [];
|
||||
selectedFile.value = null;
|
||||
selectedTemplateId.value = undefined;
|
||||
selectedStatusTemplateId.value = undefined;
|
||||
clearObsoleteSystemTargetRemind();
|
||||
}
|
||||
|
||||
// 暴露方法给父组件
|
||||
defineExpose({
|
||||
open,
|
||||
reset,
|
||||
});
|
||||
|
||||
// 店铺选项
|
||||
@@ -1392,54 +1385,43 @@ const shopOptions = computed(() => {
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal title="创建导入任务" :loading="loading">
|
||||
<div class="space-y-3">
|
||||
<!-- 步骤条 -->
|
||||
<div
|
||||
class="import-task-wizard flex h-full min-h-0 w-full flex-col overflow-hidden rounded-2xl border border-slate-200/80 bg-white shadow-sm dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(222.34deg_10.43%_12.27%)]"
|
||||
>
|
||||
<div class="shrink-0 border-b border-slate-100 px-4 py-3 dark:border-[hsl(240deg_3.7%_22%)]">
|
||||
<div class="text-base font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||
创建导入任务
|
||||
</div>
|
||||
<p
|
||||
v-if="selectedFile"
|
||||
class="mb-0 mt-1 truncate text-xs text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]"
|
||||
>
|
||||
{{ selectedFile.name }} · {{ csvData.length }} 条
|
||||
</p>
|
||||
</div>
|
||||
<!-- 不用整页 Spin 包裹可滚动区域:ant-spin-container 默认会限制内部滚动交互,见官方嵌套/高度讨论 -->
|
||||
<div class="flex min-h-0 flex-1 flex-col overflow-hidden">
|
||||
<!-- Grid:第一行步骤条固定高度,第二行 minmax(0,1fr) 占满剩余高度 -->
|
||||
<div
|
||||
class="import-task-wizard-main grid min-h-0 min-w-0 w-full flex-1 grid-rows-[auto_minmax(0,1fr)] gap-3 overflow-hidden px-3 py-3"
|
||||
>
|
||||
<div class="min-w-0 shrink-0">
|
||||
<Steps :current="currentStep">
|
||||
<Steps.Step title="选择店铺" />
|
||||
<Steps.Step title="字段映射" />
|
||||
<Steps.Step title="订单状态映射" />
|
||||
<Steps.Step title="确认信息" />
|
||||
</Steps>
|
||||
|
||||
<!-- 第一步:选择店铺 -->
|
||||
<div v-if="currentStep === 0" class="py-4">
|
||||
<Form :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
|
||||
<Form.Item label="选择店铺" required>
|
||||
<Select
|
||||
v-model:value="selectedShopId"
|
||||
placeholder="请选择店铺"
|
||||
show-search
|
||||
:filter-option="false"
|
||||
:loading="shopLoading"
|
||||
@search="handleShopSearch"
|
||||
@popup-scroll="handleShopScroll"
|
||||
</div>
|
||||
<!-- 第二行:与 grid 行高对齐(h-full + min-h-0),内部步骤 flex-1 才能撑开列表滚动区 -->
|
||||
<div class="flex h-full min-h-0 min-w-0 flex-col overflow-hidden">
|
||||
<!-- 第一步:字段映射 -->
|
||||
<div
|
||||
v-if="currentStep === 0"
|
||||
class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden py-2"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="shopLoading" class="py-4 text-center">
|
||||
<Spin size="small" />
|
||||
<div class="mt-2">加载中...</div>
|
||||
</div>
|
||||
<div v-else class="py-4 text-center text-gray-400 dark:text-gray-500 dark:text-gray-400">
|
||||
暂无数据
|
||||
</div>
|
||||
</template>
|
||||
<Select.Option
|
||||
v-for="option in shopOptions"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
:label="option.label"
|
||||
<div
|
||||
class="mb-3 flex shrink-0 flex-wrap items-center justify-between gap-2 gap-y-3"
|
||||
>
|
||||
{{ option.label }}
|
||||
</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</div>
|
||||
|
||||
<!-- 第二步:字段映射 -->
|
||||
<div v-if="currentStep === 1" class="py-4">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<div class="text-sm text-gray-600 dark:text-gray-300">
|
||||
请为每个订单字段选择对应的CSV列,必填字段必须绑定
|
||||
</div>
|
||||
@@ -1480,31 +1462,67 @@ const shopOptions = computed(() => {
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="max-h-[400px] space-y-4 overflow-y-auto">
|
||||
<template v-if="fieldDefsLoading">
|
||||
<div
|
||||
class="flex min-h-[200px] flex-1 items-center justify-center text-gray-500 dark:text-gray-400"
|
||||
>
|
||||
<Spin size="large" />
|
||||
<span class="ml-3 text-sm">加载字段定义中…</span>
|
||||
</div>
|
||||
</template>
|
||||
<div
|
||||
v-else
|
||||
class="min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-y-contain pr-0.5"
|
||||
>
|
||||
<div
|
||||
v-for="fieldDef in fieldDefs"
|
||||
:key="fieldDef.id"
|
||||
class="flex items-center space-x-4 rounded border p-3"
|
||||
:class="{
|
||||
'border-red-300 dark:border-red-700 bg-red-50 dark:bg-red-900/30':
|
||||
fieldDef.required && !fieldMappings[fieldDef.id]?.mappedHeader,
|
||||
'border-blue-200 dark:border-blue-700 bg-blue-50 dark:bg-blue-900/30': isMappingFromTemplate(fieldDef.id),
|
||||
'border-yellow-200 dark:border-yellow-700 bg-yellow-50 dark:bg-yellow-900/30': isMappingChangedFromTemplate(
|
||||
fieldDef.id,
|
||||
),
|
||||
}"
|
||||
class="flex min-w-0 flex-col overflow-hidden rounded-lg border p-0"
|
||||
:class="
|
||||
fieldDef.required && !fieldMappings[fieldDef.id]?.mappedHeader
|
||||
? 'border-red-300 dark:border-red-700'
|
||||
: isMappingChangedFromTemplate(fieldDef.id)
|
||||
? 'border-yellow-200 dark:border-yellow-700'
|
||||
: isMappingFromTemplate(fieldDef.id)
|
||||
? 'border-blue-200 dark:border-blue-700'
|
||||
: 'border-slate-200 dark:border-slate-600'
|
||||
"
|
||||
>
|
||||
<div class="flex-1">
|
||||
<div class="flex items-center space-x-2">
|
||||
<span class="font-medium">{{ fieldDef.fieldLabel }}</span>
|
||||
<!-- 系统侧:订单字段(不展示内部字段名 fieldName) -->
|
||||
<div
|
||||
class="border-b border-slate-200/90 bg-gradient-to-r to-transparent px-3 py-2.5 dark:border-slate-600"
|
||||
:class="
|
||||
fieldDef.required && !fieldMappings[fieldDef.id]?.mappedHeader
|
||||
? 'from-red-50/90 dark:from-red-950/35'
|
||||
: isMappingChangedFromTemplate(fieldDef.id)
|
||||
? 'from-amber-50/75 dark:from-amber-950/30'
|
||||
: isMappingFromTemplate(fieldDef.id)
|
||||
? 'from-blue-50/90 dark:from-blue-950/40'
|
||||
: 'from-blue-50/95 dark:from-blue-950/35'
|
||||
"
|
||||
>
|
||||
<div class="mb-2 flex flex-wrap items-center gap-2">
|
||||
<span
|
||||
class="shrink-0 rounded bg-blue-600 px-2 py-0.5 text-[11px] font-semibold text-white shadow-sm dark:bg-blue-500"
|
||||
>
|
||||
系统
|
||||
</span>
|
||||
<span class="text-xs font-medium text-slate-600 dark:text-slate-300">
|
||||
订单字段
|
||||
</span>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-x-2 gap-y-1">
|
||||
<span class="font-medium leading-snug text-slate-900 dark:text-slate-100">{{
|
||||
fieldDef.fieldLabel
|
||||
}}</span>
|
||||
<span v-if="fieldDef.required" class="text-xs text-red-500 dark:text-red-400">
|
||||
(必填)
|
||||
必填
|
||||
</span>
|
||||
<span
|
||||
v-if="
|
||||
selectedTemplateId && isMappingFromTemplate(fieldDef.id)
|
||||
"
|
||||
class="ml-1 rounded bg-blue-100 dark:bg-blue-900/50 px-1.5 py-0.5 text-xs text-blue-600 dark:text-blue-400"
|
||||
class="rounded bg-blue-100 px-1.5 py-0.5 text-xs text-blue-700 dark:bg-blue-900/50 dark:text-blue-300"
|
||||
>
|
||||
模板映射
|
||||
</span>
|
||||
@@ -1513,14 +1531,11 @@ const shopOptions = computed(() => {
|
||||
selectedTemplateId &&
|
||||
isMappingChangedFromTemplate(fieldDef.id)
|
||||
"
|
||||
class="ml-1 rounded bg-yellow-100 dark:bg-yellow-900/50 px-1.5 py-0.5 text-xs text-yellow-600 dark:text-yellow-300"
|
||||
class="rounded bg-amber-100 px-1.5 py-0.5 text-xs text-amber-800 dark:bg-amber-900/40 dark:text-amber-200"
|
||||
>
|
||||
已变更
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-1 text-xs text-gray-500 dark:text-gray-400">
|
||||
字段名: {{ fieldDef.fieldName }}
|
||||
</div>
|
||||
<div
|
||||
v-if="
|
||||
selectedTemplateId &&
|
||||
@@ -1528,21 +1543,38 @@ const shopOptions = computed(() => {
|
||||
(m) => m.fieldName === fieldDef.fieldName,
|
||||
)
|
||||
"
|
||||
class="mt-1 text-xs text-gray-400 dark:text-gray-500 dark:text-gray-400"
|
||||
class="mt-1.5 text-xs text-slate-500 dark:text-slate-400"
|
||||
>
|
||||
模板原映射:
|
||||
模板原文件列:
|
||||
{{
|
||||
currentTemplateMappings.find(
|
||||
(m) => m.fieldName === fieldDef.fieldName,
|
||||
)?.fileFieldName || '(未映射)'
|
||||
)?.fileFieldName || '(未映射)'
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
<!-- 文件侧:CSV 表头 -->
|
||||
<div
|
||||
class="bg-gradient-to-r from-amber-50/90 to-transparent px-3 py-2.5 dark:from-amber-950/25"
|
||||
>
|
||||
<div class="mb-2 flex flex-wrap items-center gap-2">
|
||||
<span
|
||||
class="shrink-0 rounded bg-amber-600 px-2 py-0.5 text-[11px] font-semibold text-white shadow-sm dark:bg-amber-600"
|
||||
>
|
||||
文件
|
||||
</span>
|
||||
<span class="text-xs font-medium text-slate-600 dark:text-slate-300">
|
||||
CSV 列
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center sm:gap-2"
|
||||
>
|
||||
<Select
|
||||
v-if="fieldMappings[fieldDef.id]"
|
||||
v-model:value="fieldMappings[fieldDef.id]!.mappedHeader"
|
||||
placeholder="请选择CSV列"
|
||||
class="w-[160px]"
|
||||
placeholder="选择该订单字段对应的 CSV 列"
|
||||
class="w-full min-w-0 sm:flex-1"
|
||||
show-search
|
||||
allow-clear
|
||||
:options="
|
||||
@@ -1558,6 +1590,7 @@ const shopOptions = computed(() => {
|
||||
"
|
||||
size="small"
|
||||
type="link"
|
||||
class="h-auto shrink-0 self-start px-0 py-0 sm:self-center"
|
||||
:disabled="isMappingFromTemplate(fieldDef.id)"
|
||||
:loading="savingFieldToTemplate === fieldDef.id"
|
||||
@click="handleAddFieldToTemplate(fieldDef.id)"
|
||||
@@ -1567,10 +1600,17 @@ const shopOptions = computed(() => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 第三步:订单状态映射 -->
|
||||
<div v-if="currentStep === 2" class="py-4">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<!-- 第二步:订单状态映射 -->
|
||||
<div
|
||||
v-if="currentStep === 1"
|
||||
class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden py-2"
|
||||
>
|
||||
<div
|
||||
class="mb-3 flex shrink-0 flex-wrap items-center justify-between gap-2 gap-y-3"
|
||||
>
|
||||
<div class="text-sm text-gray-600 dark:text-gray-300">
|
||||
请为每个订单状态值映射到对应的系统订单状态(可选,可不映射)
|
||||
</div>
|
||||
@@ -1613,33 +1653,58 @@ const shopOptions = computed(() => {
|
||||
</div>
|
||||
<div
|
||||
v-if="uniqueStatusValues.length === 0"
|
||||
class="py-8 text-center text-gray-400 dark:text-gray-500 dark:text-gray-400"
|
||||
class="flex min-h-0 flex-1 items-center justify-center py-8 text-center text-gray-400 dark:text-gray-500 dark:text-gray-400"
|
||||
>
|
||||
未找到订单状态字段映射,请先在字段映射步骤中绑定status字段
|
||||
</div>
|
||||
<div v-else class="max-h-[400px] space-y-4 overflow-y-auto">
|
||||
<div
|
||||
v-else
|
||||
class="min-h-0 flex-1 space-y-3 overflow-y-auto overscroll-y-contain pr-0.5"
|
||||
>
|
||||
<div
|
||||
v-for="statusValue in uniqueStatusValues"
|
||||
:key="statusValue"
|
||||
class="flex items-center space-x-4 rounded border p-3"
|
||||
:class="{
|
||||
'border-blue-200 dark:border-blue-700 bg-blue-50 dark:bg-blue-900/30':
|
||||
class="flex min-w-0 flex-col overflow-hidden rounded-lg border p-0"
|
||||
:class="
|
||||
selectedStatusTemplateId &&
|
||||
isStatusMappingFromTemplate(statusValue),
|
||||
'border-yellow-200 dark:border-yellow-700 bg-yellow-50 dark:bg-yellow-900/30':
|
||||
selectedStatusTemplateId &&
|
||||
isStatusMappingChangedFromTemplate(statusValue),
|
||||
}"
|
||||
isStatusMappingChangedFromTemplate(statusValue)
|
||||
? 'border-amber-200 dark:border-amber-700'
|
||||
: selectedStatusTemplateId &&
|
||||
isStatusMappingFromTemplate(statusValue)
|
||||
? 'border-blue-200 dark:border-blue-700'
|
||||
: 'border-slate-200 dark:border-slate-600'
|
||||
"
|
||||
>
|
||||
<div class="flex-1">
|
||||
<div class="flex items-center space-x-2">
|
||||
<span class="font-medium">{{ statusValue }}</span>
|
||||
<!-- 系统侧:映射到的系统订单状态 -->
|
||||
<div
|
||||
class="border-b border-slate-200/90 bg-gradient-to-r to-transparent px-3 py-2.5 dark:border-slate-600"
|
||||
:class="
|
||||
selectedStatusTemplateId &&
|
||||
isStatusMappingChangedFromTemplate(statusValue)
|
||||
? 'from-amber-50/80 dark:from-amber-950/30'
|
||||
: selectedStatusTemplateId &&
|
||||
isStatusMappingFromTemplate(statusValue)
|
||||
? 'from-blue-50/90 dark:from-blue-950/40'
|
||||
: 'from-blue-50/95 dark:from-blue-950/35'
|
||||
"
|
||||
>
|
||||
<div class="mb-2 flex flex-wrap items-center gap-2">
|
||||
<span
|
||||
class="shrink-0 rounded bg-blue-600 px-2 py-0.5 text-[11px] font-semibold text-white shadow-sm dark:bg-blue-500"
|
||||
>
|
||||
系统
|
||||
</span>
|
||||
<span class="text-xs font-medium text-slate-600 dark:text-slate-300">
|
||||
系统订单状态
|
||||
</span>
|
||||
</div>
|
||||
<div class="mb-2 flex flex-wrap items-center gap-x-2 gap-y-1">
|
||||
<span
|
||||
v-if="
|
||||
selectedStatusTemplateId &&
|
||||
isStatusMappingFromTemplate(statusValue)
|
||||
"
|
||||
class="ml-1 rounded bg-blue-100 dark:bg-blue-900/50 px-1.5 py-0.5 text-xs text-blue-600 dark:text-blue-400"
|
||||
class="rounded bg-blue-100 px-1.5 py-0.5 text-xs text-blue-700 dark:bg-blue-900/50 dark:text-blue-300"
|
||||
>
|
||||
模板映射
|
||||
</span>
|
||||
@@ -1648,18 +1713,17 @@ const shopOptions = computed(() => {
|
||||
selectedStatusTemplateId &&
|
||||
isStatusMappingChangedFromTemplate(statusValue)
|
||||
"
|
||||
class="ml-1 rounded bg-yellow-100 dark:bg-yellow-900/50 px-1.5 py-0.5 text-xs text-yellow-600 dark:text-yellow-300"
|
||||
class="rounded bg-amber-100 px-1.5 py-0.5 text-xs text-amber-800 dark:bg-amber-900/40 dark:text-amber-200"
|
||||
>
|
||||
已变更
|
||||
</span>
|
||||
<span
|
||||
v-if="obsoleteRemindForDisplay.includes(statusValue)"
|
||||
class="ml-1 rounded bg-amber-100 px-1.5 py-0.5 text-xs font-medium text-amber-900 dark:bg-amber-900/40 dark:text-amber-200"
|
||||
class="rounded bg-amber-100 px-1.5 py-0.5 text-xs font-medium text-amber-900 dark:bg-amber-900/40 dark:text-amber-200"
|
||||
>
|
||||
原系统状态已删除
|
||||
</span>
|
||||
</div>
|
||||
<div class="mt-1 text-xs text-gray-500 dark:text-gray-400">CSV中的订单状态值</div>
|
||||
<div
|
||||
v-if="
|
||||
selectedStatusTemplateId &&
|
||||
@@ -1667,16 +1731,18 @@ const shopOptions = computed(() => {
|
||||
(m) => m.csvStatus === statusValue,
|
||||
)
|
||||
"
|
||||
class="mt-1 text-xs text-gray-400 dark:text-gray-500 dark:text-gray-400"
|
||||
class="mb-2 text-xs text-slate-500 dark:text-slate-400"
|
||||
>
|
||||
模板原映射:
|
||||
模板原系统状态:
|
||||
{{ getTemplateOriginalMappedLabel(statusValue) }}
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex min-w-0 flex-col gap-2 sm:flex-row sm:items-center sm:gap-2"
|
||||
>
|
||||
<Select
|
||||
v-model:value="statusMappings[statusValue]"
|
||||
placeholder="请选择订单状态(可选)"
|
||||
class="w-[160px]"
|
||||
placeholder="选择系统订单状态(可选,可不选)"
|
||||
class="w-full min-w-0 sm:flex-1"
|
||||
show-search
|
||||
allow-clear
|
||||
:loading="orderStatusLoading"
|
||||
@@ -1701,6 +1767,7 @@ const shopOptions = computed(() => {
|
||||
"
|
||||
size="small"
|
||||
type="link"
|
||||
class="h-auto shrink-0 self-start px-0 py-0 sm:self-center"
|
||||
:disabled="isStatusMappingFromTemplate(statusValue)"
|
||||
:loading="savingStatusFieldToTemplate === statusValue"
|
||||
@click="handleAddStatusFieldToTemplate(statusValue)"
|
||||
@@ -1709,11 +1776,72 @@ const shopOptions = computed(() => {
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<!-- 文件侧:导入文件中的状态原文 -->
|
||||
<div
|
||||
class="bg-gradient-to-r from-amber-50/90 to-transparent px-3 py-2.5 dark:from-amber-950/25"
|
||||
>
|
||||
<div class="mb-2 flex flex-wrap items-center gap-2">
|
||||
<span
|
||||
class="shrink-0 rounded bg-amber-600 px-2 py-0.5 text-[11px] font-semibold text-white shadow-sm dark:bg-amber-600"
|
||||
>
|
||||
文件
|
||||
</span>
|
||||
<span class="text-xs font-medium text-slate-600 dark:text-slate-300">
|
||||
文件中的状态
|
||||
</span>
|
||||
</div>
|
||||
<div
|
||||
class="min-w-0 rounded-md border border-amber-200/90 bg-white/90 px-3 py-2.5 text-sm leading-relaxed text-slate-800 shadow-sm dark:border-amber-800/50 dark:bg-slate-900/50 dark:text-slate-100"
|
||||
role="status"
|
||||
aria-label="CSV 中的状态原文"
|
||||
>
|
||||
<span class="break-words font-medium">{{ statusValue }}</span>
|
||||
</div>
|
||||
<p class="mb-0 mt-1.5 text-xs text-slate-500 dark:text-slate-400">
|
||||
以上为导入文件里的原始文本;在上方「系统订单状态」中选择对应关系即可
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 第四步:确认信息 -->
|
||||
<div v-if="currentStep === 3" class="py-4">
|
||||
<!-- 第三步:确认信息(含选择店铺) -->
|
||||
<div
|
||||
v-if="currentStep === 2"
|
||||
class="flex min-h-0 min-w-0 flex-1 flex-col overflow-y-auto py-2"
|
||||
>
|
||||
<div class="space-y-4">
|
||||
<Form :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
|
||||
<Form.Item label="选择店铺" required>
|
||||
<Select
|
||||
v-model:value="selectedShopId"
|
||||
placeholder="请选择店铺"
|
||||
show-search
|
||||
:filter-option="false"
|
||||
:loading="shopLoading"
|
||||
@search="handleShopSearch"
|
||||
@popup-scroll="handleShopScroll"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="shopLoading" class="py-4 text-center">
|
||||
<Spin size="small" />
|
||||
<div class="mt-2">加载中...</div>
|
||||
</div>
|
||||
<div v-else class="py-4 text-center text-gray-400 dark:text-gray-500 dark:text-gray-400">
|
||||
暂无数据
|
||||
</div>
|
||||
</template>
|
||||
<Select.Option
|
||||
v-for="option in shopOptions"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
:label="option.label"
|
||||
>
|
||||
{{ option.label }}
|
||||
</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
<Alert
|
||||
v-if="specCodePrechecked && missingSpecCodeCount > 0"
|
||||
type="warning"
|
||||
@@ -1741,15 +1869,6 @@ const shopOptions = computed(() => {
|
||||
show-icon
|
||||
:message="`已使用补录后的文件:${selectedFile?.name || ''}`"
|
||||
/>
|
||||
<div class="rounded bg-gray-50 dark:bg-gray-800 p-4">
|
||||
<div class="mb-2 font-medium">店铺信息</div>
|
||||
<div class="text-gray-700 dark:text-gray-200">
|
||||
{{
|
||||
shopList.find((s: ShopVO.Info) => s.id === selectedShopId)
|
||||
?.name ?? '-'
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded bg-gray-50 dark:bg-gray-800 p-4">
|
||||
<div class="mb-2 font-medium">字段映射</div>
|
||||
<div class="space-y-2">
|
||||
@@ -1789,13 +1908,17 @@ const shopOptions = computed(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<div class="flex justify-between">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
class="flex shrink-0 justify-between gap-2 border-t border-slate-100 bg-slate-50/80 px-3 py-3 dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(240deg_3.7%_15.9%/40%)]"
|
||||
>
|
||||
<Button @click="handleCancel">取消</Button>
|
||||
<div class="space-x-2">
|
||||
<div class="flex flex-wrap justify-end gap-2">
|
||||
<Button v-if="currentStep > 0" @click="handlePrev">上一步</Button>
|
||||
<Button
|
||||
v-if="currentStep < 3"
|
||||
v-if="currentStep < 2"
|
||||
type="primary"
|
||||
:disabled="!canGoToNextStep"
|
||||
@click="handleNext"
|
||||
@@ -1803,9 +1926,9 @@ const shopOptions = computed(() => {
|
||||
下一步
|
||||
</Button>
|
||||
<Button
|
||||
v-if="currentStep === 3"
|
||||
v-if="currentStep === 2"
|
||||
type="primary"
|
||||
:loading="loading"
|
||||
:loading="createTaskSubmitting"
|
||||
@click="handleCreateTask"
|
||||
>
|
||||
创建导入任务
|
||||
@@ -1847,5 +1970,17 @@ const shopOptions = computed(() => {
|
||||
<FixSpecCodeModal>
|
||||
<FixSpecCodeEditor :rows="editableMissingSpecCodeRows" />
|
||||
</FixSpecCodeModal>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 主内容区:与侧栏 flex 链衔接,第二行 grid 才能分到剩余高度 */
|
||||
.import-task-wizard-main {
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
/* 第二行格子在部分布局下需显式占满行高,否则子级 flex-1 高度为 0 */
|
||||
.import-task-wizard-main > :last-child {
|
||||
min-height: 0;
|
||||
align-self: stretch;
|
||||
}
|
||||
</style>
|
||||
@@ -3,11 +3,12 @@ import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
|
||||
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
|
||||
import CreateImportTaskModal from './components/CreateImportTaskModal.vue';
|
||||
import ImportTaskWizard from './components/ImportTaskWizard.vue';
|
||||
import FileUploadArea from './components/FileUploadArea.vue';
|
||||
import { parseFileToRawData } from './utils/fileParser';
|
||||
|
||||
@@ -21,13 +22,14 @@ const currentFile = ref<File | null>(null);
|
||||
const tableContainerRef = ref<HTMLElement>();
|
||||
const tableHeight = ref<number>(600);
|
||||
|
||||
const importTaskWizardRef = ref<InstanceType<typeof ImportTaskWizard>>();
|
||||
|
||||
// 动态生成Grid列配置
|
||||
const gridColumns = computed(() => {
|
||||
if (csvHeaders.value.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
// 序号列
|
||||
const columns: VxeGridProps<any>['columns'] = [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
@@ -37,7 +39,6 @@ const gridColumns = computed(() => {
|
||||
},
|
||||
];
|
||||
|
||||
// 根据CSV表头动态生成列
|
||||
csvHeaders.value.forEach((header) => {
|
||||
columns.push({
|
||||
field: header,
|
||||
@@ -50,7 +51,6 @@ const gridColumns = computed(() => {
|
||||
return columns;
|
||||
});
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [],
|
||||
height: tableHeight.value,
|
||||
@@ -84,11 +84,9 @@ const gridOptions: VxeGridProps<any> = {
|
||||
| 'Total'
|
||||
)[],
|
||||
},
|
||||
// 配置远程加载,实现真正的分页
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
// 如果没有数据,返回空
|
||||
if (csvData.value.length === 0) {
|
||||
return {
|
||||
items: [],
|
||||
@@ -96,13 +94,11 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
}
|
||||
|
||||
// 计算分页参数
|
||||
const currentPage = page.currentPage || 1;
|
||||
const pageSize = page.pageSize || 50;
|
||||
const startIndex = (currentPage - 1) * pageSize;
|
||||
const endIndex = startIndex + pageSize;
|
||||
|
||||
// 从 csvData 中截取当前页的数据
|
||||
const pageData = csvData.value.slice(startIndex, endIndex);
|
||||
|
||||
return {
|
||||
@@ -118,17 +114,14 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
});
|
||||
|
||||
// 更新表格列配置(不再更新 data,data 由 proxyConfig 管理)
|
||||
const updateTable = () => {
|
||||
gridApi.setGridOptions({
|
||||
columns: gridColumns.value,
|
||||
height: tableHeight.value,
|
||||
});
|
||||
// 触发重新加载数据
|
||||
gridApi.reload();
|
||||
};
|
||||
|
||||
// 监听表格高度变化,更新表格配置
|
||||
watch(
|
||||
tableHeight,
|
||||
(newHeight) => {
|
||||
@@ -139,7 +132,19 @@ watch(
|
||||
{ immediate: false },
|
||||
);
|
||||
|
||||
// 处理文件上传
|
||||
const syncWizardOpen = () => {
|
||||
if (csvData.value.length === 0 || csvHeaders.value.length === 0) {
|
||||
return;
|
||||
}
|
||||
nextTick(() => {
|
||||
importTaskWizardRef.value?.open(
|
||||
[...csvHeaders.value],
|
||||
currentFile.value ?? undefined,
|
||||
[...csvData.value],
|
||||
);
|
||||
});
|
||||
};
|
||||
|
||||
const handleFileUpload = async (file: File) => {
|
||||
importLoading.value = true;
|
||||
try {
|
||||
@@ -158,12 +163,11 @@ const handleFileUpload = async (file: File) => {
|
||||
csvHeaders.value = result.headers;
|
||||
currentFile.value = file;
|
||||
|
||||
// 更新表格
|
||||
updateTable();
|
||||
// 重新计算表格高度
|
||||
nextTick(() => {
|
||||
calculateTableHeight();
|
||||
});
|
||||
syncWizardOpen();
|
||||
|
||||
const fileExt = file.name.toLowerCase().split('.').pop() || '';
|
||||
const format = ['xlsx', 'xls'].includes(fileExt) ? 'Excel' : 'CSV';
|
||||
@@ -175,48 +179,44 @@ const handleFileUpload = async (file: File) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 创建导入任务模态框引用
|
||||
const createImportTaskModalRef =
|
||||
ref<InstanceType<typeof CreateImportTaskModal>>();
|
||||
|
||||
// 创建导入任务按钮处理
|
||||
const handleCreateImportTask = () => {
|
||||
if (csvHeaders.value.length === 0) {
|
||||
message.warning('请先上传CSV文件');
|
||||
return;
|
||||
}
|
||||
createImportTaskModalRef.value?.open(
|
||||
csvHeaders.value,
|
||||
currentFile.value ?? undefined,
|
||||
csvData.value,
|
||||
);
|
||||
};
|
||||
|
||||
// 清空数据
|
||||
const handleClearData = () => {
|
||||
csvData.value = [];
|
||||
csvHeaders.value = [];
|
||||
currentFile.value = null;
|
||||
// 更新表格
|
||||
importTaskWizardRef.value?.reset();
|
||||
updateTable();
|
||||
message.success('已清空数据');
|
||||
};
|
||||
|
||||
// 计算表格高度
|
||||
const handleWizardSuccess = () => {
|
||||
csvData.value = [];
|
||||
csvHeaders.value = [];
|
||||
currentFile.value = null;
|
||||
updateTable();
|
||||
message.success('已创建导入任务,可继续上传新文件');
|
||||
};
|
||||
|
||||
const calculateTableHeight = () => {
|
||||
nextTick(() => {
|
||||
if (tableContainerRef.value) {
|
||||
const rect = tableContainerRef.value.getBoundingClientRect();
|
||||
// 减去 padding (1.5rem * 2 = 3rem = 48px) 和其他元素的高度
|
||||
const headerHeight = 100; // 估算表头高度
|
||||
const padding = 48; // 1.5rem * 2
|
||||
const availableHeight = rect.height - padding - headerHeight;
|
||||
tableHeight.value = Math.max(400, availableHeight);
|
||||
const toolbarReserve = 56;
|
||||
const padding = 24;
|
||||
const availableHeight = rect.height - padding - toolbarReserve;
|
||||
tableHeight.value = Math.max(320, availableHeight);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 监听窗口大小变化
|
||||
watch(
|
||||
() => csvData.value.length,
|
||||
(len) => {
|
||||
if (len > 0) {
|
||||
nextTick(() => calculateTableHeight());
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
let resizeObserver: null | ResizeObserver = null;
|
||||
|
||||
onMounted(() => {
|
||||
@@ -230,41 +230,38 @@ onMounted(() => {
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
if (resizeObserver) {
|
||||
resizeObserver.disconnect();
|
||||
}
|
||||
resizeObserver?.disconnect();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="h-full overflow-hidden bg-slate-100 dark:bg-[hsl(222.34deg_10.43%_12.27%)] p-8">
|
||||
<div class="mx-auto flex h-full w-[60%] flex-col overflow-hidden">
|
||||
<!-- 头部标题 -->
|
||||
<div class="mb-12 shrink-0 text-center">
|
||||
<h1 class="mb-2 text-4xl font-black tracking-tight text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||
订单导入中心
|
||||
</h1>
|
||||
<p class="text-base font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
请上传 CSV 格式的订单原始数据进行分析
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<!-- 主体内容区域 -->
|
||||
<Page
|
||||
auto-content-height
|
||||
:content-padding-class="csvData.length === 0 ? 'p-4 sm:p-6' : 'p-2 sm:p-3'"
|
||||
content-class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-slate-100 dark:bg-[hsl(222.34deg_10.43%_12.27%)]"
|
||||
>
|
||||
<!-- 未上传:居中上传 -->
|
||||
<div
|
||||
v-if="csvData.length === 0"
|
||||
class="flex min-h-0 flex-1 flex-col overflow-hidden"
|
||||
class="mx-auto flex min-h-0 w-full max-w-3xl flex-1 flex-col items-center justify-center py-8"
|
||||
>
|
||||
<div class="mb-8 shrink-0">
|
||||
<!-- 导入区域 -->
|
||||
<div class="mb-10 shrink-0 text-center">
|
||||
<h1
|
||||
class="mb-2 text-3xl font-black tracking-tight text-slate-800 dark:text-[hsl(0deg_0%_95%)] sm:text-4xl"
|
||||
>
|
||||
订单导入中心
|
||||
</h1>
|
||||
<p class="text-sm font-medium text-slate-500 dark:text-[hsl(240deg_5%_64.9%)] sm:text-base">
|
||||
请上传 CSV / Excel 格式的订单原始数据
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
class="relative flex min-h-[400px] flex-col items-center justify-center overflow-hidden rounded-[2rem] border border-white/50 bg-white/45 dark:border-[hsl(240deg_3.7%_22%/50%)] dark:bg-[hsl(222.34deg_10.43%_12.27%/80%)] p-8 shadow-[0_25px_50px_-12px_rgba(0,0,0,0.1)] dark:shadow-none backdrop-blur-2xl"
|
||||
class="relative w-full overflow-hidden rounded-[2rem] border border-white/50 bg-white/45 p-6 dark:border-[hsl(240deg_3.7%_22%/50%)] dark:bg-[hsl(222.34deg_10.43%_12.27%/80%)] shadow-[0_25px_50px_-12px_rgba(0,0,0,0.1)] dark:shadow-none backdrop-blur-2xl sm:p-8"
|
||||
>
|
||||
<div
|
||||
class="absolute -right-10 -top-10 h-32 w-32 rounded-full bg-indigo-400 opacity-10 blur-3xl"
|
||||
></div>
|
||||
<div
|
||||
class=":deep(.ant-spin-nested-loading) :deep(.ant-spin-container) w-full"
|
||||
>
|
||||
<div class="relative w-full">
|
||||
<FileUploadArea
|
||||
:loading="importLoading"
|
||||
@file-selected="handleFileUpload"
|
||||
@@ -272,76 +269,52 @@ onUnmounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 数据表格区域 -->
|
||||
<div v-else class="flex min-h-0 w-full flex-1 flex-col overflow-hidden">
|
||||
<!-- 已上传:左表右配置(flex-1 + min-h-0 约束在布局内容高度内,避免撑开外层滚动) -->
|
||||
<div
|
||||
class="mb-6 flex shrink-0 flex-wrap items-start justify-between gap-4"
|
||||
v-else
|
||||
class="flex min-h-0 w-full min-w-0 flex-1 flex-row gap-3 overflow-hidden sm:gap-4"
|
||||
>
|
||||
<div class="flex-1">
|
||||
<h2 class="mb-1 text-2xl font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">数据预览</h2>
|
||||
<p class="m-0 text-sm text-slate-500 dark:text-[hsl(240deg_5%_64.9%)]">
|
||||
共 {{ csvData.length }} 条数据,请检查数据后创建导入任务
|
||||
<section
|
||||
class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden rounded-2xl border border-slate-200/80 bg-white/90 shadow-sm dark:border-[hsl(240deg_3.7%_22%)] dark:bg-[hsl(222.34deg_10.43%_12.27%/90%)]"
|
||||
>
|
||||
<div
|
||||
class="flex shrink-0 flex-wrap items-center justify-between gap-3 border-b border-slate-100 px-4 py-3 dark:border-[hsl(240deg_3.7%_22%)]"
|
||||
>
|
||||
<div class="min-w-0">
|
||||
<h2 class="mb-0.5 text-lg font-bold text-slate-800 dark:text-[hsl(0deg_0%_95%)]">
|
||||
数据预览
|
||||
</h2>
|
||||
<p class="m-0 text-xs text-slate-500 dark:text-[hsl(240deg_5%_64.9%)] sm:text-sm">
|
||||
共 {{ csvData.length }} 条 · 右侧配置导入任务
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<Button @click="handleClearData">清空数据</Button>
|
||||
<Button type="primary" @click="handleCreateImportTask">
|
||||
创建导入任务
|
||||
</Button>
|
||||
</div>
|
||||
<Button size="small" @click="handleClearData">清空数据</Button>
|
||||
</div>
|
||||
<div
|
||||
ref="tableContainerRef"
|
||||
class="flex min-h-0 flex-1 flex-col overflow-hidden rounded-[2rem] border border-white/50 bg-white/45 dark:border-[hsl(240deg_3.7%_22%/50%)] dark:bg-[hsl(222.34deg_10.43%_12.27%/80%)] p-6 shadow-[0_25px_50px_-12px_rgba(0,0,0,0.1)] dark:shadow-none backdrop-blur-2xl"
|
||||
class="flex min-h-0 flex-1 flex-col overflow-hidden p-3 sm:p-4"
|
||||
>
|
||||
<Grid />
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<CreateImportTaskModal ref="createImportTaskModalRef" />
|
||||
<aside
|
||||
class="flex min-h-0 w-[min(100%,440px)] shrink-0 flex-col self-stretch overflow-hidden sm:w-[400px] lg:w-[440px]"
|
||||
>
|
||||
<!-- 单独一层 flex-1,避免多根子组件时侧栏被内容撑出视口 -->
|
||||
<div class="flex min-h-0 flex-1 flex-col overflow-hidden">
|
||||
<ImportTaskWizard
|
||||
ref="importTaskWizardRef"
|
||||
@success="handleWizardSuccess"
|
||||
/>
|
||||
</div>
|
||||
</aside>
|
||||
</div>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 上传区域深度选择器样式 */
|
||||
:deep(.ant-spin-nested-loading),
|
||||
:deep(.ant-spin-container) {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.border-dashed) {
|
||||
background: transparent;
|
||||
border: 2px dashed rgba(99, 102, 241, 0.3);
|
||||
border-radius: 2rem;
|
||||
padding: 3rem;
|
||||
transition: all 0.3s ease;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.border-dashed:hover) {
|
||||
border-color: #6366f1;
|
||||
background: rgba(99, 102, 241, 0.05);
|
||||
transform: scale(1.01);
|
||||
}
|
||||
|
||||
:deep(.border-blue-500) {
|
||||
border-color: #6366f1 !important;
|
||||
background: rgba(99, 102, 241, 0.05) !important;
|
||||
}
|
||||
|
||||
html.dark :deep(.border-dashed) {
|
||||
border-color: hsl(240deg 3.7% 30%);
|
||||
}
|
||||
|
||||
html.dark :deep(.border-dashed:hover) {
|
||||
border-color: #818cf8;
|
||||
background: hsl(240deg 3.7% 15.9% / 15%);
|
||||
}
|
||||
|
||||
/* VxeGrid 表格样式 */
|
||||
:deep(.vxe-grid) {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
|
||||
Reference in New Issue
Block a user