feat(chat): 完善固资预览与下载权限
This commit is contained in:
1 parent
6ce0942fef
commit
bf18a7ef1d
19 files changed
+1163
-86
No files matched your search
@@ -19,6 +19,7 @@ const emit = defineEmits<{
|
||||
close: [];
|
||||
'change-page': [delta: number];
|
||||
'open-asset-history': [payload: { assetId: string; assetName: string }];
|
||||
'open-asset-image': [payload: { assetId: string; assetName: string }];
|
||||
}>();
|
||||
|
||||
const totalPages = computed(() =>
|
||||
@@ -26,19 +27,34 @@ const totalPages = computed(() =>
|
||||
);
|
||||
const assetIdColumnIndex = computed(() => props.state.columns.findIndex((column) => column === '资产编号'));
|
||||
const assetNameColumnIndex = computed(() => props.state.columns.findIndex((column) => column === '资产名称'));
|
||||
const imageColumnIndex = computed(() => props.state.columns.findIndex((column) => column === '图片'));
|
||||
|
||||
function isHighlightColumn(column: string): boolean {
|
||||
return column === '资产编号' || column === '图片';
|
||||
}
|
||||
|
||||
function normalizeCellText(cell: unknown): string {
|
||||
return String(cell ?? '').trim();
|
||||
}
|
||||
|
||||
function canOpenAssetHistory(row: unknown[], cellIndex: number): boolean {
|
||||
return cellIndex === assetIdColumnIndex.value && !!normalizeCellText(row[cellIndex]);
|
||||
if (cellIndex === assetIdColumnIndex.value) {
|
||||
return !!normalizeCellText(row[cellIndex]);
|
||||
}
|
||||
if (cellIndex === imageColumnIndex.value) {
|
||||
return !!normalizeCellText(row[assetIdColumnIndex.value]);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function emitAssetHistory(row: unknown[]): void {
|
||||
function emitAssetAction(row: unknown[], cellIndex: number): void {
|
||||
const assetId = normalizeCellText(row[assetIdColumnIndex.value]);
|
||||
const assetName = assetNameColumnIndex.value >= 0 ? normalizeCellText(row[assetNameColumnIndex.value]) : '';
|
||||
if (!assetId) return;
|
||||
if (cellIndex === imageColumnIndex.value) {
|
||||
emit('open-asset-image', { assetId, assetName });
|
||||
return;
|
||||
}
|
||||
emit('open-asset-history', { assetId, assetName });
|
||||
}
|
||||
</script>
|
||||
@@ -97,7 +113,10 @@ function emitAssetHistory(row: unknown[]): void {
|
||||
<th
|
||||
v-for="column in state.columns"
|
||||
:key="`query-preview-col-${column}`"
|
||||
class="border border-slate-200 px-3 py-2 text-left font-semibold text-primary"
|
||||
:class="[
|
||||
'border border-slate-200 px-3 py-2 text-left font-semibold',
|
||||
isHighlightColumn(column) ? 'text-blue-800' : 'text-primary',
|
||||
]"
|
||||
>
|
||||
{{ column }}
|
||||
</th>
|
||||
@@ -117,8 +136,8 @@ function emitAssetHistory(row: unknown[]): void {
|
||||
<button
|
||||
v-if="canOpenAssetHistory(row, cellIndex)"
|
||||
type="button"
|
||||
class="whitespace-pre-wrap break-all text-left font-medium text-brand-600 underline-offset-2 transition hover:underline"
|
||||
@click="emitAssetHistory(row)"
|
||||
class="whitespace-pre-wrap break-all text-left font-semibold text-blue-700 underline-offset-2 transition hover:text-blue-800 hover:underline"
|
||||
@click="emitAssetAction(row, cellIndex)"
|
||||
>
|
||||
{{ cell ?? '-' }}
|
||||
</button>
|
||||
|
||||
Reference in new issue
Block a user