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.

93 lines
2.9 KiB

<template>
2 years ago
<div>
<BasicTable @register="registerTable">
<template #toolbar>
<a-button type="primary" v-auth="['system:tenant:create']" :preIcon="IconEnum.ADD" @click="handleCreate">
{{ t('action.create') }}
</a-button>
<a-button type="warning" v-auth="['system:tenant:export']" :preIcon="IconEnum.EXPORT" @click="handleExport">
{{ t('action.export') }}
</a-button>
2 years ago
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{ icon: IconEnum.EDIT, label: t('action.edit'), auth: 'system:tenant:update', onClick: handleEdit.bind(null, record) },
2 years ago
{
2 years ago
icon: IconEnum.DELETE,
2 years ago
color: 'error',
2 years ago
label: t('action.delete'),
auth: 'system:tenant:delete',
2 years ago
popConfirm: {
2 years ago
title: t('common.delMessage'),
2 years ago
placement: 'left',
confirm: handleDelete.bind(null, record)
}
}
]"
/>
</template>
</template>
</BasicTable>
<TenantModal @register="registerModal" @success="reload()" />
2 years ago
</div>
</template>
<script lang="ts" setup>
2 years ago
import { BasicTable, useTable, TableAction } from '@/components/Table'
import { TenantExportReqVO, deleteTenant, exportTenant, getTenantPage } from '@/api/system/tenant'
2 years ago
import { useModal } from '@/components/Modal'
import TenantModal from './TenantModal.vue'
2 years ago
import { IconEnum } from '@/enums/appEnum'
2 years ago
import { columns, searchFormSchema } from './tenant.data'
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
defineOptions({ name: 'SystemTenant' })
2 years ago
const { t } = useI18n()
const { createConfirm, createMessage } = useMessage()
const [registerModal, { openModal }] = useModal()
const [registerTable, { getForm, reload }] = useTable({
title: '租户列表',
api: getTenantPage,
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'
}
})
function handleCreate() {
openModal(true, { isUpdate: false })
2 years ago
}
function handleEdit(record: Recordable) {
openModal(true, { record, isUpdate: true })
2 years ago
}
async function handleExport() {
createConfirm({
2 years ago
title: t('common.exportTitle'),
2 years ago
iconType: 'warning',
2 years ago
content: t('common.exportMessage'),
2 years ago
async onOk() {
await exportTenant(getForm().getFieldsValue() as TenantExportReqVO)
2 years ago
createMessage.success(t('common.exportSuccessText'))
}
})
}
async function handleDelete(record: Recordable) {
await deleteTenant(record.id)
2 years ago
createMessage.success(t('common.delSuccessText'))
2 years ago
reload()
}
</script>