first commit
This commit is contained in:
66
src/views/system/notify/message/NotifyMessageDetail.vue
Normal file
66
src/views/system/notify/message/NotifyMessageDetail.vue
Normal file
@@ -0,0 +1,66 @@
|
||||
<template>
|
||||
<Dialog v-model="dialogVisible" :max-height="500" :scroll="true" title="详情">
|
||||
<el-descriptions :column="1" border>
|
||||
<el-descriptions-item label="编号" min-width="120">
|
||||
{{ detailData.id }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="用户类型">
|
||||
<dict-tag :type="DICT_TYPE.USER_TYPE" :value="detailData.userType" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="用户编号">
|
||||
{{ detailData.userId }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="模版编号">
|
||||
{{ detailData.templateId }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="模板编码">
|
||||
{{ detailData.templateCode }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="发送人名称">
|
||||
{{ detailData.templateNickname }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="模版内容">
|
||||
{{ detailData.templateContent }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="模版参数">
|
||||
{{ detailData.templateParams }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="模版类型">
|
||||
<dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="detailData.templateType" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="是否已读">
|
||||
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="detailData.readStatus" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="阅读时间">
|
||||
{{ formatDate(detailData.readTime) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="创建时间">
|
||||
{{ formatDate(detailData.createTime) }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE } from '@/utils/dict'
|
||||
import { formatDate } from '@/utils/formatTime'
|
||||
import * as NotifyMessageApi from '@/api/system/notify/message'
|
||||
|
||||
defineOptions({ name: 'SystemNotifyMessageDetail' })
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const detailLoading = ref(false) // 表单的加载中
|
||||
const detailData = ref({} as NotifyMessageApi.NotifyMessageVO) // 详情数据
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (data: NotifyMessageApi.NotifyMessageVO) => {
|
||||
dialogVisible.value = true
|
||||
// 设置数据
|
||||
detailLoading.value = true
|
||||
try {
|
||||
detailData.value = data
|
||||
} finally {
|
||||
detailLoading.value = false
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
</script>
|
||||
212
src/views/system/notify/message/index.vue
Normal file
212
src/views/system/notify/message/index.vue
Normal file
@@ -0,0 +1,212 @@
|
||||
<template>
|
||||
<doc-alert title="站内信配置" url="https://doc.iocoder.cn/notify/" />
|
||||
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="用户编号" prop="userId">
|
||||
<el-input
|
||||
v-model="queryParams.userId"
|
||||
placeholder="请输入用户编号"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="用户类型" prop="userType">
|
||||
<el-select
|
||||
v-model="queryParams.userType"
|
||||
placeholder="请选择用户类型"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="模板编码" prop="templateCode">
|
||||
<el-input
|
||||
v-model="queryParams.templateCode"
|
||||
placeholder="请输入模板编码"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="模版类型" prop="templateType">
|
||||
<el-select
|
||||
v-model="queryParams.templateType"
|
||||
placeholder="请选择模版类型"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.createTime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list">
|
||||
<el-table-column label="编号" align="center" prop="id" />
|
||||
<el-table-column label="用户类型" align="center" prop="userType">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.USER_TYPE" :value="scope.row.userType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="用户编号" align="center" prop="userId" width="80" />
|
||||
<el-table-column label="模板编码" align="center" prop="templateCode" width="80" />
|
||||
<el-table-column label="发送人名称" align="center" prop="templateNickname" width="180" />
|
||||
<el-table-column
|
||||
label="模版内容"
|
||||
align="center"
|
||||
prop="templateContent"
|
||||
width="200"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column
|
||||
label="模版参数"
|
||||
align="center"
|
||||
prop="templateParams"
|
||||
width="180"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="scope"> {{ scope.row.templateParams }}</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="模版类型" align="center" prop="templateType" width="120">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="scope.row.templateType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否已读" align="center" prop="readStatus" width="100">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.readStatus" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="阅读时间"
|
||||
align="center"
|
||||
prop="readTime"
|
||||
width="180"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
width="180"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<el-table-column label="操作" align="center" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openDetail(scope.row)"
|
||||
v-hasPermi="['system:notify-message:query']"
|
||||
>
|
||||
详情
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:详情 -->
|
||||
<NotifyMessageDetail ref="detailRef" />
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import * as NotifyMessageApi from '@/api/system/notify/message'
|
||||
import NotifyMessageDetail from './NotifyMessageDetail.vue'
|
||||
|
||||
defineOptions({ name: 'SystemNotifyMessage' })
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const total = ref(0) // 列表的总页数
|
||||
const list = ref([]) // 列表的数据
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
userType: undefined,
|
||||
userId: undefined,
|
||||
templateCode: undefined,
|
||||
templateType: undefined,
|
||||
createTime: []
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await NotifyMessageApi.getNotifyMessagePage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 详情操作 */
|
||||
const detailRef = ref()
|
||||
const openDetail = (data: NotifyMessageApi.NotifyMessageVO) => {
|
||||
detailRef.value.open(data)
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
48
src/views/system/notify/my/MyNotifyMessageDetail.vue
Normal file
48
src/views/system/notify/my/MyNotifyMessageDetail.vue
Normal file
@@ -0,0 +1,48 @@
|
||||
<template>
|
||||
<Dialog v-model="dialogVisible" :max-height="500" :scroll="true" title="消息详情">
|
||||
<el-descriptions :column="1" border>
|
||||
<el-descriptions-item label="发送人">
|
||||
{{ detailData.templateNickname }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="发送时间">
|
||||
{{ formatDate(detailData.createTime) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="消息类型">
|
||||
<dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="detailData.templateType" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="是否已读">
|
||||
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="detailData.readStatus" />
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item v-if="detailData.readStatus" label="阅读时间">
|
||||
{{ formatDate(detailData.readTime) }}
|
||||
</el-descriptions-item>
|
||||
<el-descriptions-item label="内容">
|
||||
{{ detailData.templateContent }}
|
||||
</el-descriptions-item>
|
||||
</el-descriptions>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE } from '@/utils/dict'
|
||||
import { formatDate } from '@/utils/formatTime'
|
||||
import * as NotifyMessageApi from '@/api/system/notify/message'
|
||||
|
||||
defineOptions({ name: 'MyNotifyMessageDetailDetail' })
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const detailLoading = ref(false) // 表单的加载中
|
||||
const detailData = ref({} as NotifyMessageApi.NotifyMessageVO) // 详情数据
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (data: NotifyMessageApi.NotifyMessageVO) => {
|
||||
dialogVisible.value = true
|
||||
// 设置数据
|
||||
detailLoading.value = true
|
||||
try {
|
||||
detailData.value = data
|
||||
} finally {
|
||||
detailLoading.value = false
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
</script>
|
||||
218
src/views/system/notify/my/index.vue
Normal file
218
src/views/system/notify/my/index.vue
Normal file
@@ -0,0 +1,218 @@
|
||||
<template>
|
||||
<doc-alert title="站内信配置" url="https://doc.iocoder.cn/notify/" />
|
||||
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="是否已读" prop="readStatus">
|
||||
<el-select
|
||||
v-model="queryParams.readStatus"
|
||||
placeholder="请选择状态"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getBoolDictOptions(DICT_TYPE.INFRA_BOOLEAN_STRING)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="发送时间" prop="createTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.createTime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
<el-button @click="handleUpdateList">
|
||||
<Icon icon="ep:reading" class="mr-5px" /> 标记已读
|
||||
</el-button>
|
||||
<el-button @click="handleUpdateAll">
|
||||
<Icon icon="ep:reading" class="mr-5px" /> 全部已读
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="list"
|
||||
ref="tableRef"
|
||||
row-key="id"
|
||||
@selection-change="handleSelectionChange"
|
||||
>
|
||||
<el-table-column type="selection" :selectable="selectable" :reserve-selection="true" />
|
||||
<el-table-column label="发送人" align="center" prop="templateNickname" width="180" />
|
||||
<el-table-column
|
||||
label="发送时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
width="200"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<el-table-column label="类型" align="center" prop="templateType" width="180">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="scope.row.templateType" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="消息内容"
|
||||
align="center"
|
||||
prop="templateContent"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column label="是否已读" align="center" prop="readStatus" width="160">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.readStatus" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column
|
||||
label="阅读时间"
|
||||
align="center"
|
||||
prop="readTime"
|
||||
width="200"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<el-table-column label="操作" align="center" width="160">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
:type="scope.row.readStatus ? 'primary' : 'warning'"
|
||||
@click="openDetail(scope.row)"
|
||||
>
|
||||
{{ scope.row.readStatus ? '详情' : '已读' }}
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:详情 -->
|
||||
<MyNotifyMessageDetail ref="detailRef" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE, getBoolDictOptions } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import * as NotifyMessageApi from '@/api/system/notify/message'
|
||||
import MyNotifyMessageDetail from './MyNotifyMessageDetail.vue'
|
||||
|
||||
defineOptions({ name: 'SystemMyNotify' })
|
||||
|
||||
const message = useMessage() // 消息
|
||||
|
||||
const loading = ref(true) // 列表的加载中
|
||||
const total = ref(0) // 列表的总页数
|
||||
const list = ref([]) // 列表的数据
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
readStatus: undefined,
|
||||
createTime: []
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
const tableRef = ref() // 表格的 Ref
|
||||
const selectedIds = ref<number[]>([]) // 表格的选中 ID 数组
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await NotifyMessageApi.getMyNotifyMessagePage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
tableRef.value.clearSelection()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 详情操作 */
|
||||
const detailRef = ref()
|
||||
const openDetail = (data: NotifyMessageApi.NotifyMessageVO) => {
|
||||
if (!data.readStatus) {
|
||||
handleReadOne(data.id)
|
||||
}
|
||||
detailRef.value.open(data)
|
||||
}
|
||||
|
||||
/** 标记一条站内信已读 */
|
||||
const handleReadOne = async (id) => {
|
||||
await NotifyMessageApi.updateNotifyMessageRead(id)
|
||||
await getList()
|
||||
}
|
||||
|
||||
/** 标记全部站内信已读 **/
|
||||
const handleUpdateAll = async () => {
|
||||
await NotifyMessageApi.updateAllNotifyMessageRead()
|
||||
message.success('全部已读成功!')
|
||||
tableRef.value.clearSelection()
|
||||
await getList()
|
||||
}
|
||||
|
||||
/** 标记一些站内信已读 **/
|
||||
const handleUpdateList = async () => {
|
||||
if (selectedIds.value.length === 0) {
|
||||
return
|
||||
}
|
||||
await NotifyMessageApi.updateNotifyMessageRead(selectedIds.value)
|
||||
message.success('批量已读成功!')
|
||||
tableRef.value.clearSelection()
|
||||
await getList()
|
||||
}
|
||||
|
||||
/** 某一行,是否允许选中 */
|
||||
const selectable = (row) => {
|
||||
return !row.readStatus
|
||||
}
|
||||
|
||||
/** 当表格选择项发生变化时会触发该事件 */
|
||||
const handleSelectionChange = (array: NotifyMessageApi.NotifyMessageVO[]) => {
|
||||
selectedIds.value = []
|
||||
if (!array) {
|
||||
return
|
||||
}
|
||||
array.forEach((row) => selectedIds.value.push(row.id))
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
141
src/views/system/notify/template/NotifyTemplateForm.vue
Normal file
141
src/views/system/notify/template/NotifyTemplateForm.vue
Normal file
@@ -0,0 +1,141 @@
|
||||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="140px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="模版编码" prop="code">
|
||||
<el-input v-model="formData.code" placeholder="请输入模版编码" />
|
||||
</el-form-item>
|
||||
<el-form-item label="模板名称" prop="name">
|
||||
<el-input v-model="formData.name" placeholder="请输入模版名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="发件人名称" prop="nickname">
|
||||
<el-input v-model="formData.nickname" placeholder="请输入发件人名称" />
|
||||
</el-form-item>
|
||||
<el-form-item label="模板内容" prop="content">
|
||||
<el-input type="textarea" v-model="formData.content" placeholder="请输入模板内容" />
|
||||
</el-form-item>
|
||||
<el-form-item label="类型" prop="type">
|
||||
<el-select v-model="formData.type" placeholder="请选择类型">
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="开启状态" prop="status">
|
||||
<el-radio-group v-model="formData.status">
|
||||
<el-radio
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||
:key="dict.value"
|
||||
:value="dict.value"
|
||||
>
|
||||
{{ dict.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="备注" prop="remark">
|
||||
<el-input v-model="formData.remark" placeholder="请输入备注" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import * as NotifyTemplateApi from '@/api/system/notify/template'
|
||||
import { CommonStatusEnum } from '@/utils/constants'
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const dialogTitle = ref('') // 弹窗的标题
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formType = ref('') // 表单的类型
|
||||
const formData = ref<NotifyTemplateApi.NotifyTemplateVO>({
|
||||
id: undefined,
|
||||
name: '',
|
||||
nickname: '',
|
||||
code: '',
|
||||
content: '',
|
||||
type: undefined,
|
||||
params: '',
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
remark: ''
|
||||
})
|
||||
const formRules = reactive({
|
||||
type: [{ required: true, message: '消息类型不能为空', trigger: 'change' }],
|
||||
status: [{ required: true, message: '开启状态不能为空', trigger: 'blur' }],
|
||||
code: [{ required: true, message: '模板编码不能为空', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '模板名称不能为空', trigger: 'blur' }],
|
||||
nickname: [{ required: true, message: '发件人姓名不能为空', trigger: 'blur' }],
|
||||
content: [{ required: true, message: '模板内容不能为空', trigger: 'blur' }]
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
|
||||
/** 打开弹窗 */
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
dialogTitle.value = type
|
||||
formType.value = type
|
||||
resetForm()
|
||||
// 修改时,设置数据
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
formData.value = await NotifyTemplateApi.getNotifyTemplate(id)
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
if (!formRef) return
|
||||
const valid = await formRef.value.validate()
|
||||
if (!valid) return
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as NotifyTemplateApi.NotifyTemplateVO
|
||||
if (formType.value === 'create') {
|
||||
await NotifyTemplateApi.createNotifyTemplate(data)
|
||||
message.success('新增成功')
|
||||
} else {
|
||||
await NotifyTemplateApi.updateNotifyTemplate(data)
|
||||
message.success('修改成功')
|
||||
}
|
||||
dialogVisible.value = false
|
||||
// 发送操作成功的事件
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
name: '',
|
||||
nickname: '',
|
||||
code: '',
|
||||
content: '',
|
||||
type: undefined,
|
||||
params: '',
|
||||
status: CommonStatusEnum.ENABLE,
|
||||
remark: ''
|
||||
}
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
146
src/views/system/notify/template/NotifyTemplateSendForm.vue
Normal file
146
src/views/system/notify/template/NotifyTemplateSendForm.vue
Normal file
@@ -0,0 +1,146 @@
|
||||
<template>
|
||||
<Dialog v-model="dialogVisible" title="测试发送" :max-height="500">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
v-loading="formLoading"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="140px"
|
||||
>
|
||||
<el-form-item label="模板内容" prop="content">
|
||||
<el-input
|
||||
v-model="formData.content"
|
||||
placeholder="请输入模板内容"
|
||||
readonly
|
||||
type="textarea"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="用户类型" prop="userType">
|
||||
<el-radio-group v-model="formData.userType">
|
||||
<el-radio
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)"
|
||||
:key="dict.value"
|
||||
:value="dict.value"
|
||||
>
|
||||
{{ dict.label }}
|
||||
</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<el-form-item v-show="formData.userType === 1" label="接收人ID" prop="userId">
|
||||
<el-input v-model="formData.userId" style="width: 160px" />
|
||||
</el-form-item>
|
||||
<el-form-item v-show="formData.userType === 2" label="接收人" prop="userId">
|
||||
<el-select v-model="formData.userId" placeholder="请选择接收人">
|
||||
<el-option
|
||||
v-for="item in userOption"
|
||||
:key="item.id"
|
||||
:label="item.nickname"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item
|
||||
v-for="param in formData.params"
|
||||
:key="param"
|
||||
:label="'参数 {' + param + '}'"
|
||||
:prop="'templateParams.' + param"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.templateParams[param]"
|
||||
:placeholder="'请输入 ' + param + ' 参数'"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<el-button :disabled="formLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import * as UserApi from '@/api/system/user'
|
||||
import * as NotifyTemplateApi from '@/api/system/notify/template'
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
|
||||
defineOptions({ name: 'SystemNotifyTemplateSendForm' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
|
||||
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||
const formData = ref({
|
||||
content: '',
|
||||
params: {},
|
||||
userId: undefined,
|
||||
userType: 1,
|
||||
templateCode: '',
|
||||
templateParams: new Map()
|
||||
})
|
||||
const formRules = reactive({
|
||||
userId: [{ required: true, message: '用户编号不能为空', trigger: 'change' }],
|
||||
templateCode: [{ required: true, message: '模版编号不能为空', trigger: 'blur' }],
|
||||
templateParams: {}
|
||||
})
|
||||
const formRef = ref() // 表单 Ref
|
||||
const userOption = ref<UserApi.UserVO[]>([])
|
||||
|
||||
const open = async (id: number) => {
|
||||
dialogVisible.value = true
|
||||
resetForm()
|
||||
// 设置数据
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = await NotifyTemplateApi.getNotifyTemplate(id)
|
||||
// 设置动态表单
|
||||
formData.value.content = data.content
|
||||
formData.value.params = data.params
|
||||
formData.value.templateCode = data.code
|
||||
formData.value.templateParams = data.params.reduce((obj, item) => {
|
||||
obj[item] = '' // 给每个动态属性赋值,避免无法读取
|
||||
return obj
|
||||
}, {})
|
||||
formRules.templateParams = data.params.reduce((obj, item) => {
|
||||
obj[item] = { required: true, message: '参数 ' + item + ' 不能为空', trigger: 'blur' }
|
||||
return obj
|
||||
}, {})
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
// 加载用户列表
|
||||
userOption.value = await UserApi.getSimpleUserList()
|
||||
}
|
||||
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||
|
||||
/** 提交表单 */
|
||||
const submitForm = async () => {
|
||||
// 校验表单
|
||||
if (!formRef) return
|
||||
const valid = await formRef.value.validate()
|
||||
if (!valid) return
|
||||
// 提交请求
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = formData.value as unknown as NotifyTemplateApi.NotifySendReqVO
|
||||
const logId = await NotifyTemplateApi.sendNotify(data)
|
||||
if (logId) {
|
||||
message.success('提交发送成功!发送结果,见发送日志编号:' + logId)
|
||||
}
|
||||
dialogVisible.value = false
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 重置表单 */
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
content: '',
|
||||
params: {},
|
||||
mobile: '',
|
||||
templateCode: '',
|
||||
templateParams: new Map(),
|
||||
userType: 1
|
||||
} as any
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
264
src/views/system/notify/template/index.vue
Normal file
264
src/views/system/notify/template/index.vue
Normal file
@@ -0,0 +1,264 @@
|
||||
<template>
|
||||
<doc-alert title="站内信配置" url="https://doc.iocoder.cn/notify/" />
|
||||
|
||||
<!-- 搜索工作栏 -->
|
||||
<ContentWrap>
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="68px"
|
||||
>
|
||||
<el-form-item label="模板名称" prop="name">
|
||||
<el-input
|
||||
v-model="queryParams.name"
|
||||
placeholder="请输入模板名称"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="模板编号" prop="code">
|
||||
<el-input
|
||||
v-model="queryParams.code"
|
||||
placeholder="请输入模版编码"
|
||||
clearable
|
||||
@keyup.enter="handleQuery"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item label="状态" prop="status">
|
||||
<el-select
|
||||
v-model="queryParams.status"
|
||||
placeholder="请选择开启状态"
|
||||
clearable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
:value="dict.value"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="创建时间" prop="createTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.createTime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]"
|
||||
class="!w-240px"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
|
||||
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
@click="openForm('create')"
|
||||
v-hasPermi="['system:notify-template:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" />新增
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
:disabled="checkedIds.length === 0"
|
||||
@click="handleDeleteBatch"
|
||||
v-hasPermi="['system:notify-template:delete']"
|
||||
>
|
||||
<Icon icon="ep:delete" class="mr-5px" />批量删除
|
||||
</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table v-loading="loading" :data="list" @selection-change="handleRowCheckboxChange">
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column
|
||||
label="模板编码"
|
||||
align="center"
|
||||
prop="code"
|
||||
width="120"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column
|
||||
label="模板名称"
|
||||
align="center"
|
||||
prop="name"
|
||||
width="120"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column label="类型" align="center" prop="type">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="scope.row.type" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="发送人名称" align="center" prop="nickname" />
|
||||
<el-table-column
|
||||
label="模板内容"
|
||||
align="center"
|
||||
prop="content"
|
||||
width="200"
|
||||
:show-overflow-tooltip="true"
|
||||
/>
|
||||
<el-table-column label="开启状态" align="center" prop="status" width="80">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
<el-table-column
|
||||
label="创建时间"
|
||||
align="center"
|
||||
prop="createTime"
|
||||
width="180"
|
||||
:formatter="dateFormatter"
|
||||
/>
|
||||
<el-table-column label="操作" align="center" width="210" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
v-hasPermi="['system:notify-template:update']"
|
||||
>
|
||||
修改
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openSendForm(scope.row)"
|
||||
v-hasPermi="['system:notify-template:send-notify']"
|
||||
>
|
||||
测试
|
||||
</el-button>
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['system:notify-template:delete']"
|
||||
>
|
||||
删除
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<NotifyTemplateForm ref="formRef" @success="getList" />
|
||||
<!-- 表单弹窗:测试发送 -->
|
||||
<NotifyTemplateSendForm ref="sendFormRef" />
|
||||
</template>
|
||||
<script lang="ts" setup>
|
||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import * as NotifyTemplateApi from '@/api/system/notify/template'
|
||||
import NotifyTemplateForm from './NotifyTemplateForm.vue'
|
||||
import NotifyTemplateSendForm from './NotifyTemplateSendForm.vue'
|
||||
|
||||
defineOptions({ name: 'NotifySmsTemplate' })
|
||||
|
||||
const message = useMessage() // 消息弹窗
|
||||
const { t } = useI18n() // 国际化
|
||||
|
||||
const loading = ref(false) // 列表的加载中
|
||||
const total = ref(0) // 列表的总页数
|
||||
const list = ref([]) // 列表的数据
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
name: undefined,
|
||||
status: undefined,
|
||||
code: undefined,
|
||||
createTime: []
|
||||
})
|
||||
const queryFormRef = ref() // 搜索的表单
|
||||
|
||||
/** 查询列表 */
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await NotifyTemplateApi.getNotifyTemplatePage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.pageNo = 1
|
||||
getList()
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
const resetQuery = () => {
|
||||
queryFormRef.value.resetFields()
|
||||
handleQuery()
|
||||
}
|
||||
|
||||
/** 添加/修改操作 */
|
||||
const formRef = ref()
|
||||
const openForm = (type: string, id?: number) => {
|
||||
formRef.value.open(type, id)
|
||||
}
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (id: number) => {
|
||||
try {
|
||||
// 删除的二次确认
|
||||
await message.delConfirm()
|
||||
// 发起删除
|
||||
await NotifyTemplateApi.deleteNotifyTemplate(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 批量删除按钮操作 */
|
||||
const checkedIds = ref<number[]>([])
|
||||
const handleRowCheckboxChange = (rows: NotifyTemplateApi.NotifyTemplateVO[]) => {
|
||||
checkedIds.value = rows.map((row) => row.id!)
|
||||
}
|
||||
|
||||
const handleDeleteBatch = async () => {
|
||||
try {
|
||||
// 删除的二次确认
|
||||
await message.delConfirm()
|
||||
// 发起批量删除
|
||||
await NotifyTemplateApi.deleteNotifyTemplateList(checkedIds.value)
|
||||
message.success(t('common.delSuccess'))
|
||||
// 刷新列表
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
/** 发送站内信按钮 */
|
||||
const sendFormRef = ref() // 表单 Ref
|
||||
const openSendForm = (row: NotifyTemplateApi.NotifyTemplateVO) => {
|
||||
sendFormRef.value.open(row.id)
|
||||
}
|
||||
|
||||
/** 初始化 **/
|
||||
onMounted(() => {
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
Reference in New Issue
Block a user