fix: 修复全局字段权限导致数据显示为空的问题

根因: /permissions/role/<role_code> 接口要求 system_permission,
非管理员角色无法获取自身权限 → 权限数组为空 → 前后端字段全被过滤

修复:
- permission.py: 查自己角色不再需要 system_permission, 解除权限死锁
- 5个 inbound API: 恢复完整 field_to_perm 映射, 每个字段均可独立权限管控
- 补齐遗漏字段(qty_inbound/qty_stock/qty_available/request_id/request_no)
- buy.vue: 入库表单价格字段加入 hasFormFieldPermission 守卫
This commit is contained in:
yueli
2026-07-14 16:09:41 +08:00
parent 593484aba3
commit 8f468a0a39
7 changed files with 106 additions and 62 deletions

View File

@ -513,19 +513,19 @@
<el-row :gutter="20">
<el-col :span="8">
<el-form-item label="币种">
<el-form-item v-if="hasFormFieldPermission('currency')" label="币种">
<el-autocomplete v-model="form.currency" :fetch-suggestions="querySearchCurrency" placeholder="币种" style="width: 100%" :trigger-on-focus="true">
<template #default="{ item }"><span>{{ item.value }}</span><span style="float:right; color:#999; font-size:12px">{{ item.desc }}</span></template>
</el-autocomplete>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="汇率">
<el-form-item v-if="hasFormFieldPermission('exchange_rate')" label="汇率">
<el-input-number v-model="form.exchange_rate" :precision="2" controls-position="right" style="width:100%"/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="税率">
<el-form-item v-if="hasFormFieldPermission('tax_rate')" label="税率">
<el-select v-model="form.tax_rate" style="width:100%" @change="updatePrices('tax')">
<el-option label="0%" :value="0" />
<el-option label="1%" :value="1" />
@ -537,7 +537,7 @@
<el-row :gutter="20" style="margin-top: 15px;">
<el-col :span="8">
<el-form-item label="不含税单价" prop="unit_price">
<el-form-item v-if="hasFormFieldPermission('unit_price')" label="不含税单价" prop="unit_price">
<el-input-number
v-model="form.unit_price"
:precision="2"
@ -549,7 +549,7 @@
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="含税单价">
<el-form-item v-if="hasFormFieldPermission('unit_price')" label="含税单价">
<el-input-number
v-model="form.post_tax_unit_price"
:precision="2"
@ -561,7 +561,7 @@
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="不含税总价">
<el-form-item v-if="hasFormFieldPermission('total_price')" label="不含税总价">
<el-input-number
v-model="form.total_price"
:precision="2"
@ -710,7 +710,7 @@
</template>
</el-table-column>
<el-table-column prop="quantity" label="申请数量" width="85" align="right" />
<el-table-column prop="unit_price" label="单价" width="100" align="right">
<el-table-column v-if="hasFormFieldPermission('unit_price')" prop="unit_price" label="单价" width="100" align="right">
<template #default="scope">
{{ scope.row.unit_price ? '¥' + Number(scope.row.unit_price).toFixed(2) : '-' }}
</template>
@ -1861,27 +1861,26 @@ const confirmPurchaseImport = () => {
return
}
// 2. 填充采购商务信息(单价/总价互相推算,缺哪个补哪个)
// 2. 填充采购商务信息
const qty = Number(po.quantity) || 1
form.in_quantity = qty
const hasUnitPrice = po.unit_price !== null && po.unit_price !== undefined && Number(po.unit_price) > 0
const hasTotalPrice = po.total_price !== null && po.total_price !== undefined && Number(po.total_price) > 0
// 价格字段:仅具有单价查看权限的用户才自动填充
if (hasFormFieldPermission('unit_price')) {
const hasUnitPrice = po.unit_price !== null && po.unit_price !== undefined && Number(po.unit_price) > 0
const hasTotalPrice = po.total_price !== null && po.total_price !== undefined && Number(po.total_price) > 0
if (hasUnitPrice && hasTotalPrice) {
// 两者都有,直接使用
form.unit_price = Number(po.unit_price)
form.total_price = Number(po.total_price)
} else if (hasUnitPrice) {
// 只有单价 → 用数量推算总价
form.unit_price = Number(po.unit_price)
form.total_price = Number((qty * form.unit_price).toFixed(2))
} else if (hasTotalPrice) {
// 只有总价 → 用数量反推单价
form.total_price = Number(po.total_price)
form.unit_price = Number((form.total_price / qty).toFixed(4))
if (hasUnitPrice && hasTotalPrice) {
form.unit_price = Number(po.unit_price)
form.total_price = Number(po.total_price)
} else if (hasUnitPrice) {
form.unit_price = Number(po.unit_price)
form.total_price = Number((qty * form.unit_price).toFixed(2))
} else if (hasTotalPrice) {
form.total_price = Number(po.total_price)
form.unit_price = Number((form.total_price / qty).toFixed(4))
}
}
// 都没有就都不填
if (po.supplier_link) {
form.source_link = po.supplier_link
}