Browse Source

fix(menus): there are multiple refreshing menus meta.

pull/901/head
colin 2 years ago
parent
commit
080d6dec41
  1. 24
      apps/vue/src/views/platform/menu/components/MenuTable.vue
  2. 19
      apps/vue/src/views/platform/menu/components/TableData.ts
  3. 13
      apps/vue/src/views/platform/menu/hooks/useMenuFormContext.ts

24
apps/vue/src/views/platform/menu/components/MenuTable.vue

@ -2,12 +2,22 @@
<div> <div>
<BasicTable @register="registerTable"> <BasicTable @register="registerTable">
<template #toolbar> <template #toolbar>
<a-button type="primary" @click="handleAddNew">{{ L('Menu:AddNew') }}</a-button> <a-button v-auth="['Platform.Menu.Create']" type="primary" @click="handleAddNew">{{ L('Menu:AddNew') }}</a-button>
</template> </template>
<template #bodyCell="{ column, record }"> <template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'"> <template v-if="column.key === 'displayName'">
<Icon v-if="record.meta.icon" style="margin-right: 10px;" :icon="record.meta.icon" />
<span>{{ record.displayName }}</span>
</template>
<template v-else-if="column.key === 'action'">
<TableAction <TableAction
:actions="[ :actions="[
{
auth: 'Platform.Menu.Create',
label: L('Menu:AddNew'),
icon: 'ant-design:plus-outlined',
onClick: handleAddNew.bind(null, record),
},
{ {
auth: 'Platform.Menu.Update', auth: 'Platform.Menu.Update',
label: L('Edit'), label: L('Edit'),
@ -35,6 +45,7 @@
import { useMessage } from '/@/hooks/web/useMessage'; import { useMessage } from '/@/hooks/web/useMessage';
import { useLocalization } from '/@/hooks/abp/useLocalization'; import { useLocalization } from '/@/hooks/abp/useLocalization';
import { BasicTable, useTable, TableAction } from '/@/components/Table'; import { BasicTable, useTable, TableAction } from '/@/components/Table';
import { Icon } from '/@/components/Icon';
import { useDrawer } from '/@/components/Drawer'; import { useDrawer } from '/@/components/Drawer';
import { getDataColumns } from './TableData'; import { getDataColumns } from './TableData';
import { getSearchFormSchemas } from './ModalData'; import { getSearchFormSchemas } from './ModalData';
@ -70,7 +81,7 @@
canResize: false, canResize: false,
formConfig: getSearchFormSchemas(), formConfig: getSearchFormSchemas(),
actionColumn: { actionColumn: {
width: 160, width: 280,
title: L('Actions'), title: L('Actions'),
dataIndex: 'action', dataIndex: 'action',
}, },
@ -78,8 +89,11 @@
const [registerDrawer, { openDrawer }] = useDrawer(); const [registerDrawer, { openDrawer }] = useDrawer();
function handleAddNew() { function handleAddNew(record?: Recordable) {
openDrawer(true, {}); openDrawer(true, {
layoutId: record?.layoutId,
parentId: record?.id,
});
} }
function handleEdit(record: Recordable) { function handleEdit(record: Recordable) {

19
apps/vue/src/views/platform/menu/components/TableData.ts

@ -29,41 +29,54 @@ export function getDataColumns(): BasicColumn[] {
dataIndex: 'name', dataIndex: 'name',
align: 'left', align: 'left',
width: 150, width: 150,
resizable: true,
sorter: (a: Menu, b: Menu) => a.name.localeCompare(b.name), sorter: (a: Menu, b: Menu) => a.name.localeCompare(b.name),
}, },
{ {
title: L('DisplayName:DisplayName'), title: L('DisplayName:DisplayName'),
dataIndex: 'displayName', dataIndex: 'displayName',
align: 'left',
width: 180, width: 180,
resizable: true,
sorter: (a: Menu, b: Menu) => a.displayName.localeCompare(b.displayName), sorter: (a: Menu, b: Menu) => a.displayName.localeCompare(b.displayName),
}, },
{ {
title: L('DisplayName:Path'), title: L('DisplayName:Path'),
dataIndex: 'path', dataIndex: 'path',
width: 180, align: 'left',
width: 260,
resizable: true,
sorter: (a: Menu, b: Menu) => a.path.localeCompare(b.path), sorter: (a: Menu, b: Menu) => a.path.localeCompare(b.path),
}, },
{ {
title: L('DisplayName:Component'), title: L('DisplayName:Component'),
dataIndex: 'component', dataIndex: 'component',
width: 180, align: 'left',
width: 240,
resizable: true,
sorter: (a: Menu, b: Menu) => a.component.localeCompare(b.component), sorter: (a: Menu, b: Menu) => a.component.localeCompare(b.component),
}, },
{ {
title: L('DisplayName:UIFramework'), title: L('DisplayName:UIFramework'),
dataIndex: 'framework', dataIndex: 'framework',
align: 'left',
width: 180, width: 180,
resizable: true,
sorter: (a: Menu, b: Menu) => a.framework.localeCompare(b.framework), sorter: (a: Menu, b: Menu) => a.framework.localeCompare(b.framework),
}, },
{ {
title: L('DisplayName:Description'), title: L('DisplayName:Description'),
dataIndex: 'description', dataIndex: 'description',
align: 'left',
resizable: true,
width: 250, width: 250,
}, },
{ {
title: L('DisplayName:Redirect'), title: L('DisplayName:Redirect'),
dataIndex: 'redirect', dataIndex: 'redirect',
width: 'auto', align: 'left',
width: 180,
resizable: true,
}, },
]; ];
} }

13
apps/vue/src/views/platform/menu/hooks/useMenuFormContext.ts

@ -127,10 +127,10 @@ export function useMenuFormContext({ menuModel, formElRef, framework }: UseMenuF
onChange(val) { onChange(val) {
fetchLayoutResource(val); fetchLayoutResource(val);
}, },
onOptionsChange() { // onOptionsChange() {
const menu = unref(menuModel); // const menu = unref(menuModel);
fetchLayoutResource(menu.layoutId); // fetchLayoutResource(menu.layoutId);
}, // },
}, },
}, },
{ {
@ -252,7 +252,10 @@ export function useMenuFormContext({ menuModel, formElRef, framework }: UseMenuF
schemas.push(x); schemas.push(x);
formEl?.appendSchemaByField(x, ''); formEl?.appendSchemaByField(x, '');
}); });
formEl?.setFieldsValue(unref(menuModel)); formEl?.setFieldsValue({
...unref(menuModel),
layoutId: layoutId,
});
} }
} }

Loading…
Cancel
Save