|
@@ -34,7 +34,6 @@
|
|
|
import { CollapseContainer } from '/@/components/Container/index';
|
|
|
import Popup from './popup.vue';
|
|
|
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';
|
|
@@ -58,29 +57,33 @@
|
|
|
interface PopupData {
|
|
|
title: string;
|
|
|
treeData: object[];
|
|
|
+ group_ids: number[];
|
|
|
}
|
|
|
interface Btn {
|
|
|
btn_text: string;
|
|
|
btn_status: boolean;
|
|
|
disable_btn: boolean;
|
|
|
}
|
|
|
- // interface Group {
|
|
|
- // id: string;
|
|
|
- // name: boolean;
|
|
|
- // }
|
|
|
+
|
|
|
+ interface Group {
|
|
|
+ id: any;
|
|
|
+ name: string;
|
|
|
+ }
|
|
|
|
|
|
export default defineComponent({
|
|
|
components: { CollapseContainer, BasicTable, TableAction, Popup, ExpExcelModel },
|
|
|
setup() {
|
|
|
const userStore = useUserStore();
|
|
|
+ const groups = userStore.getUserInfo.groups as Group[];
|
|
|
+ const group_ids = groups.map((item) => item.id);
|
|
|
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: [{}],
|
|
|
+ group_ids: [],
|
|
|
});
|
|
|
|
|
|
const btn = reactive<Btn>({
|
|
@@ -128,6 +131,7 @@
|
|
|
function addGroupFn() {
|
|
|
console.log('添加');
|
|
|
popupData.title = '添加';
|
|
|
+ popupData.group_ids = group_ids;
|
|
|
openPopup(true, {});
|
|
|
}
|
|
|
|
|
@@ -149,8 +153,7 @@
|
|
|
}
|
|
|
|
|
|
function handleEdit(record: EditRecordRow) {
|
|
|
- console.log(`record 5555`, record);
|
|
|
- if (record.pid === 0) {
|
|
|
+ if (record.pid === 0 || group_ids.includes(record.id)) {
|
|
|
return;
|
|
|
}
|
|
|
currentEditKeyRef.value = record.id; // record.key
|
|
@@ -162,24 +165,28 @@
|
|
|
record = item;
|
|
|
}
|
|
|
});
|
|
|
- console.log(`record ===group`, record);
|
|
|
openPopup(true, record);
|
|
|
}
|
|
|
|
|
|
async function handleDelete(record: Recordable) {
|
|
|
- console.log('点击了删除', record.id);
|
|
|
console.log(record);
|
|
|
- await deleteGroup({ id: record.id }).then((res) => {
|
|
|
- console.log(res);
|
|
|
+ await deleteGroup({ id: record.id }).then(() => {
|
|
|
getTableAction().reload();
|
|
|
ExpandAllRows();
|
|
|
success('删除成功!');
|
|
|
});
|
|
|
}
|
|
|
|
|
|
- function selectionChange() {
|
|
|
- console.log(`userStore`, userStore.getUserInfo());
|
|
|
+ async function selectionChange() {
|
|
|
const keys = getTableAction().getSelectRowKeys();
|
|
|
+ groups.map((item) => {
|
|
|
+ if (keys.includes(item.id)) {
|
|
|
+ keys.splice(
|
|
|
+ keys.findIndex((keyItem) => keyItem === item.id),
|
|
|
+ 1
|
|
|
+ );
|
|
|
+ }
|
|
|
+ });
|
|
|
if (keys.length) {
|
|
|
btn.disable_btn = false;
|
|
|
} else {
|
|
@@ -192,8 +199,7 @@
|
|
|
if (!ids) {
|
|
|
return;
|
|
|
}
|
|
|
- await deleteBatchesGroup({ ids }).then((res) => {
|
|
|
- console.log(res);
|
|
|
+ await deleteBatchesGroup({ ids }).then(() => {
|
|
|
getTableAction().reload();
|
|
|
ExpandAllRows();
|
|
|
success('删除成功!');
|
|
@@ -208,23 +214,19 @@
|
|
|
const closeModel = params.closeModal;
|
|
|
console.log(`data`, data);
|
|
|
if (!data.id) {
|
|
|
- await addGroup(data).then((res) => {
|
|
|
- console.log(res);
|
|
|
+ await addGroup(data).then(() => {
|
|
|
getTableAction().reload();
|
|
|
closeModel();
|
|
|
ExpandAllRows();
|
|
|
success('创建成功!');
|
|
|
});
|
|
|
- console.log('----------add---');
|
|
|
} else {
|
|
|
- await editGroup(data).then((res) => {
|
|
|
- console.log(res);
|
|
|
+ await editGroup(data).then(() => {
|
|
|
getTableAction().reload();
|
|
|
closeModel();
|
|
|
ExpandAllRows();
|
|
|
success('修改成功!');
|
|
|
});
|
|
|
- console.log('----------edit---');
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -241,7 +243,14 @@
|
|
|
}
|
|
|
|
|
|
function createActions(record: EditRecordRow): ActionItem[] {
|
|
|
- if (record.pid !== 0) {
|
|
|
+ if (record.pid === 0 || group_ids.includes(record.id)) {
|
|
|
+ return [
|
|
|
+ {
|
|
|
+ label: '',
|
|
|
+ icon: '',
|
|
|
+ },
|
|
|
+ ];
|
|
|
+ } else {
|
|
|
return [
|
|
|
{
|
|
|
label: '编辑',
|
|
@@ -259,13 +268,6 @@
|
|
|
},
|
|
|
},
|
|
|
];
|
|
|
- } else {
|
|
|
- return [
|
|
|
- {
|
|
|
- label: '',
|
|
|
- icon: '',
|
|
|
- },
|
|
|
- ];
|
|
|
}
|
|
|
}
|
|
|
return {
|