|
@@ -62,7 +62,7 @@ const defaultProps = {
|
|
|
children: "children",
|
|
|
label: "label",
|
|
|
};
|
|
|
-const tree = ref(null)
|
|
|
+const tree = ref(null);
|
|
|
const sourceList = ref({
|
|
|
data: [],
|
|
|
pagination: {
|
|
@@ -325,21 +325,38 @@ const select = (_selection, row) => {
|
|
|
selection.value.data = _selection;
|
|
|
console.log(_selection.length);
|
|
|
};
|
|
|
+const getSubset = (list, data) => {
|
|
|
+ for (let i = 0; i < list.length; i++) {
|
|
|
+ if (list[i].children && list[i].children.length > 0) {
|
|
|
+ getSubset(list[i].children, data);
|
|
|
+ } else {
|
|
|
+ data.push(list[i].id);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+};
|
|
|
const openRoomModal = () => {
|
|
|
proxy.get("/tenantInfo/roleMenuTreeSelect/" + selection.value.data[0].tenantId).then((res) => {
|
|
|
- console.log(res);
|
|
|
if (res.code == 200) {
|
|
|
- formData.treeData = res.checkedKeys;
|
|
|
treeData.value = res.menus;
|
|
|
+ let data = getSubset(res.menus, []);
|
|
|
+ formData.treeData = res.checkedKeys.filter((item) => {
|
|
|
+ return data.some((i) => item == i);
|
|
|
+ });
|
|
|
roomDialogVisible.value = true;
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
+const noRepeat = (arr) => {
|
|
|
+ var newArr = [...new Set(arr)];
|
|
|
+ return newArr;
|
|
|
+};
|
|
|
const submitTree = () => {
|
|
|
+ let data = noRepeat(tree.value.getHalfCheckedKeys().concat(tree.value.getCheckedKeys()));
|
|
|
proxy
|
|
|
.post("/tenantInfo/bindingMenu", {
|
|
|
tenantId: selection.value.data[0].tenantId,
|
|
|
- menuIdList: tree.value.getCheckedKeys(),
|
|
|
+ menuIdList: data,
|
|
|
})
|
|
|
.then((res) => {
|
|
|
ElMessage({
|
|
@@ -349,11 +366,9 @@ const submitTree = () => {
|
|
|
roomDialogVisible.value = false;
|
|
|
});
|
|
|
};
|
|
|
-
|
|
|
const submitForm = () => {
|
|
|
byform.value.handleSubmit((valid) => {
|
|
|
submitLoading.value = true;
|
|
|
-
|
|
|
proxy
|
|
|
.post("/tenantInfo/" + modalType.value, formData.data)
|
|
|
.then((res) => {
|