mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 03:49: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>
|
||||
Reference in New Issue
Block a user