diff --git a/src/utils/util.ts b/src/utils/util.ts
index c640665..b4890f9 100644
--- a/src/utils/util.ts
+++ b/src/utils/util.ts
@@ -261,9 +261,9 @@ export function formatFileSize(bytes: number) {
*/
export function retain(value: any, n: any): string {
if (n === 'null' || n === 'undefined' || n === 0) return value
- let tran = Math.round(value * Math.pow(10, n)) / Math.pow(10, n)
+ const tran = Math.round(value * Math.pow(10, n)) / Math.pow(10, n)
let tranV = tran.toString()
- let newVal = tranV.indexOf('.')
+ const newVal = tranV.indexOf('.')
if (newVal < 0) {
tranV += '.'
}
@@ -272,3 +272,40 @@ export function retain(value: any, n: any): string {
}
return tranV
}
+export function formatString(input) {
+ const processNumber = numStr => {
+ if (!numStr.includes('.')) return numStr
+
+ // 分割整数和小数部分(处理 .00 和 20. 等情况)
+ const parts = numStr.split('.', 2)
+ let [intPart, decPart] = parts
+
+ // 处理类似 ".00" 的情况
+ intPart = intPart || '0'
+
+ // 处理小数部分全零或无小数部分的情况
+ if (!decPart || decPart.trimEnd().replace(/^0+$/, '') === '') {
+ return intPart
+ }
+
+ // 去除末尾零并处理格式问题
+ const strippedDec = decPart.trimEnd().replace(/^0+$/, '')
+ const result = `${intPart}.${strippedDec}`
+
+ // 处理特殊情况
+ if (strippedDec === '') return intPart // 123.000 → 123
+ if (result.endsWith('.')) return intPart // 123. → 123
+ if (result.startsWith('.') && strippedDec) return `0${result}` // .55 → 0.55
+
+ return result
+ }
+
+ if (!input) return
+ const parts = input.split('-', 2)
+ if (parts.length !== 2) return input
+
+ const left = processNumber(parts[0])
+ const right = processNumber(parts[1])
+
+ return `${left}-${right}`
+}
diff --git a/src/views/order/lists/detail.vue b/src/views/order/lists/detail.vue
index 8d10960..03fc8d4 100644
--- a/src/views/order/lists/detail.vue
+++ b/src/views/order/lists/detail.vue
@@ -240,7 +240,7 @@
- {{ parsePrice(scope.row) }}
+ ¥{{ parsePrice(scope.row) }}
@@ -299,7 +299,7 @@ import { PriceEnum, ReceiveOrderEnum, getTypeMap, useGoodsTypeMap } from '@/enum
import { useCreateModal } from '@/hooks/useCreateModal'
import area from '@/utils/area'
import feedback from '@/utils/feedback'
-import { parseCouponTime, parseEmpty } from '@/utils/util'
+import { formatString, parseCouponTime, parseEmpty } from '@/utils/util'
import { ref } from 'vue'
import cancelOrderDialog from './components/cancelOrderDialog.vue'
import dispatchDialog from './components/dispatchDialog.vue'
@@ -401,8 +401,7 @@ const orderRefundDetailVo = computed(() => (unref(isShowOrderRefundDetailVo) ? u
const isDispatch = computed(() => (status: number) => status === ReceiveOrderEnum.PAUSE)
const parsePrice = computed(() => row => {
const { priceType, priceRange, goodsPrice } = row
- const [minPrice = 0, maxPrice = 0] = priceRange.split('-')
- return priceType == PriceEnum.CUSTOMER_PRICE ? goodsPrice : minPrice + '-' + maxPrice
+ return priceType == PriceEnum.CUSTOMER_PRICE ? goodsPrice : formatString(priceRange)
})
function generateCouponFields(res: any) {
diff --git a/src/views/order/lists/index.vue b/src/views/order/lists/index.vue
index a600aa2..a9efb95 100644
--- a/src/views/order/lists/index.vue
+++ b/src/views/order/lists/index.vue
@@ -95,10 +95,13 @@
+
+ ¥{{ parsePrice(scope.row) }}
+
-
+
{{ scope.row.appointTime }} {{ scope.row.weekDay }} {{ scope.row.appointTimeStartStr }}-{{ scope.row.appointTimeEndStr }}
@@ -168,7 +171,7 @@ import Pagination from '@/components/pagination/index.vue'
import DataPicker from '@/components/daterange-picker/index.vue'
import cancelOrderDialog from './components/cancelOrderDialog.vue'
import { usePaging } from '@/hooks/usePaging'
-import { parseEmpty } from '@/utils/util'
+import { formatString, parseEmpty } from '@/utils/util'
import { optionMap } from '@/config/status'
import { useCancelOrderAction } from './hook'
@@ -211,8 +214,7 @@ const setStatusColor = computed(() => {
})
const parsePrice = computed(() => row => {
const { priceType, priceRange, goodsPrice } = row
- const [minPrice = 0, maxPrice = 0] = priceRange.split('-')
- return priceType == PriceEnum.CUSTOMER_PRICE ? goodsPrice : minPrice + '-' + maxPrice
+ return priceType == PriceEnum.CUSTOMER_PRICE ? goodsPrice : formatString(priceRange)
})
const { pager, getLists, resetPage, resetParams } = usePaging({