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.

103 lines
3.3 KiB

<template>
2 years ago
<div>
<BasicTable @register="registerTable">
<template #toolbar>
<a-button type="primary" v-auth="['system:sms-template:create']" :preIcon="IconEnum.ADD" @click="handleCreate">
{{ t('action.create') }}
</a-button>
<a-button type="warning" v-auth="['system:sms-template: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.TEST,
label: t('action.test'),
auth: 'system:sms-template:send-sms',
onClick: handleSendSms.bind(null, record)
},
{ icon: IconEnum.EDIT, label: t('action.edit'), auth: 'system:sms-template: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:sms-template: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>
<SmsTemplateModal @register="registerModal" @success="reload()" />
2 years ago
</div>
</template>
<script lang="ts" setup>
2 years ago
import { BasicTable, useTable, TableAction } from '@/components/Table'
import { SmsTemplateExportReqVO, deleteSmsTemplate, exportSmsTemplate, getSmsTemplatePage } from '@/api/system/sms/smsTemplate'
2 years ago
import { useModal } from '@/components/Modal'
2 years ago
import { IconEnum } from '@/enums/appEnum'
import SmsTemplateModal from './SmsTemplateModal.vue'
2 years ago
import { columns, searchFormSchema } from './smsTemplate.data'
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
defineOptions({ name: 'SystemSmsTemplate' })
2 years ago
const { t } = useI18n()
const { createConfirm, createMessage } = useMessage()
const [registerModal, { openModal }] = useModal()
const [registerTable, { getForm, reload }] = useTable({
title: '短信模版列表',
api: getSmsTemplatePage,
2 years ago
columns,
formConfig: { labelWidth: 120, schemas: searchFormSchema },
2 years ago
useSearchForm: true,
showTableSetting: true,
showIndexColumn: false,
actionColumn: {
width: 220,
2 years ago
title: t('common.action'),
2 years ago
dataIndex: 'action',
fixed: 'right'
}
})
function handleCreate() {
openModal(true, { isUpdate: false })
2 years ago
}
function handleSendSms(record: Recordable) {
console.info(record)
}
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 exportSmsTemplate(getForm().getFieldsValue() as SmsTemplateExportReqVO)
2 years ago
createMessage.success(t('common.exportSuccessText'))
}
})
}
async function handleDelete(record: Recordable) {
await deleteSmsTemplate(record.id)
2 years ago
createMessage.success(t('common.delSuccessText'))
2 years ago
reload()
}
</script>