新增查看页面

This commit is contained in:
2026-01-18 23:51:55 +08:00
parent 9df4db2510
commit a5cfeb02a1
4 changed files with 51 additions and 46 deletions

View File

@@ -122,13 +122,13 @@ const tableProps: BasicTableProps = {
},
columns: tableColumns,
formConfig: searchForm,
rowKey: 'userCode',
rowKey: 'loginCode',
};
export default {
modalProps,
tableProps,
itemCode: 'userCode',
itemCode: 'loginCode',
itemName: 'userName',
isShowCode: true,
};

View File

@@ -1,5 +1,5 @@
<script lang="tsx">
import { defineComponent, CSSProperties, nextTick, ref } from 'vue';
import { defineComponent, CSSProperties, nextTick, ref, computed } from 'vue';
import { useResizeObserver } from '@vueuse/core';
import { fileListProps } from './props';
import { isFunction } from '@jeesite/core/utils/is';
@@ -11,65 +11,67 @@
props: fileListProps,
setup(props) {
const modalFn = useModalContext();
const tableRef = ref<HTMLTableElement>();
useResizeObserver(tableRef, () => {
nextTick(() => {
modalFn?.redoModalHeight?.();
});
const tableRef = ref<HTMLTableElement | null>(null);
const columnList = computed(() => {
const { columns = [], actionColumn } = props;
return actionColumn ? [...columns, actionColumn] : [...columns];
});
useResizeObserver(tableRef, () => {
nextTick(modalFn?.redoModalHeight);
});
return () => {
const { columns, actionColumn, dataSource } = props;
const columnList = [...columns, actionColumn];
const { dataSource = [], emptyText = '暂无数据' } = props;
const columns = columnList.value;
return (
<table class="file-table" ref={tableRef}>
<colgroup>
{columnList.map((item) => {
{columns.map((item) => {
const { width = 0, dataIndex } = item;
const style: CSSProperties = {
width: `${width}px`,
minWidth: `${width}px`,
};
return <col style={width ? style : {}} key={dataIndex} />;
const style: CSSProperties = width ? { width: `${width}px`, minWidth: `${width}px` } : {};
return <col style={style} key={dataIndex} />;
})}
</colgroup>
<thead>
<tr class="file-table-tr">
{columnList.map((item) => {
{columns.map((item) => {
const { title = '', align = 'center', dataIndex } = item;
return (
dataIndex && (
<th class={['file-table-th', align]} key={dataIndex}>
{title}
</th>
)
return dataIndex && (
<th class={['file-table-th', align]} key={dataIndex}>
{title}
</th>
);
})}
</tr>
</thead>
<tbody>
{dataSource.map((record = {}, index) => {
{dataSource.map((record, index) => {
const currentRecord = record || {};
const rowKey = currentRecord.id || currentRecord.name || `row-${index}`;
return (
<tr class="file-table-tr" key={`${index + record.name || ''}`}>
{columnList.map((item) => {
<tr class="file-table-tr" key={rowKey}>
{columns.map((item) => {
const { dataIndex = '', customRender, align = 'center' } = item;
const render = customRender && isFunction(customRender);
return (
dataIndex && (
<td class={['file-table-td', align]} key={dataIndex}>
{render
? customRender?.({ text: get(record, dataIndex), record, index })
: get(record, dataIndex)}
</td>
)
const cellValue = get(currentRecord, dataIndex);
return dataIndex && (
<td class={['file-table-td', align]} key={dataIndex}>
{isFunction(customRender)
? customRender({ text: cellValue, record: currentRecord, index })
: cellValue
}
</td>
);
})}
</tr>
);
})}
{dataSource.length == 0 && (
{!dataSource.length && (
<tr class="file-table-tr">
<td class="file-table-td center" colspan={columnList.length}>
{props.emptyText}
<td class="file-table-td center" colSpan={columns.length}>
{emptyText}
</td>
</tr>
)}
@@ -80,18 +82,17 @@
},
});
</script>
<style lang="less">
<style lang="less" scoped>
.file-table {
width: 100%;
border-top: 1px solid @border-color-base;
border-right: 1px solid @border-color-base;
border: 1px solid @border-color-base;
border-collapse: separate;
border-spacing: 0;
table-layout: auto;
&-th,
&-td {
border-left: 1px solid @border-color-base;
border-bottom: 1px solid @border-color-base;
padding: 12px 8px;
overflow-wrap: break-word;
word-break: break-all;
@@ -101,8 +102,10 @@
thead {
background-color: @background-color-light;
font-weight: 500;
}
// 对齐样式保留
.center {
text-align: center;
}
@@ -116,11 +119,13 @@
}
}
// 暗黑模式适配,保留原有逻辑
html[data-theme='dark'] {
.file-table {
border-color: #333;
thead {
background-color: #1a1a1a;
}
}
}
</style>
</style>

View File

@@ -1,6 +1,6 @@
<template>
<BasicModal
width="80%"
width="45%"
:title="t('component.upload.upload')"
:okText="t('component.upload.save')"
v-bind="$attrs"

View File

@@ -1,7 +1,7 @@
<template>
<BasicModal
v-if="!props.showPreviewList"
width="80%"
width="45%"
:title="t('component.upload.view')"
:cancelText="t('component.modal.okText')"
wrapClassName="upload-preview-modal"