V3.38版本修改,三种入库按照基础信息内容进行修改
This commit is contained in:
@ -239,7 +239,7 @@ const handleLogout = () => {
|
|||||||
<footer v-if="!isLoginPage" class="app-footer">
|
<footer v-if="!isLoginPage" class="app-footer">
|
||||||
<span class="version-tag">
|
<span class="version-tag">
|
||||||
<el-icon style="vertical-align: middle; margin-right: 4px"><InfoFilled /></el-icon>
|
<el-icon style="vertical-align: middle; margin-right: 4px"><InfoFilled /></el-icon>
|
||||||
当前版本:V3.37
|
当前版本:V3.38
|
||||||
</span>
|
</span>
|
||||||
</footer>
|
</footer>
|
||||||
|
|
||||||
|
|||||||
@ -111,18 +111,32 @@
|
|||||||
<template #reference>
|
<template #reference>
|
||||||
<el-button :icon="Setting" circle class="circle-btn" />
|
<el-button :icon="Setting" circle class="circle-btn" />
|
||||||
</template>
|
</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-checkbox-group v-model="visibleColumnProps" class="column-selector">
|
||||||
<div class="col-group-title">基础信息</div>
|
<div class="col-group-title">基础信息</div>
|
||||||
<el-row :gutter="10">
|
<el-row :gutter="10">
|
||||||
<el-col :span="12" v-for="c in baseColumns" :key="c.prop">
|
<template v-for="c in baseColumns" :key="c.prop">
|
||||||
<el-checkbox :label="c.prop">{{ c.label }}</el-checkbox>
|
<el-col :span="12" v-if="hasColumnPermission(c.prop)">
|
||||||
</el-col>
|
<el-checkbox :label="c.prop">{{ c.label }}</el-checkbox>
|
||||||
|
</el-col>
|
||||||
|
</template>
|
||||||
</el-row>
|
</el-row>
|
||||||
<div class="col-group-title" style="margin-top:10px">库存与商务</div>
|
<div class="col-group-title" style="margin-top:10px">库存与商务</div>
|
||||||
<el-row :gutter="10">
|
<el-row :gutter="10">
|
||||||
<el-col :span="12" v-for="c in stockColumns" :key="c.prop">
|
<template v-for="c in stockColumns" :key="c.prop">
|
||||||
<el-checkbox :label="c.prop">{{ c.label }}</el-checkbox>
|
<el-col :span="12" v-if="hasColumnPermission(c.prop)">
|
||||||
</el-col>
|
<el-checkbox :label="c.prop">{{ c.label }}</el-checkbox>
|
||||||
|
</el-col>
|
||||||
|
</template>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
@ -193,6 +207,7 @@
|
|||||||
:src="getImageUrl(getImagesOnly(scope.row[col.prop])[0])"
|
:src="getImageUrl(getImagesOnly(scope.row[col.prop])[0])"
|
||||||
:preview-src-list="getImagesOnly(scope.row[col.prop]).map(u => getImageUrl(u))"
|
:preview-src-list="getImagesOnly(scope.row[col.prop]).map(u => getImageUrl(u))"
|
||||||
preview-teleported
|
preview-teleported
|
||||||
|
hide-on-click-modal
|
||||||
fit="cover"
|
fit="cover"
|
||||||
lazy
|
lazy
|
||||||
>
|
>
|
||||||
@ -897,6 +912,8 @@ const operatorOptions = ref([
|
|||||||
{ value: 'le', label: '小于等于' }
|
{ value: 'le', label: '小于等于' }
|
||||||
])
|
])
|
||||||
|
|
||||||
|
// ================= 第一步:声明基础数据 =================
|
||||||
|
|
||||||
// 基础列
|
// 基础列
|
||||||
const baseColumns = [
|
const baseColumns = [
|
||||||
{prop: 'company_name', label: '所属公司'},
|
{prop: 'company_name', label: '所属公司'},
|
||||||
@ -937,6 +954,8 @@ const stockColumns = [
|
|||||||
{prop: 'inspection_report', label: '检测报告', minWidth: '100'}
|
{prop: 'inspection_report', label: '检测报告', minWidth: '100'}
|
||||||
]
|
]
|
||||||
|
|
||||||
|
const allColumns = [...baseColumns, ...stockColumns]
|
||||||
|
|
||||||
// 列与权限Code的映射关系(数据库中的code)
|
// 列与权限Code的映射关系(数据库中的code)
|
||||||
const permissionMap: Record<string, string> = {
|
const permissionMap: Record<string, string> = {
|
||||||
id: 'inbound_buy:id',
|
id: 'inbound_buy:id',
|
||||||
@ -971,14 +990,15 @@ const permissionMap: Record<string, string> = {
|
|||||||
inspection_report: 'inbound_buy:inspection_report'
|
inspection_report: 'inbound_buy:inspection_report'
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化列显示状态(纯权限驱动,废除本地缓存)
|
// ================= 第二步:声明响应式变量 =================
|
||||||
const initColumnPermissions = () => {
|
const visibleColumnProps = ref<string[]>([])
|
||||||
visibleColumnProps.value = allColumns
|
|
||||||
.filter(col => hasColumnPermission(col.prop))
|
|
||||||
.map(col => col.prop)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查列权限
|
// ================= 第三步:按依赖顺序放置方法和监听 =================
|
||||||
|
|
||||||
|
// 1. 获取唯一缓存 Key
|
||||||
|
const getStorageKey = () => `MOM_INBOUND_BUY_COLS_${userStore.username || 'DEFAULT'}`;
|
||||||
|
|
||||||
|
// 2. 检查列权限(依赖 permissionMap)
|
||||||
const hasColumnPermission = (prop: string) => {
|
const hasColumnPermission = (prop: string) => {
|
||||||
if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') {
|
if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') {
|
||||||
return true
|
return true
|
||||||
@ -987,9 +1007,49 @@ const hasColumnPermission = (prop: string) => {
|
|||||||
return code ? userStore.hasPermission(code) : false
|
return code ? userStore.hasPermission(code) : false
|
||||||
}
|
}
|
||||||
|
|
||||||
const allColumns = [...baseColumns, ...stockColumns]
|
// 3. 初始化列权限(依赖 allColumns / hasColumnPermission / getStorageKey)
|
||||||
|
const initColumnPermissions = () => {
|
||||||
|
const allowedProps = allColumns
|
||||||
|
.filter(col => hasColumnPermission(col.prop))
|
||||||
|
.map(col => col.prop);
|
||||||
|
|
||||||
const visibleColumnProps = ref<string[]>([])
|
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 = [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
id: undefined, base_id: undefined as number | undefined,
|
id: undefined, base_id: undefined as number | undefined,
|
||||||
|
|||||||
@ -123,9 +123,23 @@
|
|||||||
<el-button :icon="Refresh" @click="fetchData" class="action-btn">刷新</el-button>
|
<el-button :icon="Refresh" @click="fetchData" class="action-btn">刷新</el-button>
|
||||||
<el-popover placement="bottom-end" title="列配置" :width="500" trigger="click">
|
<el-popover placement="bottom-end" title="列配置" :width="500" trigger="click">
|
||||||
<template #reference><el-button :icon="Setting" class="action-btn">表头</el-button></template>
|
<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-checkbox-group v-model="visibleColumnProps" class="column-selector">
|
||||||
<el-row :gutter="10">
|
<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-row>
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
@ -193,6 +207,7 @@
|
|||||||
:src="getImageUrl(getImagesOnly(scope.row[col.prop])[0])"
|
:src="getImageUrl(getImagesOnly(scope.row[col.prop])[0])"
|
||||||
:preview-src-list="getImagesOnly(scope.row[col.prop]).map(u => getImageUrl(u))"
|
:preview-src-list="getImagesOnly(scope.row[col.prop]).map(u => getImageUrl(u))"
|
||||||
preview-teleported
|
preview-teleported
|
||||||
|
hide-on-click-modal
|
||||||
fit="cover"
|
fit="cover"
|
||||||
lazy
|
lazy
|
||||||
>
|
>
|
||||||
@ -745,6 +760,8 @@ const scannerDialogVisible = ref(false)
|
|||||||
// 库位级联选择器数据
|
// 库位级联选择器数据
|
||||||
const warehouseOptions = ref<any[]>([])
|
const warehouseOptions = ref<any[]>([])
|
||||||
|
|
||||||
|
// ================= 第一步:声明基础数据 =================
|
||||||
|
|
||||||
// [核心优化] 所有列定义
|
// [核心优化] 所有列定义
|
||||||
const allColumns = [
|
const allColumns = [
|
||||||
{ prop: 'company_name', label: '所属公司', minWidth: '100', sortable: true }, // [新增]
|
{ prop: 'company_name', label: '所属公司', minWidth: '100', sortable: true }, // [新增]
|
||||||
@ -810,15 +827,15 @@ const permissionMap: Record<string, string> = {
|
|||||||
detail_link: 'inbound_product:detail_link',
|
detail_link: 'inbound_product:detail_link',
|
||||||
}
|
}
|
||||||
|
|
||||||
// 根据用户权限初始化列显示状态
|
// ================= 第二步:声明响应式变量 =================
|
||||||
// 初始化列显示状态(纯权限驱动,废除本地缓存)
|
const visibleColumnProps = ref<string[]>([])
|
||||||
const initColumnPermissions = () => {
|
|
||||||
visibleColumnProps.value = allColumns
|
|
||||||
.filter(col => hasColumnPermission(col.prop))
|
|
||||||
.map(col => col.prop)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 检查列权限
|
// ================= 第三步:按依赖顺序放置方法和监听 =================
|
||||||
|
|
||||||
|
// 1. 获取唯一缓存 Key
|
||||||
|
const getStorageKey = () => `MOM_INBOUND_PROD_COLS_${userStore.username || 'DEFAULT'}`;
|
||||||
|
|
||||||
|
// 2. 检查列权限(依赖 permissionMap)
|
||||||
const hasColumnPermission = (prop: string) => {
|
const hasColumnPermission = (prop: string) => {
|
||||||
if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') {
|
if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') {
|
||||||
return true
|
return true
|
||||||
@ -827,6 +844,50 @@ const hasColumnPermission = (prop: string) => {
|
|||||||
return code ? userStore.hasPermission(code) : false
|
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 聚合库存
|
// ★ 智能聚合:当无序列号权限时,按 SKU 聚合库存
|
||||||
const displayData = computed(() => {
|
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 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({
|
const form = reactive({
|
||||||
id: undefined, base_id: undefined as number | undefined,
|
id: undefined, base_id: undefined as number | undefined,
|
||||||
|
|||||||
@ -127,18 +127,32 @@
|
|||||||
<template #reference>
|
<template #reference>
|
||||||
<el-button :icon="Setting" circle class="circle-btn" />
|
<el-button :icon="Setting" circle class="circle-btn" />
|
||||||
</template>
|
</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-checkbox-group v-model="visibleColumnProps" class="column-selector">
|
||||||
<div class="col-group-title">基础信息</div>
|
<div class="col-group-title">基础信息</div>
|
||||||
<el-row :gutter="10">
|
<el-row :gutter="10">
|
||||||
<el-col :span="12" v-for="c in baseColumns" :key="c.prop">
|
<template v-for="c in baseColumns" :key="c.prop">
|
||||||
<el-checkbox :label="c.prop">{{ c.label }}</el-checkbox>
|
<el-col :span="12" v-if="hasColumnPermission(c.prop)">
|
||||||
</el-col>
|
<el-checkbox :label="c.prop">{{ c.label }}</el-checkbox>
|
||||||
|
</el-col>
|
||||||
|
</template>
|
||||||
</el-row>
|
</el-row>
|
||||||
<div class="col-group-title" style="margin-top:10px">生产与库存</div>
|
<div class="col-group-title" style="margin-top:10px">生产与库存</div>
|
||||||
<el-row :gutter="10">
|
<el-row :gutter="10">
|
||||||
<el-col :span="12" v-for="c in stockColumns" :key="c.prop">
|
<template v-for="c in stockColumns" :key="c.prop">
|
||||||
<el-checkbox :label="c.prop">{{ c.label }}</el-checkbox>
|
<el-col :span="12" v-if="hasColumnPermission(c.prop)">
|
||||||
</el-col>
|
<el-checkbox :label="c.prop">{{ c.label }}</el-checkbox>
|
||||||
|
</el-col>
|
||||||
|
</template>
|
||||||
</el-row>
|
</el-row>
|
||||||
</el-checkbox-group>
|
</el-checkbox-group>
|
||||||
</el-popover>
|
</el-popover>
|
||||||
@ -216,6 +230,7 @@
|
|||||||
:src="getImageUrl(getImagesOnly(scope.row[col.prop])[0])"
|
:src="getImageUrl(getImagesOnly(scope.row[col.prop])[0])"
|
||||||
:preview-src-list="getImagesOnly(scope.row[col.prop]).map(u => getImageUrl(u))"
|
:preview-src-list="getImagesOnly(scope.row[col.prop]).map(u => getImageUrl(u))"
|
||||||
preview-teleported
|
preview-teleported
|
||||||
|
hide-on-click-modal
|
||||||
fit="cover"
|
fit="cover"
|
||||||
lazy
|
lazy
|
||||||
>
|
>
|
||||||
@ -798,6 +813,8 @@ const warehouseOptions = ref<any[]>([])
|
|||||||
const entryMode = ref('batch')
|
const entryMode = ref('batch')
|
||||||
const modeLocked = ref(false)
|
const modeLocked = ref(false)
|
||||||
|
|
||||||
|
// ================= 第一步:声明基础数据 =================
|
||||||
|
|
||||||
// 列定义
|
// 列定义
|
||||||
const baseColumns = [
|
const baseColumns = [
|
||||||
{prop: 'company_name', label: '所属公司', sortable: true}, // [新增]
|
{prop: 'company_name', label: '所属公司', sortable: true}, // [新增]
|
||||||
@ -834,14 +851,8 @@ const stockColumns = [
|
|||||||
{prop: 'quality_report_link', label: '质量报告', minWidth: '100', sortable: false},
|
{prop: 'quality_report_link', label: '质量报告', minWidth: '100', sortable: false},
|
||||||
{prop: 'detail_link', label: '详情链接', minWidth: '100', sortable: false},
|
{prop: 'detail_link', label: '详情链接', minWidth: '100', sortable: false},
|
||||||
]
|
]
|
||||||
const allColumns = [...baseColumns, ...stockColumns]
|
|
||||||
|
|
||||||
// 初始化列显示状态(纯权限驱动,废除本地缓存)
|
const allColumns = [...baseColumns, ...stockColumns]
|
||||||
const initColumnPermissions = () => {
|
|
||||||
visibleColumnProps.value = allColumns
|
|
||||||
.filter(col => hasColumnPermission(col.prop))
|
|
||||||
.map(col => col.prop)
|
|
||||||
}
|
|
||||||
|
|
||||||
// 列与权限Code的映射关系(数据库中的code)
|
// 列与权限Code的映射关系(数据库中的code)
|
||||||
const permissionMap: Record<string, string> = {
|
const permissionMap: Record<string, string> = {
|
||||||
@ -882,7 +893,15 @@ const permissionMap: Record<string, string> = {
|
|||||||
detail_link: 'inbound_semi:detail_link',
|
detail_link: 'inbound_semi:detail_link',
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查列权限
|
// ================= 第二步:声明响应式变量 =================
|
||||||
|
const visibleColumnProps = ref<string[]>([])
|
||||||
|
|
||||||
|
// ================= 第三步:按依赖顺序放置方法和监听 =================
|
||||||
|
|
||||||
|
// 1. 获取唯一缓存 Key
|
||||||
|
const getStorageKey = () => `MOM_INBOUND_SEMI_COLS_${userStore.username || 'DEFAULT'}`;
|
||||||
|
|
||||||
|
// 2. 检查列权限(依赖 permissionMap)
|
||||||
const hasColumnPermission = (prop: string) => {
|
const hasColumnPermission = (prop: string) => {
|
||||||
if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') {
|
if (userStore.role === 'SUPER_ADMIN' || userStore.username === 'IRIS') {
|
||||||
return true
|
return true
|
||||||
@ -891,8 +910,51 @@ const hasColumnPermission = (prop: string) => {
|
|||||||
return code ? userStore.hasPermission(code) : false
|
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 = [];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const defaultColumns = ['company_name', 'material_name', 'spec_model', 'unit', 'inbound_date', 'sn_bn', 'status', 'quality_status', 'bom_code', 'work_order_code', 'qty_stock', 'qty_available', 'unit_total_cost', 'arrival_photo', 'quality_report_link']
|
const defaultColumns = ['company_name', 'material_name', 'spec_model', 'unit', 'inbound_date', 'sn_bn', 'status', 'quality_status', 'bom_code', 'work_order_code', 'qty_stock', 'qty_available', 'unit_total_cost', 'arrival_photo', 'quality_report_link']
|
||||||
const visibleColumnProps = ref<string[]>([])
|
|
||||||
|
|
||||||
const form = reactive({
|
const form = reactive({
|
||||||
id: undefined, base_id: undefined as number | undefined,
|
id: undefined, base_id: undefined as number | undefined,
|
||||||
|
|||||||
Reference in New Issue
Block a user