mirror of
https://github.com/YunaiV/ruoyi-vue-pro.git
synced 2025-11-04 00:03:52 +08:00
reactor:【infra 基础设施】处理 vben + vben 树形模版
This commit is contained in:
@ -117,6 +117,10 @@ const [Modal, modalApi] = useVbenModal({
|
|||||||
// 加载数据
|
// 加载数据
|
||||||
const data = modalApi.getData<${apiName}.${simpleClassName}>();
|
const data = modalApi.getData<${apiName}.${simpleClassName}>();
|
||||||
if (!data || !data.id) {
|
if (!data || !data.id) {
|
||||||
|
#if (${table.templateType} == 2)## 树表特有
|
||||||
|
// 设置上级
|
||||||
|
await formApi.setValues(data);
|
||||||
|
#end
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
modalApi.lock();
|
modalApi.lock();
|
||||||
|
|||||||
@ -6,7 +6,7 @@ import type { ${apiName} } from '#/api/${table.moduleName}/${table.businessName}
|
|||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
import {#if ($table.templateType != 2 && $deleteBatchEnable) confirm,#end Page, useVbenModal } from '@vben/common-ui';
|
import {#if ($table.templateType != 2 && $deleteBatchEnable) confirm,#end Page, useVbenModal } from '@vben/common-ui';
|
||||||
import { downloadFileFromBlobPart, isEmpty } from '@vben/utils';
|
import { downloadFileFromBlobPart#if ($table.templateType != 2 && $deleteBatchEnable), isEmpty#end } from '@vben/utils';
|
||||||
|
|
||||||
import { message#if ($table.templateType == 11), Tabs#end } from 'ant-design-vue';
|
import { message#if ($table.templateType == 11), Tabs#end } from 'ant-design-vue';
|
||||||
|
|
||||||
@ -73,18 +73,18 @@ function onRefresh() {
|
|||||||
function handleCreate() {
|
function handleCreate() {
|
||||||
formModalApi.setData(null).open();
|
formModalApi.setData(null).open();
|
||||||
}
|
}
|
||||||
|
#if (${table.templateType} == 2)## 树表特有:新增下级
|
||||||
|
|
||||||
|
/** 添加下级${table.classComment} */
|
||||||
|
function handleAppend(row: ${apiName}.${simpleClassName}) {
|
||||||
|
formModalApi.setData({ ${treeParentColumn.javaField}: row.id }).open();
|
||||||
|
}
|
||||||
|
#end
|
||||||
|
|
||||||
/** 编辑${table.classComment} */
|
/** 编辑${table.classComment} */
|
||||||
function handleEdit(row: ${apiName}.${simpleClassName}) {
|
function handleEdit(row: ${apiName}.${simpleClassName}) {
|
||||||
formModalApi.setData(row).open();
|
formModalApi.setData(row).open();
|
||||||
}
|
}
|
||||||
#if (${table.templateType} == 2)## 树表特有:新增下级
|
|
||||||
|
|
||||||
/** 新增下级${table.classComment} */
|
|
||||||
function handleAppend(row: ${apiName}.${simpleClassName}) {
|
|
||||||
formModalApi.setData({ ${treeParentColumn.javaField}: row.id }).open();
|
|
||||||
}
|
|
||||||
#end
|
|
||||||
|
|
||||||
/** 删除${table.classComment} */
|
/** 删除${table.classComment} */
|
||||||
async function handleDelete(row: ${apiName}.${simpleClassName}) {
|
async function handleDelete(row: ${apiName}.${simpleClassName}) {
|
||||||
@ -147,16 +147,9 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
height: 'auto',
|
height: 'auto',
|
||||||
#end
|
#end
|
||||||
#if (${table.templateType} == 2)## 树表设置
|
#if (${table.templateType} == 2)## 树表设置
|
||||||
treeConfig: {
|
pagerConfig: {
|
||||||
parentField: '${treeParentColumn.javaField}',
|
enabled: false,
|
||||||
rowField: 'id',
|
},
|
||||||
transform: true,
|
|
||||||
expandAll: true,
|
|
||||||
reserve: true,
|
|
||||||
},
|
|
||||||
pagerConfig: {
|
|
||||||
enabled: false,
|
|
||||||
},
|
|
||||||
#else## 标准表设置
|
#else## 标准表设置
|
||||||
keepSource: true,
|
keepSource: true,
|
||||||
#end
|
#end
|
||||||
@ -188,15 +181,24 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
refresh: true,
|
refresh: true,
|
||||||
search: true,
|
search: true,
|
||||||
},
|
},
|
||||||
|
#if (${table.templateType} == 2)## 树表设置
|
||||||
|
treeConfig: {
|
||||||
|
parentField: '${treeParentColumn.javaField}',
|
||||||
|
rowField: 'id',
|
||||||
|
transform: true,
|
||||||
|
expandAll: true,
|
||||||
|
reserve: true,
|
||||||
|
},
|
||||||
|
#end
|
||||||
} as VxeTableGridOptions<${apiName}.${simpleClassName}>,
|
} as VxeTableGridOptions<${apiName}.${simpleClassName}>,
|
||||||
#if (${table.templateType} == 11 || $deleteBatchEnable)
|
#if (${table.templateType} == 11 || (${table.templateType} != 2 && $deleteBatchEnable))
|
||||||
gridEvents: {
|
gridEvents: {
|
||||||
#if(${table.templateType} == 11)
|
#if(${table.templateType} == 11)
|
||||||
cellClick: ({ row }: { row: ${apiName}.${simpleClassName}}) => {
|
cellClick: ({ row }: { row: ${apiName}.${simpleClassName}}) => {
|
||||||
select${simpleClassName}.value = row;
|
select${simpleClassName}.value = row;
|
||||||
},
|
},
|
||||||
#end
|
#end
|
||||||
#if(${table.templateType} != 2 && $deleteBatchEnable)
|
#if (${table.templateType} != 2 && $deleteBatchEnable)
|
||||||
checkboxAll: handleRowCheckboxChange,
|
checkboxAll: handleRowCheckboxChange,
|
||||||
checkboxChange: handleRowCheckboxChange,
|
checkboxChange: handleRowCheckboxChange,
|
||||||
#end
|
#end
|
||||||
@ -231,13 +233,6 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
<template #toolbar-tools>
|
<template #toolbar-tools>
|
||||||
<TableAction
|
<TableAction
|
||||||
:actions="[
|
:actions="[
|
||||||
#if (${table.templateType} == 2)## 树表特有:展开/收缩按钮
|
|
||||||
{
|
|
||||||
label: isExpanded ? '收缩' : '展开',
|
|
||||||
type: 'primary',
|
|
||||||
onClick: toggleExpand,
|
|
||||||
},
|
|
||||||
#end
|
|
||||||
{
|
{
|
||||||
label: $t('ui.actionTitle.create', ['${table.classComment}']),
|
label: $t('ui.actionTitle.create', ['${table.classComment}']),
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
@ -245,6 +240,13 @@ const [Grid, gridApi] = useVbenVxeGrid({
|
|||||||
auth: ['${table.moduleName}:${simpleClassName_strikeCase}:create'],
|
auth: ['${table.moduleName}:${simpleClassName_strikeCase}:create'],
|
||||||
onClick: handleCreate,
|
onClick: handleCreate,
|
||||||
},
|
},
|
||||||
|
#if (${table.templateType} == 2)## 树表特有:展开/收缩按钮
|
||||||
|
{
|
||||||
|
label: isExpanded ? '收缩' : '展开',
|
||||||
|
type: 'primary',
|
||||||
|
onClick: toggleExpand,
|
||||||
|
},
|
||||||
|
#end
|
||||||
{
|
{
|
||||||
label: $t('ui.actionTitle.export'),
|
label: $t('ui.actionTitle.export'),
|
||||||
type: 'primary',
|
type: 'primary',
|
||||||
|
|||||||
Reference in New Issue
Block a user