mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 03:09:19 +08:00
fix: 修复前端若干类型报错
This commit is contained in:
+4
-2
@@ -114,13 +114,14 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入状态名称(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'statusName',
|
||||
label: '状态名称',
|
||||
@@ -134,7 +135,7 @@ const formOptions = computed(() => ({
|
||||
{ label: '不参与自动统计', value: 0 },
|
||||
],
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'autoStatistics',
|
||||
label: '自动统计',
|
||||
@@ -152,6 +153,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '订单状态配置',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 刷新表格数据
|
||||
function refreshTable() {
|
||||
|
||||
+4
-2
@@ -128,13 +128,14 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入类型名称(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'typeName',
|
||||
label: '类型名称',
|
||||
@@ -148,7 +149,7 @@ const formOptions = computed(() => ({
|
||||
{ label: '禁用', value: 0 },
|
||||
],
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'isActive',
|
||||
label: '状态',
|
||||
@@ -166,6 +167,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '推广费用类型配置',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 刷新表格数据
|
||||
function refreshTable() {
|
||||
|
||||
+89
-28
@@ -32,8 +32,8 @@ import {
|
||||
import { createImportTaskApi } from '#/api/ecommerce/import-task';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
import { uploadFileToOss } from '#/utils/oss-upload';
|
||||
import { useImportTaskStore } from '#/store';
|
||||
import { uploadFileToOss } from '#/utils/oss-upload';
|
||||
|
||||
// 定义映射项数据结构
|
||||
interface FieldMappingItem {
|
||||
@@ -97,14 +97,14 @@ const fieldMappings = ref<
|
||||
>({});
|
||||
|
||||
// 映射模板相关
|
||||
const mappingTemplates = ref<ImportMappingVO.ImportMappingVO[]>([]);
|
||||
const mappingTemplates = ref<ImportMappingVO.ImportMappingInfoVO[]>([]);
|
||||
const selectedTemplateId = ref<number | undefined>();
|
||||
const selectedTemplateName = ref('');
|
||||
const templateLoading = ref(false);
|
||||
const savingTemplate = ref(false);
|
||||
const templateName = ref('');
|
||||
// 保存单个字段映射到模板
|
||||
const savingFieldToTemplate = ref<number | null>(null);
|
||||
const savingFieldToTemplate = ref<null | number>(null);
|
||||
// 当前模板的原始映射数据(用于对比哪些字段是模板的)
|
||||
const currentTemplateMappings = ref<FieldMappingItem[]>([]);
|
||||
|
||||
@@ -117,7 +117,7 @@ const selectedStatusTemplateName = ref('');
|
||||
const statusTemplateLoading = ref(false);
|
||||
const savingStatusTemplate = ref(false);
|
||||
const statusTemplateName = ref('');
|
||||
const savingStatusFieldToTemplate = ref<string | null>(null);
|
||||
const savingStatusFieldToTemplate = ref<null | string>(null);
|
||||
// 当前状态模板的原始映射数据
|
||||
const currentStatusTemplateMappings = ref<StatusMappingItem[]>([]);
|
||||
// 订单状态列表
|
||||
@@ -206,7 +206,10 @@ const isMappingChangedFromTemplate = (fieldDefId: number): boolean => {
|
||||
if (!templateItem) return false;
|
||||
const currentMapping = fieldMappings.value[fieldDefId];
|
||||
// 模板有定义,但当前映射与模板不同
|
||||
if (templateItem.fileFieldName && currentMapping?.mappedHeader !== templateItem.fileFieldName) {
|
||||
if (
|
||||
templateItem.fileFieldName &&
|
||||
currentMapping?.mappedHeader !== templateItem.fileFieldName
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -214,7 +217,10 @@ const isMappingChangedFromTemplate = (fieldDefId: number): boolean => {
|
||||
|
||||
// 判断某个订单状态的当前映射是否来自模板
|
||||
const isStatusMappingFromTemplate = (csvStatus: string): boolean => {
|
||||
if (!selectedStatusTemplateId.value || currentStatusTemplateMappings.value.length === 0) {
|
||||
if (
|
||||
!selectedStatusTemplateId.value ||
|
||||
currentStatusTemplateMappings.value.length === 0
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
const templateItem = currentStatusTemplateMappings.value.find(
|
||||
@@ -226,7 +232,10 @@ const isStatusMappingFromTemplate = (csvStatus: string): boolean => {
|
||||
|
||||
// 判断某个订单状态的映射与模板原始定义是否相同
|
||||
const isStatusMappingChangedFromTemplate = (csvStatus: string): boolean => {
|
||||
if (!selectedStatusTemplateId.value || currentStatusTemplateMappings.value.length === 0) {
|
||||
if (
|
||||
!selectedStatusTemplateId.value ||
|
||||
currentStatusTemplateMappings.value.length === 0
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
const templateItem = currentStatusTemplateMappings.value.find(
|
||||
@@ -520,10 +529,10 @@ const handleAddFieldToTemplate = async (fieldDefId: number) => {
|
||||
const existingIdx = mappingItems.findIndex(
|
||||
(item) => item.fieldName === fieldDef.fieldName,
|
||||
);
|
||||
if (existingIdx >= 0) {
|
||||
mappingItems[existingIdx] = fieldItem;
|
||||
} else {
|
||||
if (existingIdx === -1) {
|
||||
mappingItems.push(fieldItem);
|
||||
} else {
|
||||
mappingItems[existingIdx] = fieldItem;
|
||||
}
|
||||
|
||||
const mappingJson = JSON.stringify(mappingItems);
|
||||
@@ -634,10 +643,10 @@ const handleAddStatusFieldToTemplate = async (csvStatus: string) => {
|
||||
const existingIdx = mappingItems.findIndex(
|
||||
(item) => item.csvStatus === csvStatus,
|
||||
);
|
||||
if (existingIdx >= 0) {
|
||||
mappingItems[existingIdx] = statusItem;
|
||||
} else {
|
||||
if (existingIdx === -1) {
|
||||
mappingItems.push(statusItem);
|
||||
} else {
|
||||
mappingItems[existingIdx] = statusItem;
|
||||
}
|
||||
|
||||
const mappingJson = JSON.stringify(mappingItems);
|
||||
@@ -1169,7 +1178,10 @@ const shopOptions = computed(() => {
|
||||
</span>
|
||||
</Select.Option>
|
||||
</Select>
|
||||
<Button :disabled="selectedTemplateId !== undefined" @click="handleSaveTemplate">
|
||||
<Button
|
||||
:disabled="selectedTemplateId !== undefined"
|
||||
@click="handleSaveTemplate"
|
||||
>
|
||||
保存为模板
|
||||
</Button>
|
||||
</div>
|
||||
@@ -1183,7 +1195,9 @@ const shopOptions = computed(() => {
|
||||
'border-red-300 bg-red-50':
|
||||
fieldDef.required && !fieldMappings[fieldDef.id]?.mappedHeader,
|
||||
'border-blue-200 bg-blue-50': isMappingFromTemplate(fieldDef.id),
|
||||
'border-yellow-200 bg-yellow-50': isMappingChangedFromTemplate(fieldDef.id),
|
||||
'border-yellow-200 bg-yellow-50': isMappingChangedFromTemplate(
|
||||
fieldDef.id,
|
||||
),
|
||||
}"
|
||||
>
|
||||
<div class="flex-1">
|
||||
@@ -1193,13 +1207,18 @@ const shopOptions = computed(() => {
|
||||
(必填)
|
||||
</span>
|
||||
<span
|
||||
v-if="selectedTemplateId && isMappingFromTemplate(fieldDef.id)"
|
||||
v-if="
|
||||
selectedTemplateId && isMappingFromTemplate(fieldDef.id)
|
||||
"
|
||||
class="ml-1 rounded bg-blue-100 px-1.5 py-0.5 text-xs text-blue-600"
|
||||
>
|
||||
模板映射
|
||||
</span>
|
||||
<span
|
||||
v-if="selectedTemplateId && isMappingChangedFromTemplate(fieldDef.id)"
|
||||
v-if="
|
||||
selectedTemplateId &&
|
||||
isMappingChangedFromTemplate(fieldDef.id)
|
||||
"
|
||||
class="ml-1 rounded bg-yellow-100 px-1.5 py-0.5 text-xs text-yellow-600"
|
||||
>
|
||||
已变更
|
||||
@@ -1209,10 +1228,20 @@ const shopOptions = computed(() => {
|
||||
字段名: {{ fieldDef.fieldName }}
|
||||
</div>
|
||||
<div
|
||||
v-if="selectedTemplateId && currentTemplateMappings.find((m) => m.fieldName === fieldDef.fieldName)"
|
||||
v-if="
|
||||
selectedTemplateId &&
|
||||
currentTemplateMappings.some(
|
||||
(m) => m.fieldName === fieldDef.fieldName,
|
||||
)
|
||||
"
|
||||
class="mt-1 text-xs text-gray-400"
|
||||
>
|
||||
模板原映射: {{ currentTemplateMappings.find((m) => m.fieldName === fieldDef.fieldName)?.fileFieldName || '(未映射)' }}
|
||||
模板原映射:
|
||||
{{
|
||||
currentTemplateMappings.find(
|
||||
(m) => m.fieldName === fieldDef.fieldName,
|
||||
)?.fileFieldName || '(未映射)'
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
<Select
|
||||
@@ -1230,7 +1259,9 @@ const shopOptions = computed(() => {
|
||||
"
|
||||
/>
|
||||
<Button
|
||||
v-if="selectedTemplateId && fieldMappings[fieldDef.id]?.mappedHeader"
|
||||
v-if="
|
||||
selectedTemplateId && fieldMappings[fieldDef.id]?.mappedHeader
|
||||
"
|
||||
size="small"
|
||||
type="link"
|
||||
:disabled="isMappingFromTemplate(fieldDef.id)"
|
||||
@@ -1278,7 +1309,10 @@ const shopOptions = computed(() => {
|
||||
</span>
|
||||
</Select.Option>
|
||||
</Select>
|
||||
<Button :disabled="selectedStatusTemplateId !== undefined" @click="handleSaveStatusTemplate">
|
||||
<Button
|
||||
:disabled="selectedStatusTemplateId !== undefined"
|
||||
@click="handleSaveStatusTemplate"
|
||||
>
|
||||
保存为模板
|
||||
</Button>
|
||||
</div>
|
||||
@@ -1295,21 +1329,31 @@ const shopOptions = computed(() => {
|
||||
:key="statusValue"
|
||||
class="flex items-center space-x-4 rounded border p-3"
|
||||
:class="{
|
||||
'border-blue-200 bg-blue-50': selectedStatusTemplateId && isStatusMappingFromTemplate(statusValue),
|
||||
'border-yellow-200 bg-yellow-50': selectedStatusTemplateId && isStatusMappingChangedFromTemplate(statusValue),
|
||||
'border-blue-200 bg-blue-50':
|
||||
selectedStatusTemplateId &&
|
||||
isStatusMappingFromTemplate(statusValue),
|
||||
'border-yellow-200 bg-yellow-50':
|
||||
selectedStatusTemplateId &&
|
||||
isStatusMappingChangedFromTemplate(statusValue),
|
||||
}"
|
||||
>
|
||||
<div class="flex-1">
|
||||
<div class="flex items-center space-x-2">
|
||||
<span class="font-medium">{{ statusValue }}</span>
|
||||
<span
|
||||
v-if="selectedStatusTemplateId && isStatusMappingFromTemplate(statusValue)"
|
||||
v-if="
|
||||
selectedStatusTemplateId &&
|
||||
isStatusMappingFromTemplate(statusValue)
|
||||
"
|
||||
class="ml-1 rounded bg-blue-100 px-1.5 py-0.5 text-xs text-blue-600"
|
||||
>
|
||||
模板映射
|
||||
</span>
|
||||
<span
|
||||
v-if="selectedStatusTemplateId && isStatusMappingChangedFromTemplate(statusValue)"
|
||||
v-if="
|
||||
selectedStatusTemplateId &&
|
||||
isStatusMappingChangedFromTemplate(statusValue)
|
||||
"
|
||||
class="ml-1 rounded bg-yellow-100 px-1.5 py-0.5 text-xs text-yellow-600"
|
||||
>
|
||||
已变更
|
||||
@@ -1317,10 +1361,24 @@ const shopOptions = computed(() => {
|
||||
</div>
|
||||
<div class="mt-1 text-xs text-gray-500">CSV中的订单状态值</div>
|
||||
<div
|
||||
v-if="selectedStatusTemplateId && currentStatusTemplateMappings.find((m) => m.csvStatus === statusValue)"
|
||||
v-if="
|
||||
selectedStatusTemplateId &&
|
||||
currentStatusTemplateMappings.some(
|
||||
(m) => m.csvStatus === statusValue,
|
||||
)
|
||||
"
|
||||
class="mt-1 text-xs text-gray-400"
|
||||
>
|
||||
模板原映射: {{ orderStatusList.find((s) => s.id === currentStatusTemplateMappings.find((m) => m.csvStatus === statusValue)?.mappedStatusId)?.statusName || '(未映射)' }}
|
||||
模板原映射:
|
||||
{{
|
||||
orderStatusList.find(
|
||||
(s) =>
|
||||
s.id ===
|
||||
currentStatusTemplateMappings.find(
|
||||
(m) => m.csvStatus === statusValue,
|
||||
)?.mappedStatusId,
|
||||
)?.statusName || '(未映射)'
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
<Select
|
||||
@@ -1338,7 +1396,10 @@ const shopOptions = computed(() => {
|
||||
"
|
||||
/>
|
||||
<Button
|
||||
v-if="selectedStatusTemplateId && statusMappings[statusValue] !== undefined"
|
||||
v-if="
|
||||
selectedStatusTemplateId &&
|
||||
statusMappings[statusValue] !== undefined
|
||||
"
|
||||
size="small"
|
||||
type="link"
|
||||
:disabled="isStatusMappingFromTemplate(statusValue)"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
<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/types';
|
||||
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
@@ -12,12 +13,8 @@ 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 { 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';
|
||||
@@ -37,7 +34,7 @@ const shopPageSize = 20;
|
||||
const shopTotal = ref(0);
|
||||
const shopLoading = ref(false);
|
||||
const shopSearchKeyword = ref('');
|
||||
let shopSearchTimer: ReturnType<typeof setTimeout> | null = null;
|
||||
let shopSearchTimer: null | ReturnType<typeof setTimeout> = null;
|
||||
|
||||
// 订单状态选项
|
||||
const orderStatusOptions = ref<{ label: string; value: number }[]>([]);
|
||||
@@ -50,7 +47,7 @@ const searchForm = ref({
|
||||
});
|
||||
|
||||
// 当前排序状态
|
||||
const currentSort = ref<{ field: string; order: 'asc' | 'desc' } | null>(null);
|
||||
const currentSort = ref<null | { field: string; order: 'asc' | 'desc' }>(null);
|
||||
|
||||
// 加载店铺列表(支持分页)
|
||||
async function fetchShops(page = 1, append = false) {
|
||||
@@ -63,17 +60,18 @@ async function fetchShops(page = 1, append = false) {
|
||||
filters: shopSearchKeyword.value ? { name: shopSearchKeyword.value } : {},
|
||||
};
|
||||
const data = await getShopPageApi(params);
|
||||
if (append) {
|
||||
shopOptions.value = [...shopOptions.value, ...data.records.map((shop: ShopVO.Info) => ({
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
}))];
|
||||
} else {
|
||||
shopOptions.value = data.records.map((shop: ShopVO.Info) => ({
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
}));
|
||||
}
|
||||
shopOptions.value = append
|
||||
? [
|
||||
...shopOptions.value,
|
||||
...data.records.map((shop: ShopVO.Info) => ({
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
})),
|
||||
]
|
||||
: data.records.map((shop: ShopVO.Info) => ({
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
}));
|
||||
shopTotal.value = data.total;
|
||||
shopPage.value = page;
|
||||
} catch (error) {
|
||||
@@ -182,11 +180,6 @@ const gridOptions: VxeGridProps<any> = {
|
||||
multiple: false,
|
||||
orders: ['desc', 'asc'],
|
||||
},
|
||||
sortChange: ({ field, order }) => {
|
||||
// 保存排序状态并触发搜索
|
||||
currentSort.value = { field, order: order || 'desc' };
|
||||
gridApi?.reload();
|
||||
},
|
||||
toolbarConfig: {
|
||||
custom: true,
|
||||
refresh: true,
|
||||
@@ -226,7 +219,10 @@ const gridOptions: VxeGridProps<any> = {
|
||||
const searchParams = form || {};
|
||||
// 合并表单值和本地状态
|
||||
const filters = {
|
||||
platformOrderNo: searchParams.platformOrderNo || searchForm.value.platformOrderNo || undefined,
|
||||
platformOrderNo:
|
||||
searchParams.platformOrderNo ||
|
||||
searchForm.value.platformOrderNo ||
|
||||
undefined,
|
||||
shopId: searchParams.shopId ?? searchForm.value.shopId,
|
||||
statusId: searchParams.statusId ?? searchForm.value.statusId,
|
||||
};
|
||||
@@ -237,7 +233,12 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
// 处理排序参数
|
||||
if (currentSort.value) {
|
||||
params.sorts = [{ field: currentSort.value.field, order: currentSort.value.order }];
|
||||
params.sorts = [
|
||||
{
|
||||
field: currentSort.value.field,
|
||||
order: currentSort.value.order,
|
||||
},
|
||||
];
|
||||
}
|
||||
const data = await getOrderPageApi(params);
|
||||
return {
|
||||
@@ -260,13 +261,14 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入平台订单号(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'platformOrderNo',
|
||||
label: '平台订单号',
|
||||
@@ -283,7 +285,7 @@ const formOptions = computed(() => ({
|
||||
onPopupScroll: handleShopPopupScroll,
|
||||
onChange: (val: any) => {
|
||||
searchForm.value.shopId = val;
|
||||
gridApi?.reload();
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
loading: shopLoading,
|
||||
dropdownMenuColumnStyle: { maxHeight: '300px', overflow: 'auto' },
|
||||
@@ -299,7 +301,7 @@ const formOptions = computed(() => ({
|
||||
allowClear: true,
|
||||
onChange: (val: any) => {
|
||||
searchForm.value.statusId = val;
|
||||
gridApi?.reload();
|
||||
gridReloadRef.value?.();
|
||||
},
|
||||
},
|
||||
fieldName: 'statusId',
|
||||
@@ -318,6 +320,17 @@ function refreshTable() {
|
||||
}
|
||||
}
|
||||
|
||||
function handleSortChange({
|
||||
field,
|
||||
order,
|
||||
}: {
|
||||
field?: string;
|
||||
order?: 'asc' | 'desc' | null;
|
||||
}) {
|
||||
currentSort.value = field ? { field, order: order || 'desc' } : null;
|
||||
gridReloadRef.value?.();
|
||||
}
|
||||
|
||||
// 获取店铺选项(首次加载)
|
||||
async function fetchShopOptions() {
|
||||
await fetchShops(1, false);
|
||||
@@ -343,6 +356,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '订单管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 处理添加订单
|
||||
function handleAdd() {
|
||||
@@ -381,7 +395,7 @@ onMounted(async () => {
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<!-- VbenVxeGrid 表格 -->
|
||||
<Grid :loading="loading">
|
||||
<Grid :loading="loading" @sort-change="handleSortChange">
|
||||
<!-- 工具栏工具 -->
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
@@ -417,10 +431,7 @@ onMounted(async () => {
|
||||
|
||||
<!-- 订单状态列 -->
|
||||
<template #orderStatus="{ row }: { row: any }">
|
||||
<Tag
|
||||
:color="row.orderStatus?.color || 'blue'"
|
||||
type="outline"
|
||||
>
|
||||
<Tag :color="row.orderStatus?.color || 'blue'" type="outline">
|
||||
{{ row.statusName || '未知状态' }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
+6
-4
@@ -201,13 +201,14 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品名称(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '商品名称',
|
||||
@@ -216,7 +217,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品编码(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'productCode',
|
||||
label: '商品编码',
|
||||
@@ -225,7 +226,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入规格编码(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'specCode',
|
||||
label: '规格编码',
|
||||
@@ -234,7 +235,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入规格名称(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'specName',
|
||||
label: '规格名称',
|
||||
@@ -259,6 +260,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '商品管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 事件处理
|
||||
const handleEdit = (product: ProductVO.Info) => {
|
||||
|
||||
@@ -178,6 +178,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
@@ -187,7 +188,7 @@ const formOptions = computed(() => ({
|
||||
// TODO: 这里需要从店铺API获取店铺列表
|
||||
options: [],
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'shopId',
|
||||
label: '店铺',
|
||||
@@ -199,7 +200,7 @@ const formOptions = computed(() => ({
|
||||
// TODO: 这里需要从推广费类型API获取类型列表
|
||||
options: [],
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'feeTypeId',
|
||||
label: '推广费类型',
|
||||
@@ -210,7 +211,7 @@ const formOptions = computed(() => ({
|
||||
placeholder: '请选择平台',
|
||||
options: platformOptions,
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'platform',
|
||||
label: '平台',
|
||||
@@ -220,7 +221,7 @@ const formOptions = computed(() => ({
|
||||
componentProps: {
|
||||
placeholder: '开始日期',
|
||||
style: { width: '100%' },
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'feeDateStart',
|
||||
label: '发生日期',
|
||||
@@ -230,7 +231,7 @@ const formOptions = computed(() => ({
|
||||
componentProps: {
|
||||
placeholder: '结束日期',
|
||||
style: { width: '100%' },
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'feeDateEnd',
|
||||
label: '至',
|
||||
@@ -255,6 +256,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '推广费管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 处理新增
|
||||
const handleAdd = () => {
|
||||
|
||||
+4
-2
@@ -139,13 +139,14 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品名称(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '商品名称',
|
||||
@@ -154,7 +155,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品编码(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'productCode',
|
||||
label: '商品编码',
|
||||
@@ -172,6 +173,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '商品列表',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 监听 shopId 变化,刷新表格
|
||||
watch(
|
||||
|
||||
+4
-2
@@ -139,13 +139,14 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品名称(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '商品名称',
|
||||
@@ -154,7 +155,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入商品编码(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'productCode',
|
||||
label: '商品编码',
|
||||
@@ -172,6 +173,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '商品列表',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 监听 shopId 变化,刷新表格
|
||||
watch(
|
||||
|
||||
@@ -157,13 +157,14 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入店铺名称(回车搜索)',
|
||||
onPressEnter: () => gridApi?.reload(),
|
||||
onPressEnter: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'name',
|
||||
label: '店铺名称',
|
||||
@@ -174,7 +175,7 @@ const formOptions = computed(() => ({
|
||||
placeholder: '请选择平台',
|
||||
options: platformOptions,
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'platform',
|
||||
label: '平台',
|
||||
@@ -192,6 +193,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '店铺管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 刷新表格数据
|
||||
function refreshTable() {
|
||||
|
||||
+2
-3
@@ -5,7 +5,6 @@ import type {
|
||||
} from '#/api/ecommerce/shop-monthly-target';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
|
||||
import dayjs from 'dayjs';
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
@@ -18,12 +17,13 @@ import {
|
||||
message,
|
||||
Select,
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
import {
|
||||
createShopMonthlyTargetApi,
|
||||
updateShopMonthlyTargetApi,
|
||||
} from '#/api/ecommerce/shop-monthly-target';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
defineOptions({ name: 'ShopMonthlyTargetFormModal' });
|
||||
|
||||
@@ -271,4 +271,3 @@ onMounted(() => {
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
|
||||
@@ -161,6 +161,8 @@ const gridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const gridReloadRef = ref<(() => void) | null>(null);
|
||||
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
@@ -169,7 +171,7 @@ const formOptions = computed(() => ({
|
||||
placeholder: '请选择店铺',
|
||||
options: shopOptions,
|
||||
allowClear: true,
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'shopId',
|
||||
label: '店铺',
|
||||
@@ -180,7 +182,7 @@ const formOptions = computed(() => ({
|
||||
placeholder: '开始月份',
|
||||
picker: 'month',
|
||||
style: { width: '100%' },
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'startTargetMonth',
|
||||
label: '目标月份',
|
||||
@@ -191,7 +193,7 @@ const formOptions = computed(() => ({
|
||||
placeholder: '结束月份',
|
||||
picker: 'month',
|
||||
style: { width: '100%' },
|
||||
onChange: () => gridApi?.reload(),
|
||||
onChange: () => gridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'endTargetMonth',
|
||||
label: '至',
|
||||
@@ -216,6 +218,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
showSearchForm: true,
|
||||
tableTitle: '店铺月销量目标管理',
|
||||
});
|
||||
gridReloadRef.value = () => gridApi.reload();
|
||||
|
||||
// 处理新增
|
||||
const handleAdd = () => {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
<script lang="ts" setup>
|
||||
import type { EchartsUIType } from '@vben/plugins/echarts';
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { OrderDTO } from '#/api/ecommerce/order';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
|
||||
import type { ShopDTO, ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, onActivated, onMounted, ref, watch } from 'vue';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
@@ -16,10 +17,9 @@ import { Button, DatePicker, message, Spin, Tag } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { getShopOverviewStatisticsApi } from '#/api/ecommerce/shop';
|
||||
import { getOrderPageApi } from '#/api/ecommerce/order';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
|
||||
import { getShopOverviewStatisticsApi } from '#/api/ecommerce/shop';
|
||||
import { exportByPost } from '#/utils/export';
|
||||
|
||||
defineOptions({ name: 'ShopOverview' });
|
||||
@@ -517,7 +517,8 @@ const orderGridOptions: VxeGridProps<any> = {
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
shopId: shopId.value,
|
||||
platformOrderNo: orderSearchForm.value.platformOrderNo || undefined,
|
||||
platformOrderNo:
|
||||
orderSearchForm.value.platformOrderNo || undefined,
|
||||
statusId: orderSearchForm.value.statusId,
|
||||
minReceivedAmount: orderSearchForm.value.minReceivedAmount,
|
||||
maxReceivedAmount: orderSearchForm.value.maxReceivedAmount,
|
||||
@@ -525,7 +526,10 @@ const orderGridOptions: VxeGridProps<any> = {
|
||||
},
|
||||
};
|
||||
// 添加排序参数
|
||||
if (orderSearchForm.value.sortField && orderSearchForm.value.sortOrder) {
|
||||
if (
|
||||
orderSearchForm.value.sortField &&
|
||||
orderSearchForm.value.sortOrder
|
||||
) {
|
||||
params.sorts = [
|
||||
{
|
||||
field: orderSearchForm.value.sortField,
|
||||
@@ -540,7 +544,11 @@ const orderGridOptions: VxeGridProps<any> = {
|
||||
};
|
||||
} catch (error: any) {
|
||||
console.error('获取订单列表失败:', error);
|
||||
message.error('获取订单列表失败: ' + (error?.message || error?.response?.data?.message || '未知错误'));
|
||||
message.error(
|
||||
`获取订单列表失败: ${
|
||||
error?.message || error?.response?.data?.message || '未知错误'
|
||||
}`,
|
||||
);
|
||||
return {
|
||||
items: [],
|
||||
total: 0,
|
||||
@@ -553,6 +561,9 @@ const orderGridOptions: VxeGridProps<any> = {
|
||||
},
|
||||
};
|
||||
|
||||
/** 避免 orderFormOptions 与 orderGridApi 循环引用导致隐式 any */
|
||||
const orderGridReloadRef = ref<(() => void) | null>(null);
|
||||
|
||||
// 订单搜索表单配置
|
||||
const orderFormOptions = computed(() => ({
|
||||
schema: [
|
||||
@@ -560,7 +571,7 @@ const orderFormOptions = computed(() => ({
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入平台订单号(回车搜索)',
|
||||
onPressEnter: () => orderGridApi?.reload(),
|
||||
onPressEnter: () => orderGridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'platformOrderNo',
|
||||
label: '订单号',
|
||||
@@ -571,7 +582,7 @@ const orderFormOptions = computed(() => ({
|
||||
placeholder: '请选择订单状态',
|
||||
options: orderStatusOptions,
|
||||
allowClear: true,
|
||||
onChange: () => orderGridApi?.reload(),
|
||||
onChange: () => orderGridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'statusId',
|
||||
label: '订单状态',
|
||||
@@ -582,7 +593,7 @@ const orderFormOptions = computed(() => ({
|
||||
placeholder: '最小金额',
|
||||
min: 0,
|
||||
style: { width: '100%' },
|
||||
onPressEnter: () => orderGridApi?.reload(),
|
||||
onPressEnter: () => orderGridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'minReceivedAmount',
|
||||
label: '实收金额(起)',
|
||||
@@ -593,7 +604,7 @@ const orderFormOptions = computed(() => ({
|
||||
placeholder: '最大金额',
|
||||
min: 0,
|
||||
style: { width: '100%' },
|
||||
onPressEnter: () => orderGridApi?.reload(),
|
||||
onPressEnter: () => orderGridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'maxReceivedAmount',
|
||||
label: '实收金额(止)',
|
||||
@@ -607,7 +618,7 @@ const orderFormOptions = computed(() => ({
|
||||
{ label: '未确认', value: 0 },
|
||||
],
|
||||
allowClear: true,
|
||||
onChange: () => orderGridApi?.reload(),
|
||||
onChange: () => orderGridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'confirm',
|
||||
label: '确认状态',
|
||||
@@ -618,7 +629,7 @@ const orderFormOptions = computed(() => ({
|
||||
placeholder: '选择排序字段',
|
||||
options: orderSortFieldOptions,
|
||||
allowClear: true,
|
||||
onChange: () => orderGridApi?.reload(),
|
||||
onChange: () => orderGridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'sortField',
|
||||
label: '排序字段',
|
||||
@@ -629,7 +640,7 @@ const orderFormOptions = computed(() => ({
|
||||
placeholder: '选择排序方式',
|
||||
options: orderSortOrderOptions,
|
||||
allowClear: true,
|
||||
onChange: () => orderGridApi?.reload(),
|
||||
onChange: () => orderGridReloadRef.value?.(),
|
||||
},
|
||||
fieldName: 'sortOrder',
|
||||
label: '排序方式',
|
||||
@@ -646,6 +657,7 @@ const [OrderGrid, orderGridApi] = useVbenVxeGrid({
|
||||
formOptions: orderFormOptions.value,
|
||||
showSearchForm: true,
|
||||
});
|
||||
orderGridReloadRef.value = () => orderGridApi.reload();
|
||||
|
||||
// 刷新订单列表
|
||||
function refreshOrderGrid() {
|
||||
|
||||
Reference in New Issue
Block a user