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 | 25 | label: '编辑', |
| 26 | 26 | auth: 'api:yt:organization:update', |
| 27 | 27 | icon: 'clarity:note-edit-line', |
| 28 | + disabled: record.isRoot && getIsChildTenant, | |
| 28 | 29 | onClick: handleEdit.bind(null, record), |
| 29 | 30 | }, |
| 30 | 31 | { |
| ... | ... | @@ -32,6 +33,7 @@ |
| 32 | 33 | auth: 'api:yt:organization:delete', |
| 33 | 34 | icon: 'ant-design:delete-outlined', |
| 34 | 35 | color: 'error', |
| 36 | + disabled: record.isRoot && getIsChildTenant, | |
| 35 | 37 | popConfirm: { |
| 36 | 38 | title: getDeleteTitle(), //是否确认删除//getDeleteTitle() |
| 37 | 39 | confirm: handleDeleteOrBatchDelete.bind(null, record), |
| ... | ... | @@ -45,7 +47,7 @@ |
| 45 | 47 | </div> |
| 46 | 48 | </template> |
| 47 | 49 | <script lang="ts"> |
| 48 | - import { computed, defineComponent, nextTick } from 'vue'; | |
| 50 | + import { computed, defineComponent, nextTick, unref } from 'vue'; | |
| 49 | 51 | import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
| 50 | 52 | // 加载自定义侧边弹出框 组件 |
| 51 | 53 | import { useDrawer } from '/@/components/Drawer'; |
| ... | ... | @@ -56,6 +58,8 @@ |
| 56 | 58 | import { useBatchDelete } from '/@/hooks/web/useBatchDelete'; |
| 57 | 59 | import { Authority } from '/@/components/Authority'; |
| 58 | 60 | import { Popconfirm } from 'ant-design-vue'; |
| 61 | + import { getJwtToken } from '/@/utils/auth'; | |
| 62 | + import jwtDecode from 'jwt-decode'; | |
| 59 | 63 | |
| 60 | 64 | export default defineComponent({ |
| 61 | 65 | name: 'DeptManagement', |
| ... | ... | @@ -65,6 +69,11 @@ |
| 65 | 69 | const { t } = useI18n(); // 加载国际化 |
| 66 | 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 | 77 | const [registerTable, { reload, expandAll, setProps }] = useTable({ |
| 69 | 78 | title: t('routes.common.organization.toolOrganizationList'), |
| 70 | 79 | api: getOrganizationList, |
| ... | ... | @@ -76,6 +85,14 @@ |
| 76 | 85 | showTableSetting: true, |
| 77 | 86 | bordered: true, |
| 78 | 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 | 96 | actionColumn: { |
| 80 | 97 | width: 200, |
| 81 | 98 | title: t('routes.common.common.operation'), //操作 |
| ... | ... | @@ -91,7 +108,15 @@ |
| 91 | 108 | setProps |
| 92 | 109 | ); |
| 93 | 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 | 149 | } |
| 125 | 150 | |
| 126 | 151 | return { |
| 152 | + getIsChildTenant, | |
| 127 | 153 | getI18n, |
| 128 | 154 | registerTable, |
| 129 | 155 | registerModal, | ... | ... |
| 1 | +import jwtDecode from 'jwt-decode'; | |
| 1 | 2 | import { BasicColumn } from '/@/components/Table'; |
| 2 | 3 | import { FormSchema } from '/@/components/Table'; |
| 3 | 4 | import { useI18n } from '/@/hooks/web/useI18n'; |
| 5 | +import { getJwtToken } from '/@/utils/auth'; | |
| 4 | 6 | import { createOrganizationSearch } from '/@/utils/organizationSearch'; |
| 5 | 7 | const { t } = useI18n(); |
| 6 | 8 | |
| ... | ... | @@ -32,6 +34,12 @@ export const formSchema: FormSchema[] = [ |
| 32 | 34 | field: 'parentId', |
| 33 | 35 | label: t('routes.common.organization.parentOrganization'), |
| 34 | 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 | 43 | componentProps: { |
| 36 | 44 | replaceFields: { |
| 37 | 45 | title: 'name', | ... | ... |