admin-vben/src/views/system/sensitiveWord/index.vue

103 lines
2.7 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<template>
<div>
<BasicTable @register="registerTable">
<template #toolbar>
<a-button type="primary" @click="handleCreate"> </a-button>
<a-button type="warning" @click="handleExport"> </a-button>
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{
icon: 'clarity:note-edit-line',
onClick: handleEdit.bind(null, record)
},
{
icon: 'ant-design:delete-outlined',
color: 'error',
popConfirm: {
title: '是否确认删除',
placement: 'left',
confirm: handleDelete.bind(null, record)
}
}
]"
/>
</template>
</template>
</BasicTable>
<SensitiveWordModel @register="registerModal" @success="reload()" />
</div>
</template>
<script lang="ts" setup name="SensitiveWord">
import { BasicTable, useTable, TableAction } from '@/components/Table'
import {
SensitiveWordExportReqVO,
deleteSensitiveWordApi,
exportSensitiveWordApi,
getSensitiveWordPageApi
} from '@/api/system/sensitiveWord'
import { useModal } from '@/components/Modal'
import SensitiveWordModel from './SensitiveWordModel.vue'
import { columns, searchFormSchema } from './sensitiveWord.data'
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
const { t } = useI18n()
const { createConfirm, createMessage } = useMessage()
const [registerModal, { openModal }] = useModal()
const [registerTable, { getForm, reload }] = useTable({
title: '',
api: getSensitiveWordPageApi,
columns,
formConfig: {
labelWidth: 120,
schemas: searchFormSchema
},
useSearchForm: true,
showTableSetting: true,
showIndexColumn: false,
actionColumn: {
width: 120,
title: '',
dataIndex: 'action',
fixed: 'right'
}
})
function handleCreate() {
openModal(true, {
isUpdate: false
})
}
function handleEdit(record: Recordable) {
openModal(true, {
record,
isUpdate: true
})
}
async function handleExport() {
createConfirm({
title: '',
iconType: 'warning',
content: '',
async onOk() {
await exportSensitiveWordApi(getForm().getFieldsValue() as SensitiveWordExportReqVO)
createMessage.success(t('common.exportSuccessText'))
}
})
}
async function handleDelete(record: Recordable) {
console.log(record)
const res = await deleteSensitiveWordApi(record.id)
if (res) {
createMessage.success('')
reload()
}
}
</script>