|
@@ -3,13 +3,13 @@
|
|
|
<BasicTable
|
|
|
ref="tableRef"
|
|
|
@register="registerTable"
|
|
|
- @fetchSuccess="fetchSuccess"
|
|
|
+ @fetchSuccess="ExpandAllRows"
|
|
|
defaultExpandAllRows
|
|
|
rowKey="id"
|
|
|
>
|
|
|
<template #toolbar>
|
|
|
<a-button type="primary" @click="toggleRowShow">{{ btn_text }}</a-button>
|
|
|
- <a-button type="primary" @click="addRole"> 添加 </a-button>
|
|
|
+ <a-button type="primary" @click="addGroupFn"> 添加 </a-button>
|
|
|
<a-button type="danger" @click="deleteBatches"> 删除 </a-button>
|
|
|
</template>
|
|
|
<template #action="{ record, column }">
|
|
@@ -25,6 +25,7 @@
|
|
|
import { useModal } from '/@/components/Modal';
|
|
|
// import { getAllMenuList } from '/@/api/sys/menu';
|
|
|
import { columns } from './data';
|
|
|
+ import { useUserStore } from '/@/store/modules/user';
|
|
|
import { useMessage } from '/@/hooks/web/useMessage';
|
|
|
import {
|
|
|
getGroupTree,
|
|
@@ -50,14 +51,20 @@
|
|
|
btn_text: string;
|
|
|
btn_status: boolean;
|
|
|
}
|
|
|
+ interface Group {
|
|
|
+ id: string;
|
|
|
+ name: boolean;
|
|
|
+ }
|
|
|
|
|
|
export default defineComponent({
|
|
|
components: { BasicTable, TableAction, Popup },
|
|
|
setup() {
|
|
|
+ const userStore = useUserStore();
|
|
|
const { createMessage } = useMessage();
|
|
|
const { success /*, error */ } = createMessage;
|
|
|
const tableRef = ref<Nullable<TableActionType>>(null);
|
|
|
const currentEditKeyRef = ref('');
|
|
|
+ const groups = userStore.getUserInfo.groups as Group[];
|
|
|
const popupData = reactive<PopupData>({
|
|
|
title: '添加',
|
|
|
treeData: [{}],
|
|
@@ -88,21 +95,9 @@
|
|
|
bordered: true,
|
|
|
});
|
|
|
const [addRegister, { openModal: openPopup }] = useModal();
|
|
|
- function mapTree(tree) {
|
|
|
- tree.map((item) => {
|
|
|
- if (item.children) {
|
|
|
- item.children.map((c_item) => {
|
|
|
- c_item.pname = item.name;
|
|
|
- });
|
|
|
- mapTree(item.children);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
|
|
|
function afterFetch(result) {
|
|
|
- mapTree(result);
|
|
|
popupData.treeData = result;
|
|
|
- console.log(`result--fetch`, result);
|
|
|
}
|
|
|
|
|
|
function getTableAction() {
|
|
@@ -123,13 +118,13 @@
|
|
|
console.log(getTableAction().getSelectRowKeys());
|
|
|
}
|
|
|
|
|
|
- function addRole() {
|
|
|
+ function addGroupFn() {
|
|
|
console.log('添加');
|
|
|
popupData.title = '添加';
|
|
|
openPopup(true, {});
|
|
|
}
|
|
|
|
|
|
- function fetchSuccess() {
|
|
|
+ function ExpandAllRows() {
|
|
|
setTimeout(() => {
|
|
|
toggleRowShow();
|
|
|
}, 1);
|
|
@@ -157,12 +152,6 @@
|
|
|
if (item.id === record.id) {
|
|
|
record = item;
|
|
|
}
|
|
|
- if (record.pid === 0) {
|
|
|
- record.pname = null;
|
|
|
- }
|
|
|
- if (record.pid === item.id) {
|
|
|
- record.pname = item.name;
|
|
|
- }
|
|
|
});
|
|
|
openPopup(true, record);
|
|
|
}
|
|
@@ -173,7 +162,7 @@
|
|
|
await deleteGroup({ id: record.id }).then((res) => {
|
|
|
console.log(res);
|
|
|
getTableAction().reload();
|
|
|
- fetchSuccess();
|
|
|
+ ExpandAllRows();
|
|
|
success('删除成功!');
|
|
|
});
|
|
|
}
|
|
@@ -186,7 +175,7 @@
|
|
|
await deleteBatchesGroup({ id }).then((res) => {
|
|
|
console.log(res);
|
|
|
getTableAction().reload();
|
|
|
- fetchSuccess();
|
|
|
+ ExpandAllRows();
|
|
|
success('删除成功!');
|
|
|
getTableAction().setSelectedRowKeys([]);
|
|
|
});
|
|
@@ -194,6 +183,7 @@
|
|
|
|
|
|
async function saveData(params: any) {
|
|
|
console.log('------------save---------');
|
|
|
+ params.data.rules = params.data.rules.toString();
|
|
|
const data = params.data;
|
|
|
const closeModel = params.closeModal;
|
|
|
console.log(`data`, data);
|
|
@@ -202,6 +192,7 @@
|
|
|
console.log(res);
|
|
|
getTableAction().reload();
|
|
|
closeModel();
|
|
|
+ ExpandAllRows();
|
|
|
success('创建成功!');
|
|
|
});
|
|
|
console.log('----------add---');
|
|
@@ -210,6 +201,7 @@
|
|
|
console.log(res);
|
|
|
getTableAction().reload();
|
|
|
closeModel();
|
|
|
+ ExpandAllRows();
|
|
|
success('修改成功!');
|
|
|
});
|
|
|
console.log('----------edit---');
|
|
@@ -225,6 +217,17 @@
|
|
|
},
|
|
|
];
|
|
|
}
|
|
|
+
|
|
|
+ const permission = groups.some((item) => item.id > record.pid);
|
|
|
+
|
|
|
+ if (permission) {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ label: '',
|
|
|
+ icon: '',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ }
|
|
|
return [
|
|
|
{
|
|
|
label: '编辑',
|
|
@@ -247,7 +250,7 @@
|
|
|
popupData,
|
|
|
tableRef,
|
|
|
registerTable,
|
|
|
- addRole,
|
|
|
+ addGroupFn,
|
|
|
handleEdit,
|
|
|
deleteBatches,
|
|
|
createActions,
|
|
@@ -257,7 +260,7 @@
|
|
|
toggleRowShow,
|
|
|
addRegister,
|
|
|
saveData,
|
|
|
- fetchSuccess,
|
|
|
+ ExpandAllRows,
|
|
|
...toRefs(btn),
|
|
|
};
|
|
|
},
|