feat:【mall 商城】交易订单(30% antd list 优化代码风格)

This commit is contained in:
YunaiV
2025-10-14 23:49:51 +08:00
parent 8c5680de81
commit cc44ee3daa
3 changed files with 74 additions and 39 deletions

View File

@@ -4,13 +4,11 @@ import type { MallDeliveryPickUpStoreApi } from '#/api/mall/trade/delivery/pickU
import { ref } from 'vue'; import { ref } from 'vue';
import { DeliveryTypeEnum } from '@vben/constants'; import { DeliveryTypeEnum, DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { getSimpleDeliveryExpressList } from '#/api/mall/trade/delivery/express'; import { getSimpleDeliveryExpressList } from '#/api/mall/trade/delivery/express';
import { getSimpleDeliveryPickUpStoreList } from '#/api/mall/trade/delivery/pickUpStore'; import { getSimpleDeliveryPickUpStoreList } from '#/api/mall/trade/delivery/pickUpStore';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { getRangePickerDefaultProps } from '#/utils'; import { getRangePickerDefaultProps } from '#/utils';
const pickUpStoreList = ref<MallDeliveryPickUpStoreApi.PickUpStore[]>([]); const pickUpStoreList = ref<MallDeliveryPickUpStoreApi.PickUpStore[]>([]);
@@ -28,6 +26,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.TRADE_ORDER_STATUS, 'number'), options: getDictOptions(DICT_TYPE.TRADE_ORDER_STATUS, 'number'),
placeholder: '请选择订单状态',
allowClear: true,
}, },
}, },
{ {
@@ -36,13 +36,10 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.PAY_CHANNEL_CODE, 'number'), options: getDictOptions(DICT_TYPE.PAY_CHANNEL_CODE, 'number'),
placeholder: '请选择支付方式',
allowClear: true,
}, },
}, },
{
fieldName: 'name',
label: '品牌名称',
component: 'Input',
},
{ {
fieldName: 'createTime', fieldName: 'createTime',
label: '创建时间', label: '创建时间',
@@ -58,6 +55,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.TERMINAL, 'number'), options: getDictOptions(DICT_TYPE.TERMINAL, 'number'),
placeholder: '请选择订单来源',
allowClear: true,
}, },
}, },
{ {
@@ -66,6 +65,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Select', component: 'Select',
componentProps: { componentProps: {
options: getDictOptions(DICT_TYPE.TRADE_DELIVERY_TYPE, 'number'), options: getDictOptions(DICT_TYPE.TRADE_DELIVERY_TYPE, 'number'),
placeholder: '请选择配送方式',
allowClear: true,
}, },
}, },
{ {
@@ -78,6 +79,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: 'name', label: 'name',
value: 'id', value: 'id',
}, },
placeholder: '请选择快递公司',
allowClear: true,
}, },
dependencies: { dependencies: {
triggerFields: ['deliveryType'], triggerFields: ['deliveryType'],
@@ -94,6 +97,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
label: 'name', label: 'name',
value: 'id', value: 'id',
}, },
placeholder: '请选择自提门店',
allowClear: true,
}, },
dependencies: { dependencies: {
triggerFields: ['deliveryType'], triggerFields: ['deliveryType'],
@@ -104,11 +109,51 @@ export function useGridFormSchema(): VbenFormSchema[] {
fieldName: 'deliveryType', fieldName: 'deliveryType',
label: '核销码', label: '核销码',
component: 'Input', component: 'Input',
componentProps: {
placeholder: '请输入核销码',
allowClear: true,
},
dependencies: { dependencies: {
triggerFields: ['deliveryType'], triggerFields: ['deliveryType'],
show: (values) => values.deliveryType === DeliveryTypeEnum.PICK_UP.type, show: (values) => values.deliveryType === DeliveryTypeEnum.PICK_UP.type,
}, },
}, },
{
fieldName: 'no',
label: '订单号',
component: 'Input',
componentProps: {
placeholder: '请输入订单号',
allowClear: true,
},
},
{
fieldName: 'userId',
label: '用户 UID',
component: 'Input',
componentProps: {
placeholder: '请输入用户 UID',
allowClear: true,
},
},
{
fieldName: 'userNickname',
label: '用户昵称',
component: 'Input',
componentProps: {
placeholder: '请输入用户昵称',
allowClear: true,
},
},
{
fieldName: 'userMobile',
label: '用户电话',
component: 'Input',
componentProps: {
placeholder: '请输入用户电话',
allowClear: true,
},
},
]; ];
} }

View File

@@ -2,10 +2,9 @@
import type { VxeTableGridOptions } from '#/adapter/vxe-table'; import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { MallOrderApi } from '#/api/mall/trade/order'; import type { MallOrderApi } from '#/api/mall/trade/order';
import { h } from 'vue';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { DocAlert, Page, prompt, useVbenModal } from '@vben/common-ui'; import { DocAlert, Page, useVbenModal } from '@vben/common-ui';
import { import {
DeliveryTypeEnum, DeliveryTypeEnum,
DICT_TYPE, DICT_TYPE,
@@ -13,20 +12,26 @@ import {
} from '@vben/constants'; } from '@vben/constants';
import { fenToYuan } from '@vben/utils'; import { fenToYuan } from '@vben/utils';
import { Image, List, Tag, Textarea } from 'ant-design-vue'; import { Image, List, Tag } from 'ant-design-vue';
import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table'; import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
import { getOrderPage, updateOrderRemark } from '#/api/mall/trade/order'; import { getOrderPage } from '#/api/mall/trade/order';
import { DictTag } from '#/components/dict-tag'; import { DictTag } from '#/components/dict-tag';
import { $t } from '#/locales'; import { $t } from '#/locales';
import { useGridColumns, useGridFormSchema } from './data'; import { useGridColumns, useGridFormSchema } from './data';
import DeleveryForm from './modules/delevery-form.vue'; import DeliveryForm from './modules/delivery-form.vue';
import UpdateRemarkForm from './modules/update-remark-form.vue';
const { push } = useRouter(); const { push } = useRouter();
const [DeleveryFormModal, deleveryFormModalApi] = useVbenModal({ const [DeliveryFormModal, deliveryFormModalApi] = useVbenModal({
connectedComponent: DeleveryForm, connectedComponent: DeliveryForm,
destroyOnClose: true,
});
const [UpdateRemarkFormModal, updateRemarkFormModalApi] = useVbenModal({
connectedComponent: UpdateRemarkForm,
destroyOnClose: true, destroyOnClose: true,
}); });
@@ -42,30 +47,12 @@ function handleDetail(row: MallOrderApi.Order) {
/** 发货 */ /** 发货 */
function handleDelivery(row: MallOrderApi.Order) { function handleDelivery(row: MallOrderApi.Order) {
deleveryFormModalApi.setData(row).open(); deliveryFormModalApi.setData(row).open();
} }
/** 备注 */ /** 备注 */
function handleRemake(row: MallOrderApi.Order) { function handleRemark(row: MallOrderApi.Order) {
prompt({ updateRemarkFormModalApi.setData(row).open();
component: () => {
return h(Textarea, {
defaultValue: row.remark,
rows: 3,
});
},
content: '请输入订单备注',
title: '订单备注',
modelPropName: 'value',
}).then(async (val) => {
if (val) {
await updateOrderRemark({
id: row.id as number,
remark: val,
});
handleRefresh();
}
});
} }
const [Grid, gridApi] = useVbenVxeGrid({ const [Grid, gridApi] = useVbenVxeGrid({
@@ -94,6 +81,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
}, },
rowConfig: { rowConfig: {
keyField: 'id', keyField: 'id',
isHover: true,
}, },
toolbarConfig: { toolbarConfig: {
refresh: true, refresh: true,
@@ -115,7 +103,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
url="https://doc.iocoder.cn/mall/trade-cart/" url="https://doc.iocoder.cn/mall/trade-cart/"
/> />
</template> </template>
<DeleveryFormModal @success="handleRefresh" />
<DeliveryFormModal @success="handleRefresh" />
<UpdateRemarkFormModal @success="handleRefresh" />
<Grid table-title="订单列表"> <Grid table-title="订单列表">
<template #expand_content="{ row }"> <template #expand_content="{ row }">
<List item-layout="vertical" :data-source="row.items"> <List item-layout="vertical" :data-source="row.items">
@@ -173,7 +163,7 @@ const [Grid, gridApi] = useVbenVxeGrid({
{ {
label: '备注', label: '备注',
type: 'link', type: 'link',
onClick: handleRemake.bind(null, row), onClick: handleRemark.bind(null, row),
}, },
]" ]"
/> />