|
|
@@ -9,7 +9,7 @@
|
|
|
</el-form-item>
|
|
|
<el-form-item label="币种">
|
|
|
<el-select v-model="query.currencyType" clearable filterable placeholder="全部" style="width: 120px">
|
|
|
- <el-option v-for="item in currencyOptions" :key="item.value" :label="item.label" :value="String(item.value)" />
|
|
|
+ <el-option v-for="item in currencyOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
<el-form-item label="启用">
|
|
|
@@ -34,12 +34,16 @@
|
|
|
<el-table-column prop="supplierType" label="供应类别" width="100" show-overflow-tooltip />
|
|
|
<el-table-column label="启用" width="72" align="center">
|
|
|
<template #default="{ row }">
|
|
|
- <el-tag :type="row.isActive ? 'success' : 'info'" size="small">{{ row.isActive ? '是' : '否' }}</el-tag>
|
|
|
+ <el-tag v-if="row.isActive === true" type="success" size="small">是</el-tag>
|
|
|
+ <el-tag v-else-if="row.isActive === false" type="info" size="small">否</el-tag>
|
|
|
+ <span v-else>-</span>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
<el-table-column prop="supplier" label="供应商" min-width="160" show-overflow-tooltip />
|
|
|
<el-table-column prop="orderPrice" label="不含税单价" width="100" align="right" />
|
|
|
- <el-table-column prop="currencyType" label="币种" width="80" show-overflow-tooltip />
|
|
|
+ <el-table-column label="币种" width="80" show-overflow-tooltip>
|
|
|
+ <template #default="{ row }">{{ currencyLabel(row.currencyType) }}</template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column prop="taxrate" label="增值税率%" width="100" align="right" />
|
|
|
<el-table-column prop="quotaRate" label="配额比例%" width="100" align="right" />
|
|
|
<el-table-column label="采购前置期" width="120" align="center">
|
|
|
@@ -176,7 +180,7 @@
|
|
|
<el-col :span="12">
|
|
|
<el-form-item label="币种">
|
|
|
<el-select v-model="form.currencyType" clearable filterable style="width: 100%">
|
|
|
- <el-option v-for="item in currencyOptions" :key="item.value" :label="item.label" :value="String(item.value)" />
|
|
|
+ <el-option v-for="item in currencyOptions" :key="item.value" :label="item.label" :value="item.value" />
|
|
|
</el-select>
|
|
|
</el-form-item>
|
|
|
</el-col>
|
|
|
@@ -283,7 +287,7 @@ const query = reactive({
|
|
|
companyRefId: undefined as string | undefined,
|
|
|
factoryRefId: undefined as string | undefined,
|
|
|
supplierType: '',
|
|
|
- currencyType: '',
|
|
|
+ currencyType: undefined as number | undefined,
|
|
|
isActive: undefined as boolean | undefined,
|
|
|
page: 1,
|
|
|
pageSize: 20,
|
|
|
@@ -323,7 +327,7 @@ const form = reactive<S0SrmPurchaseUpsert & { icitemId: number; supplierId: numb
|
|
|
supplierName: '',
|
|
|
supplierNumber: '',
|
|
|
orderPrice: null,
|
|
|
- currencyType: '',
|
|
|
+ currencyType: null,
|
|
|
taxrate: null,
|
|
|
tariff: null,
|
|
|
freight: null,
|
|
|
@@ -447,10 +451,21 @@ async function loadOptions() {
|
|
|
]);
|
|
|
companyOptions.value = companies;
|
|
|
factoryOptions.value = factories;
|
|
|
- currencyOptions.value = currencies;
|
|
|
+ // 币种字典 value 归一为数值(业务确认仅 1=CNY);仅保留 value 为有限数值的项,
|
|
|
+ // 过滤掉历史遗留的非数值码(USD/EUR/JPY/HKD),避免 Number(非数值)=NaN 污染下拉与提交。
|
|
|
+ currencyOptions.value = currencies
|
|
|
+ .map((item) => ({ label: item.label, value: Number(item.value) }))
|
|
|
+ .filter((item) => Number.isFinite(item.value));
|
|
|
supplyCategoryOptions.value = supplyCat;
|
|
|
}
|
|
|
|
|
|
+// 币种列表展示:按数值匹配字典 label(1→CNY);未命中回退显示原值,null/undefined 显示空。
|
|
|
+function currencyLabel(value: number | null | undefined): string {
|
|
|
+ if (value === null || value === undefined) return '';
|
|
|
+ const hit = currencyOptions.value.find((item) => Number(item.value) === Number(value));
|
|
|
+ return hit ? hit.label : String(value);
|
|
|
+}
|
|
|
+
|
|
|
async function loadList() {
|
|
|
loading.value = true;
|
|
|
try {
|
|
|
@@ -481,7 +496,7 @@ function resetQuery() {
|
|
|
query.companyRefId = undefined;
|
|
|
query.factoryRefId = undefined;
|
|
|
query.supplierType = '';
|
|
|
- query.currencyType = '';
|
|
|
+ query.currencyType = undefined;
|
|
|
query.isActive = undefined;
|
|
|
query.page = 1;
|
|
|
void loadList();
|
|
|
@@ -501,7 +516,7 @@ function resetForm() {
|
|
|
supplierName: '',
|
|
|
supplierNumber: '',
|
|
|
orderPrice: null,
|
|
|
- currencyType: '',
|
|
|
+ currencyType: null,
|
|
|
taxrate: null,
|
|
|
tariff: null,
|
|
|
freight: null,
|
|
|
@@ -547,7 +562,9 @@ async function openEdit(row: S0SrmPurchaseRow) {
|
|
|
supplierName: row.supplierName ?? '',
|
|
|
supplierNumber: row.supplierNumber ?? '',
|
|
|
orderPrice: row.orderPrice ?? null,
|
|
|
- currencyType: row.currencyType ?? '',
|
|
|
+ // 后端全局将 long 序列化为字符串(防雪花 ID 精度丢失),currencyType 到手可能是 "1";
|
|
|
+ // 编辑回填统一强转数值,避免与下拉数值选项发生 1 !== "1" 不匹配而回显空白。
|
|
|
+ currencyType: row.currencyType === null || row.currencyType === undefined ? null : Number(row.currencyType),
|
|
|
taxrate: row.taxrate ?? null,
|
|
|
tariff: row.tariff ?? null,
|
|
|
freight: row.freight ?? null,
|
|
|
@@ -584,21 +601,27 @@ async function openEdit(row: S0SrmPurchaseRow) {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-// 币种字段后端为 long?(数值可空),而 s0_currency 字典给的是币种码字符串(如 CNY)、未选择时为空串,
|
|
|
-// 二者都无法绑定 long? 会导致保存 400。保存前规范化:纯数值串转数值,空串/非数值一律 null(可空放行)。
|
|
|
-function normalizeCurrencyType(v: string | number | null | undefined): number | null {
|
|
|
- if (v === '' || v === null || v === undefined) return null;
|
|
|
+// 币种提交解析:选项 value 已是数值(1=CNY)。未选择=null 放行;已选但非有限数值(异常态)阻止提交,不静默转 null。
|
|
|
+function resolveCurrencyForSubmit(v: number | null | undefined): number | null {
|
|
|
+ if (v === null || v === undefined) return null;
|
|
|
const n = Number(v);
|
|
|
- return Number.isInteger(n) ? n : null;
|
|
|
+ if (!Number.isFinite(n)) {
|
|
|
+ ElMessage.error('币种值无效,请重新选择');
|
|
|
+ throw new Error('invalid currencyType');
|
|
|
+ }
|
|
|
+ return n;
|
|
|
}
|
|
|
|
|
|
async function submitForm() {
|
|
|
await formRef.value?.validate();
|
|
|
// 提交前统一归属:缺则补默认、有则保留(含货源历史 0/0),不做 legacy↔雪花映射。
|
|
|
normalizeOrgScopeForSubmit(form, editingId.value ? 'edit' : 'create', companyOptions.value, factoryOptions.value);
|
|
|
+ const currencyType = resolveCurrencyForSubmit(form.currencyType);
|
|
|
+ // 供应类别提交前 trim;trim 后为空 → undefined(后端落 null),字典命中与否不强制改写用户原文。
|
|
|
+ const supplierType = form.supplierType?.trim() || undefined;
|
|
|
saving.value = true;
|
|
|
try {
|
|
|
- const payload: S0SrmPurchaseUpsert = { ...form, currencyType: normalizeCurrencyType(form.currencyType) };
|
|
|
+ const payload: S0SrmPurchaseUpsert = { ...form, currencyType, supplierType };
|
|
|
if (editingId.value) {
|
|
|
await s0SrmPurchasesApi.update(editingId.value, payload);
|
|
|
ElMessage.success('已保存');
|