feat: 统一半成品和成品入库页面的高级筛选权限管理

- 将semi.vue和product.vue的fieldOptions改为computed属性,根据用户权限动态过滤
- 确保筛选字段与后端支持的字段完全一致
- 完善permissionMap,添加缺失的字段权限映射
- 遵循buy.vue和material/list.vue的权限管理模式
This commit is contained in:
openhands
2026-03-03 03:08:29 +00:00
parent ec8bdb2476
commit d095a370ad
2 changed files with 91 additions and 74 deletions

View File

@ -495,7 +495,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import { ref, reactive, onMounted, watch } from 'vue' import { ref, reactive, onMounted, watch, computed } from 'vue'
import { Plus, Setting, Refresh, Search, Box, House, Link, InfoFilled, Printer, Camera, Picture } from '@element-plus/icons-vue' import { Plus, Setting, Refresh, Search, Box, House, Link, InfoFilled, Printer, Camera, Picture } from '@element-plus/icons-vue'
import { ElMessage, ElLoading } from 'element-plus' import { ElMessage, ElLoading } from 'element-plus'
import dayjs from 'dayjs' import dayjs from 'dayjs'
@ -554,36 +554,40 @@ const typeOptions = ref<string[]>([])
const companyOptions = ref<string[]>([]) // [新增] const companyOptions = ref<string[]>([]) // [新增]
const advancedFilterVisible = ref(false) const advancedFilterVisible = ref(false)
const advancedConditions = ref([{ field: '', operator: '', value: '' }]) const advancedConditions = ref([{ field: '', operator: '', value: '' }])
const fieldOptions = ref([ const fieldOptions = computed(() => {
{ label: 'ID', value: 'id' }, const allFields = [
{ label: 'BaseID', value: 'base_id' }, { value: 'id', label: 'ID', perm: 'inbound_product:id' },
{ label: '所属公司', value: 'company_name' }, { value: 'base_id', label: 'BaseID', perm: 'inbound_product:base_id' },
{ label: '名称', value: 'material_name' }, { value: 'company_name', label: '所属公司', perm: 'inbound_product:company_name' },
{ label: '规格', value: 'spec_model' }, { value: 'material_name', label: '名称', perm: 'inbound_product:material_name' },
{ label: '类别', value: 'category' }, { value: 'spec_model', label: '规格', perm: 'inbound_product:spec_model' },
{ label: '类', value: 'material_type' }, { value: 'category', label: '类', perm: 'inbound_product:category' },
{ label: '单位', value: 'unit' }, { value: 'material_type', label: '类型', perm: 'inbound_product:material_type' },
{ label: 'SKU', value: 'sku' }, { value: 'unit', label: '单位', perm: 'inbound_product:unit' },
{ label: '入库日期', value: 'inbound_date' }, { value: 'sku', label: 'SKU', perm: 'inbound_product:sku' },
{ label: '条码', value: 'barcode' }, { value: 'inbound_date', label: '入库日期', perm: 'inbound_product:inbound_date' },
{ label: '序列号(SN)', value: 'serial_number' }, { value: 'barcode', label: '条码', perm: 'inbound_product:barcode' },
{ label: '批号', value: 'batch_number' }, { value: 'serial_number', label: '序列号(SN)', perm: 'inbound_product:serial_number' },
{ label: '库存状态', value: 'status' }, { value: 'batch_number', label: '批号', perm: 'inbound_product:serial_number' },
{ label: '质量状态', value: 'quality_status' }, { value: 'status', label: '库存状态', perm: 'inbound_product:status' },
{ label: '入库数量', value: 'in_quantity' }, { value: 'quality_status', label: '质量状态', perm: 'inbound_product:quality_status' },
{ label: '库存数', value: 'stock_quantity' }, { value: 'in_quantity', label: '入库数量', perm: 'inbound_product:in_quantity' },
{ label: '可用数', value: 'available_quantity' }, { value: 'stock_quantity', label: '库存数', perm: 'inbound_product:stock_quantity' },
{ label: '库位', value: 'warehouse_location' }, { value: 'available_quantity', label: '可用数', perm: 'inbound_product:available_quantity' },
{ label: 'BOM编号', value: 'bom_code' }, { value: 'warehouse_location', label: '库位', perm: 'inbound_product:warehouse_location' },
{ label: 'BOM版本', value: 'bom_version' }, { value: 'bom_code', label: 'BOM编号', perm: 'inbound_product:bom_code' },
{ label: '工单号', value: 'work_order_code' }, { value: 'bom_version', label: 'BOM版本', perm: 'inbound_product:bom_version' },
{ label: '原料成本', value: 'raw_material_cost' }, { value: 'work_order_code', label: '工单号', perm: 'inbound_product:work_order_code' },
{ label: '单件成本', value: 'unit_total_cost' }, { value: 'raw_material_cost', label: '原料成本', perm: 'inbound_product:raw_material_cost' },
{ label: '成本', value: 'total_price' }, { value: 'unit_total_cost', label: '单件成本', perm: 'inbound_product:unit_total_cost' },
{ label: '订单号', value: 'order_id' }, { value: 'total_price', label: '总成本', perm: 'inbound_product:total_price' },
{ label: '产品定价', value: 'sale_price' }, { value: 'order_id', label: '订单号', perm: 'inbound_product:order_id' },
{ label: '负责人', value: 'production_manager' }, { value: 'sale_price', label: '产品定价', perm: 'inbound_product:sale_price' },
]) { value: 'production_manager', label: '负责人', perm: 'inbound_product:production_manager' }
]
// 根据用户权限过滤
return allFields.filter(item => userStore.hasPermission(item.perm))
})
const operatorOptions = ref([ const operatorOptions = ref([
{ label: '等于', value: '=' }, { label: '等于', value: '=' },
{ label: '不等于', value: '!=' }, { label: '不等于', value: '!=' },
@ -652,27 +656,37 @@ const allColumns = [
// 列与权限Code的映射关系数据库中的code // 列与权限Code的映射关系数据库中的code
const permissionMap: Record<string, string> = { const permissionMap: Record<string, string> = {
id: 'inbound_product:id',
base_id: 'inbound_product:base_id',
company_name: 'inbound_product:company_name', company_name: 'inbound_product:company_name',
material_name: 'inbound_product:material_name', material_name: 'inbound_product:material_name',
spec_model: 'inbound_product:spec_model',
category: 'inbound_product:category',
material_type: 'inbound_product:material_type',
unit: 'inbound_product:unit',
sku: 'inbound_product:sku', sku: 'inbound_product:sku',
inbound_date: 'inbound_product:inbound_date',
barcode: 'inbound_product:barcode',
serial_number: 'inbound_product:serial_number', serial_number: 'inbound_product:serial_number',
qty_stock: 'inbound_product:stock_quantity', batch_number: 'inbound_product:serial_number',
status: 'inbound_product:status', status: 'inbound_product:status',
quality_status: 'inbound_product:quality_status', quality_status: 'inbound_product:quality_status',
spec_model: 'inbound_product:spec_model', in_quantity: 'inbound_product:in_quantity',
unit: 'inbound_product:unit', stock_quantity: 'inbound_product:stock_quantity',
product_photo: 'inbound_product:product_photo', available_quantity: 'inbound_product:available_quantity',
sale_price: 'inbound_product:sale_price', warehouse_location: 'inbound_product:warehouse_location',
order_id: 'inbound_product:order_id',
work_order_code: 'inbound_product:work_order_code',
quality_report_link: 'inbound_product:quality_report_link',
inspection_report_link: 'inbound_product:inspection_report_link',
bom_code: 'inbound_product:bom_code', bom_code: 'inbound_product:bom_code',
production_manager: 'inbound_product:production_manager', bom_version: 'inbound_product:bom_version',
work_order_code: 'inbound_product:work_order_code',
raw_material_cost: 'inbound_product:raw_material_cost', raw_material_cost: 'inbound_product:raw_material_cost',
unit_total_cost: 'inbound_product:unit_total_cost', unit_total_cost: 'inbound_product:unit_total_cost',
total_price: 'inbound_product:total_price', total_price: 'inbound_product:total_price',
inbound_date: 'inbound_product:inbound_date', order_id: 'inbound_product:order_id',
sale_price: 'inbound_product:sale_price',
production_manager: 'inbound_product:production_manager',
product_photo: 'inbound_product:product_photo',
quality_report_link: 'inbound_product:quality_report_link',
inspection_report_link: 'inbound_product:inspection_report_link',
detail_link: 'inbound_product:detail_link', detail_link: 'inbound_product:detail_link',
} }

View File

@ -559,7 +559,7 @@
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
import {ref, reactive, onMounted, watch} from 'vue' import {ref, reactive, onMounted, watch, computed} from 'vue'
import {Plus, Setting, Refresh, Search, Lock, Box, House, InfoFilled, Link, Printer, Camera, Picture} from '@element-plus/icons-vue' import {Plus, Setting, Refresh, Search, Lock, Box, House, InfoFilled, Link, Printer, Camera, Picture} from '@element-plus/icons-vue'
import {ElMessage, ElLoading} from 'element-plus' import {ElMessage, ElLoading} from 'element-plus'
import dayjs from 'dayjs' import dayjs from 'dayjs'
@ -620,37 +620,40 @@ const typeOptions = ref<string[]>([])
const companyOptions = ref<string[]>([]) // [新增] const companyOptions = ref<string[]>([]) // [新增]
const advancedFilterVisible = ref(false) const advancedFilterVisible = ref(false)
const advancedConditions = ref([{ field: '', operator: '', value: '' }]) const advancedConditions = ref([{ field: '', operator: '', value: '' }])
const fieldOptions = ref([ const fieldOptions = computed(() => {
{ label: 'ID', value: 'id' }, const allFields = [
{ label: 'BaseID', value: 'base_id' }, { value: 'id', label: 'ID', perm: 'inbound_semi:id' },
{ label: '所属公司', value: 'company_name' }, { value: 'base_id', label: 'BaseID', perm: 'inbound_semi:base_id' },
{ label: '名称', value: 'material_name' }, { value: 'company_name', label: '所属公司', perm: 'inbound_semi:company_name' },
{ label: '规格型号', value: 'spec_model' }, { value: 'material_name', label: '名称', perm: 'inbound_semi:material_name' },
{ label: '类别', value: 'category' }, { value: 'spec_model', label: '规格型号', perm: 'inbound_semi:spec_model' },
{ label: '类', value: 'material_type' }, { value: 'category', label: '类', perm: 'inbound_semi:category' },
{ label: '单位', value: 'unit' }, { value: 'material_type', label: '类型', perm: 'inbound_semi:material_type' },
{ label: 'SKU', value: 'sku' }, { value: 'unit', label: '单位', perm: 'inbound_semi:unit' },
{ label: '入库日期', value: 'inbound_date' }, { value: 'sku', label: 'SKU', perm: 'inbound_semi:sku' },
{ label: '条码', value: 'barcode' }, { value: 'inbound_date', label: '入库日期', perm: 'inbound_semi:inbound_date' },
{ label: '批号', value: 'batch_number' }, { value: 'barcode', label: '条码', perm: 'inbound_semi:barcode' },
{ label: '序列号', value: 'serial_number' }, { value: 'batch_number', label: '号', perm: 'inbound_semi:sn_bn' },
{ label: '库位', value: 'warehouse_location' }, { value: 'serial_number', label: '序列号', perm: 'inbound_semi:sn_bn' },
{ label: '入库数量', value: 'qty_inbound' }, { value: 'warehouse_location', label: '库位', perm: 'inbound_semi:warehouse_loc' },
{ label: '当前库存', value: 'qty_stock' }, { value: 'qty_inbound', label: '入库数量', perm: 'inbound_semi:qty_inbound' },
{ label: '当前可用', value: 'qty_available' }, { value: 'qty_stock', label: '当前库存', perm: 'inbound_semi:qty_stock' },
{ label: '库存状态', value: 'status' }, { value: 'qty_available', label: '当前可用', perm: 'inbound_semi:qty_available' },
{ label: '质量状态', value: 'quality_status' }, { value: 'status', label: '库存状态', perm: 'inbound_semi:status' },
{ label: 'BOM编号', value: 'bom_code' }, { value: 'quality_status', label: '质量状态', perm: 'inbound_semi:quality_status' },
{ label: 'BOM版本', value: 'bom_version' }, { value: 'bom_code', label: 'BOM编号', perm: 'inbound_semi:bom_code' },
{ label: '工单号', value: 'work_order_code' }, { value: 'bom_version', label: 'BOM版本', perm: 'inbound_semi:bom_version' },
{ label: '生产负责人', value: 'production_manager' }, { value: 'work_order_code', label: '工单号', perm: 'inbound_semi:work_order_code' },
{ label: '生产时间', value: 'production_start_time' }, { value: 'production_manager', label: '生产负责人', perm: 'inbound_semi:production_manager' },
{ label: '生产结束时间', value: 'production_end_time' }, { value: 'production_start_time', label: '生产开始时间', perm: 'inbound_semi:production_start_time' },
{ label: '估算成本', value: 'raw_material_cost' }, { value: 'production_end_time', label: '生产结束时间', perm: 'inbound_semi:production_end_time' },
{ label: '基于BOM成本', value: 'unit_total_cost' }, { value: 'raw_material_cost', label: '估算成本', perm: 'inbound_semi:raw_material_cost' },
{ label: '成本', value: 'total_price' }, { value: 'unit_total_cost', label: '基于BOM成本', perm: 'inbound_semi:unit_total_cost' },
{ label: '详情链接', value: 'detail_link' }, { value: 'total_price', label: '总成本', perm: 'inbound_semi:total_price' }
]) ]
// 根据用户权限过滤
return allFields.filter(item => userStore.hasPermission(item.perm))
})
const operatorOptions = ref([ const operatorOptions = ref([
{ label: '等于', value: '=' }, { label: '等于', value: '=' },
{ label: '不等于', value: '!=' }, { label: '不等于', value: '!=' },