fix: 组织管理自测及优化
This commit is contained in:
parent
8e92b62c5c
commit
df1fe4bd0f
|
@ -36,6 +36,7 @@
|
|||
:params="query.params.value"
|
||||
:rowSelection="{
|
||||
selectedRowKeys: table._selectedRowKeys.value,
|
||||
onChange: pageChange
|
||||
}"
|
||||
@cancelSelect="table.cancelSelect"
|
||||
>
|
||||
|
@ -420,6 +421,9 @@ const table: any = {
|
|||
},
|
||||
};
|
||||
table.init();
|
||||
const pageChange = ()=>{
|
||||
console.log(1111,table._selectedRowKeys.value);
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="less" scoped>
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
visible
|
||||
:title="title"
|
||||
width="520px"
|
||||
@cancel="emits('update:visible',false)"
|
||||
@cancel="emits('update:visible', false)"
|
||||
@ok="confirm"
|
||||
class="edit-dialog-container"
|
||||
cancelText="取消"
|
||||
|
@ -16,7 +16,7 @@
|
|||
v-model:value="form.data.parentId"
|
||||
style="width: 100%"
|
||||
placeholder="请选择上级组织"
|
||||
:tree-data="props.treeData"
|
||||
:tree-data="treeData"
|
||||
:field-names="{ value: 'id' }"
|
||||
>
|
||||
<template #title="{ name }"> {{ name }} </template>
|
||||
|
@ -80,6 +80,42 @@ const confirm = () => {
|
|||
})
|
||||
.finally(() => (loading.value = false));
|
||||
};
|
||||
|
||||
const treeData = computed(() => {
|
||||
if (!props.data.id) return props.treeData;
|
||||
const result = cloneDeep(props.treeData) as treeType[];
|
||||
const me = findItemById(result, props.data.id) as treeType;
|
||||
me.disabled = true;
|
||||
me.children && me.children.length > 0 && filterTree(me.children);
|
||||
return result;
|
||||
});
|
||||
/**
|
||||
* 在给定的树中通过id匹配
|
||||
* @param node
|
||||
* @param id
|
||||
*/
|
||||
const findItemById = (node: treeType[], id: string): treeType | null => {
|
||||
let result = null;
|
||||
for (const item of node) {
|
||||
if (item.id === id) return item;
|
||||
else if (item.children && item.children.length > 0) {
|
||||
result = findItemById(item.children, id);
|
||||
if (result) return result;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
};
|
||||
/**
|
||||
* 将此树下的所有节点禁用
|
||||
* @param treeNode
|
||||
*/
|
||||
const filterTree = (treeNode: treeType[]) => {
|
||||
if (treeNode.length < 1) return;
|
||||
treeNode.forEach((item) => {
|
||||
item.disabled = true;
|
||||
item.children && item.children.length > 0 && filterTree(item.children);
|
||||
});
|
||||
};
|
||||
// 表单相关
|
||||
const formRef = ref<FormInstance>();
|
||||
const form = reactive({
|
||||
|
@ -124,6 +160,14 @@ const form = reactive({
|
|||
});
|
||||
form.init();
|
||||
|
||||
type treeType = {
|
||||
id: string;
|
||||
parentId?: string;
|
||||
name: string;
|
||||
sortIndex: string | number;
|
||||
children?: treeType[];
|
||||
disabled?: boolean;
|
||||
};
|
||||
type formType = {
|
||||
id?: string;
|
||||
parentId?: string;
|
||||
|
|
|
@ -194,8 +194,9 @@ const openDialog = (row: any = {}) => {
|
|||
if (row.parentId) {
|
||||
childrens = row.children;
|
||||
} else childrens = treeData.value;
|
||||
const indexs = childrens.length > 0 ? childrens?.map((item) => item.sortIndex) :[0]
|
||||
sortIndex =
|
||||
Math.max(...(childrens?.map((item) => item.sortIndex) || [0])) + 1;
|
||||
Math.max(...indexs) + 1;
|
||||
}
|
||||
|
||||
dialog.selectItem = { ...row, sortIndex };
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
:params="queryParams"
|
||||
:rowSelection="{
|
||||
selectedRowKeys: table._selectedRowKeys.value,
|
||||
onChange:(keys:string[])=>table._selectedRowKeys.value = [...keys]
|
||||
}"
|
||||
:columns="columns"
|
||||
@cancelSelect="table.cancelSelect"
|
||||
|
@ -145,7 +146,7 @@
|
|||
</a-dropdown>
|
||||
<PermissionButton
|
||||
v-else
|
||||
:uhasPermission="item.permission"
|
||||
:hasPermission="item.permission"
|
||||
:tooltip="item.tooltip"
|
||||
:pop-confirm="item.popConfirm"
|
||||
@click="item.onClick"
|
||||
|
@ -157,23 +158,6 @@
|
|||
}}</span>
|
||||
</PermissionButton>
|
||||
</a-tooltip>
|
||||
|
||||
<!-- <PermissionButton
|
||||
:uhasPermission="`${permission}:assert`"
|
||||
@click="() => table.clickEdit(slotProps)"
|
||||
>
|
||||
<AIcon type="EditOutlined" />
|
||||
</PermissionButton>
|
||||
|
||||
<PermissionButton
|
||||
:uhasPermission="`${permission}:bind`"
|
||||
:popConfirm="{
|
||||
title: `是否解除绑定`,
|
||||
onConfirm: () => table.clickUnBind(slotProps),
|
||||
}"
|
||||
>
|
||||
<AIcon type="DisconnectOutlined" />
|
||||
</PermissionButton> -->
|
||||
</template>
|
||||
</CardBox>
|
||||
</template>
|
||||
|
@ -199,7 +183,7 @@
|
|||
<a-space :size="16">
|
||||
<PermissionButton
|
||||
v-for="i in table.getActions(slotProps, 'table')"
|
||||
:uhasPermission="i.permission"
|
||||
:hasPermission="i.permission"
|
||||
type="link"
|
||||
:tooltip="i?.tooltip"
|
||||
:pop-confirm="i.popConfirm"
|
||||
|
@ -334,7 +318,7 @@ const tableRef = ref();
|
|||
const table = {
|
||||
_selectedRowKeys: ref<string[]>([]),
|
||||
selectedRows: [] as any[],
|
||||
permissionList: ref<dictType>([]),
|
||||
permissionList: ref<any[]>([]),
|
||||
|
||||
init: () => {
|
||||
table.getPermissionDict();
|
||||
|
@ -354,14 +338,14 @@ const table = {
|
|||
else
|
||||
return [
|
||||
{
|
||||
permission: true,
|
||||
permission: `${permission}:assert`,
|
||||
key: 'edit',
|
||||
tooltip: { title: '编辑' },
|
||||
icon: 'EditOutlined',
|
||||
onClick: () => table.clickEdit(data),
|
||||
},
|
||||
{
|
||||
permission: true,
|
||||
permission: `${permission}:assert`,
|
||||
key: 'unbind',
|
||||
tooltip: { title: '解除绑定' },
|
||||
popConfirm: {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
<template>
|
||||
<div>
|
||||
<Search :columns="columns" @search="(p:any)=>params = p" />
|
||||
<j-advanced-search :columns="columns" @search="(p:any)=>params = p" />
|
||||
|
||||
<j-pro-table
|
||||
ref="tableRef"
|
||||
|
@ -17,7 +17,7 @@
|
|||
<template #headerTitle>
|
||||
<PermissionButton
|
||||
type="primary"
|
||||
:uhasPermission="`${permission}:bind-user`"
|
||||
:hasPermission="`${permission}:bind-user`"
|
||||
@click="dialogVisible = true"
|
||||
style="margin-right: 15px"
|
||||
>
|
||||
|
@ -27,7 +27,7 @@
|
|||
style="display: inline-block; width: 12px; height: 1px"
|
||||
></div>
|
||||
<PermissionButton
|
||||
:uhasPermission="`${permission}:bind`"
|
||||
:hasPermission="`${permission}:bind`"
|
||||
:popConfirm="{
|
||||
title: `是否解除绑定`,
|
||||
onConfirm: () => table.unBind(),
|
||||
|
@ -50,7 +50,7 @@
|
|||
<j-space :size="16">
|
||||
<PermissionButton
|
||||
type="link"
|
||||
:uhasPermission="`${permission}:bind`"
|
||||
:hasPermission="`${permission}:bind`"
|
||||
:popConfirm="{
|
||||
title: `是否解除绑定`,
|
||||
onConfirm: () => table.unBind(slotProps),
|
||||
|
|
Loading…
Reference in New Issue