feat(物料管理): 优化物料折纯率显示和输入方式
将生产折纯、客户折纯和报关折纯的显示和输入方式优化为百分比形式,提高用户体验。修改了相关组件的逻辑,确保数据在存储和显示时正确转换。
This commit is contained in:
parent
b594f39056
commit
8e8b65495a
@ -1,4 +1,4 @@
|
||||
import { defineComponent, ref, onMounted } from 'vue';
|
||||
import { defineComponent, ref, onMounted, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useAlertService } from '@/shared/alert/alert.service';
|
||||
import { useRoute, useRouter } from 'vue-router';
|
||||
@ -48,6 +48,9 @@ export default defineComponent({
|
||||
sortNo: 0,
|
||||
version: 0,
|
||||
status: '',
|
||||
productionRateDisplay: 0,
|
||||
customerRateDisplay: 0,
|
||||
customsRateDisplay: 0,
|
||||
});
|
||||
|
||||
const loadData = async () => {
|
||||
@ -89,6 +92,10 @@ export default defineComponent({
|
||||
|
||||
if (route.params?.id) {
|
||||
material.value = materialRes.data;
|
||||
// 设置百分比显示值
|
||||
material.value.productionRateDisplay = material.value.productionRate ? (material.value.productionRate * 100).toFixed(2) : 0;
|
||||
material.value.customerRateDisplay = material.value.customerRate ? (material.value.customerRate * 100).toFixed(2) : 0;
|
||||
material.value.customsRateDisplay = material.value.customsRate ? (material.value.customsRate * 100).toFixed(2) : 0;
|
||||
} else {
|
||||
// 设置新建material时的默认状态值
|
||||
const defaultStatus = statusDictsRes.data.find(item => {
|
||||
@ -152,6 +159,11 @@ export default defineComponent({
|
||||
return;
|
||||
}
|
||||
|
||||
// 转换百分比值为小数
|
||||
material.value.productionRate = material.value.productionRateDisplay ? (material.value.productionRateDisplay / 100).toFixed(4) : null;
|
||||
material.value.customerRate = material.value.customerRateDisplay ? (material.value.customerRateDisplay / 100).toFixed(4) : null;
|
||||
material.value.customsRate = material.value.customsRateDisplay ? (material.value.customsRateDisplay / 100).toFixed(4) : null;
|
||||
|
||||
isSaving.value = true;
|
||||
try {
|
||||
if (material.value.id) {
|
||||
|
||||
@ -51,17 +51,23 @@
|
||||
</vxe-form-item>
|
||||
<vxe-form-item field="productionRate" :title="$t('jewpmsApp.material.productionRate')" :item-render="{}">
|
||||
<template #default="{ data }">
|
||||
<vxe-input v-model="data.productionRate" type="float" step="0.001" clearable data-cy="productionRate" />
|
||||
<vxe-input v-model="data.productionRateDisplay" type="number" min="0" max="100" step="0.01" clearable data-cy="productionRate">
|
||||
<template #suffix>%</template>
|
||||
</vxe-input>
|
||||
</template>
|
||||
</vxe-form-item>
|
||||
<vxe-form-item field="customerRate" :title="$t('jewpmsApp.material.customerRate')" :item-render="{}">
|
||||
<template #default="{ data }">
|
||||
<vxe-input v-model="data.customerRate" type="float" step="0.001" clearable data-cy="customerRate" />
|
||||
<vxe-input v-model="data.customerRateDisplay" type="number" min="0" max="100" step="0.01" clearable data-cy="customerRate">
|
||||
<template #suffix>%</template>
|
||||
</vxe-input>
|
||||
</template>
|
||||
</vxe-form-item>
|
||||
<vxe-form-item field="customsRate" :title="$t('jewpmsApp.material.customsRate')" :item-render="{}">
|
||||
<template #default="{ data }">
|
||||
<vxe-input v-model="data.customsRate" type="float" step="0.001" clearable data-cy="customsRate" />
|
||||
<vxe-input v-model="data.customsRateDisplay" type="number" min="0" max="100" step="0.01" clearable data-cy="customsRate">
|
||||
<template #suffix>%</template>
|
||||
</vxe-input>
|
||||
</template>
|
||||
</vxe-form-item>
|
||||
<vxe-form-item
|
||||
|
||||
@ -83,6 +83,11 @@ export default defineComponent({
|
||||
field: 'productionRate',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
title: $t('jewpmsApp.material.customerRate'),
|
||||
field: 'customerRate',
|
||||
sortable: true,
|
||||
},
|
||||
{
|
||||
title: $t('jewpmsApp.material.customsRate'),
|
||||
field: 'customsRate',
|
||||
|
||||
@ -110,6 +110,15 @@
|
||||
<template #default="{ row }" v-if="column.field === 'status'">
|
||||
{{ statusDicts.find(s => s.number === String(row.status))?.name || row.status }}
|
||||
</template>
|
||||
<template #default="{ row }" v-if="column.field === 'productionRate'">
|
||||
{{ row.productionRate !== null && row.productionRate !== undefined ? (row.productionRate * 100).toFixed(2) + '%' : '' }}
|
||||
</template>
|
||||
<template #default="{ row }" v-if="column.field === 'customerRate'">
|
||||
{{ row.customerRate !== null && row.customerRate !== undefined ? (row.customerRate * 100).toFixed(2) + '%' : '' }}
|
||||
</template>
|
||||
<template #default="{ row }" v-if="column.field === 'customsRate'">
|
||||
{{ row.customsRate !== null && row.customsRate !== undefined ? (row.customsRate * 100).toFixed(2) + '%' : '' }}
|
||||
</template>
|
||||
<template #default="{ row }" v-if="column.title === $t('entity.action.actions')">
|
||||
<div class="vxe-group">
|
||||
<vxe-button class="btn-circle">
|
||||
|
||||
@ -23,9 +23,9 @@
|
||||
"category": "类别",
|
||||
"unitWeight": "重量单位",
|
||||
"spec": "规格",
|
||||
"productionRate": "生产折纯%",
|
||||
"customerRate": "客户折纯%",
|
||||
"customsRate": "报关折纯%",
|
||||
"productionRate": "生产折纯",
|
||||
"customerRate": "客户折纯",
|
||||
"customsRate": "报关折纯",
|
||||
"matGroup00": "组别0",
|
||||
"matGroup01": "组别1",
|
||||
"matGroup02": "组别2",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user