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.

98 lines
2.9 KiB

<template>
2 years ago
<div>
<BasicTable @register="registerTable">
<template #toolbar>
2 years ago
<a-button type="primary" @click="handleCreate"> {{ t('action.create') }} </a-button>
<a-button type="warning" @click="handleExport"> {{ t('action.export') }} </a-button>
2 years ago
</template>
<template #bodyCell="{ column, record }">
<template v-if="column.key === 'action'">
<TableAction
:actions="[
{ icon: 'clarity:note-edit-line', label: t('action.test'), onClick: handleSendSms.bind(null, record) },
{ icon: 'clarity:note-edit-line', label: t('action.edit'), onClick: handleEdit.bind(null, record) },
2 years ago
{
icon: 'ant-design:delete-outlined',
color: 'error',
2 years ago
label: t('action.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>
2 years ago
<script lang="ts" setup name="SmsTemplate">
import { BasicTable, useTable, TableAction } from '@/components/Table'
import { SmsTemplateExportReqVO, deleteSmsTemplateApi, exportSmsTemplateApi, getSmsTemplatePageApi } from '@/api/system/sms/smsTemplate'
import { useModal } from '@/components/Modal'
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'
const { t } = useI18n()
const { createConfirm, createMessage } = useMessage()
const [registerModal, { openModal }] = useModal()
const [registerTable, { getForm, reload }] = useTable({
title: '短信模版列表',
api: getSmsTemplatePageApi,
columns,
formConfig: {
labelWidth: 120,
schemas: searchFormSchema
},
useSearchForm: true,
showTableSetting: true,
showIndexColumn: false,
actionColumn: {
width: 180,
2 years ago
title: t('common.action'),
2 years ago
dataIndex: 'action',
fixed: 'right'
}
})
function handleCreate() {
openModal(true, {
isUpdate: false
})
}
function handleSendSms(record: Recordable) {
console.info(record)
}
function handleEdit(record: Recordable) {
openModal(true, {
record,
isUpdate: true
})
}
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 exportSmsTemplateApi(getForm().getFieldsValue() as SmsTemplateExportReqVO)
createMessage.success(t('common.exportSuccessText'))
}
})
}
async function handleDelete(record: Recordable) {
await deleteSmsTemplateApi(record.id)
2 years ago
createMessage.success(t('common.delSuccessText'))
2 years ago
reload()
}
</script>