| | |
| | | <template #action="{ row }"> |
| | | <Space> |
| | | <ghost-button @click="handleEdit(row)">编辑</ghost-button> |
| | | <ghost-button class="btn-success" @click="handleSubAdd(row)">新增</ghost-button> |
| | | <Popconfirm :get-popup-container="getVxePopupContainer" placement="left" title="确认删除?" @confirm="handleDelete(row)"> |
| | | <ghost-button danger @click.stop="">删除</ghost-button> |
| | | </Popconfirm> |
| | | </Space> |
| | | </template> |
| | | </BasicTable> |
| | | <PageDrawer ref="pageModalRef" @reload="tableApi.query()" /> |
| | | <PageDrawer ref="pageModalRef" @reload="tableApi.query()" :menu-array="menuArray" /> |
| | | </Page> |
| | | <Fallback v-else description="您没有页面生成器的访问权限" status="403" /> |
| | | </template> |
| | |
| | | import PageDrawer from './page-drawer.vue'; |
| | | import FcDesigner from '@form-create/designer'; |
| | | import { pageList, pageRemove } from '#/api/tool/page-designer'; |
| | | |
| | | import { menuList } from '../../../api/system/menu'; |
| | | import { listToTree} from '@vben/utils'; |
| | | // 移除mock数据 |
| | | // const pageList = async (params: any) => { ... }; |
| | | // const pageRemove = async (ids: number[]) => {}; |
| | | const menuArray = ref([]); |
| | | const processedMenuTree = ref([]); |
| | | onMounted(async () => { |
| | | try { |
| | | // 获取原始菜单数据 |
| | | const rawMenuData = await menuList(); |
| | | menuArray.value = rawMenuData; |
| | | |
| | | // 处理菜单数据 |
| | | processMenuData(); |
| | | } catch (error) { |
| | | console.error('获取菜单数据失败:', error); |
| | | } |
| | | }); |
| | | // 处理菜单数据的函数 |
| | | const processMenuData = () => { |
| | | if (!menuArray.value || menuArray.value.length === 0) return; |
| | | |
| | | // 1. 过滤掉按钮类型(F)和菜单类型(C) |
| | | const filteredList = menuArray.value.filter(item => |
| | | item.menuType !== 'F' && item.menuType !== 'C' |
| | | ); |
| | | |
| | | // 2. 转换为树形结构 |
| | | const treeData = listToTree(filteredList, { |
| | | id: 'menuId', |
| | | pid: 'parentId' |
| | | }); |
| | | |
| | | // 3. 添加根节点 |
| | | processedMenuTree.value = [ |
| | | { |
| | | menuId: 0, |
| | | parentId: 0, |
| | | menuName: '根目录', |
| | | children: treeData |
| | | } |
| | | ]; |
| | | }; |
| | | const formOptions: VbenFormProps = { |
| | | commonConfig: { |
| | | labelWidth: 80, |
| | |
| | | schema: querySchema(), |
| | | wrapperClass: 'grid-cols-1 md:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4', |
| | | }; |
| | | const getFullMenuPath = (id: number) => { |
| | | if (!processedMenuTree.value || processedMenuTree.value.length === 0) return ''; |
| | | |
| | | // 递归查找菜单路径 |
| | | const findPath = (tree, currentId, path = []): string[] | null => { |
| | | for (const item of tree) { |
| | | if (item.menuId === currentId) { |
| | | return [...path, item.menuName]; |
| | | } |
| | | if (item.children && item.children.length > 0) { |
| | | const found = findPath(item.children, currentId, [...path, item.menuName]); |
| | | if (found) return found; |
| | | } |
| | | } |
| | | return null; |
| | | }; |
| | | |
| | | const path = findPath(processedMenuTree.value, id); |
| | | return path ? path.join(' / ') : '根目录'; |
| | | }; |
| | | const gridOptions: VxeGridProps = { |
| | | columns, |
| | | height: 'auto', |
| | |
| | | proxyConfig: { |
| | | ajax: { |
| | | query: async ({ page }, formValues = {}) => { |
| | | console.log('查询参数:', { page, formValues }); |
| | | const resp = await pageList({ |
| | | pageNum: page.currentPage, |
| | | pageSize: page.pageSize, |
| | | ...formValues, |
| | | }); |
| | | console.log('接口返回数据:', resp); |
| | | |
| | | // 处理返回数据,添加menuParentName |
| | | const processedRows = resp.rows.map(row => { |
| | | return { |
| | | rows: resp.rows, |
| | | ...row, |
| | | menuParentName: getFullMenuPath(row.menuParentId) || '根目录' |
| | | }; |
| | | }); |
| | | return { |
| | | rows: processedRows, // 使用处理后的数据 |
| | | total: resp.total, |
| | | }; |
| | | }, |