Commit 2b2b1bc44765bf991d32ef9c7350bccce0bf17ec
1 parent
ad4917d5
fix:修改百分比显示
Showing
4 changed files
with
38 additions
and
10 deletions
src/views/project/config/costCreate.vue
@@ -101,11 +101,23 @@ | @@ -101,11 +101,23 @@ | ||
101 | } | 101 | } |
102 | } | 102 | } |
103 | 103 | ||
104 | + // 格式化百分比值,去除百分号并除以100 | ||
105 | + function formatPercentage(value) { | ||
106 | + if (!value) return ''; | ||
107 | + // 检查值是否包含百分号 | ||
108 | + if (typeof value === 'string' && value.includes('%')) { | ||
109 | + // 去除百分号并转为数值,然后除以100 | ||
110 | + return (parseFloat(value.replace('%', '')) / 100).toString(); | ||
111 | + } | ||
112 | + // 如果没有百分号但是是数值,直接除以100 | ||
113 | + return value; | ||
114 | + } | ||
115 | + | ||
104 | async function handleOk() { | 116 | async function handleOk() { |
105 | try { | 117 | try { |
106 | relationValue.value[0].relationValue = fixCost.value; | 118 | relationValue.value[0].relationValue = fixCost.value; |
107 | - relationValue.value[1].relationValue = ratio.value; | ||
108 | - relationValue.value[2].relationValue = spainRatio.value; | 119 | + relationValue.value[1].relationValue = formatPercentage(ratio.value); |
120 | + relationValue.value[2].relationValue = formatPercentage(spainRatio.value); | ||
109 | await addConfig({ | 121 | await addConfig({ |
110 | settingCode: 'customerCode', | 122 | settingCode: 'customerCode', |
111 | settingName: '客户提成成本配置', | 123 | settingName: '客户提成成本配置', |
src/views/project/config/costEdit.vue
@@ -24,20 +24,22 @@ | @@ -24,20 +24,22 @@ | ||
24 | </template> | 24 | </template> |
25 | <script lang="ts" setup> | 25 | <script lang="ts" setup> |
26 | import { BasicDrawer, useDrawerInner } from '@/components/Drawer'; | 26 | import { BasicDrawer, useDrawerInner } from '@/components/Drawer'; |
27 | - import { BasicForm, FormSchema, useForm } from '@/components/Form'; | ||
28 | - import { defineComponent, ref, computed, unref, toRaw, reactive, onMounted } from 'vue'; | 27 | + import { ref } from 'vue'; |
29 | import { saveConfig } from '/@/api/sys/config'; | 28 | import { saveConfig } from '/@/api/sys/config'; |
30 | 29 | ||
31 | - // const emit = defineEmits(['success']); | ||
32 | - // const isUpdate = ref(true); | ||
33 | const emit = defineEmits(['success']); | 30 | const emit = defineEmits(['success']); |
34 | 31 | ||
35 | const [register, { closeDrawer }] = useDrawerInner((data) => { | 32 | const [register, { closeDrawer }] = useDrawerInner((data) => { |
36 | listAll.value = data.data; | 33 | listAll.value = data.data; |
37 | relationValue.value = JSON.parse(listAll.value.relationValue); | 34 | relationValue.value = JSON.parse(listAll.value.relationValue); |
38 | fixCost.value = relationValue.value[0].relationValue; | 35 | fixCost.value = relationValue.value[0].relationValue; |
39 | - ratio.value = relationValue.value[1].relationValue; | ||
40 | - spainRatio.value = relationValue.value[2].relationValue; | 36 | + // 将小数转换为百分比格式显示 |
37 | + ratio.value = relationValue.value[1].relationValue | ||
38 | + ? (parseFloat(relationValue.value[1].relationValue) * 100).toFixed(2) + '%' | ||
39 | + : ''; | ||
40 | + spainRatio.value = relationValue.value[2].relationValue | ||
41 | + ? (parseFloat(relationValue.value[2].relationValue) * 100).toFixed(2) + '%' | ||
42 | + : ''; | ||
41 | }); | 43 | }); |
42 | //获取现有的列表 | 44 | //获取现有的列表 |
43 | const listAll = ref(); | 45 | const listAll = ref(); |
@@ -46,11 +48,23 @@ | @@ -46,11 +48,23 @@ | ||
46 | const spainRatio = ref(); | 48 | const spainRatio = ref(); |
47 | const relationValue = ref(); | 49 | const relationValue = ref(); |
48 | 50 | ||
51 | + // 格式化百分比值,去除百分号并除以100 | ||
52 | + function formatPercentage(value) { | ||
53 | + if (!value) return ''; | ||
54 | + // 检查值是否包含百分号 | ||
55 | + if (typeof value === 'string' && value.includes('%')) { | ||
56 | + // 去除百分号并转为数值,然后除以100 | ||
57 | + return (parseFloat(value.replace('%', '')) / 100).toString(); | ||
58 | + } | ||
59 | + // 如果没有百分号但是是数值,直接除以100 | ||
60 | + return value; | ||
61 | + } | ||
62 | + | ||
49 | //完成编辑 | 63 | //完成编辑 |
50 | async function handleSubmit() { | 64 | async function handleSubmit() { |
51 | relationValue.value[0].relationValue = fixCost.value; | 65 | relationValue.value[0].relationValue = fixCost.value; |
52 | - relationValue.value[1].relationValue = ratio.value; | ||
53 | - relationValue.value[2].relationValue = spainRatio.value; | 66 | + relationValue.value[1].relationValue = formatPercentage(ratio.value); |
67 | + relationValue.value[2].relationValue = formatPercentage(spainRatio.value); | ||
54 | await saveConfig({ | 68 | await saveConfig({ |
55 | id: listAll.value.id, | 69 | id: listAll.value.id, |
56 | settingCode: 'customerCode', | 70 | settingCode: 'customerCode', |
src/views/project/finance/financeProfit/ProductProfit/InnerData/ApproveReason.vue
@@ -32,6 +32,7 @@ | @@ -32,6 +32,7 @@ | ||
32 | orderId: baseFieldValues.value.orderId, | 32 | orderId: baseFieldValues.value.orderId, |
33 | productionActualPrice: baseFieldValues.value.productionActualPrice, | 33 | productionActualPrice: baseFieldValues.value.productionActualPrice, |
34 | productionDepartmentPredictPrice: baseFieldValues.value.productionDepartmentPredictPrice, | 34 | productionDepartmentPredictPrice: baseFieldValues.value.productionDepartmentPredictPrice, |
35 | + applyRemark: baseFieldValues.value.applyRemark, | ||
35 | type: 70, | 36 | type: 70, |
36 | }); | 37 | }); |
37 | emit('success'); | 38 | emit('success'); |
src/views/project/finance/financeProfit/ProductProfit/InnerProduce/ApproveReason.vue
@@ -33,6 +33,7 @@ | @@ -33,6 +33,7 @@ | ||
33 | projectNoPrefix: baseFieldValues.value.projectNoPrefix, | 33 | projectNoPrefix: baseFieldValues.value.projectNoPrefix, |
34 | projectInnerProfitInfoEndTime: baseFieldValues.value.projectInnerProfitInfoEndTime, | 34 | projectInnerProfitInfoEndTime: baseFieldValues.value.projectInnerProfitInfoEndTime, |
35 | projectInnerProfitInfoStartTime: baseFieldValues.value.projectInnerProfitInfoStartTime, | 35 | projectInnerProfitInfoStartTime: baseFieldValues.value.projectInnerProfitInfoStartTime, |
36 | + applyRemark: baseFieldValues.value.applyRemark, | ||
36 | type: 'INNER_PROFIT_FIELD_EDIT_APPLY', | 37 | type: 'INNER_PROFIT_FIELD_EDIT_APPLY', |
37 | }); | 38 | }); |
38 | emit('success'); | 39 | emit('success'); |