You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.

79 lines
2.4 KiB

<script lang="ts" setup>
import ClientModal from './ClientModal.vue'
import { columns, searchFormSchema } from './client.data'
2 years ago
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
2 years ago
import { useModal } from '@/components/Modal'
2 years ago
import { IconEnum } from '@/enums/appEnum'
import { BasicTable, TableAction, useTable } from '@/components/Table'
import { deleteOAuth2Client, getOAuth2ClientPage } from '@/api/system/oauth2/client'
2 years ago
defineOptions({ name: 'SystemClient' })
2 years ago
const { t } = useI18n()
2 years ago
const { createMessage } = useMessage()
const [registerModal, { openModal }] = useModal()
const [registerTable, { reload }] = useTable({
title: '应用列表',
api: getOAuth2ClientPage,
2 years ago
columns,
formConfig: { labelWidth: 120, schemas: searchFormSchema },
2 years ago
useSearchForm: true,
showTableSetting: true,
showIndexColumn: false,
actionColumn: {
width: 140,
2 years ago
title: t('common.action'),
2 years ago
dataIndex: 'action',
fixed: 'right',
},
2 years ago
})
function handleCreate() {
openModal(true, { isUpdate: false })
2 years ago
}
function handleEdit(record: Recordable) {
openModal(true, { record, isUpdate: true })
2 years ago
}
async function handleDelete(record: Recordable) {
await deleteOAuth2Client(record.id)
2 years ago
createMessage.success(t('common.delSuccessText'))
2 years ago
reload()
}
</script>
<template>
<div>
<BasicTable @register="registerTable">
<template #toolbar>
<a-button v-auth="['system:oauth2-client:create']" type="primary" :pre-icon="IconEnum.ADD" @click="handleCreate">
{{ t('action.create') }}
</a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{ icon: IconEnum.EDIT, label: t('action.edit'), auth: 'system:oauth2-client:update', onClick: handleEdit.bind(null, record) },
{
icon: IconEnum.DELETE,
danger: true,
label: t('action.delete'),
auth: 'system:oauth2-client:delete',
popConfirm: {
title: t('common.delMessage'),
placement: 'left',
confirm: handleDelete.bind(null, record),
},
},
]"
/>
</template>
</template>
</BasicTable>
<ClientModal @register="registerModal" @success="reload()" />
</div>
</template>