feat:【mall 商城】交易订单(70% ele 初始化)

This commit is contained in:
YunaiV
2025-10-15 12:37:15 +08:00
parent 318cbc31b2
commit a82d492f58
10 changed files with 1036 additions and 814 deletions

View File

@@ -1,16 +1,16 @@
import type { VbenFormSchema } from '#/adapter/form';
import type { VxeTableGridOptions } from '#/adapter/vxe-table';
import type { VxeGridPropTypes } from '#/adapter/vxe-table';
import type { MallDeliveryPickUpStoreApi } from '#/api/mall/trade/delivery/pickUpStore';
import { ref } from 'vue';
import { DeliveryTypeEnum } from '@vben/constants';
import { DeliveryTypeEnum, DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { convertToInteger, formatToFraction } from '@vben/utils';
import { getSimpleDeliveryExpressList } from '#/api/mall/trade/delivery/express';
import { getSimpleDeliveryPickUpStoreList } from '#/api/mall/trade/delivery/pickUpStore';
import { DICT_TYPE } from '@vben/constants';
import { getDictOptions } from '@vben/hooks';
import { getAreaTree } from '#/api/system/area';
import { getRangePickerDefaultProps } from '#/utils';
const pickUpStoreList = ref<MallDeliveryPickUpStoreApi.PickUpStore[]>([]);
@@ -28,6 +28,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.TRADE_ORDER_STATUS, 'number'),
placeholder: '请选择订单状态',
clearable: true,
},
},
{
@@ -36,13 +38,10 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.PAY_CHANNEL_CODE, 'number'),
placeholder: '请选择支付方式',
clearable: true,
},
},
{
fieldName: 'name',
label: '品牌名称',
component: 'Input',
},
{
fieldName: 'createTime',
label: '创建时间',
@@ -58,6 +57,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.TERMINAL, 'number'),
placeholder: '请选择订单来源',
clearable: true,
},
},
{
@@ -66,6 +67,8 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'Select',
componentProps: {
options: getDictOptions(DICT_TYPE.TRADE_DELIVERY_TYPE, 'number'),
placeholder: '请选择配送方式',
clearable: true,
},
},
{
@@ -74,8 +77,12 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'ApiSelect',
componentProps: {
api: getSimpleDeliveryExpressList,
labelField: 'name',
valueField: 'id',
fieldNames: {
label: 'name',
value: 'id',
},
placeholder: '请选择快递公司',
clearable: true,
},
dependencies: {
triggerFields: ['deliveryType'],
@@ -88,8 +95,12 @@ export function useGridFormSchema(): VbenFormSchema[] {
component: 'ApiSelect',
componentProps: {
api: getSimpleDeliveryPickUpStoreList,
labelField: 'name',
valueField: 'id',
fieldNames: {
label: 'name',
value: 'id',
},
placeholder: '请选择自提门店',
clearable: true,
},
dependencies: {
triggerFields: ['deliveryType'],
@@ -100,16 +111,56 @@ export function useGridFormSchema(): VbenFormSchema[] {
fieldName: 'pickUpVerifyCode',
label: '核销码',
component: 'Input',
componentProps: {
placeholder: '请输入核销码',
clearable: true,
},
dependencies: {
triggerFields: ['deliveryType'],
show: (values) => values.deliveryType === DeliveryTypeEnum.PICK_UP.type,
},
},
{
fieldName: 'no',
label: '订单号',
component: 'Input',
componentProps: {
placeholder: '请输入订单号',
clearable: true,
},
},
{
fieldName: 'userId',
label: '用户 UID',
component: 'Input',
componentProps: {
placeholder: '请输入用户 UID',
clearable: true,
},
},
{
fieldName: 'userNickname',
label: '用户昵称',
component: 'Input',
componentProps: {
placeholder: '请输入用户昵称',
clearable: true,
},
},
{
fieldName: 'userMobile',
label: '用户电话',
component: 'Input',
componentProps: {
placeholder: '请输入用户电话',
clearable: true,
},
},
];
}
/** 表格列配置 */
export function useGridColumns(): VxeTableGridOptions['columns'] {
export function useGridColumns(): VxeGridPropTypes.Columns {
return [
{
type: 'expand',
@@ -162,11 +213,10 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
},
minWidth: 80,
},
{
field: 'payPrice',
title: '实际支付',
formatter: 'formatFenToYuanAmount',
formatter: 'formatAmount2',
minWidth: 180,
},
{
@@ -212,3 +262,199 @@ export function useGridColumns(): VxeTableGridOptions['columns'] {
},
];
}
/** 订单备注表单配置 */
export function useRemarkFormSchema(): VbenFormSchema[] {
return [
{
component: 'Input',
fieldName: 'id',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'remark',
label: '备注',
component: 'Input',
componentProps: {
type: 'textarea',
rows: 3,
},
},
];
}
/** 订单调价表单配置 */
export function usePriceFormSchema(): VbenFormSchema[] {
return [
{
component: 'Input',
fieldName: 'id',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'payPrice',
label: '应付金额(总)',
component: 'Input',
componentProps: {
placeholder: '请输入应付金额(总)',
disabled: true,
formatter: (value: string) => `${value}`,
},
},
{
fieldName: 'adjustPrice',
label: '订单调价',
component: 'InputNumber',
componentProps: {
placeholder: '请输入订单调价',
step: 0.1,
precision: 2,
},
help: '订单调价。 正数,加价;负数,减价',
rules: 'required',
},
{
fieldName: 'newPayPrice',
label: '调价后',
component: 'Input',
componentProps: {
placeholder: '',
formatter: (value: string) => `${value}`,
},
dependencies: {
triggerFields: ['payPrice', 'adjustPrice'],
disabled: true,
trigger(values, form) {
const originalPrice = convertToInteger(values.payPrice);
const adjustPrice = convertToInteger(values.adjustPrice);
const newPrice = originalPrice + adjustPrice;
form.setFieldValue('newPayPrice', formatToFraction(newPrice));
},
},
},
];
}
/** 订单修改地址表单配置 */
export function useAddressFormSchema(): VbenFormSchema[] {
return [
{
component: 'Input',
fieldName: 'id',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'receiverName',
label: '收件人',
component: 'Input',
componentProps: {
placeholder: '请输入收件人名称',
},
rules: 'required',
},
{
fieldName: 'receiverMobile',
label: '手机号',
component: 'Input',
componentProps: {
placeholder: '请输入收件人手机号',
},
rules: 'required',
},
{
fieldName: 'receiverAreaId',
label: '所在地',
component: 'ApiTreeSelect',
componentProps: {
api: () => getAreaTree(),
fieldNames: {
label: 'name',
value: 'id',
children: 'children',
},
placeholder: '请选择收件人所在地',
treeDefaultExpandAll: true,
},
rules: 'required',
},
{
fieldName: 'receiverDetailAddress',
label: '详细地址',
component: 'Input',
componentProps: {
placeholder: '请输入收件人详细地址',
type: 'textarea',
rows: 3,
},
rules: 'required',
},
];
}
/** 订单发货表单配置 */
export function useDeliveryFormSchema(): VbenFormSchema[] {
return [
{
component: 'Input',
fieldName: 'id',
dependencies: {
triggerFields: [''],
show: () => false,
},
},
{
fieldName: 'expressType',
label: '发货方式',
component: 'RadioGroup',
componentProps: {
options: [
{ label: '快递', value: 'express' },
{ label: '无需发货', value: 'none' },
],
buttonStyle: 'solid',
optionType: 'button',
},
defaultValue: 'express',
},
{
fieldName: 'logisticsId',
label: '物流公司',
component: 'ApiSelect',
componentProps: {
api: getSimpleDeliveryExpressList,
fieldNames: {
label: 'name',
value: 'id',
},
placeholder: '请选择物流公司',
},
dependencies: {
triggerFields: ['expressType'],
show: (values) => values.expressType === 'express',
},
rules: 'required',
},
{
fieldName: 'logisticsNo',
label: '物流单号',
component: 'Input',
componentProps: {
placeholder: '请输入物流单号',
},
dependencies: {
triggerFields: ['expressType'],
show: (values) => values.expressType === 'express',
},
rules: 'required',
},
];
}