mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 23:09:19 +08:00
1
This commit is contained in:
+10
-11
@@ -41,7 +41,7 @@ const currentRecord = ref<null | OrderStatusVO.Info>(null);
|
||||
const formData = ref<Partial<OrderStatusDTO.Create>>({
|
||||
statusName: '',
|
||||
description: '',
|
||||
isActive: 1,
|
||||
isDefaultStat: 1,
|
||||
sortOrder: 0,
|
||||
});
|
||||
|
||||
@@ -66,13 +66,13 @@ function open(edit: boolean, record?: OrderStatusVO.Info) {
|
||||
? {
|
||||
statusName: record.statusName,
|
||||
description: record.description || '',
|
||||
isActive: record.isActive,
|
||||
isDefaultStat: record.isDefaultStat,
|
||||
sortOrder: record.sortOrder || 0,
|
||||
}
|
||||
: {
|
||||
statusName: '',
|
||||
description: '',
|
||||
isActive: 1,
|
||||
isDefaultStat: 1,
|
||||
sortOrder: 0,
|
||||
};
|
||||
}
|
||||
@@ -93,20 +93,19 @@ async function handleSubmit() {
|
||||
if (isEdit.value && currentRecord.value) {
|
||||
// 更新订单状态
|
||||
const updateData: OrderStatusDTO.Update = {
|
||||
id: currentRecord.value.id,
|
||||
statusName: formData.value.statusName!,
|
||||
description: formData.value.description,
|
||||
isActive: formData.value.isActive,
|
||||
isDefaultStat: formData.value.isDefaultStat!,
|
||||
sortOrder: formData.value.sortOrder,
|
||||
};
|
||||
await updateOrderStatusApi(updateData);
|
||||
await updateOrderStatusApi(currentRecord.value.id, updateData);
|
||||
message.success('更新订单状态成功');
|
||||
} else {
|
||||
// 创建订单状态
|
||||
const createData: OrderStatusDTO.Create = {
|
||||
statusName: formData.value.statusName!,
|
||||
description: formData.value.description,
|
||||
isActive: formData.value.isActive,
|
||||
isDefaultStat: formData.value.isDefaultStat!,
|
||||
sortOrder: formData.value.sortOrder,
|
||||
};
|
||||
await createOrderStatusApi(createData);
|
||||
@@ -177,13 +176,13 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="启用状态" name="isActive">
|
||||
<Form.Item label="默认参与统计" name="isDefaultStat">
|
||||
<Switch
|
||||
v-model:checked="formData.isActive"
|
||||
v-model:checked="formData.isDefaultStat"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
checked-children="启用"
|
||||
un-checked-children="禁用"
|
||||
checked-children="参与"
|
||||
un-checked-children="不参与"
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
+12
-12
@@ -52,9 +52,9 @@ const gridOptions: VxeGridProps<any> = {
|
||||
minWidth: 'auto',
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
title: '是否默认参与统计',
|
||||
minWidth: 'auto',
|
||||
slots: { default: 'status' },
|
||||
slots: { default: 'isDefaultStat' },
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
@@ -128,15 +128,15 @@ const formOptions = computed(() => ({
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择状态',
|
||||
placeholder: '请选择是否参与统计',
|
||||
options: [
|
||||
{ label: '启用', value: 1 },
|
||||
{ label: '禁用', value: 0 },
|
||||
{ label: '参与默认统计', value: 1 },
|
||||
{ label: '不参默认与统计', value: 0 },
|
||||
],
|
||||
allowClear: true,
|
||||
},
|
||||
fieldName: 'isActive',
|
||||
label: '状态',
|
||||
fieldName: 'isDefaultStat',
|
||||
label: '是否参与默认统计',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
@@ -191,7 +191,7 @@ function handleModalSuccess() {
|
||||
<Page title="订单状态配置" auto-content-height>
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2">
|
||||
管理订单状态类型,包括状态名称、描述和启用状态
|
||||
管理订单状态类型,包括状态名称、描述和是否默认参与统计
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -207,10 +207,10 @@ function handleModalSuccess() {
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<!-- 状态列 -->
|
||||
<template #status="{ row }: { row: any }">
|
||||
<Tag :color="row.isActive === 1 ? 'green' : 'red'">
|
||||
{{ row.isActive === 1 ? '启用' : '禁用' }}
|
||||
<!-- 是否默认参与统计列 -->
|
||||
<template #isDefaultStat="{ row }: { row: OrderStatusVO.Info }">
|
||||
<Tag :color="row.isDefaultStat === 1 ? 'green' : 'default'">
|
||||
{{ row.isDefaultStat === 1 ? '参与统计' : '不参与统计' }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
|
||||
+514
-51
@@ -5,6 +5,7 @@ import type {
|
||||
ImportMappingVO,
|
||||
} from '#/api/ecommerce/import-mapping';
|
||||
import type { ImportTaskDTO } from '#/api/ecommerce/import-task';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
@@ -25,8 +26,11 @@ import { getFieldDefsByTypeApi } from '#/api/ecommerce/import-field-def';
|
||||
import {
|
||||
createImportMappingApi,
|
||||
getImportMappingPageApi,
|
||||
ImportMappingType,
|
||||
updateImportMappingApi,
|
||||
} from '#/api/ecommerce/import-mapping';
|
||||
import { createImportTaskApi } from '#/api/ecommerce/import-task';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
import { uploadFileApi } from '#/api/media/file';
|
||||
import { useImportTaskStore } from '#/store';
|
||||
@@ -43,6 +47,14 @@ interface FieldMappingItem {
|
||||
required: boolean;
|
||||
}
|
||||
|
||||
// 定义订单状态映射项数据结构
|
||||
interface StatusMappingItem {
|
||||
/** CSV中的订单状态值 */
|
||||
csvStatus: string;
|
||||
/** 映射到的订单状态ID */
|
||||
mappedStatusId: number;
|
||||
}
|
||||
|
||||
defineOptions({ name: 'CreateImportTaskModal' });
|
||||
|
||||
// 创建 vben modal
|
||||
@@ -60,6 +72,7 @@ const [Modal, modalApi] = useVbenModal({
|
||||
const currentStep = ref(0);
|
||||
const loading = ref(false);
|
||||
const csvHeaders = ref<string[]>([]);
|
||||
const csvData = ref<any[]>([]);
|
||||
const selectedFile = ref<File | null>(null);
|
||||
|
||||
// 第一步:店铺选择
|
||||
@@ -90,6 +103,18 @@ const templateLoading = ref(false);
|
||||
const savingTemplate = ref(false);
|
||||
const templateName = ref('');
|
||||
|
||||
// 第三步:订单状态映射
|
||||
const statusMappings = ref<Record<string, number>>({});
|
||||
const uniqueStatusValues = ref<string[]>([]);
|
||||
const statusMappingTemplates = ref<ImportMappingVO.ImportMappingInfoVO[]>([]);
|
||||
const selectedStatusTemplateId = ref<number | undefined>();
|
||||
const statusTemplateLoading = ref(false);
|
||||
const savingStatusTemplate = ref(false);
|
||||
const statusTemplateName = ref('');
|
||||
// 订单状态列表
|
||||
const orderStatusList = ref<OrderStatusVO.Info[]>([]);
|
||||
const orderStatusLoading = ref(false);
|
||||
|
||||
// 创建保存模板的 vben modal
|
||||
const [SaveTemplateModal, saveTemplateModalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
@@ -106,8 +131,21 @@ const [SaveTemplateModal, saveTemplateModalApi] = useVbenModal({
|
||||
},
|
||||
});
|
||||
|
||||
// 表单引用
|
||||
const formRef = ref();
|
||||
// 创建保存订单状态映射模板的 vben modal
|
||||
const [SaveStatusTemplateModal, saveStatusTemplateModalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[500px]',
|
||||
title: '保存订单状态映射模板',
|
||||
showCancelButton: true,
|
||||
showConfirmButton: true,
|
||||
confirmText: '保存',
|
||||
cancelText: '取消',
|
||||
onConfirm: handleConfirmSaveStatusTemplate,
|
||||
onCancel() {
|
||||
statusTemplateName.value = '';
|
||||
saveStatusTemplateModalApi.close();
|
||||
},
|
||||
});
|
||||
|
||||
// 导入任务store
|
||||
const importTaskStore = useImportTaskStore();
|
||||
@@ -124,6 +162,12 @@ const canGoToNextStep = computed(() => {
|
||||
return mapping && mapping.mappedHeader;
|
||||
});
|
||||
}
|
||||
if (currentStep.value === 2) {
|
||||
// 订单状态映射步骤:所有唯一的订单状态值都必须映射
|
||||
return uniqueStatusValues.value.every(
|
||||
(status) => statusMappings.value[status] !== undefined,
|
||||
);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
|
||||
@@ -230,10 +274,19 @@ const fetchMappingTemplates = async () => {
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
filters: {
|
||||
type: 'order',
|
||||
type: ImportMappingType.ORDER,
|
||||
},
|
||||
});
|
||||
mappingTemplates.value = result.records || [];
|
||||
|
||||
// 修复:自动选择第一个模板并应用
|
||||
if (mappingTemplates.value.length > 0 && !selectedTemplateId.value) {
|
||||
const firstTemplate = mappingTemplates.value[0];
|
||||
if (firstTemplate?.id) {
|
||||
selectedTemplateId.value = firstTemplate.id;
|
||||
await handleSelectTemplate(firstTemplate.id);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取映射模板列表失败:', error);
|
||||
message.error('获取映射模板列表失败');
|
||||
@@ -242,10 +295,62 @@ const fetchMappingTemplates = async () => {
|
||||
}
|
||||
};
|
||||
|
||||
// 获取订单状态列表
|
||||
const fetchOrderStatusList = async () => {
|
||||
if (orderStatusLoading.value) return;
|
||||
|
||||
try {
|
||||
orderStatusLoading.value = true;
|
||||
const result = await getAllOrderStatusListApi();
|
||||
orderStatusList.value = result || [];
|
||||
} catch (error) {
|
||||
console.error('获取订单状态列表失败:', error);
|
||||
message.error('获取订单状态列表失败');
|
||||
} finally {
|
||||
orderStatusLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 获取订单状态映射模板列表
|
||||
const fetchStatusMappingTemplates = async () => {
|
||||
try {
|
||||
statusTemplateLoading.value = true;
|
||||
const result = await getImportMappingPageApi({
|
||||
page: 1,
|
||||
pageSize: 100,
|
||||
filters: {
|
||||
type: ImportMappingType.ORDER_STATUS,
|
||||
},
|
||||
});
|
||||
statusMappingTemplates.value = result.records || [];
|
||||
|
||||
// 修复:自动选择第一个模板并应用
|
||||
if (
|
||||
statusMappingTemplates.value.length > 0 &&
|
||||
!selectedStatusTemplateId.value
|
||||
) {
|
||||
const firstTemplate = statusMappingTemplates.value[0];
|
||||
if (firstTemplate?.id) {
|
||||
selectedStatusTemplateId.value = firstTemplate.id;
|
||||
await handleSelectStatusTemplate(firstTemplate.id);
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取订单状态映射模板列表失败:', error);
|
||||
message.error('获取订单状态映射模板列表失败');
|
||||
} finally {
|
||||
statusTemplateLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 选择映射模板
|
||||
const handleSelectTemplate = async (value: any) => {
|
||||
const templateId = typeof value === 'number' ? value : undefined;
|
||||
if (!templateId) {
|
||||
// 如果清空选择,重置映射
|
||||
if (fieldDefs.value.length > 0) {
|
||||
initFieldMappings();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -290,7 +395,43 @@ const handleSelectTemplate = async (value: any) => {
|
||||
}
|
||||
};
|
||||
|
||||
// 打开保存模板模态框
|
||||
// 选择订单状态映射模板
|
||||
const handleSelectStatusTemplate = async (value: any) => {
|
||||
const templateId = typeof value === 'number' ? value : undefined;
|
||||
if (!templateId) {
|
||||
// 如果清空选择,重置映射
|
||||
statusMappings.value = {};
|
||||
return;
|
||||
}
|
||||
|
||||
const template = statusMappingTemplates.value.find(
|
||||
(t) => t.id === templateId,
|
||||
);
|
||||
if (!template) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
// 解析模板的 mapping JSON
|
||||
const mappingItems: StatusMappingItem[] = JSON.parse(template.mapping);
|
||||
|
||||
// 根据模板填充订单状态映射
|
||||
const mappings: typeof statusMappings.value = {};
|
||||
mappingItems.forEach((item) => {
|
||||
if (uniqueStatusValues.value.includes(item.csvStatus)) {
|
||||
mappings[item.csvStatus] = item.mappedStatusId;
|
||||
}
|
||||
});
|
||||
|
||||
statusMappings.value = mappings;
|
||||
message.success('已应用订单状态映射模板');
|
||||
} catch (error) {
|
||||
console.error('应用订单状态映射模板失败:', error);
|
||||
message.error('应用订单状态映射模板失败,模板格式可能不正确');
|
||||
}
|
||||
};
|
||||
|
||||
// 打开保存/更新模板模态框
|
||||
const handleSaveTemplate = () => {
|
||||
// 验证是否有映射数据
|
||||
const mappingItems: FieldMappingItem[] = Object.values(fieldMappings.value)
|
||||
@@ -307,11 +448,46 @@ const handleSaveTemplate = () => {
|
||||
return;
|
||||
}
|
||||
|
||||
templateName.value = '';
|
||||
// 如果选择了模板,使用模板名称;否则清空
|
||||
if (selectedTemplateId.value) {
|
||||
const template = mappingTemplates.value.find(
|
||||
(t) => t.id === selectedTemplateId.value,
|
||||
);
|
||||
templateName.value = template?.name || '';
|
||||
} else {
|
||||
templateName.value = '';
|
||||
}
|
||||
saveTemplateModalApi.open();
|
||||
};
|
||||
|
||||
// 确认保存映射模板
|
||||
// 打开保存/更新订单状态映射模板模态框
|
||||
const handleSaveStatusTemplate = () => {
|
||||
// 验证是否有映射数据
|
||||
const mappingItems: StatusMappingItem[] = uniqueStatusValues.value
|
||||
.filter((status) => statusMappings.value[status] !== undefined)
|
||||
.map((status) => ({
|
||||
csvStatus: status,
|
||||
mappedStatusId: statusMappings.value[status]!,
|
||||
}));
|
||||
|
||||
if (mappingItems.length === 0) {
|
||||
message.warning('请先完成订单状态映射');
|
||||
return;
|
||||
}
|
||||
|
||||
// 如果选择了模板,使用模板名称;否则清空
|
||||
if (selectedStatusTemplateId.value) {
|
||||
const template = statusMappingTemplates.value.find(
|
||||
(t) => t.id === selectedStatusTemplateId.value,
|
||||
);
|
||||
statusTemplateName.value = template?.name || '';
|
||||
} else {
|
||||
statusTemplateName.value = '';
|
||||
}
|
||||
saveStatusTemplateModalApi.open();
|
||||
};
|
||||
|
||||
// 确认保存/更新映射模板
|
||||
async function handleConfirmSaveTemplate() {
|
||||
if (!templateName.value.trim()) {
|
||||
message.warning('请输入模板名称');
|
||||
@@ -346,58 +522,209 @@ async function handleConfirmSaveTemplate() {
|
||||
required: m.fieldDef.required,
|
||||
}));
|
||||
|
||||
const createData: ImportMappingDTO.CreateImportMappingDTO = {
|
||||
type: 'order',
|
||||
name: templateName.value.trim(),
|
||||
mapping: JSON.stringify(mappingItems),
|
||||
};
|
||||
const mappingJson = JSON.stringify(mappingItems);
|
||||
|
||||
// 如果选择了模板,则更新;否则创建
|
||||
if (selectedTemplateId.value) {
|
||||
await updateImportMappingApi(selectedTemplateId.value, {
|
||||
name: templateName.value.trim(),
|
||||
mapping: mappingJson,
|
||||
});
|
||||
message.success('更新映射模板成功');
|
||||
} else {
|
||||
const createData: ImportMappingDTO.CreateImportMappingDTO = {
|
||||
type: ImportMappingType.ORDER,
|
||||
name: templateName.value.trim(),
|
||||
mapping: mappingJson,
|
||||
};
|
||||
await createImportMappingApi(createData);
|
||||
message.success('保存映射模板成功');
|
||||
}
|
||||
|
||||
await createImportMappingApi(createData);
|
||||
message.success('保存映射模板成功');
|
||||
templateName.value = '';
|
||||
saveTemplateModalApi.close();
|
||||
// 刷新模板列表
|
||||
await fetchMappingTemplates();
|
||||
// 清空选中的模板
|
||||
selectedTemplateId.value = undefined;
|
||||
// 如果是更新,保持选中状态;如果是创建,清空选中
|
||||
if (!selectedTemplateId.value) {
|
||||
selectedTemplateId.value = undefined;
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('保存映射模板失败:', error);
|
||||
message.error(error?.message || '保存映射模板失败');
|
||||
console.error('保存/更新映射模板失败:', error);
|
||||
message.error(error?.message || '保存/更新映射模板失败');
|
||||
} finally {
|
||||
savingTemplate.value = false;
|
||||
saveTemplateModalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// 确认保存/更新订单状态映射模板
|
||||
async function handleConfirmSaveStatusTemplate() {
|
||||
if (!statusTemplateName.value.trim()) {
|
||||
message.warning('请输入模板名称');
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证所有订单状态是否都已映射
|
||||
const unMappedStatuses = uniqueStatusValues.value.filter(
|
||||
(status) => statusMappings.value[status] === undefined,
|
||||
);
|
||||
|
||||
if (unMappedStatuses.length > 0) {
|
||||
message.warning(`请先映射所有订单状态:${unMappedStatuses.join('、')}`);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
savingStatusTemplate.value = true;
|
||||
saveStatusTemplateModalApi.lock();
|
||||
|
||||
// 构建映射数据(已验证所有状态都已映射,所以不会有 undefined)
|
||||
const mappingItems: StatusMappingItem[] = uniqueStatusValues.value.map(
|
||||
(status) => ({
|
||||
csvStatus: status,
|
||||
mappedStatusId: statusMappings.value[status]!,
|
||||
}),
|
||||
);
|
||||
|
||||
const mappingJson = JSON.stringify(mappingItems);
|
||||
|
||||
// 如果选择了模板,则更新;否则创建
|
||||
if (selectedStatusTemplateId.value) {
|
||||
await updateImportMappingApi(selectedStatusTemplateId.value, {
|
||||
name: statusTemplateName.value.trim(),
|
||||
mapping: mappingJson,
|
||||
});
|
||||
message.success('更新订单状态映射模板成功');
|
||||
} else {
|
||||
const createData: ImportMappingDTO.CreateImportMappingDTO = {
|
||||
type: ImportMappingType.ORDER_STATUS,
|
||||
name: statusTemplateName.value.trim(),
|
||||
mapping: mappingJson,
|
||||
};
|
||||
await createImportMappingApi(createData);
|
||||
message.success('保存订单状态映射模板成功');
|
||||
}
|
||||
|
||||
statusTemplateName.value = '';
|
||||
saveStatusTemplateModalApi.close();
|
||||
// 刷新模板列表
|
||||
await fetchStatusMappingTemplates();
|
||||
// 如果是更新,保持选中状态;如果是创建,清空选中
|
||||
if (!selectedStatusTemplateId.value) {
|
||||
selectedStatusTemplateId.value = undefined;
|
||||
}
|
||||
} catch (error: any) {
|
||||
console.error('保存/更新订单状态映射模板失败:', error);
|
||||
message.error(error?.message || '保存/更新订单状态映射模板失败');
|
||||
} finally {
|
||||
savingStatusTemplate.value = false;
|
||||
saveStatusTemplateModalApi.unlock();
|
||||
}
|
||||
}
|
||||
|
||||
// 解析订单状态:从CSV数据中提取status字段映射列的所有唯一值
|
||||
const parseOrderStatuses = () => {
|
||||
// 查找status字段的映射
|
||||
const statusFieldDef = fieldDefs.value.find((f) => f.fieldName === 'status');
|
||||
if (!statusFieldDef) {
|
||||
uniqueStatusValues.value = [];
|
||||
statusMappings.value = {};
|
||||
return;
|
||||
}
|
||||
|
||||
const statusMapping = fieldMappings.value[statusFieldDef.id];
|
||||
if (!statusMapping || !statusMapping.mappedHeader) {
|
||||
uniqueStatusValues.value = [];
|
||||
statusMappings.value = {};
|
||||
return;
|
||||
}
|
||||
|
||||
// 从CSV数据中提取该列的所有唯一值
|
||||
const statusColumn = statusMapping.mappedHeader;
|
||||
const statusSet = new Set<string>();
|
||||
|
||||
csvData.value.forEach((row) => {
|
||||
const statusValue = row[statusColumn];
|
||||
if (
|
||||
statusValue !== null &&
|
||||
statusValue !== undefined &&
|
||||
statusValue !== ''
|
||||
) {
|
||||
statusSet.add(String(statusValue).trim());
|
||||
}
|
||||
});
|
||||
|
||||
uniqueStatusValues.value = [...statusSet].sort();
|
||||
|
||||
// 重置订单状态映射
|
||||
statusMappings.value = {};
|
||||
};
|
||||
|
||||
// 下一步
|
||||
const handleNext = () => {
|
||||
if (currentStep.value === 0) {
|
||||
if (!selectedShopId.value) {
|
||||
message.warning('请选择店铺');
|
||||
return;
|
||||
switch (currentStep.value) {
|
||||
case 0: {
|
||||
if (!selectedShopId.value) {
|
||||
message.warning('请选择店铺');
|
||||
return;
|
||||
}
|
||||
currentStep.value = 1;
|
||||
if (fieldDefs.value.length === 0) {
|
||||
fetchFieldDefs();
|
||||
}
|
||||
// 加载映射模板列表
|
||||
if (mappingTemplates.value.length === 0) {
|
||||
fetchMappingTemplates();
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
currentStep.value = 1;
|
||||
if (fieldDefs.value.length === 0) {
|
||||
fetchFieldDefs();
|
||||
case 1: {
|
||||
// 验证必填字段
|
||||
const requiredFields = fieldDefs.value.filter((f) => f.required);
|
||||
const unMappedFields = requiredFields.filter((field) => {
|
||||
const mapping = fieldMappings.value[field.id];
|
||||
return !mapping || !mapping.mappedHeader;
|
||||
});
|
||||
if (unMappedFields.length > 0) {
|
||||
message.warning(
|
||||
`请先绑定必填字段:${unMappedFields.map((f) => f.fieldLabel).join('、')}`,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
// 在进入订单状态映射步骤前,解析所有订单状态
|
||||
parseOrderStatuses();
|
||||
|
||||
// 加载订单状态列表
|
||||
if (orderStatusList.value.length === 0) {
|
||||
fetchOrderStatusList();
|
||||
}
|
||||
|
||||
// 加载订单状态映射模板列表
|
||||
if (statusMappingTemplates.value.length === 0) {
|
||||
fetchStatusMappingTemplates();
|
||||
}
|
||||
|
||||
currentStep.value = 2;
|
||||
|
||||
break;
|
||||
}
|
||||
// 加载映射模板列表
|
||||
if (mappingTemplates.value.length === 0) {
|
||||
fetchMappingTemplates();
|
||||
}
|
||||
} else if (currentStep.value === 1) {
|
||||
// 验证必填字段
|
||||
const requiredFields = fieldDefs.value.filter((f) => f.required);
|
||||
const unMappedFields = requiredFields.filter((field) => {
|
||||
const mapping = fieldMappings.value[field.id];
|
||||
return !mapping || !mapping.mappedHeader;
|
||||
});
|
||||
if (unMappedFields.length > 0) {
|
||||
message.warning(
|
||||
`请先绑定必填字段:${unMappedFields.map((f) => f.fieldLabel).join('、')}`,
|
||||
case 2: {
|
||||
// 验证所有订单状态是否都已映射
|
||||
const unMappedStatuses = uniqueStatusValues.value.filter(
|
||||
(status) => statusMappings.value[status] === undefined,
|
||||
);
|
||||
return;
|
||||
if (unMappedStatuses.length > 0) {
|
||||
message.warning(`请先映射所有订单状态:${unMappedStatuses.join('、')}`);
|
||||
return;
|
||||
}
|
||||
currentStep.value = 3;
|
||||
|
||||
break;
|
||||
}
|
||||
currentStep.value = 2;
|
||||
// No default
|
||||
}
|
||||
};
|
||||
|
||||
@@ -454,12 +781,25 @@ const handleCreateTask = async () => {
|
||||
required: m.fieldDef.required,
|
||||
}));
|
||||
|
||||
// 构建订单状态映射 JSON(已验证所有状态都已映射,所以不会有 undefined)
|
||||
const statusMappingItems: StatusMappingItem[] =
|
||||
uniqueStatusValues.value.map((status) => ({
|
||||
csvStatus: status,
|
||||
mappedStatusId: statusMappings.value[status]!,
|
||||
}));
|
||||
|
||||
// 构建完整的映射JSON,包含字段映射和订单状态映射
|
||||
const fullMapping = {
|
||||
fieldMapping: mappingItems,
|
||||
statusMapping: statusMappingItems,
|
||||
};
|
||||
|
||||
const createData: ImportTaskDTO.CreateImportTaskDTO = {
|
||||
shopId: selectedShopId.value!,
|
||||
type: 'order',
|
||||
fileName: selectedFile.value.name,
|
||||
filePath: fileInfo.url,
|
||||
mapping: JSON.stringify(mappingItems),
|
||||
mapping: JSON.stringify(fullMapping),
|
||||
};
|
||||
|
||||
const task = await createImportTaskApi(createData);
|
||||
@@ -478,8 +818,13 @@ const handleCreateTask = async () => {
|
||||
currentStep.value = 0;
|
||||
selectedShopId.value = undefined;
|
||||
fieldMappings.value = {};
|
||||
statusMappings.value = {};
|
||||
uniqueStatusValues.value = [];
|
||||
csvHeaders.value = [];
|
||||
csvData.value = [];
|
||||
selectedFile.value = null;
|
||||
selectedTemplateId.value = undefined;
|
||||
selectedStatusTemplateId.value = undefined;
|
||||
modalApi.close();
|
||||
} catch (error: any) {
|
||||
message.destroy();
|
||||
@@ -491,17 +836,20 @@ const handleCreateTask = async () => {
|
||||
};
|
||||
|
||||
// 暴露给父组件的方法
|
||||
function open(headers: string[], file?: File) {
|
||||
function open(headers: string[], file?: File, data?: any[]) {
|
||||
const headersChanged =
|
||||
JSON.stringify(csvHeaders.value) !== JSON.stringify(headers);
|
||||
|
||||
csvHeaders.value = headers;
|
||||
csvData.value = data || [];
|
||||
selectedFile.value = file || null;
|
||||
// 步骤保持不变,不清空
|
||||
|
||||
// 如果 CSV 表头变化了,需要重新初始化字段映射
|
||||
if (headersChanged) {
|
||||
fieldMappings.value = {};
|
||||
statusMappings.value = {};
|
||||
uniqueStatusValues.value = [];
|
||||
// 如果已有字段定义,重新初始化映射
|
||||
if (fieldDefs.value.length > 0) {
|
||||
initFieldMappings();
|
||||
@@ -543,16 +891,13 @@ const shopOptions = computed(() => {
|
||||
<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
|
||||
ref="formRef"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
|
||||
<Form.Item label="选择店铺" required>
|
||||
<Select
|
||||
v-model:value="selectedShopId"
|
||||
@@ -620,7 +965,10 @@ const shopOptions = computed(() => {
|
||||
</span>
|
||||
</Select.Option>
|
||||
</Select>
|
||||
<Button @click="handleSaveTemplate">保存为模板</Button>
|
||||
<Button v-if="!selectedTemplateId" @click="handleSaveTemplate">
|
||||
保存为模板
|
||||
</Button>
|
||||
<Button v-else @click="handleSaveTemplate"> 更新模板 </Button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="max-h-[400px] space-y-4 overflow-y-auto">
|
||||
@@ -662,8 +1010,89 @@ const shopOptions = computed(() => {
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 第三步:确认信息 -->
|
||||
<!-- 第三步:订单状态映射 -->
|
||||
<div v-if="currentStep === 2" class="py-4">
|
||||
<div class="mb-4 flex items-center justify-between">
|
||||
<div class="text-sm text-gray-600">
|
||||
请为每个订单状态值映射到对应的系统订单状态,所有状态必须映射
|
||||
</div>
|
||||
<div class="flex items-center space-x-2">
|
||||
<Select
|
||||
v-model:value="selectedStatusTemplateId"
|
||||
placeholder="选择已有模板"
|
||||
class="w-[200px]"
|
||||
:loading="statusTemplateLoading"
|
||||
allow-clear
|
||||
@change="handleSelectStatusTemplate"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="statusTemplateLoading" 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">
|
||||
暂无模板
|
||||
</div>
|
||||
</template>
|
||||
<Select.Option
|
||||
v-for="template in statusMappingTemplates"
|
||||
:key="template.id"
|
||||
:value="template.id"
|
||||
>
|
||||
{{ template.name }}
|
||||
<span class="ml-2 text-xs text-gray-400">
|
||||
({{ new Date(template.createTime).toLocaleDateString() }})
|
||||
</span>
|
||||
</Select.Option>
|
||||
</Select>
|
||||
<Button
|
||||
v-if="!selectedStatusTemplateId"
|
||||
@click="handleSaveStatusTemplate"
|
||||
>
|
||||
保存为模板
|
||||
</Button>
|
||||
<Button v-else @click="handleSaveStatusTemplate"> 更新模板 </Button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
v-if="uniqueStatusValues.length === 0"
|
||||
class="py-8 text-center text-gray-400"
|
||||
>
|
||||
未找到订单状态字段映射,请先在字段映射步骤中绑定status字段
|
||||
</div>
|
||||
<div v-else class="max-h-[400px] space-y-4 overflow-y-auto">
|
||||
<div
|
||||
v-for="statusValue in uniqueStatusValues"
|
||||
:key="statusValue"
|
||||
class="flex items-center space-x-4 rounded border p-3"
|
||||
:class="{
|
||||
'border-red-300 bg-red-50':
|
||||
statusMappings[statusValue] === undefined,
|
||||
}"
|
||||
>
|
||||
<div class="flex-1">
|
||||
<div class="font-medium">{{ statusValue }}</div>
|
||||
<div class="mt-1 text-xs text-gray-500">CSV中的订单状态值</div>
|
||||
</div>
|
||||
<Select
|
||||
v-model:value="statusMappings[statusValue]"
|
||||
placeholder="请选择订单状态"
|
||||
class="w-[200px]"
|
||||
show-search
|
||||
:loading="orderStatusLoading"
|
||||
:options="
|
||||
orderStatusList.map((status) => ({
|
||||
label: status.statusName,
|
||||
value: status.id,
|
||||
}))
|
||||
"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 第四步:确认信息 -->
|
||||
<div v-if="currentStep === 3" class="py-4">
|
||||
<div class="space-y-4">
|
||||
<div class="rounded bg-gray-50 p-4">
|
||||
<div class="mb-2 font-medium">店铺信息</div>
|
||||
@@ -691,6 +1120,25 @@ const shopOptions = computed(() => {
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="rounded bg-gray-50 p-4">
|
||||
<div class="mb-2 font-medium">订单状态映射</div>
|
||||
<div class="space-y-2">
|
||||
<div
|
||||
v-for="statusValue in uniqueStatusValues"
|
||||
:key="statusValue"
|
||||
class="flex justify-between text-sm"
|
||||
>
|
||||
<span class="text-gray-600">{{ statusValue }}:</span>
|
||||
<span class="font-medium">
|
||||
{{
|
||||
orderStatusList.find(
|
||||
(status) => status.id === statusMappings[statusValue],
|
||||
)?.statusName ?? '-'
|
||||
}}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -700,7 +1148,7 @@ const shopOptions = computed(() => {
|
||||
<div class="space-x-2">
|
||||
<Button v-if="currentStep > 0" @click="handlePrev">上一步</Button>
|
||||
<Button
|
||||
v-if="currentStep < 2"
|
||||
v-if="currentStep < 3"
|
||||
type="primary"
|
||||
:disabled="!canGoToNextStep"
|
||||
@click="handleNext"
|
||||
@@ -708,7 +1156,7 @@ const shopOptions = computed(() => {
|
||||
下一步
|
||||
</Button>
|
||||
<Button
|
||||
v-if="currentStep === 2"
|
||||
v-if="currentStep === 3"
|
||||
type="primary"
|
||||
:loading="loading"
|
||||
@click="handleCreateTask"
|
||||
@@ -733,6 +1181,21 @@ const shopOptions = computed(() => {
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</SaveTemplateModal>
|
||||
|
||||
<!-- 保存订单状态映射模板模态框 -->
|
||||
<SaveStatusTemplateModal :confirm-loading="savingStatusTemplate">
|
||||
<Form :label-col="{ span: 6 }" :wrapper-col="{ span: 18 }">
|
||||
<Form.Item label="模板名称" required>
|
||||
<Input
|
||||
v-model:value="statusTemplateName"
|
||||
placeholder="请输入模板名称"
|
||||
:maxlength="50"
|
||||
show-count
|
||||
@press-enter="handleConfirmSaveStatusTemplate"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</SaveStatusTemplateModal>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -170,21 +170,40 @@ const handleCreateImportTask = () => {
|
||||
createImportTaskModalRef.value?.open(
|
||||
csvHeaders.value,
|
||||
currentFile.value ?? undefined,
|
||||
csvData.value,
|
||||
);
|
||||
};
|
||||
|
||||
// 清空数据
|
||||
const handleClearData = () => {
|
||||
csvData.value = [];
|
||||
csvHeaders.value = [];
|
||||
currentFile.value = null;
|
||||
// 更新表格
|
||||
updateTable();
|
||||
message.success('已清空数据');
|
||||
};
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<!-- 顶部栏 -->
|
||||
<template #extra>
|
||||
<Button
|
||||
type="primary"
|
||||
:disabled="csvHeaders.length === 0"
|
||||
@click="handleCreateImportTask"
|
||||
>
|
||||
创建导入任务
|
||||
</Button>
|
||||
<div class="flex items-center space-x-2">
|
||||
<Button
|
||||
:disabled="csvData.length === 0"
|
||||
@click="handleClearData"
|
||||
>
|
||||
清空数据
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
:disabled="csvHeaders.length === 0"
|
||||
@click="handleCreateImportTask"
|
||||
>
|
||||
创建导入任务
|
||||
</Button>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 主体内容区域 -->
|
||||
|
||||
+53
-47
@@ -1,6 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { OrderDTO, OrderVO } from '#/api/ecommerce/order';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status';
|
||||
import type {
|
||||
ProductSpecDTO,
|
||||
ProductSpecVO,
|
||||
@@ -24,8 +23,12 @@ import {
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { createOrderApi, updateOrderApi } from '#/api/ecommerce/order';
|
||||
import { getActiveOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import {
|
||||
createOrderApi,
|
||||
updateOrderApi,
|
||||
} from '#/api/ecommerce/order';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
|
||||
import { getProductPageApi } from '#/api/ecommerce/product';
|
||||
import { getProductSpecPageApi } from '#/api/ecommerce/product-spec';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
@@ -56,13 +59,13 @@ const currentRecord = ref<null | OrderVO.Info>(null);
|
||||
const formData = ref<Partial<OrderDTO.Create>>({
|
||||
shopId: undefined,
|
||||
platformOrderNo: '',
|
||||
statusId: undefined,
|
||||
statusId: undefined as number | undefined,
|
||||
receivedAmount: 0,
|
||||
orderDate: dayjs().format('YYYY-MM-DD'),
|
||||
orderTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: undefined,
|
||||
productSpecId: undefined,
|
||||
productName: '',
|
||||
specName: '',
|
||||
linkProductName: '',
|
||||
linkSpecName: '',
|
||||
quantity: 1,
|
||||
unitPrice: 0,
|
||||
costPrice: 0,
|
||||
@@ -93,9 +96,11 @@ const rules = {
|
||||
receivedAmount: [
|
||||
{ required: true, message: '请输入实收金额', trigger: 'blur' },
|
||||
],
|
||||
orderDate: [{ required: true, message: '请选择下单时间', trigger: 'change' }],
|
||||
orderTime: [{ required: true, message: '请选择下单时间', trigger: 'change' }],
|
||||
productId: [{ required: true, message: '请选择商品', trigger: 'change' }],
|
||||
productName: [{ required: true, message: '请输入商品名称', trigger: 'blur' }],
|
||||
linkProductName: [
|
||||
{ required: true, message: '请输入链接商品名称', trigger: 'blur' },
|
||||
],
|
||||
quantity: [{ required: true, message: '请输入数量', trigger: 'blur' }],
|
||||
unitPrice: [{ required: true, message: '请输入销售单价', trigger: 'blur' }],
|
||||
costPrice: [{ required: true, message: '请输入成本价', trigger: 'blur' }],
|
||||
@@ -125,7 +130,7 @@ async function fetchShopOptions() {
|
||||
// 获取订单状态选项
|
||||
async function fetchOrderStatusOptions() {
|
||||
try {
|
||||
const data = await getActiveOrderStatusListApi();
|
||||
const data = await getAllOrderStatusListApi();
|
||||
orderStatusOptions.value = data.map((status: OrderStatusVO.Info) => ({
|
||||
label: status.statusName,
|
||||
value: status.id,
|
||||
@@ -199,14 +204,14 @@ function handleProductChange(productId: number | undefined) {
|
||||
(opt) => opt.value === productId,
|
||||
);
|
||||
if (selectedProduct) {
|
||||
formData.value.productName = selectedProduct.product.name;
|
||||
formData.value.linkProductName = selectedProduct.product.name;
|
||||
// 加载该商品的规格列表
|
||||
searchProductSpecs('');
|
||||
}
|
||||
} else {
|
||||
formData.value.productName = '';
|
||||
formData.value.linkProductName = '';
|
||||
formData.value.productSpecId = undefined;
|
||||
formData.value.specName = '';
|
||||
formData.value.linkSpecName = '';
|
||||
formData.value.costPrice = 0;
|
||||
productSpecOptions.value = [];
|
||||
}
|
||||
@@ -219,11 +224,11 @@ function handleProductSpecChange(specId: number | undefined) {
|
||||
(opt) => opt.value === specId,
|
||||
);
|
||||
if (selectedSpec) {
|
||||
formData.value.specName = selectedSpec.spec.name;
|
||||
formData.value.linkSpecName = selectedSpec.spec.name;
|
||||
formData.value.costPrice = selectedSpec.spec.costPrice;
|
||||
}
|
||||
} else {
|
||||
formData.value.specName = '';
|
||||
formData.value.linkSpecName = '';
|
||||
formData.value.costPrice = 0;
|
||||
}
|
||||
}
|
||||
@@ -247,8 +252,8 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
currentRecord.value = record || null;
|
||||
|
||||
// 加载下拉选项数据
|
||||
fetchShopOptions();
|
||||
fetchOrderStatusOptions();
|
||||
await fetchShopOptions();
|
||||
await fetchOrderStatusOptions();
|
||||
|
||||
modalApi.open();
|
||||
|
||||
@@ -260,13 +265,13 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
platformOrderNo: record.platformOrderNo || '',
|
||||
statusId: record.statusId,
|
||||
receivedAmount: record.receivedAmount,
|
||||
orderDate: record.orderDate
|
||||
? dayjs(record.orderDate).format('YYYY-MM-DD')
|
||||
: dayjs().format('YYYY-MM-DD'),
|
||||
orderTime: record.orderTime
|
||||
? dayjs(record.orderTime).format('YYYY-MM-DD HH:mm:ss')
|
||||
: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: record.productId,
|
||||
productSpecId: record.productSpecId,
|
||||
productName: record.productName,
|
||||
specName: record.specName,
|
||||
linkProductName: record.linkProductName,
|
||||
linkSpecName: record.linkSpecName,
|
||||
quantity: record.quantity,
|
||||
unitPrice: record.unitPrice,
|
||||
costPrice: record.costPrice,
|
||||
@@ -276,11 +281,11 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
platformOrderNo: '',
|
||||
statusId: undefined,
|
||||
receivedAmount: 0,
|
||||
orderDate: dayjs().format('YYYY-MM-DD'),
|
||||
orderTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: undefined,
|
||||
productSpecId: undefined,
|
||||
productName: '',
|
||||
specName: '',
|
||||
linkProductName: '',
|
||||
linkSpecName: '',
|
||||
quantity: 1,
|
||||
unitPrice: 0,
|
||||
costPrice: 0,
|
||||
@@ -288,20 +293,20 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
|
||||
// 如果是编辑模式且有商品ID,加载商品和规格选项
|
||||
if (edit && record?.productId) {
|
||||
await searchProducts(record.productName || '');
|
||||
await searchProducts(record.linkProductName || '');
|
||||
// 确保选中的商品在选项中
|
||||
if (!productOptions.value.some((opt) => opt.value === record.productId)) {
|
||||
productOptions.value.push({
|
||||
label: record.productName,
|
||||
label: record.linkProductName,
|
||||
value: record.productId,
|
||||
product: {
|
||||
id: record.productId,
|
||||
name: record.productName,
|
||||
name: record.linkProductName,
|
||||
} as ProductVO.Info,
|
||||
});
|
||||
}
|
||||
if (record.productSpecId) {
|
||||
await searchProductSpecs(record.specName || '');
|
||||
await searchProductSpecs(record.linkSpecName || '');
|
||||
// 确保选中的规格在选项中
|
||||
if (
|
||||
!productSpecOptions.value.some(
|
||||
@@ -309,11 +314,11 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
)
|
||||
) {
|
||||
productSpecOptions.value.push({
|
||||
label: record.specName || '',
|
||||
label: record.linkSpecName || '',
|
||||
value: record.productSpecId,
|
||||
spec: {
|
||||
id: record.productSpecId,
|
||||
name: record.specName || '',
|
||||
name: record.linkSpecName || '',
|
||||
costPrice: record.costPrice,
|
||||
} as ProductSpecVO.Info,
|
||||
});
|
||||
@@ -342,11 +347,11 @@ async function handleSubmit() {
|
||||
platformOrderNo: formData.value.platformOrderNo,
|
||||
statusId: formData.value.statusId,
|
||||
receivedAmount: formData.value.receivedAmount!,
|
||||
orderDate: formData.value.orderDate!,
|
||||
orderTime: formData.value.orderTime!,
|
||||
productId: formData.value.productId,
|
||||
productSpecId: formData.value.productSpecId,
|
||||
productName: formData.value.productName,
|
||||
specName: formData.value.specName,
|
||||
linkProductName: formData.value.linkProductName,
|
||||
linkSpecName: formData.value.linkSpecName,
|
||||
quantity: formData.value.quantity,
|
||||
unitPrice: formData.value.unitPrice,
|
||||
costPrice: formData.value.costPrice,
|
||||
@@ -360,11 +365,11 @@ async function handleSubmit() {
|
||||
platformOrderNo: formData.value.platformOrderNo,
|
||||
statusId: formData.value.statusId!,
|
||||
receivedAmount: formData.value.receivedAmount!,
|
||||
orderDate: formData.value.orderDate!,
|
||||
orderTime: formData.value.orderTime!,
|
||||
productId: formData.value.productId!,
|
||||
productSpecId: formData.value.productSpecId,
|
||||
productName: formData.value.productName!,
|
||||
specName: formData.value.specName,
|
||||
linkProductName: formData.value.linkProductName!,
|
||||
linkSpecName: formData.value.linkSpecName,
|
||||
quantity: formData.value.quantity!,
|
||||
unitPrice: formData.value.unitPrice!,
|
||||
costPrice: formData.value.costPrice!,
|
||||
@@ -424,13 +429,14 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="下单时间" name="orderDate">
|
||||
<Form.Item label="下单时间" name="orderTime">
|
||||
<DatePicker
|
||||
v-model:value="formData.orderDate"
|
||||
v-model:value="formData.orderTime"
|
||||
placeholder="请选择下单时间"
|
||||
style="width: 100%"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
show-time
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
@@ -491,17 +497,17 @@ defineExpose({
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<Form.Item label="商品名称" name="productName">
|
||||
<Form.Item label="链接商品名称" name="linkProductName">
|
||||
<Input
|
||||
v-model:value="formData.productName"
|
||||
placeholder="请输入商品名称"
|
||||
v-model:value="formData.linkProductName"
|
||||
placeholder="请输入链接商品名称"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="规格名称" name="specName">
|
||||
<Form.Item label="链接规格名称" name="linkSpecName">
|
||||
<Input
|
||||
v-model:value="formData.specName"
|
||||
placeholder="请输入规格名称(可选)"
|
||||
v-model:value="formData.linkSpecName"
|
||||
placeholder="请输入链接规格名称"
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { OrderDTO, OrderVO } from '#/api/ecommerce/order';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
@@ -13,8 +12,12 @@ import { createIconifyIcon } from '@vben/icons';
|
||||
import { Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteOrderApi, getOrderPageApi } from '#/api/ecommerce/order';
|
||||
import { getActiveOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import {
|
||||
deleteOrderApi,
|
||||
getOrderPageApi,
|
||||
} from '#/api/ecommerce/order';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
import OrderFormModal from './components/OrderFormModal.vue';
|
||||
@@ -79,7 +82,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
slots: { default: 'orderStatus' },
|
||||
},
|
||||
{
|
||||
field: 'orderDate',
|
||||
field: 'orderTime',
|
||||
title: '下单时间',
|
||||
minWidth: 'auto',
|
||||
},
|
||||
@@ -190,7 +193,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择状态',
|
||||
options: orderStatusOptions.value,
|
||||
options: orderStatusOptions,
|
||||
allowClear: true,
|
||||
},
|
||||
fieldName: 'statusId',
|
||||
@@ -230,7 +233,7 @@ async function fetchShopOptions() {
|
||||
// 获取订单状态选项
|
||||
async function fetchOrderStatusOptions() {
|
||||
try {
|
||||
const data = await getActiveOrderStatusListApi();
|
||||
const data = await getAllOrderStatusListApi();
|
||||
orderStatusOptions.value = data.map((status: OrderStatusVO.Info) => ({
|
||||
label: status.statusName,
|
||||
value: status.id,
|
||||
@@ -277,7 +280,8 @@ function handleModalSuccess() {
|
||||
|
||||
// 初始化
|
||||
onMounted(async () => {
|
||||
await Promise.all([fetchShopOptions(), fetchOrderStatusOptions()]);
|
||||
await fetchShopOptions();
|
||||
await fetchOrderStatusOptions();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -297,10 +301,10 @@ onMounted(async () => {
|
||||
|
||||
<!-- 商品信息列 -->
|
||||
<template #productInfo="{ row }: { row: any }">
|
||||
<div v-if="row.productName">
|
||||
<div style="font-weight: bold">{{ row.productName }}</div>
|
||||
<div v-if="row.specName" style="color: #666; font-size: 12px">
|
||||
{{ row.specName }}
|
||||
<div v-if="row.linkProductName">
|
||||
<div style="font-weight: bold">{{ row.linkProductName }}</div>
|
||||
<div v-if="row.linkSpecName" style="color: #666; font-size: 12px">
|
||||
{{ row.linkSpecName }}
|
||||
</div>
|
||||
</div>
|
||||
<span v-else style="color: #999">暂无商品信息</span>
|
||||
@@ -321,11 +325,7 @@ onMounted(async () => {
|
||||
<!-- 订单状态列 -->
|
||||
<template #orderStatus="{ row }: { row: any }">
|
||||
<Tag color="blue">
|
||||
{{
|
||||
orderStatusOptions.find((s) => s.value === row.statusId)?.label ||
|
||||
row.statusName ||
|
||||
'未知状态'
|
||||
}}
|
||||
{{ row.statusName || '未知状态' }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user