2024-10-04 23:05:28 +08:00
|
|
|
|
import { h } from 'vue';
|
|
|
|
|
|
|
|
|
|
import { setupVbenVxeTable, useVbenVxeGrid } from '@vben/plugins/vxe-table';
|
|
|
|
|
|
|
|
|
|
import { ElButton, ElImage } from 'element-plus';
|
|
|
|
|
|
|
|
|
|
import { useVbenForm } from './form';
|
|
|
|
|
|
|
|
|
|
setupVbenVxeTable({
|
|
|
|
|
configVxeTable: (vxeUI) => {
|
|
|
|
|
vxeUI.setConfig({
|
|
|
|
|
grid: {
|
|
|
|
|
align: 'center',
|
2024-10-24 22:51:04 +08:00
|
|
|
|
border: false,
|
|
|
|
|
columnConfig: {
|
|
|
|
|
resizable: true,
|
|
|
|
|
},
|
2024-10-04 23:05:28 +08:00
|
|
|
|
minHeight: 180,
|
2024-11-02 15:46:19 +08:00
|
|
|
|
formConfig: {
|
|
|
|
|
// 全局禁用vxe-table的表单配置,使用formOptions
|
|
|
|
|
enabled: false,
|
|
|
|
|
},
|
2024-10-04 23:05:28 +08:00
|
|
|
|
proxyConfig: {
|
|
|
|
|
autoLoad: true,
|
|
|
|
|
response: {
|
|
|
|
|
result: 'items',
|
|
|
|
|
total: 'total',
|
|
|
|
|
list: 'items',
|
|
|
|
|
},
|
|
|
|
|
showActiveMsg: true,
|
|
|
|
|
showResponseMsg: false,
|
|
|
|
|
},
|
|
|
|
|
round: true,
|
2024-10-24 22:51:04 +08:00
|
|
|
|
showOverflow: true,
|
2024-10-04 23:05:28 +08:00
|
|
|
|
size: 'small',
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 表格配置项可以用 cellRender: { name: 'CellImage' },
|
|
|
|
|
vxeUI.renderer.add('CellImage', {
|
|
|
|
|
renderDefault(_renderOpts, params) {
|
|
|
|
|
const { column, row } = params;
|
|
|
|
|
const src = row[column.field];
|
|
|
|
|
return h(ElImage, { src, previewSrcList: [src] });
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 表格配置项可以用 cellRender: { name: 'CellLink' },
|
|
|
|
|
vxeUI.renderer.add('CellLink', {
|
|
|
|
|
renderDefault(renderOpts) {
|
|
|
|
|
const { props } = renderOpts;
|
|
|
|
|
return h(
|
|
|
|
|
ElButton,
|
|
|
|
|
{ size: 'small', link: true },
|
|
|
|
|
{ default: () => props?.text },
|
|
|
|
|
);
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 这里可以自行扩展 vxe-table 的全局配置,比如自定义格式化
|
|
|
|
|
// vxeUI.formats.add
|
|
|
|
|
},
|
|
|
|
|
useVbenForm,
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
export { useVbenVxeGrid };
|
|
|
|
|
|
|
|
|
|
export type * from '@vben/plugins/vxe-table';
|