Commit 332b01a11a5bac187104eff216e4f89da5b2614c
Merge branch 'fix/DEFECT-2063' into 'feat/account-role-manage'
fix: 修复子租户管理员新增组织可以创建平级组织 See merge request yunteng/thingskit-front!1313
Showing
2 changed files
with
36 additions
and
2 deletions
@@ -25,6 +25,7 @@ | @@ -25,6 +25,7 @@ | ||
25 | label: '编辑', | 25 | label: '编辑', |
26 | auth: 'api:yt:organization:update', | 26 | auth: 'api:yt:organization:update', |
27 | icon: 'clarity:note-edit-line', | 27 | icon: 'clarity:note-edit-line', |
28 | + disabled: record.isRoot && getIsChildTenant, | ||
28 | onClick: handleEdit.bind(null, record), | 29 | onClick: handleEdit.bind(null, record), |
29 | }, | 30 | }, |
30 | { | 31 | { |
@@ -32,6 +33,7 @@ | @@ -32,6 +33,7 @@ | ||
32 | auth: 'api:yt:organization:delete', | 33 | auth: 'api:yt:organization:delete', |
33 | icon: 'ant-design:delete-outlined', | 34 | icon: 'ant-design:delete-outlined', |
34 | color: 'error', | 35 | color: 'error', |
36 | + disabled: record.isRoot && getIsChildTenant, | ||
35 | popConfirm: { | 37 | popConfirm: { |
36 | title: getDeleteTitle(), //是否确认删除//getDeleteTitle() | 38 | title: getDeleteTitle(), //是否确认删除//getDeleteTitle() |
37 | confirm: handleDeleteOrBatchDelete.bind(null, record), | 39 | confirm: handleDeleteOrBatchDelete.bind(null, record), |
@@ -45,7 +47,7 @@ | @@ -45,7 +47,7 @@ | ||
45 | </div> | 47 | </div> |
46 | </template> | 48 | </template> |
47 | <script lang="ts"> | 49 | <script lang="ts"> |
48 | - import { computed, defineComponent, nextTick } from 'vue'; | 50 | + import { computed, defineComponent, nextTick, unref } from 'vue'; |
49 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; | 51 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
50 | // 加载自定义侧边弹出框 组件 | 52 | // 加载自定义侧边弹出框 组件 |
51 | import { useDrawer } from '/@/components/Drawer'; | 53 | import { useDrawer } from '/@/components/Drawer'; |
@@ -56,6 +58,8 @@ | @@ -56,6 +58,8 @@ | ||
56 | import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; | 58 | import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; |
57 | import { Authority } from '/@/components/Authority'; | 59 | import { Authority } from '/@/components/Authority'; |
58 | import { Popconfirm } from 'ant-design-vue'; | 60 | import { Popconfirm } from 'ant-design-vue'; |
61 | + import { getJwtToken } from '/@/utils/auth'; | ||
62 | + import jwtDecode from 'jwt-decode'; | ||
59 | 63 | ||
60 | export default defineComponent({ | 64 | export default defineComponent({ |
61 | name: 'DeptManagement', | 65 | name: 'DeptManagement', |
@@ -65,6 +69,11 @@ | @@ -65,6 +69,11 @@ | ||
65 | const { t } = useI18n(); // 加载国际化 | 69 | const { t } = useI18n(); // 加载国际化 |
66 | const getI18n = computed(() => t('routes.common.organization.toolCreateOrganization')); | 70 | const getI18n = computed(() => t('routes.common.organization.toolCreateOrganization')); |
67 | 71 | ||
72 | + const getIsChildTenant = computed(() => { | ||
73 | + const token = getJwtToken(); | ||
74 | + return !!(jwtDecode(token as string) as Recordable)?.isCommonTenant; | ||
75 | + }); | ||
76 | + | ||
68 | const [registerTable, { reload, expandAll, setProps }] = useTable({ | 77 | const [registerTable, { reload, expandAll, setProps }] = useTable({ |
69 | title: t('routes.common.organization.toolOrganizationList'), | 78 | title: t('routes.common.organization.toolOrganizationList'), |
70 | api: getOrganizationList, | 79 | api: getOrganizationList, |
@@ -76,6 +85,14 @@ | @@ -76,6 +85,14 @@ | ||
76 | showTableSetting: true, | 85 | showTableSetting: true, |
77 | bordered: true, | 86 | bordered: true, |
78 | showIndexColumn: false, | 87 | showIndexColumn: false, |
88 | + afterFetch: (data: Recordable[]) => { | ||
89 | + if (data && data.length) { | ||
90 | + data.forEach((item) => { | ||
91 | + item.isRoot = true; | ||
92 | + }); | ||
93 | + } | ||
94 | + return data; | ||
95 | + }, | ||
79 | actionColumn: { | 96 | actionColumn: { |
80 | width: 200, | 97 | width: 200, |
81 | title: t('routes.common.common.operation'), //操作 | 98 | title: t('routes.common.common.operation'), //操作 |
@@ -91,7 +108,15 @@ | @@ -91,7 +108,15 @@ | ||
91 | setProps | 108 | setProps |
92 | ); | 109 | ); |
93 | nextTick(() => { | 110 | nextTick(() => { |
94 | - setProps(selectionOptions); | 111 | + setProps({ |
112 | + ...selectionOptions, | ||
113 | + rowSelection: { | ||
114 | + ...selectionOptions.rowSelection, | ||
115 | + getCheckboxProps: (data) => { | ||
116 | + return { disabled: data?.isRoot && unref(getIsChildTenant) }; | ||
117 | + }, | ||
118 | + }, | ||
119 | + }); | ||
95 | }); | 120 | }); |
96 | /** | 121 | /** |
97 | * 获得删除提示框的文字 | 122 | * 获得删除提示框的文字 |
@@ -124,6 +149,7 @@ | @@ -124,6 +149,7 @@ | ||
124 | } | 149 | } |
125 | 150 | ||
126 | return { | 151 | return { |
152 | + getIsChildTenant, | ||
127 | getI18n, | 153 | getI18n, |
128 | registerTable, | 154 | registerTable, |
129 | registerModal, | 155 | registerModal, |
1 | +import jwtDecode from 'jwt-decode'; | ||
1 | import { BasicColumn } from '/@/components/Table'; | 2 | import { BasicColumn } from '/@/components/Table'; |
2 | import { FormSchema } from '/@/components/Table'; | 3 | import { FormSchema } from '/@/components/Table'; |
3 | import { useI18n } from '/@/hooks/web/useI18n'; | 4 | import { useI18n } from '/@/hooks/web/useI18n'; |
5 | +import { getJwtToken } from '/@/utils/auth'; | ||
4 | import { createOrganizationSearch } from '/@/utils/organizationSearch'; | 6 | import { createOrganizationSearch } from '/@/utils/organizationSearch'; |
5 | const { t } = useI18n(); | 7 | const { t } = useI18n(); |
6 | 8 | ||
@@ -32,6 +34,12 @@ export const formSchema: FormSchema[] = [ | @@ -32,6 +34,12 @@ export const formSchema: FormSchema[] = [ | ||
32 | field: 'parentId', | 34 | field: 'parentId', |
33 | label: t('routes.common.organization.parentOrganization'), | 35 | label: t('routes.common.organization.parentOrganization'), |
34 | component: 'TreeSelect', | 36 | component: 'TreeSelect', |
37 | + dynamicRules: () => { | ||
38 | + const token = getJwtToken(); | ||
39 | + const res = jwtDecode(token as string) as Record<'isCommonTenant', boolean>; | ||
40 | + return [{ required: res?.isCommonTenant, message: '请选择上级组织' }]; | ||
41 | + }, | ||
42 | + rulesMessageJoinLabel: true, | ||
35 | componentProps: { | 43 | componentProps: { |
36 | replaceFields: { | 44 | replaceFields: { |
37 | title: 'name', | 45 | title: 'name', |