|
|
|
@ -15,31 +15,33 @@ |
|
|
|
* limitations under the License. |
|
|
|
*/ |
|
|
|
|
|
|
|
import { h, ref, watch, onMounted } from 'vue' |
|
|
|
import { useI18n } from 'vue-i18n' |
|
|
|
import { h, ref, watch, onMounted, RendererElement, RendererNode, VNode} from 'vue' |
|
|
|
import {useI18n} from 'vue-i18n' |
|
|
|
import { |
|
|
|
NSpace, |
|
|
|
NTooltip, |
|
|
|
NButton, |
|
|
|
NIcon, |
|
|
|
NTag, |
|
|
|
NDropdown, |
|
|
|
NPopconfirm |
|
|
|
NSpace, |
|
|
|
NTooltip, |
|
|
|
NButton, |
|
|
|
NIcon, |
|
|
|
NTag, |
|
|
|
NDropdown, |
|
|
|
NPopconfirm |
|
|
|
} from 'naive-ui' |
|
|
|
import { EditOutlined, DeleteOutlined, UserOutlined } from '@vicons/antd' |
|
|
|
import {EditOutlined, DeleteOutlined, UserOutlined} from '@vicons/antd' |
|
|
|
import { |
|
|
|
COLUMN_WIDTH_CONFIG, |
|
|
|
calculateTableWidth, |
|
|
|
DefaultTableWidth |
|
|
|
COLUMN_WIDTH_CONFIG, |
|
|
|
calculateTableWidth, |
|
|
|
DefaultTableWidth |
|
|
|
} from '@/common/column-width-config' |
|
|
|
import type { TableColumns, InternalRowData } from './types' |
|
|
|
import type {TableColumns, InternalRowData} from './types' |
|
|
|
import {useUserStore} from "@/store/user/user"; |
|
|
|
|
|
|
|
export function useColumns(onCallback: Function) { |
|
|
|
const { t } = useI18n() |
|
|
|
|
|
|
|
const {t} = useI18n() |
|
|
|
|
|
|
|
const columnsRef = ref({ |
|
|
|
columns: [] as TableColumns, |
|
|
|
tableWidth: DefaultTableWidth |
|
|
|
columns: [] as TableColumns, |
|
|
|
tableWidth: DefaultTableWidth |
|
|
|
}) |
|
|
|
|
|
|
|
const createColumns = () => { |
|
|
|
@ -118,111 +120,220 @@ export function useColumns(onCallback: Function) { |
|
|
|
key: 'operation', |
|
|
|
...COLUMN_WIDTH_CONFIG['operation'](3), |
|
|
|
render: (rowData: any, unused: number) => { |
|
|
|
return h(NSpace, null, { |
|
|
|
default: () => [ |
|
|
|
h( |
|
|
|
NDropdown, |
|
|
|
{ |
|
|
|
trigger: 'click', |
|
|
|
options: [ |
|
|
|
{ |
|
|
|
label: t('security.user.project'), |
|
|
|
key: 'authorize_project' |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: t('security.user.resource'), |
|
|
|
key: 'authorize_resource' |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: t('security.user.datasource'), |
|
|
|
key: 'authorize_datasource' |
|
|
|
}, |
|
|
|
{ label: t('security.user.udf'), key: 'authorize_udf' }, |
|
|
|
const userStore = useUserStore() |
|
|
|
let operateArr: VNode<RendererNode, RendererElement, { [key: string]: any }>[] = [ |
|
|
|
h( |
|
|
|
NDropdown, |
|
|
|
{ |
|
|
|
label: t('security.user.namespace'), |
|
|
|
key: 'authorize_namespace' |
|
|
|
} |
|
|
|
], |
|
|
|
onSelect: (key) => |
|
|
|
void onCallback({ rowData, key }, 'authorize') |
|
|
|
}, |
|
|
|
() => |
|
|
|
h( |
|
|
|
NTooltip, |
|
|
|
{ |
|
|
|
trigger: 'hover' |
|
|
|
trigger: 'click', |
|
|
|
options: [ |
|
|
|
{ |
|
|
|
label: t('security.user.project'), |
|
|
|
key: 'authorize_project' |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: t('security.user.resource'), |
|
|
|
key: 'authorize_resource' |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: t('security.user.datasource'), |
|
|
|
key: 'authorize_datasource' |
|
|
|
}, |
|
|
|
{ label: t('security.user.udf'), key: 'authorize_udf' }, |
|
|
|
{ |
|
|
|
label: t('security.user.namespace'), |
|
|
|
key: 'authorize_namespace' |
|
|
|
} |
|
|
|
], |
|
|
|
onSelect: (key) => |
|
|
|
void onCallback({ rowData, key }, 'authorize') |
|
|
|
}, |
|
|
|
{ |
|
|
|
trigger: () => |
|
|
|
() => |
|
|
|
h( |
|
|
|
NButton, |
|
|
|
{ |
|
|
|
circle: true, |
|
|
|
type: 'warning', |
|
|
|
size: 'small', |
|
|
|
class: 'authorize' |
|
|
|
}, |
|
|
|
{ |
|
|
|
icon: () => h(NIcon, null, () => h(UserOutlined)) |
|
|
|
} |
|
|
|
), |
|
|
|
default: () => t('security.user.authorize') |
|
|
|
} |
|
|
|
) |
|
|
|
), |
|
|
|
h( |
|
|
|
NTooltip, |
|
|
|
{ trigger: 'hover' }, |
|
|
|
{ |
|
|
|
trigger: () => |
|
|
|
h( |
|
|
|
NButton, |
|
|
|
{ |
|
|
|
circle: true, |
|
|
|
type: 'info', |
|
|
|
size: 'small', |
|
|
|
class: 'edit', |
|
|
|
onClick: () => void onCallback({ rowData }, 'edit') |
|
|
|
}, |
|
|
|
() => h(NIcon, null, () => h(EditOutlined)) |
|
|
|
), |
|
|
|
default: () => t('security.user.edit') |
|
|
|
} |
|
|
|
), |
|
|
|
h( |
|
|
|
NPopconfirm, |
|
|
|
{ |
|
|
|
onPositiveClick: () => void onCallback({ rowData }, 'delete') |
|
|
|
}, |
|
|
|
{ |
|
|
|
trigger: () => |
|
|
|
h( |
|
|
|
NTooltip, |
|
|
|
{}, |
|
|
|
{ |
|
|
|
trigger: () => |
|
|
|
h( |
|
|
|
NButton, |
|
|
|
NTooltip, |
|
|
|
{ |
|
|
|
circle: true, |
|
|
|
type: 'error', |
|
|
|
size: 'small', |
|
|
|
class: 'delete' |
|
|
|
trigger: 'hover' |
|
|
|
}, |
|
|
|
{ |
|
|
|
icon: () => |
|
|
|
h(NIcon, null, { |
|
|
|
default: () => h(DeleteOutlined) |
|
|
|
}) |
|
|
|
trigger: () => |
|
|
|
h( |
|
|
|
NButton, |
|
|
|
{ |
|
|
|
circle: true, |
|
|
|
type: 'warning', |
|
|
|
size: 'small', |
|
|
|
class: 'authorize' |
|
|
|
}, |
|
|
|
{ |
|
|
|
icon: () => h(NIcon, null, () => h(UserOutlined)) |
|
|
|
} |
|
|
|
), |
|
|
|
default: () => t('security.user.authorize') |
|
|
|
} |
|
|
|
), |
|
|
|
default: () => t('security.user.delete') |
|
|
|
} |
|
|
|
), |
|
|
|
default: () => t('security.user.delete_confirm') |
|
|
|
} |
|
|
|
) |
|
|
|
) |
|
|
|
), |
|
|
|
] |
|
|
|
// if (userStore.getIsShowTop){
|
|
|
|
// operateArr = [
|
|
|
|
// h(
|
|
|
|
// NDropdown,
|
|
|
|
// {
|
|
|
|
// trigger: 'click',
|
|
|
|
// options: [
|
|
|
|
// {
|
|
|
|
// label: t('security.user.project'),
|
|
|
|
// key: 'authorize_project'
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// label: t('security.user.resource'),
|
|
|
|
// key: 'authorize_resource'
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// label: t('security.user.datasource'),
|
|
|
|
// key: 'authorize_datasource'
|
|
|
|
// },
|
|
|
|
// { label: t('security.user.udf'), key: 'authorize_udf' },
|
|
|
|
// {
|
|
|
|
// label: t('security.user.namespace'),
|
|
|
|
// key: 'authorize_namespace'
|
|
|
|
// }
|
|
|
|
// ],
|
|
|
|
// onSelect: (key) =>
|
|
|
|
// void onCallback({ rowData, key }, 'authorize')
|
|
|
|
// },
|
|
|
|
// () =>
|
|
|
|
// h(
|
|
|
|
// NTooltip,
|
|
|
|
// {
|
|
|
|
// trigger: 'hover'
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// trigger: () =>
|
|
|
|
// h(
|
|
|
|
// NButton,
|
|
|
|
// {
|
|
|
|
// circle: true,
|
|
|
|
// type: 'warning',
|
|
|
|
// size: 'small',
|
|
|
|
// class: 'authorize'
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// icon: () => h(NIcon, null, () => h(UserOutlined))
|
|
|
|
// }
|
|
|
|
// ),
|
|
|
|
// default: () => t('security.user.authorize')
|
|
|
|
// }
|
|
|
|
// )
|
|
|
|
// ),
|
|
|
|
// h(
|
|
|
|
// NTooltip,
|
|
|
|
// { trigger: 'hover' },
|
|
|
|
// {
|
|
|
|
// trigger: () =>
|
|
|
|
// h(
|
|
|
|
// NButton,
|
|
|
|
// {
|
|
|
|
// circle: true,
|
|
|
|
// type: 'info',
|
|
|
|
// size: 'small',
|
|
|
|
// class: 'edit',
|
|
|
|
// onClick: () => void onCallback({ rowData }, 'edit')
|
|
|
|
// },
|
|
|
|
// () => h(NIcon, null, () => h(EditOutlined))
|
|
|
|
// ),
|
|
|
|
// default: () => t('security.user.edit')
|
|
|
|
// }
|
|
|
|
// ),
|
|
|
|
// h(
|
|
|
|
// NPopconfirm,
|
|
|
|
// {
|
|
|
|
// onPositiveClick: () => void onCallback({ rowData }, 'delete')
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// trigger: () =>
|
|
|
|
// h(
|
|
|
|
// NTooltip,
|
|
|
|
// {},
|
|
|
|
// {
|
|
|
|
// trigger: () =>
|
|
|
|
// h(
|
|
|
|
// NButton,
|
|
|
|
// {
|
|
|
|
// circle: true,
|
|
|
|
// type: 'error',
|
|
|
|
// size: 'small',
|
|
|
|
// class: 'delete'
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// icon: () =>
|
|
|
|
// h(NIcon, null, {
|
|
|
|
// default: () => h(DeleteOutlined)
|
|
|
|
// })
|
|
|
|
// }
|
|
|
|
// ),
|
|
|
|
// default: () => t('security.user.delete')
|
|
|
|
// }
|
|
|
|
// ),
|
|
|
|
// default: () => t('security.user.delete_confirm')
|
|
|
|
// }
|
|
|
|
// )
|
|
|
|
// ]
|
|
|
|
// }else {
|
|
|
|
// operateArr = [
|
|
|
|
// h(
|
|
|
|
// NDropdown,
|
|
|
|
// {
|
|
|
|
// trigger: 'click',
|
|
|
|
// options: [
|
|
|
|
// {
|
|
|
|
// label: t('security.user.project'),
|
|
|
|
// key: 'authorize_project'
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// label: t('security.user.resource'),
|
|
|
|
// key: 'authorize_resource'
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// label: t('security.user.datasource'),
|
|
|
|
// key: 'authorize_datasource'
|
|
|
|
// },
|
|
|
|
// { label: t('security.user.udf'), key: 'authorize_udf' },
|
|
|
|
// {
|
|
|
|
// label: t('security.user.namespace'),
|
|
|
|
// key: 'authorize_namespace'
|
|
|
|
// }
|
|
|
|
// ],
|
|
|
|
// onSelect: (key) =>
|
|
|
|
// void onCallback({ rowData, key }, 'authorize')
|
|
|
|
// },
|
|
|
|
// () =>
|
|
|
|
// h(
|
|
|
|
// NTooltip,
|
|
|
|
// {
|
|
|
|
// trigger: 'hover'
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// trigger: () =>
|
|
|
|
// h(
|
|
|
|
// NButton,
|
|
|
|
// {
|
|
|
|
// circle: true,
|
|
|
|
// type: 'warning',
|
|
|
|
// size: 'small',
|
|
|
|
// class: 'authorize'
|
|
|
|
// },
|
|
|
|
// {
|
|
|
|
// icon: () => h(NIcon, null, () => h(UserOutlined))
|
|
|
|
// }
|
|
|
|
// ),
|
|
|
|
// default: () => t('security.user.authorize')
|
|
|
|
// }
|
|
|
|
// )
|
|
|
|
// ),
|
|
|
|
// ]
|
|
|
|
// }
|
|
|
|
return h(NSpace, null, { |
|
|
|
default: () => operateArr |
|
|
|
}) |
|
|
|
} |
|
|
|
} |
|
|
|
|