mirror of
https://gitee.com/qqtt-ah/ecom-dmb.git
synced 2026-11-25 03:09:19 +08:00
1
This commit is contained in:
+53
-47
@@ -1,6 +1,5 @@
|
||||
<script lang="ts" setup>
|
||||
import type { OrderDTO, OrderVO } from '#/api/ecommerce/order';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status';
|
||||
import type {
|
||||
ProductSpecDTO,
|
||||
ProductSpecVO,
|
||||
@@ -24,8 +23,12 @@ import {
|
||||
} from 'ant-design-vue';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
import { createOrderApi, updateOrderApi } from '#/api/ecommerce/order';
|
||||
import { getActiveOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import {
|
||||
createOrderApi,
|
||||
updateOrderApi,
|
||||
} from '#/api/ecommerce/order';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
|
||||
import { getProductPageApi } from '#/api/ecommerce/product';
|
||||
import { getProductSpecPageApi } from '#/api/ecommerce/product-spec';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
@@ -56,13 +59,13 @@ const currentRecord = ref<null | OrderVO.Info>(null);
|
||||
const formData = ref<Partial<OrderDTO.Create>>({
|
||||
shopId: undefined,
|
||||
platformOrderNo: '',
|
||||
statusId: undefined,
|
||||
statusId: undefined as number | undefined,
|
||||
receivedAmount: 0,
|
||||
orderDate: dayjs().format('YYYY-MM-DD'),
|
||||
orderTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: undefined,
|
||||
productSpecId: undefined,
|
||||
productName: '',
|
||||
specName: '',
|
||||
linkProductName: '',
|
||||
linkSpecName: '',
|
||||
quantity: 1,
|
||||
unitPrice: 0,
|
||||
costPrice: 0,
|
||||
@@ -93,9 +96,11 @@ const rules = {
|
||||
receivedAmount: [
|
||||
{ required: true, message: '请输入实收金额', trigger: 'blur' },
|
||||
],
|
||||
orderDate: [{ required: true, message: '请选择下单时间', trigger: 'change' }],
|
||||
orderTime: [{ required: true, message: '请选择下单时间', trigger: 'change' }],
|
||||
productId: [{ required: true, message: '请选择商品', trigger: 'change' }],
|
||||
productName: [{ required: true, message: '请输入商品名称', trigger: 'blur' }],
|
||||
linkProductName: [
|
||||
{ required: true, message: '请输入链接商品名称', trigger: 'blur' },
|
||||
],
|
||||
quantity: [{ required: true, message: '请输入数量', trigger: 'blur' }],
|
||||
unitPrice: [{ required: true, message: '请输入销售单价', trigger: 'blur' }],
|
||||
costPrice: [{ required: true, message: '请输入成本价', trigger: 'blur' }],
|
||||
@@ -125,7 +130,7 @@ async function fetchShopOptions() {
|
||||
// 获取订单状态选项
|
||||
async function fetchOrderStatusOptions() {
|
||||
try {
|
||||
const data = await getActiveOrderStatusListApi();
|
||||
const data = await getAllOrderStatusListApi();
|
||||
orderStatusOptions.value = data.map((status: OrderStatusVO.Info) => ({
|
||||
label: status.statusName,
|
||||
value: status.id,
|
||||
@@ -199,14 +204,14 @@ function handleProductChange(productId: number | undefined) {
|
||||
(opt) => opt.value === productId,
|
||||
);
|
||||
if (selectedProduct) {
|
||||
formData.value.productName = selectedProduct.product.name;
|
||||
formData.value.linkProductName = selectedProduct.product.name;
|
||||
// 加载该商品的规格列表
|
||||
searchProductSpecs('');
|
||||
}
|
||||
} else {
|
||||
formData.value.productName = '';
|
||||
formData.value.linkProductName = '';
|
||||
formData.value.productSpecId = undefined;
|
||||
formData.value.specName = '';
|
||||
formData.value.linkSpecName = '';
|
||||
formData.value.costPrice = 0;
|
||||
productSpecOptions.value = [];
|
||||
}
|
||||
@@ -219,11 +224,11 @@ function handleProductSpecChange(specId: number | undefined) {
|
||||
(opt) => opt.value === specId,
|
||||
);
|
||||
if (selectedSpec) {
|
||||
formData.value.specName = selectedSpec.spec.name;
|
||||
formData.value.linkSpecName = selectedSpec.spec.name;
|
||||
formData.value.costPrice = selectedSpec.spec.costPrice;
|
||||
}
|
||||
} else {
|
||||
formData.value.specName = '';
|
||||
formData.value.linkSpecName = '';
|
||||
formData.value.costPrice = 0;
|
||||
}
|
||||
}
|
||||
@@ -247,8 +252,8 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
currentRecord.value = record || null;
|
||||
|
||||
// 加载下拉选项数据
|
||||
fetchShopOptions();
|
||||
fetchOrderStatusOptions();
|
||||
await fetchShopOptions();
|
||||
await fetchOrderStatusOptions();
|
||||
|
||||
modalApi.open();
|
||||
|
||||
@@ -260,13 +265,13 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
platformOrderNo: record.platformOrderNo || '',
|
||||
statusId: record.statusId,
|
||||
receivedAmount: record.receivedAmount,
|
||||
orderDate: record.orderDate
|
||||
? dayjs(record.orderDate).format('YYYY-MM-DD')
|
||||
: dayjs().format('YYYY-MM-DD'),
|
||||
orderTime: record.orderTime
|
||||
? dayjs(record.orderTime).format('YYYY-MM-DD HH:mm:ss')
|
||||
: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: record.productId,
|
||||
productSpecId: record.productSpecId,
|
||||
productName: record.productName,
|
||||
specName: record.specName,
|
||||
linkProductName: record.linkProductName,
|
||||
linkSpecName: record.linkSpecName,
|
||||
quantity: record.quantity,
|
||||
unitPrice: record.unitPrice,
|
||||
costPrice: record.costPrice,
|
||||
@@ -276,11 +281,11 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
platformOrderNo: '',
|
||||
statusId: undefined,
|
||||
receivedAmount: 0,
|
||||
orderDate: dayjs().format('YYYY-MM-DD'),
|
||||
orderTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
productId: undefined,
|
||||
productSpecId: undefined,
|
||||
productName: '',
|
||||
specName: '',
|
||||
linkProductName: '',
|
||||
linkSpecName: '',
|
||||
quantity: 1,
|
||||
unitPrice: 0,
|
||||
costPrice: 0,
|
||||
@@ -288,20 +293,20 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
|
||||
// 如果是编辑模式且有商品ID,加载商品和规格选项
|
||||
if (edit && record?.productId) {
|
||||
await searchProducts(record.productName || '');
|
||||
await searchProducts(record.linkProductName || '');
|
||||
// 确保选中的商品在选项中
|
||||
if (!productOptions.value.some((opt) => opt.value === record.productId)) {
|
||||
productOptions.value.push({
|
||||
label: record.productName,
|
||||
label: record.linkProductName,
|
||||
value: record.productId,
|
||||
product: {
|
||||
id: record.productId,
|
||||
name: record.productName,
|
||||
name: record.linkProductName,
|
||||
} as ProductVO.Info,
|
||||
});
|
||||
}
|
||||
if (record.productSpecId) {
|
||||
await searchProductSpecs(record.specName || '');
|
||||
await searchProductSpecs(record.linkSpecName || '');
|
||||
// 确保选中的规格在选项中
|
||||
if (
|
||||
!productSpecOptions.value.some(
|
||||
@@ -309,11 +314,11 @@ async function open(edit: boolean, record?: OrderVO.Info) {
|
||||
)
|
||||
) {
|
||||
productSpecOptions.value.push({
|
||||
label: record.specName || '',
|
||||
label: record.linkSpecName || '',
|
||||
value: record.productSpecId,
|
||||
spec: {
|
||||
id: record.productSpecId,
|
||||
name: record.specName || '',
|
||||
name: record.linkSpecName || '',
|
||||
costPrice: record.costPrice,
|
||||
} as ProductSpecVO.Info,
|
||||
});
|
||||
@@ -342,11 +347,11 @@ async function handleSubmit() {
|
||||
platformOrderNo: formData.value.platformOrderNo,
|
||||
statusId: formData.value.statusId,
|
||||
receivedAmount: formData.value.receivedAmount!,
|
||||
orderDate: formData.value.orderDate!,
|
||||
orderTime: formData.value.orderTime!,
|
||||
productId: formData.value.productId,
|
||||
productSpecId: formData.value.productSpecId,
|
||||
productName: formData.value.productName,
|
||||
specName: formData.value.specName,
|
||||
linkProductName: formData.value.linkProductName,
|
||||
linkSpecName: formData.value.linkSpecName,
|
||||
quantity: formData.value.quantity,
|
||||
unitPrice: formData.value.unitPrice,
|
||||
costPrice: formData.value.costPrice,
|
||||
@@ -360,11 +365,11 @@ async function handleSubmit() {
|
||||
platformOrderNo: formData.value.platformOrderNo,
|
||||
statusId: formData.value.statusId!,
|
||||
receivedAmount: formData.value.receivedAmount!,
|
||||
orderDate: formData.value.orderDate!,
|
||||
orderTime: formData.value.orderTime!,
|
||||
productId: formData.value.productId!,
|
||||
productSpecId: formData.value.productSpecId,
|
||||
productName: formData.value.productName!,
|
||||
specName: formData.value.specName,
|
||||
linkProductName: formData.value.linkProductName!,
|
||||
linkSpecName: formData.value.linkSpecName,
|
||||
quantity: formData.value.quantity!,
|
||||
unitPrice: formData.value.unitPrice!,
|
||||
costPrice: formData.value.costPrice!,
|
||||
@@ -424,13 +429,14 @@ defineExpose({
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="下单时间" name="orderDate">
|
||||
<Form.Item label="下单时间" name="orderTime">
|
||||
<DatePicker
|
||||
v-model:value="formData.orderDate"
|
||||
v-model:value="formData.orderTime"
|
||||
placeholder="请选择下单时间"
|
||||
style="width: 100%"
|
||||
format="YYYY-MM-DD"
|
||||
value-format="YYYY-MM-DD"
|
||||
show-time
|
||||
format="YYYY-MM-DD HH:mm:ss"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
@@ -491,17 +497,17 @@ defineExpose({
|
||||
</div>
|
||||
|
||||
<div class="grid grid-cols-2 gap-4">
|
||||
<Form.Item label="商品名称" name="productName">
|
||||
<Form.Item label="链接商品名称" name="linkProductName">
|
||||
<Input
|
||||
v-model:value="formData.productName"
|
||||
placeholder="请输入商品名称"
|
||||
v-model:value="formData.linkProductName"
|
||||
placeholder="请输入链接商品名称"
|
||||
/>
|
||||
</Form.Item>
|
||||
|
||||
<Form.Item label="规格名称" name="specName">
|
||||
<Form.Item label="链接规格名称" name="linkSpecName">
|
||||
<Input
|
||||
v-model:value="formData.specName"
|
||||
placeholder="请输入规格名称(可选)"
|
||||
v-model:value="formData.linkSpecName"
|
||||
placeholder="请输入链接规格名称"
|
||||
/>
|
||||
</Form.Item>
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
<script lang="ts" setup>
|
||||
import type { VxeGridProps } from '#/adapter/vxe-table';
|
||||
import type { OrderDTO, OrderVO } from '#/api/ecommerce/order';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status';
|
||||
import type { ShopVO } from '#/api/ecommerce/shop/types';
|
||||
import type { PageQueryDTO } from '#/types/common';
|
||||
|
||||
@@ -13,8 +12,12 @@ import { createIconifyIcon } from '@vben/icons';
|
||||
import { Button, message, Popconfirm, Space, Tag } from 'ant-design-vue';
|
||||
|
||||
import { useVbenVxeGrid } from '#/adapter/vxe-table';
|
||||
import { deleteOrderApi, getOrderPageApi } from '#/api/ecommerce/order';
|
||||
import { getActiveOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import {
|
||||
deleteOrderApi,
|
||||
getOrderPageApi,
|
||||
} from '#/api/ecommerce/order';
|
||||
import { getAllOrderStatusListApi } from '#/api/ecommerce/order-status';
|
||||
import type { OrderStatusVO } from '#/api/ecommerce/order-status/types';
|
||||
import { getShopPageApi } from '#/api/ecommerce/shop';
|
||||
|
||||
import OrderFormModal from './components/OrderFormModal.vue';
|
||||
@@ -79,7 +82,7 @@ const gridOptions: VxeGridProps<any> = {
|
||||
slots: { default: 'orderStatus' },
|
||||
},
|
||||
{
|
||||
field: 'orderDate',
|
||||
field: 'orderTime',
|
||||
title: '下单时间',
|
||||
minWidth: 'auto',
|
||||
},
|
||||
@@ -190,7 +193,7 @@ const formOptions = computed(() => ({
|
||||
component: 'Select',
|
||||
componentProps: {
|
||||
placeholder: '请选择状态',
|
||||
options: orderStatusOptions.value,
|
||||
options: orderStatusOptions,
|
||||
allowClear: true,
|
||||
},
|
||||
fieldName: 'statusId',
|
||||
@@ -230,7 +233,7 @@ async function fetchShopOptions() {
|
||||
// 获取订单状态选项
|
||||
async function fetchOrderStatusOptions() {
|
||||
try {
|
||||
const data = await getActiveOrderStatusListApi();
|
||||
const data = await getAllOrderStatusListApi();
|
||||
orderStatusOptions.value = data.map((status: OrderStatusVO.Info) => ({
|
||||
label: status.statusName,
|
||||
value: status.id,
|
||||
@@ -277,7 +280,8 @@ function handleModalSuccess() {
|
||||
|
||||
// 初始化
|
||||
onMounted(async () => {
|
||||
await Promise.all([fetchShopOptions(), fetchOrderStatusOptions()]);
|
||||
await fetchShopOptions();
|
||||
await fetchOrderStatusOptions();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -297,10 +301,10 @@ onMounted(async () => {
|
||||
|
||||
<!-- 商品信息列 -->
|
||||
<template #productInfo="{ row }: { row: any }">
|
||||
<div v-if="row.productName">
|
||||
<div style="font-weight: bold">{{ row.productName }}</div>
|
||||
<div v-if="row.specName" style="color: #666; font-size: 12px">
|
||||
{{ row.specName }}
|
||||
<div v-if="row.linkProductName">
|
||||
<div style="font-weight: bold">{{ row.linkProductName }}</div>
|
||||
<div v-if="row.linkSpecName" style="color: #666; font-size: 12px">
|
||||
{{ row.linkSpecName }}
|
||||
</div>
|
||||
</div>
|
||||
<span v-else style="color: #999">暂无商品信息</span>
|
||||
@@ -321,11 +325,7 @@ onMounted(async () => {
|
||||
<!-- 订单状态列 -->
|
||||
<template #orderStatus="{ row }: { row: any }">
|
||||
<Tag color="blue">
|
||||
{{
|
||||
orderStatusOptions.find((s) => s.value === row.statusId)?.label ||
|
||||
row.statusName ||
|
||||
'未知状态'
|
||||
}}
|
||||
{{ row.statusName || '未知状态' }}
|
||||
</Tag>
|
||||
</template>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user