V3.38版本修改,三种入库按照基础信息内容进行修改

This commit is contained in:
dxc
2026-05-29 14:26:52 +08:00
parent cd54ca3fe2
commit 034418df8a
4 changed files with 223 additions and 41 deletions

View File

@ -123,9 +123,23 @@
<el-button :icon="Refresh" @click="fetchData" class="action-btn">刷新</el-button>
<el-popover placement="bottom-end" title="列配置" :width="500" trigger="click">
<template #reference><el-button :icon="Setting" class="action-btn">表头</el-button></template>
<div style="display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #eee; margin-bottom: 10px; padding-bottom: 10px;">
<span style="font-weight: bold;">列展示设置</span>
<el-checkbox
:model-value="isAllSelected"
:indeterminate="isIndeterminate"
@change="handleCheckAllChange"
>
全选
</el-checkbox>
</div>
<el-checkbox-group v-model="visibleColumnProps" class="column-selector">
<el-row :gutter="10">
<el-col :span="8" v-for="c in allColumns" :key="c.prop"><el-checkbox :label="c.prop">{{ c.label }}</el-checkbox></el-col>
<template v-for="c in allColumns" :key="c.prop">
<el-col :span="8" v-if="hasColumnPermission(c.prop)">
<el-checkbox :label="c.prop">{{ c.label }}</el-checkbox>
</el-col>
</template>
</el-row>
</el-checkbox-group>
</el-popover>
@ -193,6 +207,7 @@
:src="getImageUrl(getImagesOnly(scope.row[col.prop])[0])"
:preview-src-list="getImagesOnly(scope.row[col.prop]).map(u => getImageUrl(u))"
preview-teleported
hide-on-click-modal
fit="cover"
lazy
>
@ -745,6 +760,8 @@ const scannerDialogVisible = ref(false)
// 库位级联选择器数据
const warehouseOptions = ref<any[]>([])
// ================= 第一步:声明基础数据 =================
// [核心优化] 所有列定义
const allColumns = [
{ prop: 'company_name', label: '所属公司', minWidth: '100', sortable: true }, // [新增]
@ -810,15 +827,15 @@ const permissionMap: Record<string, string> = {
detail_link: 'inbound_product:detail_link',
}
// 根据用户权限初始化列显示状态
// 初始化列显示状态(纯权限驱动,废除本地缓存)
const initColumnPermissions = () => {
visibleColumnProps.value = allColumns
.filter(col => hasColumnPermission(col.prop))
.map(col => col.prop)
}
// ================= 第二步:声明响应式变量 =================
const visibleColumnProps = ref<string[]>([])
// 检查列权限
// ================= 第三步:按依赖顺序放置方法和监听 =================
// 1. 获取唯一缓存 Key
const getStorageKey = () => `MOM_INBOUND_PROD_COLS_${userStore.username || 'DEFAULT'}`;
// 2. 检查列权限(依赖 permissionMap
const hasColumnPermission = (prop: string) => {
if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') {
return true
@ -827,6 +844,50 @@ const hasColumnPermission = (prop: string) => {
return code ? userStore.hasPermission(code) : false
}
// 3. 初始化列权限(依赖 allColumns / hasColumnPermission / getStorageKey
const initColumnPermissions = () => {
const allowedProps = allColumns
.filter(col => hasColumnPermission(col.prop))
.map(col => col.prop);
const cachedData = localStorage.getItem(getStorageKey());
if (cachedData) {
try {
const parsedCache = JSON.parse(cachedData);
visibleColumnProps.value = parsedCache.filter((prop: string) => allowedProps.includes(prop));
return;
} catch (e) {
console.error('解析列缓存失败', e);
}
}
visibleColumnProps.value = allowedProps;
};
// 4. 监听:只要用户勾选了列,就存入本地缓存
watch(visibleColumnProps, (newVal) => {
localStorage.setItem(getStorageKey(), JSON.stringify(newVal));
}, { deep: true });
// 5. 全选功能的计算属性和事件
const isAllSelected = computed(() => {
const allowedLength = allColumns.filter(c => hasColumnPermission(c.prop)).length;
return visibleColumnProps.value.length > 0 && visibleColumnProps.value.length === allowedLength;
});
const isIndeterminate = computed(() => {
const allowedLength = allColumns.filter(c => hasColumnPermission(c.prop)).length;
return visibleColumnProps.value.length > 0 && visibleColumnProps.value.length < allowedLength;
});
const handleCheckAllChange = (val: boolean) => {
if (val) {
visibleColumnProps.value = allColumns.filter(c => hasColumnPermission(c.prop)).map(c => c.prop);
} else {
visibleColumnProps.value = [];
}
};
// ★ 智能聚合:当无序列号权限时,按 SKU 聚合库存
const displayData = computed(() => {
// 检查是否有序列号权限
@ -861,7 +922,6 @@ const displayData = computed(() => {
})
const defaultVisibleCols = ['company_name', 'material_name', 'sku', 'serial_number', 'qty_stock', 'status', 'quality_status', 'product_photo', 'sale_price', 'order_id']
const visibleColumnProps = ref<string[]>([])
const form = reactive({
id: undefined, base_id: undefined as number | undefined,