diff --git a/apps/web-antd/src/views/mall/trade/order/data.ts b/apps/web-antd/src/views/mall/trade/order/data.ts index aa1e1dfc1..310949c55 100644 --- a/apps/web-antd/src/views/mall/trade/order/data.ts +++ b/apps/web-antd/src/views/mall/trade/order/data.ts @@ -6,6 +6,7 @@ import { ref } from 'vue'; 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'; @@ -284,3 +285,58 @@ export function useRemarkFormSchema(): VbenFormSchema[] { }, ]; } + +/** 订单调价表单配置 */ +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)); + }, + }, + }, + ]; +} diff --git a/apps/web-antd/src/views/mall/trade/order/detail/index.vue b/apps/web-antd/src/views/mall/trade/order/detail/index.vue index 634655c23..94598bfbe 100644 --- a/apps/web-antd/src/views/mall/trade/order/detail/index.vue +++ b/apps/web-antd/src/views/mall/trade/order/detail/index.vue @@ -26,9 +26,9 @@ import { DictTag } from '#/components/dict-tag'; import { TableAction } from '#/components/table-action'; import DeliveryForm from '../modules/delivery-form.vue'; +import PriceForm from '../modules/price-form.vue'; import RemarkForm from '../modules/remark-form.vue'; import OrderUpdateAddressForm from '../modules/update-address-form.vue'; -import OrderUpdatePriceForm from '../modules/update-price-form.vue'; import { useDeliveryInfoSchema, useExpressTrackColumns, @@ -156,8 +156,8 @@ const [OrderUpdateAddressFormModal, addressFormModalApi] = useVbenModal({ destroyOnClose: true, }); -const [OrderUpdatePriceFormModal, priceFormModalApi] = useVbenModal({ - connectedComponent: OrderUpdatePriceForm, +const [PriceFormModal, priceFormModalApi] = useVbenModal({ + connectedComponent: PriceForm, destroyOnClose: true, }); @@ -300,7 +300,7 @@ onMounted(async () => { - + diff --git a/apps/web-antd/src/views/mall/trade/order/modules/price-form.vue b/apps/web-antd/src/views/mall/trade/order/modules/price-form.vue new file mode 100644 index 000000000..9355a0fc7 --- /dev/null +++ b/apps/web-antd/src/views/mall/trade/order/modules/price-form.vue @@ -0,0 +1,89 @@ + + + diff --git a/apps/web-antd/src/views/mall/trade/order/modules/update-price-form.vue b/apps/web-antd/src/views/mall/trade/order/modules/update-price-form.vue deleted file mode 100644 index 5d6b41804..000000000 --- a/apps/web-antd/src/views/mall/trade/order/modules/update-price-form.vue +++ /dev/null @@ -1,134 +0,0 @@ - - - \ No newline at end of file