diff --git a/src/plugins/index.ts b/src/plugins/index.ts index 7449bde..1b5d412 100644 --- a/src/plugins/index.ts +++ b/src/plugins/index.ts @@ -9,7 +9,7 @@ import animate from '@/animate'; import { download as dl } from '@/utils/request'; import { useDict } from '@/utils/dict'; import { getConfigKey, updateConfigByKey } from '@/api/system/config'; -import { parseTime, addDateRange, handleTree, selectDictLabel, selectDictLabels } from '@/utils/ruoyi'; +import { parseTime, addDateRange, handleTree, selectDictLabel, selectDictLabels,formatPrice } from '@/utils/ruoyi'; import { downloadFile } from '@/utils/useFileDownload'; import { App } from 'vue'; @@ -42,4 +42,5 @@ export default function installPlugin(app: App) { app.config.globalProperties.selectDictLabels = selectDictLabels; app.config.globalProperties.animate = animate; app.config.globalProperties.downloadFile = downloadFile; + app.config.globalProperties.formatPrice = formatPrice; } diff --git a/src/utils/ruoyi.ts b/src/utils/ruoyi.ts index 8efd12c..c92994d 100644 --- a/src/utils/ruoyi.ts +++ b/src/utils/ruoyi.ts @@ -62,7 +62,23 @@ export const addDateRange = (params: any, dateRange: any[], propName?: string) = } return search; }; +// 价格格式化函数 +export const formatPrice = (price, show = true) => { + if ((!show && price == 0) || price == '' || price == undefined || price == null) return ''; + if (!price && price !== 0) return '0.0000'; + // 转换为数字并保留四位小数 + const num = Number(price); + if (isNaN(num)) return '0.0000'; + + const fixedNum = num.toFixed(4); + const [integer, decimal] = fixedNum.split('.'); + + // 千分位处理 + const formattedInteger = integer.replace(/\B(?=(\d{3})+(?!\d))/g, ','); + + return `${formattedInteger}.${decimal}`; +}; // 回显数据字典 export const selectDictLabel = (datas: any, value: number | string) => { if (value === undefined) { diff --git a/src/views/biddingManagemen/biddingLimit/index.vue b/src/views/biddingManagemen/biddingLimit/index.vue index 98c5781..18db6f4 100644 --- a/src/views/biddingManagemen/biddingLimit/index.vue +++ b/src/views/biddingManagemen/biddingLimit/index.vue @@ -58,18 +58,18 @@ - + - + - {{ scope.row.price != 0 ? Number(scope.row.price).toFixed(2) : null }} - + {{ proxy.formatPrice(scope.row.price) }} diff --git a/src/views/contract/limitPrice/indexEdit.vue b/src/views/contract/limitPrice/indexEdit.vue index facd683..4665f32 100644 --- a/src/views/contract/limitPrice/indexEdit.vue +++ b/src/views/contract/limitPrice/indexEdit.vue @@ -41,10 +41,14 @@ - - + + + + @@ -70,8 +74,12 @@ diff --git a/src/views/ctr/update/index.vue b/src/views/ctr/update/index.vue index 4908951..d813daf 100644 --- a/src/views/ctr/update/index.vue +++ b/src/views/ctr/update/index.vue @@ -1,79 +1,80 @@ diff --git a/src/views/design/designChange/indexEdit.vue b/src/views/design/designChange/indexEdit.vue index 9e6e857..7e0c7e5 100644 --- a/src/views/design/designChange/indexEdit.vue +++ b/src/views/design/designChange/indexEdit.vue @@ -145,7 +145,13 @@ > - diff --git a/src/views/formalities/formalitiesAreConsolidated/index.vue b/src/views/formalities/formalitiesAreConsolidated/index.vue index d178216..b276f4d 100644 --- a/src/views/formalities/formalitiesAreConsolidated/index.vue +++ b/src/views/formalities/formalitiesAreConsolidated/index.vue @@ -1,7 +1,6 @@