|
@@ -12,17 +12,17 @@
|
|
|
<template #form-custom > custom-slot </template>
|
|
|
|
|
|
<template #toolbar>
|
|
|
- <a-button type="primary" @click="addColumn" >
|
|
|
+ <a-button type="primary" @click="addMenu" >
|
|
|
{{ '新增菜单' }}
|
|
|
</a-button>
|
|
|
</template>
|
|
|
</BasicTable>
|
|
|
- <Add @register="addRegister" @saveData="saveData" />
|
|
|
+ <Model @register="addRegister" @saveData="saveData" />
|
|
|
</div>
|
|
|
</template>
|
|
|
<script lang="ts">
|
|
|
import { defineComponent, ref, unref } from 'vue';
|
|
|
- import Add from './add.vue'
|
|
|
+ import Model from './model.vue'
|
|
|
import { useModal } from '/@/components/Modal';
|
|
|
import { h } from 'vue';
|
|
|
import { Tag } from 'ant-design-vue';
|
|
@@ -39,7 +39,6 @@
|
|
|
} from '/@/components/Table';
|
|
|
|
|
|
|
|
|
-
|
|
|
const columns: BasicColumn[] = [
|
|
|
{
|
|
|
title: '菜单名称',
|
|
@@ -85,11 +84,12 @@
|
|
|
];
|
|
|
|
|
|
export default defineComponent({
|
|
|
- components: { BasicTable, TableAction, Add, },
|
|
|
+ components: { BasicTable, TableAction, Model, },
|
|
|
setup() {
|
|
|
const tableRef = ref<Nullable<TableActionType>>(null);
|
|
|
const currentEditKeyRef = ref('');
|
|
|
|
|
|
+
|
|
|
const [registerTable] = useTable({
|
|
|
title: "菜单列表",
|
|
|
titleHelpMessage: "温馨提醒",
|
|
@@ -125,8 +125,7 @@
|
|
|
console.log(getTableAction().getSelectRowKeys());
|
|
|
}
|
|
|
|
|
|
- function addColumn() {
|
|
|
-
|
|
|
+ function addMenu() {
|
|
|
openAdd(true, {
|
|
|
id: 0,
|
|
|
menuName: '',
|
|
@@ -164,7 +163,33 @@
|
|
|
}
|
|
|
|
|
|
function saveData(data: any) {
|
|
|
- console.log(data)
|
|
|
+ console.log('saveDate--------')
|
|
|
+ if (!data.key) {
|
|
|
+ console.log('添加菜单')
|
|
|
+ console.log(data)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ const mapTree = org => {
|
|
|
+ const haveChildren = Array.isArray(org.children) && org.children.length > 0;
|
|
|
+ if (org.key === data.key) {
|
|
|
+ org.menuName = data.menuName
|
|
|
+ org.icon = data.icon
|
|
|
+ org.status = data.status
|
|
|
+ org.detail = data.detail
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if (haveChildren) {
|
|
|
+ org.children.map(item => mapTree(item))
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ const dataSource = getTableAction().getDataSource()
|
|
|
+
|
|
|
+ if (Array.isArray(dataSource)) {
|
|
|
+ dataSource.map(item => mapTree(item))
|
|
|
+ }
|
|
|
+ getTableAction().setTableData(dataSource)
|
|
|
}
|
|
|
|
|
|
function createActions(record: EditRecordRow, column: BasicColumn): ActionItem[] {
|
|
@@ -191,14 +216,14 @@
|
|
|
tableRef,
|
|
|
registerTable,
|
|
|
rowClick,
|
|
|
- addColumn,
|
|
|
+ addMenu,
|
|
|
handleEdit,
|
|
|
createActions,
|
|
|
getTableAction,
|
|
|
getSelectRowList,
|
|
|
getSelectRowKeyList,
|
|
|
addRegister,
|
|
|
- saveData
|
|
|
+ saveData,
|
|
|
};
|
|
|
},
|
|
|
});
|