mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-24 13:09:19 +08:00
1
This commit is contained in:
+449
@@ -0,0 +1,449 @@
|
||||
<script setup lang="ts">
|
||||
import type { BrushOrderDTO, BrushOrderVO } from '#/api/ecommerce/brush-order';
|
||||
import type {
|
||||
ProductSpecDTO,
|
||||
ProductSpecVO,
|
||||
} from '#/api/ecommerce/product-spec/types';
|
||||
import type { ProductDTO, ProductVO } from '#/api/ecommerce/product/types';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
|
||||
import { useVbenModal } from '@vben/common-ui';
|
||||
|
||||
import {
|
||||
DatePicker,
|
||||
Form,
|
||||
Input,
|
||||
InputNumber,
|
||||
message,
|
||||
Select,
|
||||
Spin,
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import {
|
||||
createBrushOrderApi,
|
||||
updateBrushOrderApi,
|
||||
} from '#/api/ecommerce/brush-order';
|
||||
import { getProductPageApi } from '#/api/ecommerce/product';
|
||||
import { getProductSpecPageApi } from '#/api/ecommerce/product-spec';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
defineOptions({ name: 'BrushOrderFormModal' });
|
||||
|
||||
const props = defineProps<Props>();
|
||||
|
||||
const emit = defineEmits<Emits>();
|
||||
|
||||
// Props
|
||||
interface Props {
|
||||
open: boolean;
|
||||
brushOrderData?: null | BrushOrderVO.Info;
|
||||
}
|
||||
|
||||
// Emits
|
||||
interface Emits {
|
||||
(e: 'update:open', value: boolean): void;
|
||||
(e: 'success'): void;
|
||||
(e: 'cancel'): void;
|
||||
}
|
||||
|
||||
// 创建 vben modal
|
||||
const [Modal, modalApi] = useVbenModal({
|
||||
draggable: true,
|
||||
class: 'w-[800px]',
|
||||
onCancel() {
|
||||
handleCancel();
|
||||
},
|
||||
onConfirm() {
|
||||
handleOk();
|
||||
},
|
||||
});
|
||||
|
||||
// 响应式数据
|
||||
const formRef = ref();
|
||||
const isEdit = ref(false);
|
||||
|
||||
// 表单数据
|
||||
const formData = ref<BrushOrderDTO.Create>({
|
||||
shopId: undefined as any,
|
||||
productId: undefined,
|
||||
productSpecId: undefined,
|
||||
brushAmount: undefined as any,
|
||||
brushTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
platformOrderNo: undefined,
|
||||
quantity: 1,
|
||||
remark: undefined,
|
||||
});
|
||||
|
||||
// 表单验证规则
|
||||
const rules = {
|
||||
shopId: [{ required: true, message: '请选择店铺', trigger: 'change' }],
|
||||
brushAmount: [
|
||||
{ required: true, message: '请输入刷单金额', trigger: 'blur' },
|
||||
{ type: 'number', min: 0, message: '刷单金额必须大于等于0', trigger: 'blur' },
|
||||
],
|
||||
brushTime: [{ required: true, message: '请选择刷单时间', trigger: 'change' }],
|
||||
} as any;
|
||||
|
||||
// 店铺列表
|
||||
const shopList = ref<ShopVO.Info[]>([]);
|
||||
const shopListLoading = ref(false);
|
||||
|
||||
// 商品选项数据
|
||||
const productOptions = ref<
|
||||
{ label: string; product: ProductVO.Info; value: number }[]
|
||||
>([]);
|
||||
const productLoading = ref(false);
|
||||
const productSearchKeyword = ref('');
|
||||
|
||||
// 规格选项数据
|
||||
const productSpecOptions = ref<
|
||||
{ label: string; spec: ProductSpecVO.Info; value: number }[]
|
||||
>([]);
|
||||
const productSpecLoading = ref(false);
|
||||
const productSpecSearchKeyword = ref('');
|
||||
|
||||
// 处理日期选择器的双向绑定
|
||||
const brushTimeValue = computed({
|
||||
get() {
|
||||
return formData.value.brushTime
|
||||
? dayjs(formData.value.brushTime, 'YYYY-MM-DD HH:mm:ss')
|
||||
: null;
|
||||
},
|
||||
set(value: any) {
|
||||
formData.value.brushTime = value
|
||||
? value.format('YYYY-MM-DD HH:mm:ss')
|
||||
: '';
|
||||
},
|
||||
});
|
||||
|
||||
// 监听props变化
|
||||
watch(
|
||||
() => props.open,
|
||||
(newVal) => {
|
||||
if (newVal) {
|
||||
modalApi.open();
|
||||
isEdit.value = !!props.brushOrderData;
|
||||
if (props.brushOrderData) {
|
||||
// 编辑模式,填充表单数据
|
||||
formData.value = {
|
||||
shopId: props.brushOrderData.shopId,
|
||||
productId: props.brushOrderData.productId,
|
||||
productSpecId: props.brushOrderData.productSpecId,
|
||||
brushAmount: props.brushOrderData.brushAmount,
|
||||
brushTime: props.brushOrderData.brushTime
|
||||
? dayjs(props.brushOrderData.brushTime).format('YYYY-MM-DD HH:mm:ss')
|
||||
: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
platformOrderNo: props.brushOrderData.platformOrderNo,
|
||||
quantity: props.brushOrderData.quantity || 1,
|
||||
remark: props.brushOrderData.remark,
|
||||
};
|
||||
// 如果有商品ID,加载商品和规格选项
|
||||
if (props.brushOrderData.productId) {
|
||||
searchProducts('');
|
||||
if (props.brushOrderData.productSpecId) {
|
||||
searchProductSpecs('');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// 新增模式,重置表单数据
|
||||
resetFormData();
|
||||
}
|
||||
} else {
|
||||
modalApi.close();
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
);
|
||||
|
||||
// 加载店铺列表
|
||||
const loadShopList = async () => {
|
||||
shopListLoading.value = true;
|
||||
try {
|
||||
const response = await getShopPageApi({
|
||||
page: 1,
|
||||
pageSize: 1000,
|
||||
filters: {},
|
||||
});
|
||||
shopList.value = response.records;
|
||||
} catch (error) {
|
||||
console.error('加载店铺列表失败:', error);
|
||||
} finally {
|
||||
shopListLoading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 搜索商品
|
||||
async function searchProducts(keyword: string) {
|
||||
productSearchKeyword.value = keyword;
|
||||
productLoading.value = true;
|
||||
try {
|
||||
const params: PageQueryDTO<ProductDTO.Filters> = {
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
filters: {
|
||||
name: keyword || undefined,
|
||||
},
|
||||
};
|
||||
const data = await getProductPageApi(params);
|
||||
productOptions.value = data.records.map((product: ProductVO.Info) => ({
|
||||
label: `${product.name}${product.productCode ? ` (${product.productCode})` : ''}`,
|
||||
value: product.id,
|
||||
product,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('搜索商品失败:', error);
|
||||
message.error('搜索商品失败');
|
||||
} finally {
|
||||
productLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 搜索规格
|
||||
async function searchProductSpecs(keyword: string) {
|
||||
if (!formData.value.productId) {
|
||||
productSpecOptions.value = [];
|
||||
return;
|
||||
}
|
||||
productSpecSearchKeyword.value = keyword;
|
||||
productSpecLoading.value = true;
|
||||
try {
|
||||
const params: PageQueryDTO<ProductSpecDTO.Filters> = {
|
||||
page: 1,
|
||||
pageSize: 50,
|
||||
filters: {
|
||||
productId: formData.value.productId,
|
||||
name: keyword || undefined,
|
||||
},
|
||||
};
|
||||
const data = await getProductSpecPageApi(params);
|
||||
productSpecOptions.value = data.records.map((spec: ProductSpecVO.Info) => ({
|
||||
label: `${spec.name}${spec.specCode ? ` (${spec.specCode})` : ''}`,
|
||||
value: spec.id,
|
||||
spec,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('搜索规格失败:', error);
|
||||
message.error('搜索规格失败');
|
||||
} finally {
|
||||
productSpecLoading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
// 处理商品选择
|
||||
function handleProductChange(productId: number | undefined) {
|
||||
if (!productId) {
|
||||
formData.value.productSpecId = undefined;
|
||||
productSpecOptions.value = [];
|
||||
} else {
|
||||
// 加载该商品的规格列表
|
||||
searchProductSpecs('');
|
||||
}
|
||||
}
|
||||
|
||||
// 监听商品ID变化,加载规格列表
|
||||
watch(
|
||||
() => formData.value.productId,
|
||||
(newProductId) => {
|
||||
if (newProductId) {
|
||||
searchProductSpecs('');
|
||||
} else {
|
||||
productSpecOptions.value = [];
|
||||
formData.value.productSpecId = undefined;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
// 重置表单数据
|
||||
const resetFormData = () => {
|
||||
formData.value = {
|
||||
shopId: undefined as any,
|
||||
productId: undefined,
|
||||
productSpecId: undefined,
|
||||
brushAmount: undefined as any,
|
||||
brushTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
platformOrderNo: undefined,
|
||||
quantity: 1,
|
||||
remark: undefined,
|
||||
};
|
||||
productOptions.value = [];
|
||||
productSpecOptions.value = [];
|
||||
};
|
||||
|
||||
// 确认操作
|
||||
const handleOk = async () => {
|
||||
try {
|
||||
await formRef.value?.validate();
|
||||
|
||||
if (isEdit.value && props.brushOrderData) {
|
||||
// 更新刷单记录
|
||||
await updateBrushOrderApi(props.brushOrderData.id, formData.value);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
// 创建刷单记录
|
||||
await createBrushOrderApi(formData.value);
|
||||
message.success('创建成功');
|
||||
}
|
||||
|
||||
emit('success');
|
||||
modalApi.close();
|
||||
emit('update:open', false);
|
||||
} catch (error) {
|
||||
if ((error as any)?.errorFields) {
|
||||
// 表单验证错误
|
||||
return;
|
||||
}
|
||||
console.error('操作失败:', error);
|
||||
message.error(isEdit.value ? '更新失败' : '创建失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 取消操作
|
||||
const handleCancel = () => {
|
||||
emit('cancel');
|
||||
modalApi.close();
|
||||
emit('update:open', false);
|
||||
resetFormData();
|
||||
};
|
||||
|
||||
// 组件挂载时加载数据
|
||||
onMounted(() => {
|
||||
loadShopList();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Modal :title="isEdit ? '编辑刷单记录' : '新增刷单记录'">
|
||||
<Form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="rules"
|
||||
:label-col="{ span: 6 }"
|
||||
:wrapper-col="{ span: 18 }"
|
||||
>
|
||||
<Form.Item label="店铺" name="shopId">
|
||||
<Select
|
||||
v-model:value="formData.shopId"
|
||||
placeholder="请选择店铺"
|
||||
:loading="shopListLoading"
|
||||
>
|
||||
<Select.Option
|
||||
v-for="shop in shopList"
|
||||
:key="shop.id"
|
||||
:value="shop.id"
|
||||
>
|
||||
{{ shop.name }}
|
||||
</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="商品" name="productId">
|
||||
<Select
|
||||
v-model:value="formData.productId"
|
||||
placeholder="请选择商品(可选)"
|
||||
show-search
|
||||
:filter-option="false"
|
||||
:loading="productLoading"
|
||||
allow-clear
|
||||
@search="searchProducts"
|
||||
@change="handleProductChange"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="productLoading" 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="option in productOptions"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
>
|
||||
{{ option.label }}
|
||||
</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="商品规格" name="productSpecId">
|
||||
<Select
|
||||
v-model:value="formData.productSpecId"
|
||||
placeholder="请选择商品规格(可选)"
|
||||
show-search
|
||||
:filter-option="false"
|
||||
:loading="productSpecLoading"
|
||||
:disabled="!formData.productId"
|
||||
allow-clear
|
||||
@search="searchProductSpecs"
|
||||
>
|
||||
<template #notFoundContent>
|
||||
<div v-if="productSpecLoading" 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">
|
||||
{{ formData.productId ? '请输入关键词搜索规格' : '请先选择商品' }}
|
||||
</div>
|
||||
</template>
|
||||
<Select.Option
|
||||
v-for="option in productSpecOptions"
|
||||
:key="option.value"
|
||||
:value="option.value"
|
||||
>
|
||||
{{ option.label }}
|
||||
</Select.Option>
|
||||
</Select>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="刷单金额" name="brushAmount">
|
||||
<InputNumber
|
||||
v-model:value="formData.brushAmount"
|
||||
placeholder="请输入刷单金额"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="刷单时间" name="brushTime">
|
||||
<DatePicker
|
||||
v-model:value="brushTimeValue"
|
||||
placeholder="请选择刷单时间"
|
||||
show-time
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="平台订单号" name="platformOrderNo">
|
||||
<Input
|
||||
v-model:value="formData.platformOrderNo"
|
||||
placeholder="请输入平台订单号(可选)"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="刷单数量" name="quantity">
|
||||
<InputNumber
|
||||
v-model:value="formData.quantity"
|
||||
placeholder="请输入刷单数量"
|
||||
:min="1"
|
||||
:precision="0"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="备注" name="remark">
|
||||
<Input.TextArea
|
||||
v-model:value="formData.remark"
|
||||
placeholder="请输入备注(可选)"
|
||||
:rows="3"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</Modal>
|
||||
</template>
|
||||
@@ -0,0 +1,383 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { BrushOrderDTO, BrushOrderVO } from '#/api/ecommerce/brush-order';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
import { computed, onMounted, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { createIconifyIcon } from '@vben/icons';
|
||||
|
||||
import { Button, message, Popconfirm, Space } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import {
|
||||
deleteBrushOrderApi,
|
||||
getBrushOrderPageApi,
|
||||
} from '#/api/ecommerce/brush-order';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
import BrushOrderFormModal from './components/BrushOrderFormModal.vue';
|
||||
|
||||
defineOptions({ name: 'BrushOrderManagement' });
|
||||
|
||||
// 创建图标组件
|
||||
const PlusIcon = createIconifyIcon('lucide:plus');
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const formModalVisible = ref(false);
|
||||
const currentBrushOrderData = ref<BrushOrderVO.Info | null>(null);
|
||||
|
||||
// 搜索表单
|
||||
const searchForm = ref({
|
||||
platformOrderNo: '',
|
||||
shopId: undefined as number | undefined,
|
||||
productId: undefined as number | undefined,
|
||||
minBrushAmount: undefined as number | undefined,
|
||||
maxBrushAmount: undefined as number | undefined,
|
||||
startBrushTime: undefined as string | undefined,
|
||||
endBrushTime: undefined as string | undefined,
|
||||
});
|
||||
|
||||
// 店铺选项(从搜索表单中获取)
|
||||
const shopOptions = ref<{ label: string; value: number }[]>([]);
|
||||
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [
|
||||
{
|
||||
type: 'seq' as const,
|
||||
minWidth: 'auto',
|
||||
title: '序号',
|
||||
},
|
||||
{
|
||||
field: 'platformOrderNo',
|
||||
title: '平台订单号',
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
field: 'shopName',
|
||||
title: '店铺名称',
|
||||
minWidth: 'auto',
|
||||
showOverflow: 'tooltip' as const,
|
||||
},
|
||||
{
|
||||
title: '商品信息',
|
||||
minWidth: 'auto',
|
||||
slots: { default: 'productInfo' },
|
||||
},
|
||||
{
|
||||
field: 'quantity',
|
||||
title: '刷单数量',
|
||||
minWidth: 'auto',
|
||||
},
|
||||
{
|
||||
title: '刷单金额',
|
||||
minWidth: 'auto',
|
||||
slots: { default: 'brushAmount' },
|
||||
},
|
||||
{
|
||||
field: 'brushTime',
|
||||
title: '刷单时间',
|
||||
minWidth: 'auto',
|
||||
},
|
||||
{
|
||||
field: 'createTime',
|
||||
title: '创建时间',
|
||||
minWidth: 'auto',
|
||||
},
|
||||
{
|
||||
title: '操作',
|
||||
minWidth: 'auto',
|
||||
fixed: 'right' as const,
|
||||
slots: { default: 'action' },
|
||||
},
|
||||
],
|
||||
height: 'auto',
|
||||
border: true,
|
||||
stripe: true,
|
||||
highlightHoverRow: true,
|
||||
showOverflow: true,
|
||||
size: 'small',
|
||||
toolbarConfig: {
|
||||
custom: true,
|
||||
refresh: true,
|
||||
zoom: true,
|
||||
},
|
||||
data: [],
|
||||
pagerConfig: {
|
||||
enabled: true,
|
||||
pageSizes: [10, 20, 50, 100],
|
||||
layouts: [
|
||||
'PrevJump',
|
||||
'PrevPage',
|
||||
'Number',
|
||||
'NextPage',
|
||||
'NextJump',
|
||||
'Sizes',
|
||||
'FullJump',
|
||||
'Total',
|
||||
] as (
|
||||
| 'FullJump'
|
||||
| 'NextJump'
|
||||
| 'NextPage'
|
||||
| 'Number'
|
||||
| 'PrevJump'
|
||||
| 'PrevPage'
|
||||
| 'Sizes'
|
||||
| 'Total'
|
||||
)[],
|
||||
},
|
||||
// 配置远程加载
|
||||
proxyConfig: {
|
||||
ajax: {
|
||||
query: async ({ page }) => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: PageQueryDTO<BrushOrderDTO.Filters> = {
|
||||
page: page.currentPage,
|
||||
pageSize: page.pageSize,
|
||||
filters: {
|
||||
platformOrderNo: searchForm.value.platformOrderNo || undefined,
|
||||
shopId: searchForm.value.shopId,
|
||||
productId: searchForm.value.productId,
|
||||
minBrushAmount: searchForm.value.minBrushAmount,
|
||||
maxBrushAmount: searchForm.value.maxBrushAmount,
|
||||
startBrushTime: searchForm.value.startBrushTime,
|
||||
endBrushTime: searchForm.value.endBrushTime,
|
||||
},
|
||||
};
|
||||
const data = await getBrushOrderPageApi(params);
|
||||
return {
|
||||
items: data.records,
|
||||
total: data.total,
|
||||
};
|
||||
} catch (error) {
|
||||
console.error('获取刷单记录列表失败:', error);
|
||||
message.error('获取刷单记录列表失败');
|
||||
return {
|
||||
items: [],
|
||||
total: 0,
|
||||
};
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// 搜索表单配置
|
||||
const formOptions = computed(() => ({
|
||||
schema: [
|
||||
{
|
||||
component: 'Input',
|
||||
componentProps: {
|
||||
placeholder: '请输入平台订单号',
|
||||
},
|
||||
fieldName: 'platformOrderNo',
|
||||
label: '平台订单号',
|
||||
},
|
||||
{
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择店铺',
|
||||
options: shopOptions.value,
|
||||
allowClear: true,
|
||||
},
|
||||
fieldName: 'shopId',
|
||||
label: '店铺',
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
placeholder: '最小金额',
|
||||
min: 0,
|
||||
precision: 2,
|
||||
style: { width: '100%' },
|
||||
},
|
||||
fieldName: 'minBrushAmount',
|
||||
label: '金额范围',
|
||||
},
|
||||
{
|
||||
component: 'InputNumber',
|
||||
componentProps: {
|
||||
placeholder: '最大金额',
|
||||
min: 0,
|
||||
precision: 2,
|
||||
style: { width: '100%' },
|
||||
},
|
||||
fieldName: 'maxBrushAmount',
|
||||
label: '',
|
||||
},
|
||||
{
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
placeholder: '开始时间',
|
||||
showTime: true,
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
style: { width: '100%' },
|
||||
},
|
||||
fieldName: 'startBrushTime',
|
||||
label: '刷单时间',
|
||||
},
|
||||
{
|
||||
component: 'DatePicker',
|
||||
componentProps: {
|
||||
placeholder: '结束时间',
|
||||
showTime: true,
|
||||
format: 'YYYY-MM-DD HH:mm:ss',
|
||||
style: { width: '100%' },
|
||||
},
|
||||
fieldName: 'endBrushTime',
|
||||
label: '',
|
||||
},
|
||||
],
|
||||
showDefaultActions: true,
|
||||
collapsed: true,
|
||||
collapsedRows: 1,
|
||||
}));
|
||||
|
||||
// 刷新表格数据
|
||||
function refreshTable() {
|
||||
if (gridApi) {
|
||||
gridApi.reload();
|
||||
}
|
||||
}
|
||||
|
||||
// 创建 VbenVxeGrid 实例
|
||||
const [Grid, gridApi] = useVbenVxeGrid({
|
||||
gridOptions,
|
||||
formOptions: formOptions.value,
|
||||
showSearchForm: true,
|
||||
tableTitle: '刷单记录管理',
|
||||
});
|
||||
|
||||
// 处理新增
|
||||
const handleAdd = () => {
|
||||
currentBrushOrderData.value = null;
|
||||
formModalVisible.value = true;
|
||||
};
|
||||
|
||||
// 处理编辑
|
||||
const handleEdit = (record: BrushOrderVO.Info) => {
|
||||
currentBrushOrderData.value = record;
|
||||
formModalVisible.value = true;
|
||||
};
|
||||
|
||||
// 处理删除
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
await deleteBrushOrderApi(id);
|
||||
message.success('删除成功');
|
||||
refreshTable();
|
||||
} catch {
|
||||
message.error('删除失败');
|
||||
}
|
||||
};
|
||||
|
||||
// 处理表单成功
|
||||
const handleFormSuccess = () => {
|
||||
refreshTable();
|
||||
};
|
||||
|
||||
// 格式化金额
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${amount.toFixed(2)}`;
|
||||
};
|
||||
|
||||
// 加载店铺选项
|
||||
const loadShopOptions = async () => {
|
||||
try {
|
||||
const response = await getShopPageApi({
|
||||
page: 1,
|
||||
pageSize: 1000,
|
||||
filters: {},
|
||||
});
|
||||
shopOptions.value = response.records.map((shop: ShopVO.Info) => ({
|
||||
label: shop.name,
|
||||
value: shop.id,
|
||||
}));
|
||||
} catch (error) {
|
||||
console.error('加载店铺列表失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 组件挂载时加载数据
|
||||
onMounted(() => {
|
||||
loadShopOptions();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page title="刷单记录管理" auto-content-height>
|
||||
<template #description>
|
||||
<div class="text-foreground/80 mt-2">
|
||||
管理店铺刷单记录,支持按店铺、商品、金额、时间等维度查询和统计
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #extra>
|
||||
<Space>
|
||||
<Button type="primary" @click="handleAdd">
|
||||
<PlusIcon class="mr-2 h-4 w-4" />
|
||||
新增刷单记录
|
||||
</Button>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<Grid :loading="loading">
|
||||
<!-- 工具栏工具 -->
|
||||
<template #toolbar-tools>
|
||||
<Space>
|
||||
<span class="text-gray-500">
|
||||
支持按店铺、商品、金额、时间等维度查询刷单记录
|
||||
</span>
|
||||
</Space>
|
||||
</template>
|
||||
|
||||
<!-- 商品信息列 -->
|
||||
<template #productInfo="{ row }: { row: any }">
|
||||
<div v-if="row.productName">
|
||||
<div style="font-weight: bold">{{ row.productName }}</div>
|
||||
<div v-if="row.productSpecName" style="color: #666; font-size: 12px">
|
||||
{{ row.productSpecName }}
|
||||
</div>
|
||||
</div>
|
||||
<span v-else class="text-gray-400">-</span>
|
||||
</template>
|
||||
|
||||
<!-- 刷单金额列 -->
|
||||
<template #brushAmount="{ row }: { row: any }">
|
||||
<span class="font-medium text-green-600">
|
||||
{{ formatAmount(row.brushAmount || 0) }}
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<!-- 操作列 -->
|
||||
<template #action="{ row }: { row: any }">
|
||||
<Space>
|
||||
<Button size="small" @click="handleEdit(row)"> 编辑 </Button>
|
||||
<Popconfirm
|
||||
title="确定要删除这条刷单记录吗?"
|
||||
@confirm="handleDelete(row.id)"
|
||||
>
|
||||
<Button size="small" danger> 删除 </Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
</template>
|
||||
</Grid>
|
||||
|
||||
<!-- 表单弹窗 -->
|
||||
<BrushOrderFormModal
|
||||
v-model:open="formModalVisible"
|
||||
:brush-order-data="currentBrushOrderData"
|
||||
@success="handleFormSuccess"
|
||||
@cancel="formModalVisible = false"
|
||||
/>
|
||||
</Page>
|
||||
</template>
|
||||
@@ -0,0 +1,597 @@
|
||||
<script lang="ts" setup>
|
||||
import type { EchartsUIType } from '@vben/plugins/echarts';
|
||||
|
||||
import type {
|
||||
CompanyOverviewDTO,
|
||||
CompanyOverviewVO,
|
||||
} from '#/api/ecommerce/company-overview';
|
||||
|
||||
import { onMounted, ref, watch } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { EchartsUI, useEcharts } from '@vben/plugins/echarts';
|
||||
|
||||
import { Button, DatePicker, message, Spin } from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { getCompanyOverviewApi } from '#/api/ecommerce/company-overview';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
defineOptions({ name: 'CompanyOverview' });
|
||||
|
||||
// 响应式数据
|
||||
const loading = ref(false);
|
||||
const overviewData = ref<CompanyOverviewVO.Info | null>(null);
|
||||
const shopCount = ref(0);
|
||||
|
||||
// 日期范围
|
||||
const dateRange = ref<[dayjs.Dayjs, dayjs.Dayjs]>([
|
||||
dayjs().subtract(30, 'day'),
|
||||
dayjs(),
|
||||
]);
|
||||
|
||||
// 当前选中的时间范围类型
|
||||
const activeTimeRange = ref<
|
||||
'7days' | '30days' | 'custom' | 'today' | 'yesterday'
|
||||
>('30days');
|
||||
|
||||
// 自定义日期范围
|
||||
const customDateRange = ref<[dayjs.Dayjs, dayjs.Dayjs] | undefined>(undefined);
|
||||
|
||||
// 切换时间范围
|
||||
const switchTimeRange = (
|
||||
type: '7days' | '30days' | 'custom' | 'today' | 'yesterday',
|
||||
) => {
|
||||
activeTimeRange.value = type;
|
||||
let startDate: dayjs.Dayjs;
|
||||
let endDate: dayjs.Dayjs = dayjs();
|
||||
|
||||
switch (type) {
|
||||
case '7days': {
|
||||
startDate = dayjs().subtract(7, 'day');
|
||||
break;
|
||||
}
|
||||
case '30days': {
|
||||
startDate = dayjs().subtract(30, 'day');
|
||||
break;
|
||||
}
|
||||
case 'custom': {
|
||||
if (customDateRange.value) {
|
||||
dateRange.value = customDateRange.value;
|
||||
}
|
||||
return;
|
||||
}
|
||||
case 'today': {
|
||||
startDate = dayjs();
|
||||
endDate = dayjs();
|
||||
break;
|
||||
}
|
||||
case 'yesterday': {
|
||||
startDate = dayjs().subtract(1, 'day');
|
||||
endDate = dayjs().subtract(1, 'day');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
dateRange.value = [startDate, endDate];
|
||||
};
|
||||
|
||||
// 自定义日期范围变化
|
||||
const handleCustomDateRangeChange = (
|
||||
value: [dayjs.Dayjs, dayjs.Dayjs] | [string, string] | null,
|
||||
_dateString?: [string, string],
|
||||
) => {
|
||||
if (value && Array.isArray(value) && value.length === 2) {
|
||||
// 确保是 dayjs 对象
|
||||
const dates = [
|
||||
dayjs.isDayjs(value[0]) ? value[0] : dayjs(value[0]),
|
||||
dayjs.isDayjs(value[1]) ? value[1] : dayjs(value[1]),
|
||||
] as [dayjs.Dayjs, dayjs.Dayjs];
|
||||
customDateRange.value = dates;
|
||||
activeTimeRange.value = 'custom';
|
||||
dateRange.value = dates;
|
||||
}
|
||||
};
|
||||
|
||||
// 图表引用
|
||||
const barChartRef = ref<EchartsUIType>();
|
||||
const scatterChartRef = ref<EchartsUIType>();
|
||||
const { renderEcharts: renderBarChart } = useEcharts(barChartRef);
|
||||
const { renderEcharts: renderScatterChart } = useEcharts(scatterChartRef);
|
||||
|
||||
// 格式化金额
|
||||
const formatAmount = (amount: number) => {
|
||||
return `¥${(amount / 10_000).toFixed(2)}万`;
|
||||
};
|
||||
|
||||
// 格式化金额(完整)
|
||||
const formatAmountFull = (amount: number) => {
|
||||
return `¥${amount.toLocaleString('zh-CN')}`;
|
||||
};
|
||||
|
||||
// 格式化百分比
|
||||
const formatPercent = (value: number | undefined) => {
|
||||
if (value === undefined) return '-';
|
||||
return `${value > 0 ? '+' : ''}${value.toFixed(1)}%`;
|
||||
};
|
||||
|
||||
// 加载店铺数量
|
||||
const loadShopCount = async () => {
|
||||
try {
|
||||
const response = await getShopPageApi({
|
||||
page: 1,
|
||||
pageSize: 1,
|
||||
filters: {},
|
||||
});
|
||||
shopCount.value = response.total || 0;
|
||||
} catch (error) {
|
||||
console.error('获取店铺数量失败:', error);
|
||||
}
|
||||
};
|
||||
|
||||
// 加载概览数据
|
||||
const loadOverviewData = async () => {
|
||||
try {
|
||||
loading.value = true;
|
||||
const params: CompanyOverviewDTO.Query = {
|
||||
dateRange: [
|
||||
dateRange.value[0].format('YYYY-MM-DD'),
|
||||
dateRange.value[1].format('YYYY-MM-DD'),
|
||||
],
|
||||
};
|
||||
const data = await getCompanyOverviewApi(params);
|
||||
overviewData.value = data;
|
||||
} catch (error) {
|
||||
console.error('获取全店概览数据失败:', error);
|
||||
message.error('获取全店概览数据失败');
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
};
|
||||
|
||||
// 渲染店铺销售占比排行图表
|
||||
const renderShopBarChart = () => {
|
||||
if (!barChartRef.value || !overviewData.value?.shopSalesRatios) return;
|
||||
|
||||
const ratios = overviewData.value.shopSalesRatios;
|
||||
const shopNames = ratios.map((r) => r.shopName).reverse();
|
||||
const salesAmounts = ratios.map((r) => r.salesAmount / 1000).reverse(); // 转换为千元
|
||||
|
||||
renderBarChart({
|
||||
tooltip: {
|
||||
trigger: 'axis',
|
||||
formatter: (params: any) => {
|
||||
const param = Array.isArray(params) ? params[0] : params;
|
||||
const index = param.dataIndex;
|
||||
const shop = ratios[ratios.length - 1 - index];
|
||||
if (!shop) return '';
|
||||
return `${shop.shopName}<br/>销售额: ${formatAmountFull(shop.salesAmount)}<br/>占比: ${shop.ratio.toFixed(2)}%`;
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
type: 'value',
|
||||
show: false,
|
||||
},
|
||||
yAxis: {
|
||||
type: 'category',
|
||||
data: shopNames,
|
||||
axisLine: { show: false },
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'bar',
|
||||
data: salesAmounts,
|
||||
itemStyle: {
|
||||
color: {
|
||||
type: 'linear',
|
||||
x: 1,
|
||||
y: 0,
|
||||
x2: 0,
|
||||
y2: 0,
|
||||
colorStops: [
|
||||
{ offset: 0, color: '#6366f1' },
|
||||
{ offset: 1, color: '#a5b4fc' },
|
||||
],
|
||||
},
|
||||
borderRadius: [0, 10, 10, 0],
|
||||
},
|
||||
barWidth: 25,
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
// 渲染店铺效率象限图
|
||||
const renderShopScatterChart = () => {
|
||||
if (!scatterChartRef.value || !overviewData.value?.shopEfficiencyQuadrants)
|
||||
return;
|
||||
|
||||
const quadrants = overviewData.value.shopEfficiencyQuadrants;
|
||||
const data = quadrants.map((q) => [q.roi, q.netProfit / 1000]); // 净利转换为千元
|
||||
|
||||
renderScatterChart({
|
||||
grid: {
|
||||
top: '10%',
|
||||
bottom: '10%',
|
||||
left: '10%',
|
||||
right: '10%',
|
||||
},
|
||||
tooltip: {
|
||||
trigger: 'item',
|
||||
formatter: (params: any) => {
|
||||
const index = params.dataIndex;
|
||||
const shop = quadrants[index];
|
||||
if (!shop) return '';
|
||||
return `${shop.shopName}<br/>ROI: ${shop.roi.toFixed(2)}<br/>净利: ${formatAmountFull(shop.netProfit)}`;
|
||||
},
|
||||
},
|
||||
xAxis: {
|
||||
name: 'ROI',
|
||||
nameLocation: 'middle',
|
||||
nameGap: 30,
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
type: 'dashed',
|
||||
},
|
||||
},
|
||||
},
|
||||
yAxis: {
|
||||
name: '净利(千元)',
|
||||
nameLocation: 'middle',
|
||||
nameGap: 50,
|
||||
splitLine: {
|
||||
lineStyle: {
|
||||
type: 'dashed',
|
||||
},
|
||||
},
|
||||
},
|
||||
series: [
|
||||
{
|
||||
type: 'scatter',
|
||||
symbolSize: 40,
|
||||
data,
|
||||
itemStyle: {
|
||||
color: '#6366f1',
|
||||
opacity: 0.6,
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
};
|
||||
|
||||
// 监听数据变化,重新渲染图表
|
||||
watch(
|
||||
() => overviewData.value,
|
||||
() => {
|
||||
if (overviewData.value) {
|
||||
// 使用 setTimeout 确保 DOM 已更新
|
||||
setTimeout(() => {
|
||||
renderShopBarChart();
|
||||
renderShopScatterChart();
|
||||
}, 100);
|
||||
}
|
||||
},
|
||||
{ deep: true },
|
||||
);
|
||||
|
||||
// 监听日期范围变化
|
||||
watch(
|
||||
() => dateRange.value,
|
||||
() => {
|
||||
loadOverviewData();
|
||||
},
|
||||
);
|
||||
|
||||
// 初始化
|
||||
onMounted(async () => {
|
||||
await loadShopCount();
|
||||
await loadOverviewData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page
|
||||
title="全店铺经营大盘"
|
||||
auto-content-height
|
||||
class="bg-gradient-to-br from-rose-50 via-indigo-50 to-green-50"
|
||||
>
|
||||
<template #description>
|
||||
<div class="font-bold text-indigo-600">
|
||||
Company Dashboard · 共 {{ shopCount }} 家在营店铺
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<template #extra>
|
||||
<div class="flex items-center gap-4">
|
||||
<!-- 汇总 ROI 和总税后盈亏 -->
|
||||
<div
|
||||
class="flex items-center gap-6 rounded-[2rem] border border-white/60 bg-white/50 px-6 py-3 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<div class="text-center">
|
||||
<div class="text-[10px] font-bold uppercase text-slate-400">
|
||||
汇总 ROI
|
||||
</div>
|
||||
<div class="text-lg font-black">
|
||||
{{ overviewData?.totalROI?.toFixed(2) || '-' }}
|
||||
</div>
|
||||
</div>
|
||||
<div class="h-8 w-px bg-slate-200"></div>
|
||||
<div class="text-center">
|
||||
<div class="text-[10px] font-bold uppercase text-slate-400">
|
||||
总税后盈亏
|
||||
</div>
|
||||
<div class="text-lg font-black text-emerald-600">
|
||||
{{
|
||||
overviewData?.totalProfitAfterTax
|
||||
? formatAmount(overviewData.totalProfitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 时间选择器组件 -->
|
||||
<div
|
||||
class="flex flex-wrap items-center gap-2 rounded-2xl border border-white/60 bg-white/40 p-1.5 shadow-[0_8px_32px_0_rgba(31,38,135,0.05)] backdrop-blur-[16px]"
|
||||
>
|
||||
<!-- 快速选择按钮 -->
|
||||
<div class="flex rounded-xl bg-white/30 p-1">
|
||||
<Button
|
||||
:type="activeTimeRange === 'today' ? 'primary' : 'text'"
|
||||
size="small"
|
||||
class="!h-auto border-none !px-4 !py-1.5 !text-sm !font-bold"
|
||||
:class="
|
||||
activeTimeRange === 'today'
|
||||
? '!bg-indigo-600 !text-white !shadow-[0_4px_12px_rgba(99,102,241,0.3)]'
|
||||
: ''
|
||||
"
|
||||
@click="switchTimeRange('today')"
|
||||
>
|
||||
今日
|
||||
</Button>
|
||||
<Button
|
||||
:type="activeTimeRange === 'yesterday' ? 'primary' : 'text'"
|
||||
size="small"
|
||||
class="!h-auto border-none !px-4 !py-1.5 !text-sm !font-bold"
|
||||
:class="
|
||||
activeTimeRange === 'yesterday'
|
||||
? '!bg-indigo-600 !text-white !shadow-[0_4px_12px_rgba(99,102,241,0.3)]'
|
||||
: ''
|
||||
"
|
||||
@click="switchTimeRange('yesterday')"
|
||||
>
|
||||
昨日
|
||||
</Button>
|
||||
<Button
|
||||
:type="activeTimeRange === '7days' ? 'primary' : 'text'"
|
||||
size="small"
|
||||
class="!h-auto border-none !px-4 !py-1.5 !text-sm !font-bold"
|
||||
:class="
|
||||
activeTimeRange === '7days'
|
||||
? '!bg-indigo-600 !text-white !shadow-[0_4px_12px_rgba(99,102,241,0.3)]'
|
||||
: ''
|
||||
"
|
||||
@click="switchTimeRange('7days')"
|
||||
>
|
||||
近7日
|
||||
</Button>
|
||||
<Button
|
||||
:type="activeTimeRange === '30days' ? 'primary' : 'text'"
|
||||
size="small"
|
||||
class="!h-auto border-none !px-4 !py-1.5 !text-sm !font-bold"
|
||||
:class="
|
||||
activeTimeRange === '30days'
|
||||
? '!bg-indigo-600 !text-white !shadow-[0_4px_12px_rgba(99,102,241,0.3)]'
|
||||
: ''
|
||||
"
|
||||
@click="switchTimeRange('30days')"
|
||||
>
|
||||
近30日
|
||||
</Button>
|
||||
</div>
|
||||
<!-- 分隔线 -->
|
||||
<div class="mx-1 h-6 w-px bg-slate-300"></div>
|
||||
<!-- 自定义时间 -->
|
||||
<div
|
||||
class="flex items-center gap-2 rounded-xl bg-white/30 px-3 py-1.5"
|
||||
>
|
||||
<span class="text-[10px] font-bold uppercase text-slate-400">
|
||||
自定义
|
||||
</span>
|
||||
<DatePicker.RangePicker
|
||||
v-model:value="customDateRange"
|
||||
size="small"
|
||||
format="YYYY-MM-DD"
|
||||
:allow-clear="false"
|
||||
class="!border-none !bg-transparent"
|
||||
:class="
|
||||
activeTimeRange === 'custom'
|
||||
? '[&_.ant-picker-input>input]:!font-bold [&_.ant-picker-input>input]:!text-indigo-600'
|
||||
: ''
|
||||
"
|
||||
@change="handleCustomDateRangeChange"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<Spin :spinning="loading">
|
||||
<div class="mx-auto max-w-[1600px] space-y-8 p-6">
|
||||
<!-- 汇总卡片 -->
|
||||
<div class="grid grid-cols-1 gap-6 md:grid-cols-4">
|
||||
<!-- 全店总销售额 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 bg-gradient-to-br from-indigo-500/10 to-transparent p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<div class="text-sm font-bold text-slate-500">全店总销售额</div>
|
||||
<div class="mt-1 text-3xl font-black">
|
||||
{{
|
||||
overviewData?.totalSalesAmount
|
||||
? formatAmount(overviewData.totalSalesAmount)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
<div
|
||||
v-if="overviewData?.monthOverMonthGrowth !== undefined"
|
||||
class="mt-4 w-fit rounded-lg bg-emerald-50 px-2 py-1 text-xs font-bold text-emerald-500"
|
||||
>
|
||||
{{ formatPercent(overviewData.monthOverMonthGrowth) }} 较上月同期
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 全店总单量 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<div class="text-sm font-bold text-slate-500">全店总单量</div>
|
||||
<div class="mt-1 text-3xl font-black">
|
||||
{{
|
||||
overviewData?.totalOrderCount?.toLocaleString('zh-CN') || '-'
|
||||
}}
|
||||
</div>
|
||||
<div class="mt-4 text-xs font-bold italic text-slate-400">
|
||||
目标达成率 92%
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 总推广费支出 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<div class="text-sm font-bold text-slate-500">总推广费支出</div>
|
||||
<div class="mt-1 text-3xl font-black">
|
||||
{{
|
||||
overviewData?.totalPromotionFee
|
||||
? formatAmount(overviewData.totalPromotionFee)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
<div class="mt-4 text-xs font-bold text-indigo-400">
|
||||
平均费比:
|
||||
{{
|
||||
overviewData?.averageFeeRatio
|
||||
? `${overviewData.averageFeeRatio.toFixed(1)}%`
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 全店总净利 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 bg-gradient-to-br from-emerald-500/10 to-transparent p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<div class="text-sm font-bold text-slate-500">
|
||||
全店总净利 (税后)
|
||||
</div>
|
||||
<div class="mt-1 text-3xl font-black text-emerald-600">
|
||||
{{
|
||||
overviewData?.totalNetProfitAfterTax
|
||||
? formatAmount(overviewData.totalNetProfitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
<div class="mt-4 text-xs font-bold text-slate-400">
|
||||
扣除总税额:
|
||||
{{
|
||||
overviewData?.totalTaxAmount
|
||||
? formatAmount(overviewData.totalTaxAmount)
|
||||
: '-'
|
||||
}}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 各店对比分析 -->
|
||||
<div class="grid grid-cols-1 gap-8 lg:grid-cols-2">
|
||||
<!-- 店铺销售占比排行 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<h3 class="mb-6 text-xl font-bold">各店铺销售占比排行</h3>
|
||||
<div class="h-[400px]">
|
||||
<EchartsUI ref="barChartRef" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 店铺效率象限 -->
|
||||
<div
|
||||
class="rounded-[2rem] border border-white/60 bg-white/50 p-8 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<h3 class="mb-6 text-xl font-bold">店铺效率象限 (ROI vs 净利)</h3>
|
||||
<div class="h-[400px]">
|
||||
<EchartsUI ref="scatterChartRef" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 店铺多维度对比表 -->
|
||||
<div
|
||||
class="overflow-hidden rounded-[2rem] border border-white/60 bg-white/50 shadow-[0_10px_30px_rgba(0,0,0,0.02)] backdrop-blur-[20px]"
|
||||
>
|
||||
<div class="flex items-center justify-between p-8">
|
||||
<h3 class="text-xl font-bold">多店铺数据横向对比</h3>
|
||||
</div>
|
||||
<div class="overflow-x-auto px-4 pb-6">
|
||||
<table class="w-full border-collapse whitespace-nowrap text-left">
|
||||
<thead
|
||||
class="border-b border-white/40 text-[11px] uppercase text-slate-400"
|
||||
>
|
||||
<tr>
|
||||
<th class="p-4 font-black">店铺名称</th>
|
||||
<th class="p-4 font-black">销售额</th>
|
||||
<th class="p-4 font-black text-indigo-600">ROI</th>
|
||||
<th class="p-4 font-black text-red-400">退款/刷单费</th>
|
||||
<th class="p-4 font-black">推广费总和</th>
|
||||
<th class="p-4 font-black text-emerald-600">税后盈亏</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="text-sm">
|
||||
<tr
|
||||
v-for="shop in overviewData?.shopComparisons"
|
||||
:key="shop.shopId"
|
||||
class="border-t border-white/20 transition hover:bg-white/40"
|
||||
>
|
||||
<td class="p-4 font-bold">{{ shop.shopName }}</td>
|
||||
<td class="p-4">
|
||||
{{ formatAmountFull(shop.salesAmount) }}
|
||||
</td>
|
||||
<td class="p-4 font-black text-indigo-600">
|
||||
{{ shop.roi?.toFixed(2) || '-' }}
|
||||
</td>
|
||||
<td class="p-4 text-red-400">
|
||||
{{ formatAmountFull(shop.refundAmount || 0) }} /
|
||||
{{ formatAmountFull(shop.brushFee || 0) }}
|
||||
</td>
|
||||
<td class="p-4">
|
||||
{{
|
||||
shop.totalPromotionFee
|
||||
? formatAmountFull(shop.totalPromotionFee)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
<td class="p-4 font-black text-emerald-600">
|
||||
{{
|
||||
shop.profitAfterTax
|
||||
? formatAmountFull(shop.profitAfterTax)
|
||||
: '-'
|
||||
}}
|
||||
</td>
|
||||
</tr>
|
||||
<tr v-if="!overviewData?.shopComparisons?.length">
|
||||
<td colspan="6" class="p-8 text-center text-gray-400">
|
||||
暂无数据
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Spin>
|
||||
</Page>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 自定义样式 */
|
||||
</style>
|
||||
+7
-7
@@ -41,7 +41,7 @@ const currentRecord = ref<null | OrderStatusVO.Info>(null);
|
||||
const formData = ref<Partial<OrderStatusDTO.Create>>({
|
||||
statusName: '',
|
||||
description: '',
|
||||
isDefaultStat: 1,
|
||||
autoStatistics: 1,
|
||||
sortOrder: 0,
|
||||
});
|
||||
|
||||
@@ -66,13 +66,13 @@ function open(edit: boolean, record?: OrderStatusVO.Info) {
|
||||
? {
|
||||
statusName: record.statusName,
|
||||
description: record.description || '',
|
||||
isDefaultStat: record.isDefaultStat,
|
||||
autoStatistics: record.autoStatistics,
|
||||
sortOrder: record.sortOrder || 0,
|
||||
}
|
||||
: {
|
||||
statusName: '',
|
||||
description: '',
|
||||
isDefaultStat: 1,
|
||||
autoStatistics: 1,
|
||||
sortOrder: 0,
|
||||
};
|
||||
}
|
||||
@@ -95,7 +95,7 @@ async function handleSubmit() {
|
||||
const updateData: OrderStatusDTO.Update = {
|
||||
statusName: formData.value.statusName!,
|
||||
description: formData.value.description,
|
||||
isDefaultStat: formData.value.isDefaultStat!,
|
||||
autoStatistics: formData.value.autoStatistics!,
|
||||
sortOrder: formData.value.sortOrder,
|
||||
};
|
||||
await updateOrderStatusApi(currentRecord.value.id, updateData);
|
||||
@@ -105,7 +105,7 @@ async function handleSubmit() {
|
||||
const createData: OrderStatusDTO.Create = {
|
||||
statusName: formData.value.statusName!,
|
||||
description: formData.value.description,
|
||||
isDefaultStat: formData.value.isDefaultStat!,
|
||||
autoStatistics: formData.value.autoStatistics!,
|
||||
sortOrder: formData.value.sortOrder,
|
||||
};
|
||||
await createOrderStatusApi(createData);
|
||||
@@ -176,9 +176,9 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="默认参与统计" name="isDefaultStat">
|
||||
<Form.Item label="自动统计" name="autoStatistics">
|
||||
<Switch
|
||||
v-model:checked="formData.isDefaultStat"
|
||||
v-model:checked="formData.autoStatistics"
|
||||
:checked-value="1"
|
||||
:un-checked-value="0"
|
||||
checked-children="参与"
|
||||
|
||||
+12
-12
@@ -52,9 +52,9 @@ const gridOptions: VxeGridProps<any> = {
|
||||
minWidth: 'auto',
|
||||
},
|
||||
{
|
||||
title: '是否默认参与统计',
|
||||
title: '自动统计',
|
||||
minWidth: 'auto',
|
||||
slots: { default: 'isDefaultStat' },
|
||||
slots: { default: 'autoStatistics' },
|
||||
},
|
||||
{
|
||||
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: 'isDefaultStat',
|
||||
label: '是否参与默认统计',
|
||||
fieldName: 'autoStatistics',
|
||||
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 #isDefaultStat="{ row }: { row: OrderStatusVO.Info }">
|
||||
<Tag :color="row.isDefaultStat === 1 ? 'green' : 'default'">
|
||||
{{ row.isDefaultStat === 1 ? '参与统计' : '不参与统计' }}
|
||||
<!-- 自动统计列 -->
|
||||
<template #autoStatistics="{ row }: { row: OrderStatusVO.Info }">
|
||||
<Tag :color="row.autoStatistics === 1 ? 'green' : 'default'">
|
||||
{{ row.autoStatistics === 1 ? '参与统计' : '不参与统计' }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
|
||||
+22
-37
@@ -163,10 +163,8 @@ const canGoToNextStep = computed(() => {
|
||||
});
|
||||
}
|
||||
if (currentStep.value === 2) {
|
||||
// 订单状态映射步骤:所有唯一的订单状态值都必须映射
|
||||
return uniqueStatusValues.value.every(
|
||||
(status) => statusMappings.value[status] !== undefined,
|
||||
);
|
||||
// 订单状态映射步骤:允许不映射,所以总是返回 true
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
});
|
||||
@@ -565,13 +563,13 @@ async function handleConfirmSaveStatusTemplate() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 验证所有订单状态是否都已映射
|
||||
const unMappedStatuses = uniqueStatusValues.value.filter(
|
||||
(status) => statusMappings.value[status] === undefined,
|
||||
// 验证是否有映射数据(至少需要一个映射才能保存模板)
|
||||
const mappedStatuses = uniqueStatusValues.value.filter(
|
||||
(status) => statusMappings.value[status] !== undefined,
|
||||
);
|
||||
|
||||
if (unMappedStatuses.length > 0) {
|
||||
message.warning(`请先映射所有订单状态:${unMappedStatuses.join('、')}`);
|
||||
if (mappedStatuses.length === 0) {
|
||||
message.warning('请至少映射一个订单状态');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -579,13 +577,13 @@ async function handleConfirmSaveStatusTemplate() {
|
||||
savingStatusTemplate.value = true;
|
||||
saveStatusTemplateModalApi.lock();
|
||||
|
||||
// 构建映射数据(已验证所有状态都已映射,所以不会有 undefined)
|
||||
const mappingItems: StatusMappingItem[] = uniqueStatusValues.value.map(
|
||||
(status) => ({
|
||||
// 构建映射数据(只包含已映射的状态)
|
||||
const mappingItems: StatusMappingItem[] = uniqueStatusValues.value
|
||||
.filter((status) => statusMappings.value[status] !== undefined)
|
||||
.map((status) => ({
|
||||
csvStatus: status,
|
||||
mappedStatusId: statusMappings.value[status]!,
|
||||
}),
|
||||
);
|
||||
}));
|
||||
|
||||
const mappingJson = JSON.stringify(mappingItems);
|
||||
|
||||
@@ -712,14 +710,7 @@ const handleNext = () => {
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
// 验证所有订单状态是否都已映射
|
||||
const unMappedStatuses = uniqueStatusValues.value.filter(
|
||||
(status) => statusMappings.value[status] === undefined,
|
||||
);
|
||||
if (unMappedStatuses.length > 0) {
|
||||
message.warning(`请先映射所有订单状态:${unMappedStatuses.join('、')}`);
|
||||
return;
|
||||
}
|
||||
// 订单状态映射是可选的,可以直接进入下一步
|
||||
currentStep.value = 3;
|
||||
|
||||
break;
|
||||
@@ -781,9 +772,10 @@ const handleCreateTask = async () => {
|
||||
required: m.fieldDef.required,
|
||||
}));
|
||||
|
||||
// 构建订单状态映射 JSON(已验证所有状态都已映射,所以不会有 undefined)
|
||||
const statusMappingItems: StatusMappingItem[] =
|
||||
uniqueStatusValues.value.map((status) => ({
|
||||
// 构建订单状态映射 JSON(只包含已映射的状态)
|
||||
const statusMappingItems: StatusMappingItem[] = uniqueStatusValues.value
|
||||
.filter((status) => statusMappings.value[status] !== undefined)
|
||||
.map((status) => ({
|
||||
csvStatus: status,
|
||||
mappedStatusId: statusMappings.value[status]!,
|
||||
}));
|
||||
@@ -886,7 +878,7 @@ const shopOptions = computed(() => {
|
||||
|
||||
<template>
|
||||
<Modal title="创建导入任务" :loading="loading">
|
||||
<div class="space-y-6">
|
||||
<div class="space-y-3">
|
||||
<!-- 步骤条 -->
|
||||
<Steps :current="currentStep">
|
||||
<Steps.Step title="选择店铺" />
|
||||
@@ -1014,7 +1006,7 @@ const shopOptions = computed(() => {
|
||||
<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
|
||||
@@ -1065,10 +1057,6 @@ const shopOptions = computed(() => {
|
||||
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>
|
||||
@@ -1076,9 +1064,10 @@ const shopOptions = computed(() => {
|
||||
</div>
|
||||
<Select
|
||||
v-model:value="statusMappings[statusValue]"
|
||||
placeholder="请选择订单状态"
|
||||
placeholder="请选择订单状态(可选)"
|
||||
class="w-[200px]"
|
||||
show-search
|
||||
allow-clear
|
||||
:loading="orderStatusLoading"
|
||||
:options="
|
||||
orderStatusList.map((status) => ({
|
||||
@@ -1143,7 +1132,7 @@ const shopOptions = computed(() => {
|
||||
</div>
|
||||
|
||||
<!-- 操作按钮 -->
|
||||
<div class="flex justify-between border-t pt-4">
|
||||
<div class="flex justify-between">
|
||||
<Button @click="handleCancel">取消</Button>
|
||||
<div class="space-x-2">
|
||||
<Button v-if="currentStep > 0" @click="handlePrev">上一步</Button>
|
||||
@@ -1198,7 +1187,3 @@ const shopOptions = computed(() => {
|
||||
</SaveStatusTemplateModal>
|
||||
</Modal>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 自定义样式 */
|
||||
</style>
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
<script setup lang="ts">
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
|
||||
import { computed, ref } from 'vue';
|
||||
|
||||
import { Page } from '@vben/common-ui';
|
||||
import { computed, nextTick, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
|
||||
import { Button, message } from 'ant-design-vue';
|
||||
|
||||
@@ -20,6 +18,8 @@ const csvData = ref<any[]>([]);
|
||||
const csvHeaders = ref<string[]>([]);
|
||||
const importLoading = ref(false);
|
||||
const currentFile = ref<File | null>(null);
|
||||
const tableContainerRef = ref<HTMLElement>();
|
||||
const tableHeight = ref<number>(600);
|
||||
|
||||
// 动态生成Grid列配置
|
||||
const gridColumns = computed(() => {
|
||||
@@ -53,7 +53,7 @@ const gridColumns = computed(() => {
|
||||
// VbenVxeGrid 表格配置
|
||||
const gridOptions: VxeGridProps<any> = {
|
||||
columns: [],
|
||||
height: 'auto',
|
||||
height: tableHeight.value,
|
||||
border: true,
|
||||
stripe: true,
|
||||
highlightHoverRow: true,
|
||||
@@ -122,11 +122,23 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
||||
const updateTable = () => {
|
||||
gridApi.setGridOptions({
|
||||
columns: gridColumns.value,
|
||||
height: tableHeight.value,
|
||||
});
|
||||
// 触发重新加载数据
|
||||
gridApi.reload();
|
||||
};
|
||||
|
||||
// 监听表格高度变化,更新表格配置
|
||||
watch(
|
||||
tableHeight,
|
||||
(newHeight) => {
|
||||
gridApi.setGridOptions({
|
||||
height: newHeight,
|
||||
});
|
||||
},
|
||||
{ immediate: false },
|
||||
);
|
||||
|
||||
// 处理文件上传
|
||||
const handleFileUpload = async (file: File) => {
|
||||
importLoading.value = true;
|
||||
@@ -148,6 +160,10 @@ const handleFileUpload = async (file: File) => {
|
||||
|
||||
// 更新表格
|
||||
updateTable();
|
||||
// 重新计算表格高度
|
||||
nextTick(() => {
|
||||
calculateTableHeight();
|
||||
});
|
||||
|
||||
message.success(`成功解析 ${result.data.length} 条数据`);
|
||||
} catch (error: any) {
|
||||
@@ -183,45 +199,213 @@ const handleClearData = () => {
|
||||
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);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
// 监听窗口大小变化
|
||||
let resizeObserver: null | ResizeObserver = null;
|
||||
|
||||
onMounted(() => {
|
||||
calculateTableHeight();
|
||||
if (tableContainerRef.value) {
|
||||
resizeObserver = new ResizeObserver(() => {
|
||||
calculateTableHeight();
|
||||
});
|
||||
resizeObserver.observe(tableContainerRef.value);
|
||||
}
|
||||
});
|
||||
|
||||
onUnmounted(() => {
|
||||
if (resizeObserver) {
|
||||
resizeObserver.disconnect();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Page auto-content-height>
|
||||
<!-- 顶部栏 -->
|
||||
<template #extra>
|
||||
<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
|
||||
class="h-full overflow-hidden bg-gradient-to-br from-indigo-100 via-pink-100 to-slate-100 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">
|
||||
订单导入中心
|
||||
</h1>
|
||||
<p class="text-base font-medium text-slate-500">
|
||||
请上传 CSV 格式的订单原始数据进行分析
|
||||
</p>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- 主体内容区域 -->
|
||||
<div
|
||||
v-if="csvData.length === 0"
|
||||
class="flex h-full items-center justify-center"
|
||||
>
|
||||
<FileUploadArea
|
||||
:loading="importLoading"
|
||||
@file-selected="handleFileUpload"
|
||||
/>
|
||||
<!-- 主体内容区域 -->
|
||||
<div
|
||||
v-if="csvData.length === 0"
|
||||
class="flex min-h-0 flex-1 flex-col overflow-hidden"
|
||||
>
|
||||
<div
|
||||
class="mb-8 grid shrink-0 grid-cols-1 gap-6 lg:grid-cols-[2fr_1fr]"
|
||||
>
|
||||
<!-- 左侧:导入区域 -->
|
||||
<div
|
||||
class="relative flex min-h-[400px] flex-col items-center justify-center overflow-hidden rounded-[2rem] border border-white/50 bg-white/45 p-8 shadow-[0_25px_50px_-12px_rgba(0,0,0,0.1)] backdrop-blur-2xl"
|
||||
>
|
||||
<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"
|
||||
>
|
||||
<FileUploadArea
|
||||
:loading="importLoading"
|
||||
@file-selected="handleFileUpload"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 右侧:指引与历史 -->
|
||||
<div class="flex flex-col gap-6">
|
||||
<!-- 操作指南卡片 -->
|
||||
<div
|
||||
class="relative flex flex-col gap-4 overflow-hidden rounded-[2rem] border border-white/50 bg-white/45 p-6 shadow-[0_25px_50px_-12px_rgba(0,0,0,0.1)] backdrop-blur-2xl"
|
||||
>
|
||||
<h3 class="m-0 text-base font-bold text-slate-800">操作指南</h3>
|
||||
<div class="flex flex-col gap-4">
|
||||
<div class="flex items-start gap-3">
|
||||
<div
|
||||
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full bg-indigo-600 text-xs font-bold text-white"
|
||||
>
|
||||
1
|
||||
</div>
|
||||
<p
|
||||
class="m-0 text-xs font-medium leading-relaxed text-slate-500"
|
||||
>
|
||||
从电商后台导出【订单详情】CSV文件
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-start gap-3">
|
||||
<div
|
||||
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-indigo-100 bg-white text-xs font-bold text-indigo-600"
|
||||
>
|
||||
2
|
||||
</div>
|
||||
<p
|
||||
class="m-0 text-xs font-medium leading-relaxed text-slate-500"
|
||||
>
|
||||
检查文件是否包含【订单号】与【金额】列
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex items-start gap-3">
|
||||
<div
|
||||
class="flex h-6 w-6 shrink-0 items-center justify-center rounded-full border border-indigo-100 bg-white text-xs font-bold text-indigo-600"
|
||||
>
|
||||
3
|
||||
</div>
|
||||
<p
|
||||
class="m-0 text-xs font-medium leading-relaxed text-slate-500"
|
||||
>
|
||||
上传成功后,系统将自动解析并显示数据
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 底部全局按钮 -->
|
||||
<div class="flex justify-center gap-4 pt-4">
|
||||
<Button :disabled="csvData.length === 0" @click="handleClearData">
|
||||
清空当前选择
|
||||
</Button>
|
||||
<Button
|
||||
type="primary"
|
||||
:disabled="csvHeaders.length === 0"
|
||||
@click="handleCreateImportTask"
|
||||
>
|
||||
创建导入任务
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 数据表格区域 -->
|
||||
<div v-else class="flex min-h-0 w-full flex-1 flex-col overflow-hidden">
|
||||
<div
|
||||
class="mb-6 flex shrink-0 flex-wrap items-start justify-between gap-4"
|
||||
>
|
||||
<div class="flex-1">
|
||||
<h2 class="mb-1 text-2xl font-bold text-slate-800">数据预览</h2>
|
||||
<p class="m-0 text-sm text-slate-500">
|
||||
共 {{ csvData.length }} 条数据,请检查数据后创建导入任务
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
<Button @click="handleClearData">清空数据</Button>
|
||||
<Button type="primary" @click="handleCreateImportTask">
|
||||
创建导入任务
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div
|
||||
ref="tableContainerRef"
|
||||
class="flex min-h-0 flex-1 flex-col overflow-hidden rounded-[2rem] border border-white/50 bg-white/45 p-6 shadow-[0_25px_50px_-12px_rgba(0,0,0,0.1)] backdrop-blur-2xl"
|
||||
>
|
||||
<Grid />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<CreateImportTaskModal ref="createImportTaskModalRef" />
|
||||
</div>
|
||||
|
||||
<Grid v-else />
|
||||
<CreateImportTaskModal ref="createImportTaskModalRef" />
|
||||
</Page>
|
||||
</div>
|
||||
</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;
|
||||
}
|
||||
|
||||
/* VxeGrid 表格样式 */
|
||||
:deep(.vxe-grid) {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
:deep(.vxe-grid--body-wrapper) {
|
||||
flex: 1;
|
||||
overflow: auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
+66
-13
@@ -68,7 +68,10 @@ const formData = ref<Partial<OrderDTO.Create>>({
|
||||
linkSpecName: '',
|
||||
quantity: 1,
|
||||
unitPrice: 0,
|
||||
costPrice: 0,
|
||||
productCost: 0,
|
||||
shippingCost: 0,
|
||||
otherCost: 0,
|
||||
remark: '',
|
||||
});
|
||||
|
||||
// 下拉选项数据
|
||||
@@ -103,7 +106,7 @@ const rules = {
|
||||
],
|
||||
quantity: [{ required: true, message: '请输入数量', trigger: 'blur' }],
|
||||
unitPrice: [{ required: true, message: '请输入销售单价', trigger: 'blur' }],
|
||||
costPrice: [{ required: true, message: '请输入成本价', trigger: 'blur' }],
|
||||
productCost: [{ required: true, message: '请输入商品成本', trigger: 'blur' }],
|
||||
};
|
||||
|
||||
// 表单引用
|
||||
@@ -212,7 +215,9 @@ function handleProductChange(productId: number | undefined) {
|
||||
formData.value.linkProductName = '';
|
||||
formData.value.productSpecId = undefined;
|
||||
formData.value.linkSpecName = '';
|
||||
formData.value.costPrice = 0;
|
||||
formData.value.productCost = 0;
|
||||
formData.value.shippingCost = 0;
|
||||
formData.value.otherCost = 0;
|
||||
productSpecOptions.value = [];
|
||||
}
|
||||
}
|
||||
@@ -225,11 +230,15 @@ function handleProductSpecChange(specId: number | undefined) {
|
||||
);
|
||||
if (selectedSpec) {
|
||||
formData.value.linkSpecName = selectedSpec.spec.name;
|
||||
formData.value.costPrice = selectedSpec.spec.costPrice;
|
||||
formData.value.productCost = selectedSpec.spec.productCost;
|
||||
formData.value.shippingCost = selectedSpec.spec.shippingCost || 0;
|
||||
formData.value.otherCost = selectedSpec.spec.otherCost || 0;
|
||||
}
|
||||
} else {
|
||||
formData.value.linkSpecName = '';
|
||||
formData.value.costPrice = 0;
|
||||
formData.value.productCost = 0;
|
||||
formData.value.shippingCost = 0;
|
||||
formData.value.otherCost = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -274,7 +283,10 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
linkSpecName: record.linkSpecName,
|
||||
quantity: record.quantity,
|
||||
unitPrice: record.unitPrice,
|
||||
costPrice: record.costPrice,
|
||||
productCost: record.productCost,
|
||||
shippingCost: record.shippingCost || 0,
|
||||
otherCost: record.otherCost || 0,
|
||||
remark: record.remark || '',
|
||||
}
|
||||
: {
|
||||
shopId: undefined,
|
||||
@@ -288,7 +300,10 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
linkSpecName: '',
|
||||
quantity: 1,
|
||||
unitPrice: 0,
|
||||
costPrice: 0,
|
||||
productCost: 0,
|
||||
shippingCost: 0,
|
||||
otherCost: 0,
|
||||
remark: '',
|
||||
};
|
||||
|
||||
// 如果是编辑模式且有商品ID,加载商品和规格选项
|
||||
@@ -319,7 +334,9 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
spec: {
|
||||
id: record.productSpecId,
|
||||
name: record.linkSpecName || '',
|
||||
costPrice: record.costPrice,
|
||||
productCost: record.productCost,
|
||||
shippingCost: record.shippingCost,
|
||||
otherCost: record.otherCost,
|
||||
} as ProductSpecVO.Info,
|
||||
});
|
||||
}
|
||||
@@ -354,7 +371,10 @@ async function handleSubmit() {
|
||||
linkSpecName: formData.value.linkSpecName,
|
||||
quantity: formData.value.quantity,
|
||||
unitPrice: formData.value.unitPrice,
|
||||
costPrice: formData.value.costPrice,
|
||||
productCost: formData.value.productCost,
|
||||
shippingCost: formData.value.shippingCost,
|
||||
otherCost: formData.value.otherCost,
|
||||
remark: formData.value.remark,
|
||||
};
|
||||
await updateOrderApi(currentRecord.value.id, updateData);
|
||||
message.success('更新订单成功');
|
||||
@@ -372,7 +392,10 @@ async function handleSubmit() {
|
||||
linkSpecName: formData.value.linkSpecName,
|
||||
quantity: formData.value.quantity!,
|
||||
unitPrice: formData.value.unitPrice!,
|
||||
costPrice: formData.value.costPrice!,
|
||||
productCost: formData.value.productCost!,
|
||||
shippingCost: formData.value.shippingCost,
|
||||
otherCost: formData.value.otherCost,
|
||||
remark: formData.value.remark,
|
||||
};
|
||||
await createOrderApi(createData);
|
||||
message.success('创建订单成功');
|
||||
@@ -532,10 +555,10 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="成本价" name="costPrice">
|
||||
<Form.Item label="商品成本" name="productCost">
|
||||
<InputNumber
|
||||
v-model:value="formData.costPrice"
|
||||
placeholder="请输入成本价"
|
||||
v-model:value="formData.productCost"
|
||||
placeholder="请输入商品成本"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
@@ -543,6 +566,36 @@ defineExpose({
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<Form.Item label="运费成本" name="shippingCost">
|
||||
<InputNumber
|
||||
v-model:value="formData.shippingCost"
|
||||
placeholder="请输入运费成本"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="其他成本" name="otherCost">
|
||||
<InputNumber
|
||||
v-model:value="formData.otherCost"
|
||||
placeholder="请输入其他成本"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
<Form.Item label="备注" name="remark">
|
||||
<Input.TextArea
|
||||
v-model:value="formData.remark"
|
||||
placeholder="请输入备注"
|
||||
:rows="3"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="实收金额" name="receivedAmount">
|
||||
<InputNumber
|
||||
v-model:value="formData.receivedAmount"
|
||||
|
||||
+54
-16
@@ -51,7 +51,10 @@ const currentSpecId = ref<null | number>(null);
|
||||
const specFormData = ref({
|
||||
name: '',
|
||||
specCode: '',
|
||||
costPrice: 0,
|
||||
productCost: 0,
|
||||
shippingCost: 0,
|
||||
otherCost: 0,
|
||||
remark: '',
|
||||
});
|
||||
|
||||
// 声明模态框 API(稍后赋值)
|
||||
@@ -75,10 +78,11 @@ async function handleSpecSubmit() {
|
||||
specFormModalApi?.setState({ confirmLoading: true });
|
||||
|
||||
if (isEditSpec.value && currentSpecId.value) {
|
||||
await updateProductSpecApi(
|
||||
currentSpecId.value,
|
||||
specFormData.value as ProductSpecDTO.Update,
|
||||
);
|
||||
const updateData: ProductSpecDTO.Update = {
|
||||
id: currentSpecId.value,
|
||||
...specFormData.value,
|
||||
};
|
||||
await updateProductSpecApi(currentSpecId.value, updateData);
|
||||
message.success('更新成功');
|
||||
} else {
|
||||
if (!currentProduct.value) {
|
||||
@@ -149,12 +153,12 @@ const columns = [
|
||||
width: 150,
|
||||
},
|
||||
{
|
||||
title: '成本价',
|
||||
dataIndex: 'costPrice',
|
||||
key: 'costPrice',
|
||||
title: '商品成本',
|
||||
dataIndex: 'productCost',
|
||||
key: 'productCost',
|
||||
width: 120,
|
||||
customRender: ({ record }: { record: ProductSpecVO.Info }) => {
|
||||
return `¥${record.costPrice.toFixed(2)}`;
|
||||
return `¥${record.productCost.toFixed(2)}`;
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -236,7 +240,10 @@ function handleAddSpec() {
|
||||
specFormData.value = {
|
||||
name: '',
|
||||
specCode: '',
|
||||
costPrice: 0,
|
||||
productCost: 0,
|
||||
shippingCost: 0,
|
||||
otherCost: 0,
|
||||
remark: '',
|
||||
};
|
||||
specFormModalApi.setState({ title: '添加规格' });
|
||||
specFormModalApi.open();
|
||||
@@ -249,7 +256,10 @@ function handleEditSpec(record: ProductSpecVO.Info) {
|
||||
specFormData.value = {
|
||||
name: record.name,
|
||||
specCode: record.specCode || '',
|
||||
costPrice: record.costPrice,
|
||||
productCost: record.productCost,
|
||||
shippingCost: record.shippingCost || 0,
|
||||
otherCost: record.otherCost || 0,
|
||||
remark: record.remark || '',
|
||||
};
|
||||
specFormModalApi.setState({ title: '编辑规格' });
|
||||
specFormModalApi.open();
|
||||
@@ -358,18 +368,46 @@ defineExpose({
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item
|
||||
label="成本价"
|
||||
name="costPrice"
|
||||
:rules="[{ required: true, message: '请输入成本价' }]"
|
||||
label="商品成本"
|
||||
name="productCost"
|
||||
:rules="[{ required: true, message: '请输入商品成本' }]"
|
||||
>
|
||||
<InputNumber
|
||||
v-model:value="specFormData.costPrice"
|
||||
placeholder="请输入成本价"
|
||||
v-model:value="specFormData.productCost"
|
||||
placeholder="请输入商品成本"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="运费成本" name="shippingCost">
|
||||
<InputNumber
|
||||
v-model:value="specFormData.shippingCost"
|
||||
placeholder="请输入运费成本"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="其他成本" name="otherCost">
|
||||
<InputNumber
|
||||
v-model:value="specFormData.otherCost"
|
||||
placeholder="请输入其他成本"
|
||||
style="width: 100%"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="备注" name="remark">
|
||||
<Input.TextArea
|
||||
v-model:value="specFormData.remark"
|
||||
placeholder="请输入备注"
|
||||
:rows="3"
|
||||
/>
|
||||
</Form.Item>
|
||||
</Form>
|
||||
</SpecFormModal>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user