Bladeren bron

feat:【system】通知管理的开发:50% 初始化

YunaiV 4 maanden geleden
bovenliggende
commit
257dbbea67

+ 16 - 1
src/api/system/notify/index.ts

@@ -1,7 +1,7 @@
 import type { PageParam, PageResult } from '@/http/types'
 import { http } from '@/http/http'
 
-/** 站内信消息 */
+/** 站内信消息信息 */
 export interface NotifyMessage {
   id: number
   userId: number
@@ -17,11 +17,26 @@ export interface NotifyMessage {
   createTime?: Date
 }
 
+/** 查询站内信消息列表 */
+export function getNotifyMessagePage(params: PageParam) {
+  return http.get<PageResult<NotifyMessage>>('/system/notify-message/page', params)
+}
+
+/** 查询站内信消息详情 */
+export function getNotifyMessage(id: number) {
+  return http.get<NotifyMessage>(`/system/notify-message/get`, { id })
+}
+
 /** 获取我的站内信分页 */
 export function getMyNotifyMessagePage(params: PageParam) {
   return http.get<PageResult<NotifyMessage>>('/system/notify-message/my-page', params)
 }
 
+/** 获取我的站内信详情 */
+export function getMyNotifyMessage(id: number) {
+  return http.get<NotifyMessage>(`/system/notify-message/get`, { id })
+}
+
 /** 批量标记站内信已读 */
 export function updateNotifyMessageRead(ids: number | number[]) {
   const idsArray = Array.isArray(ids) ? ids : [ids]

+ 54 - 0
src/api/system/notify/template/index.ts

@@ -0,0 +1,54 @@
+import type { PageParam, PageResult } from '@/http/types'
+import { http } from '@/http/http'
+
+/** 站内信模板信息 */
+export interface NotifyTemplate {
+  id?: number
+  name: string
+  nickname: string
+  code: string
+  content: string
+  type?: number
+  params?: string[]
+  status: number
+  remark?: string
+  createTime?: Date
+}
+
+/** 发送站内信请求 */
+export interface NotifySendReqVO {
+  userId: number
+  userType: number
+  templateCode: string
+  templateParams: Record<string, any>
+}
+
+/** 查询站内信模板列表 */
+export function getNotifyTemplatePage(params: PageParam) {
+  return http.get<PageResult<NotifyTemplate>>('/system/notify-template/page', params)
+}
+
+/** 查询站内信模板详情 */
+export function getNotifyTemplate(id: number) {
+  return http.get<NotifyTemplate>(`/system/notify-template/get`, { id })
+}
+
+/** 新增站内信模板 */
+export function createNotifyTemplate(data: NotifyTemplate) {
+  return http.post<number>('/system/notify-template/create', data)
+}
+
+/** 修改站内信模板 */
+export function updateNotifyTemplate(data: NotifyTemplate) {
+  return http.put<boolean>('/system/notify-template/update', data)
+}
+
+/** 删除站内信模板 */
+export function deleteNotifyTemplate(id: number) {
+  return http.delete<boolean>(`/system/notify-template/delete`, { id })
+}
+
+/** 发送站内信 */
+export function sendNotify(data: NotifySendReqVO) {
+  return http.post<number>('/system/notify-template/send-notify', data)
+}

+ 133 - 0
src/pages-system/notify/components/message-list.vue

@@ -0,0 +1,133 @@
+<template>
+  <view>
+    <!-- 搜索组件 -->
+    <MessageSearchForm @search="handleQuery" @reset="handleReset" />
+
+    <!-- 消息列表 -->
+    <view class="p-24rpx">
+      <view
+        v-for="item in list"
+        :key="item.id"
+        class="mb-24rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
+        @click="handleDetail(item)"
+      >
+        <view class="p-24rpx">
+          <view class="mb-16rpx flex items-center justify-between">
+            <view class="text-32rpx text-[#333] font-semibold">
+              {{ item.templateNickname || '-' }}
+            </view>
+            <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="item.readStatus" />
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx shrink-0 text-[#999]">用户类型:</text>
+            <dict-tag :type="DICT_TYPE.USER_TYPE" :value="item.userType" />
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx shrink-0 text-[#999]">用户编号:</text>
+            <text class="min-w-0 flex-1 truncate">{{ item.userId }}</text>
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx shrink-0 text-[#999]">模板编码:</text>
+            <text class="min-w-0 flex-1 truncate">{{ item.templateCode }}</text>
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx shrink-0 text-[#999]">模版类型:</text>
+            <dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="item.templateType" />
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx shrink-0 text-[#999]">模版内容:</text>
+            <text class="min-w-0 flex-1 truncate">{{ item.templateContent }}</text>
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx text-[#999]">创建时间:</text>
+            <text>{{ formatDateTime(item.createTime) || '-' }}</text>
+          </view>
+        </view>
+      </view>
+
+      <!-- 加载更多 -->
+      <view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
+        <wd-status-tip image="content" tip="暂无站内信消息数据" />
+      </view>
+      <wd-loadmore
+        v-if="list.length > 0"
+        :state="loadMoreState"
+        @reload="loadMore"
+      />
+    </view>
+  </view>
+</template>
+
+<script lang="ts" setup>
+import type { NotifyMessage } from '@/api/system/notify/message'
+import type { LoadMoreState } from '@/http/types'
+import { ref } from 'vue'
+import { getNotifyMessagePage } from '@/api/system/notify/message'
+import { DICT_TYPE } from '@/utils/constants'
+import { formatDateTime } from '@/utils/date'
+import MessageSearchForm from './message-search-form.vue'
+
+const total = ref(0)
+const list = ref<NotifyMessage[]>([])
+const loadMoreState = ref<LoadMoreState>('loading')
+const queryParams = ref({
+  pageNo: 1,
+  pageSize: 10,
+})
+
+/** 查询列表 */
+async function getList() {
+  loadMoreState.value = 'loading'
+  try {
+    const data = await getNotifyMessagePage(queryParams.value)
+    list.value = [...list.value, ...data.list]
+    total.value = data.total
+    loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
+  } catch {
+    queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
+    loadMoreState.value = 'error'
+  }
+}
+
+/** 搜索按钮操作 */
+function handleQuery(data?: Record<string, any>) {
+  queryParams.value = {
+    ...data,
+    pageNo: 1,
+    pageSize: queryParams.value.pageSize,
+  }
+  list.value = []
+  getList()
+}
+
+/** 重置按钮操作 */
+function handleReset() {
+  handleQuery()
+}
+
+/** 加载更多 */
+function loadMore() {
+  if (loadMoreState.value === 'finished') {
+    return
+  }
+  queryParams.value.pageNo++
+  getList()
+}
+
+/** 查看详情 */
+function handleDetail(item: NotifyMessage) {
+  uni.navigateTo({
+    url: `/pages-system/notify/message/detail/index?id=${item.id}`,
+  })
+}
+
+/** 触底加载更多 */
+onReachBottom(() => {
+  loadMore()
+})
+
+/** 初始化 */
+onMounted(() => {
+  getList()
+})
+</script>

+ 197 - 0
src/pages-system/notify/components/message-search-form.vue

@@ -0,0 +1,197 @@
+<template>
+  <!-- 搜索框入口 -->
+  <view @click="visible = true">
+    <wd-search :placeholder="placeholder" hide-cancel disabled />
+  </view>
+
+  <!-- 搜索弹窗 -->
+  <wd-popup v-model="visible" position="top" @close="visible = false">
+    <view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
+      <!-- 用户编号 -->
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          用户编号
+        </view>
+        <wd-input
+          v-model="formData.userId"
+          placeholder="请输入用户编号"
+          clearable
+        />
+      </view>
+      <!-- 用户类型 -->
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          用户类型
+        </view>
+        <wd-radio-group v-model="formData.userType" shape="button">
+          <wd-radio :value="-1">
+            全部
+          </wd-radio>
+          <wd-radio
+            v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)"
+            :key="dict.value"
+            :value="dict.value"
+          >
+            {{ dict.label }}
+          </wd-radio>
+        </wd-radio-group>
+      </view>
+      <!-- 模板编码 -->
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          模板编码
+        </view>
+        <wd-input
+          v-model="formData.templateCode"
+          placeholder="请输入模板编码"
+          clearable
+        />
+      </view>
+      <!-- 模版类型 -->
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          模版类型
+        </view>
+        <wd-radio-group v-model="formData.templateType" shape="button">
+          <wd-radio :value="-1">
+            全部
+          </wd-radio>
+          <wd-radio
+            v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE)"
+            :key="dict.value"
+            :value="dict.value"
+          >
+            {{ dict.label }}
+          </wd-radio>
+        </wd-radio-group>
+      </view>
+      <!-- 创建时间 -->
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          创建时间
+        </view>
+        <view class="yd-search-form-date-range-container">
+          <view class="flex-1" @click="visibleCreateTime[0] = true">
+            <view class="yd-search-form-date-range-picker">
+              {{ formatDate(formData.createTime?.[0]) || '开始日期' }}
+            </view>
+          </view>
+          -
+          <view class="flex-1" @click="visibleCreateTime[1] = true">
+            <view class="yd-search-form-date-range-picker">
+              {{ formatDate(formData.createTime?.[1]) || '结束日期' }}
+            </view>
+          </view>
+        </view>
+        <wd-datetime-picker-view v-if="visibleCreateTime[0]" v-model="tempCreateTime[0]" type="date" />
+        <view v-if="visibleCreateTime[0]" class="yd-search-form-date-range-actions">
+          <wd-button size="small" plain @click="visibleCreateTime[0] = false">
+            取消
+          </wd-button>
+          <wd-button size="small" type="primary" @click="handleCreateTime0Confirm">
+            确定
+          </wd-button>
+        </view>
+        <wd-datetime-picker-view v-if="visibleCreateTime[1]" v-model="tempCreateTime[1]" type="date" />
+        <view v-if="visibleCreateTime[1]" class="yd-search-form-date-range-actions">
+          <wd-button size="small" plain @click="visibleCreateTime[1] = false">
+            取消
+          </wd-button>
+          <wd-button size="small" type="primary" @click="handleCreateTime1Confirm">
+            确定
+          </wd-button>
+        </view>
+      </view>
+      <view class="yd-search-form-actions">
+        <wd-button class="flex-1" plain @click="handleReset">
+          重置
+        </wd-button>
+        <wd-button class="flex-1" type="primary" @click="handleSearch">
+          搜索
+        </wd-button>
+      </view>
+    </view>
+  </wd-popup>
+</template>
+
+<script lang="ts" setup>
+import { computed, reactive, ref } from 'vue'
+import { getDictLabel, getIntDictOptions } from '@/hooks/useDict'
+import { getNavbarHeight } from '@/utils'
+import { DICT_TYPE } from '@/utils/constants'
+import { formatDate, formatDateRange } from '@/utils/date'
+
+const emit = defineEmits<{
+  search: [data: Record<string, any>]
+  reset: []
+}>()
+
+const visible = ref(false)
+const formData = reactive({
+  userId: undefined as string | undefined,
+  userType: -1,
+  templateCode: undefined as string | undefined,
+  templateType: -1,
+  createTime: [undefined, undefined] as [number | undefined, number | undefined],
+})
+
+/** 搜索条件 placeholder 拼接 */
+const placeholder = computed(() => {
+  const conditions: string[] = []
+  if (formData.userId) {
+    conditions.push(`用户:${formData.userId}`)
+  }
+  if (formData.userType !== -1) {
+    conditions.push(`类型:${getDictLabel(DICT_TYPE.USER_TYPE, formData.userType)}`)
+  }
+  if (formData.templateCode) {
+    conditions.push(`编码:${formData.templateCode}`)
+  }
+  if (formData.templateType !== -1) {
+    conditions.push(`模版:${getDictLabel(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE, formData.templateType)}`)
+  }
+  if (formData.createTime?.[0] && formData.createTime?.[1]) {
+    conditions.push(`时间:${formatDate(formData.createTime[0])}~${formatDate(formData.createTime[1])}`)
+  }
+  return conditions.length > 0 ? conditions.join(' | ') : '搜索站内信消息'
+})
+
+// 时间范围选择器状态
+const visibleCreateTime = ref<[boolean, boolean]>([false, false])
+const tempCreateTime = ref<[number, number]>([Date.now(), Date.now()])
+
+/** 创建时间[0]确认 */
+function handleCreateTime0Confirm() {
+  formData.createTime = [tempCreateTime.value[0], formData.createTime?.[1]]
+  visibleCreateTime.value[0] = false
+}
+
+/** 创建时间[1]确认 */
+function handleCreateTime1Confirm() {
+  formData.createTime = [formData.createTime?.[0], tempCreateTime.value[1]]
+  visibleCreateTime.value[1] = false
+}
+
+/** 搜索 */
+function handleSearch() {
+  visible.value = false
+  emit('search', {
+    userId: formData.userId || undefined,
+    userType: formData.userType === -1 ? undefined : formData.userType,
+    templateCode: formData.templateCode || undefined,
+    templateType: formData.templateType === -1 ? undefined : formData.templateType,
+    createTime: formatDateRange(formData.createTime),
+  })
+}
+
+/** 重置 */
+function handleReset() {
+  formData.userId = undefined
+  formData.userType = -1
+  formData.templateCode = undefined
+  formData.templateType = -1
+  formData.createTime = [undefined, undefined]
+  visible.value = false
+  emit('reset')
+}
+</script>

+ 147 - 0
src/pages-system/notify/components/template-list.vue

@@ -0,0 +1,147 @@
+<template>
+  <view>
+    <!-- 搜索组件 -->
+    <TemplateSearchForm @search="handleQuery" @reset="handleReset" />
+
+    <!-- 模板列表 -->
+    <view class="p-24rpx">
+      <view
+        v-for="item in list"
+        :key="item.id"
+        class="mb-24rpx overflow-hidden rounded-12rpx bg-white shadow-sm"
+        @click="handleDetail(item)"
+      >
+        <view class="p-24rpx">
+          <view class="mb-16rpx flex items-center justify-between">
+            <view class="text-32rpx text-[#333] font-semibold">
+              {{ item.name }}
+            </view>
+            <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="item.status" />
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx shrink-0 text-[#999]">模板编码:</text>
+            <text class="min-w-0 flex-1 truncate">{{ item.code }}</text>
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx shrink-0 text-[#999]">发送人名称:</text>
+            <text class="min-w-0 flex-1 truncate">{{ item.nickname || '-' }}</text>
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx shrink-0 text-[#999]">模板类型:</text>
+            <dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="item.type" />
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx shrink-0 text-[#999]">模板内容:</text>
+            <text class="min-w-0 flex-1 truncate">{{ item.content }}</text>
+          </view>
+          <view class="mb-12rpx flex items-center text-28rpx text-[#666]">
+            <text class="mr-8rpx text-[#999]">创建时间:</text>
+            <text>{{ formatDateTime(item.createTime) || '-' }}</text>
+          </view>
+        </view>
+      </view>
+
+      <!-- 加载更多 -->
+      <view v-if="loadMoreState !== 'loading' && list.length === 0" class="py-100rpx text-center">
+        <wd-status-tip image="content" tip="暂无站内信模板数据" />
+      </view>
+      <wd-loadmore
+        v-if="list.length > 0"
+        :state="loadMoreState"
+        @reload="loadMore"
+      />
+    </view>
+
+    <!-- 新增按钮 -->
+    <wd-fab
+      v-if="hasAccessByCodes(['system:notify-template:create'])"
+      position="right-bottom"
+      type="primary"
+      :expandable="false"
+      @click="handleAdd"
+    />
+  </view>
+</template>
+
+<script lang="ts" setup>
+import type { NotifyTemplate } from '@/api/system/notify/template'
+import type { LoadMoreState } from '@/http/types'
+import { ref } from 'vue'
+import { getNotifyTemplatePage } from '@/api/system/notify/template'
+import { useAccess } from '@/hooks/useAccess'
+import { DICT_TYPE } from '@/utils/constants'
+import { formatDateTime } from '@/utils/date'
+import TemplateSearchForm from './template-search-form.vue'
+
+const { hasAccessByCodes } = useAccess()
+const total = ref(0)
+const list = ref<NotifyTemplate[]>([])
+const loadMoreState = ref<LoadMoreState>('loading')
+const queryParams = ref({
+  pageNo: 1,
+  pageSize: 10,
+})
+
+/** 查询列表 */
+async function getList() {
+  loadMoreState.value = 'loading'
+  try {
+    const data = await getNotifyTemplatePage(queryParams.value)
+    list.value = [...list.value, ...data.list]
+    total.value = data.total
+    loadMoreState.value = list.value.length >= total.value ? 'finished' : 'loading'
+  } catch {
+    queryParams.value.pageNo = queryParams.value.pageNo > 1 ? queryParams.value.pageNo - 1 : 1
+    loadMoreState.value = 'error'
+  }
+}
+
+/** 搜索按钮操作 */
+function handleQuery(data?: Record<string, any>) {
+  queryParams.value = {
+    ...data,
+    pageNo: 1,
+    pageSize: queryParams.value.pageSize,
+  }
+  list.value = []
+  getList()
+}
+
+/** 重置按钮操作 */
+function handleReset() {
+  handleQuery()
+}
+
+/** 加载更多 */
+function loadMore() {
+  if (loadMoreState.value === 'finished') {
+    return
+  }
+  queryParams.value.pageNo++
+  getList()
+}
+
+/** 新增 */
+function handleAdd() {
+  uni.navigateTo({
+    url: '/pages-system/notify/template/form/index',
+  })
+}
+
+/** 查看详情 */
+function handleDetail(item: NotifyTemplate) {
+  uni.navigateTo({
+    url: `/pages-system/notify/template/detail/index?id=${item.id}`,
+  })
+}
+
+/** 触底加载更多 */
+onReachBottom(() => {
+  loadMore()
+})
+
+/** 初始化 */
+onMounted(() => {
+  getList()
+})
+</script>

+ 197 - 0
src/pages-system/notify/components/template-search-form.vue

@@ -0,0 +1,197 @@
+<template>
+  <!-- 搜索框入口 -->
+  <view @click="visible = true">
+    <wd-search :placeholder="placeholder" hide-cancel disabled />
+  </view>
+
+  <!-- 搜索弹窗 -->
+  <wd-popup v-model="visible" position="top" @close="visible = false">
+    <view class="yd-search-form-container" :style="{ paddingTop: `${getNavbarHeight()}px` }">
+      <!-- 模板名称 -->
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          模板名称
+        </view>
+        <wd-input
+          v-model="formData.name"
+          placeholder="请输入模板名称"
+          clearable
+        />
+      </view>
+      <!-- 模板编码 -->
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          模板编码
+        </view>
+        <wd-input
+          v-model="formData.code"
+          placeholder="请输入模板编码"
+          clearable
+        />
+      </view>
+      <!-- 状态 -->
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          状态
+        </view>
+        <wd-radio-group v-model="formData.status" shape="button">
+          <wd-radio :value="-1">
+            全部
+          </wd-radio>
+          <wd-radio
+            v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
+            :key="dict.value"
+            :value="dict.value"
+          >
+            {{ dict.label }}
+          </wd-radio>
+        </wd-radio-group>
+      </view>
+      <!-- 模板类型 -->
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          模板类型
+        </view>
+        <wd-radio-group v-model="formData.type" shape="button">
+          <wd-radio :value="-1">
+            全部
+          </wd-radio>
+          <wd-radio
+            v-for="dict in getIntDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE)"
+            :key="dict.value"
+            :value="dict.value"
+          >
+            {{ dict.label }}
+          </wd-radio>
+        </wd-radio-group>
+      </view>
+      <!-- 创建时间 -->
+      <view class="yd-search-form-item">
+        <view class="yd-search-form-label">
+          创建时间
+        </view>
+        <view class="yd-search-form-date-range-container">
+          <view class="flex-1" @click="visibleCreateTime[0] = true">
+            <view class="yd-search-form-date-range-picker">
+              {{ formatDate(formData.createTime?.[0]) || '开始日期' }}
+            </view>
+          </view>
+          -
+          <view class="flex-1" @click="visibleCreateTime[1] = true">
+            <view class="yd-search-form-date-range-picker">
+              {{ formatDate(formData.createTime?.[1]) || '结束日期' }}
+            </view>
+          </view>
+        </view>
+        <wd-datetime-picker-view v-if="visibleCreateTime[0]" v-model="tempCreateTime[0]" type="date" />
+        <view v-if="visibleCreateTime[0]" class="yd-search-form-date-range-actions">
+          <wd-button size="small" plain @click="visibleCreateTime[0] = false">
+            取消
+          </wd-button>
+          <wd-button size="small" type="primary" @click="handleCreateTime0Confirm">
+            确定
+          </wd-button>
+        </view>
+        <wd-datetime-picker-view v-if="visibleCreateTime[1]" v-model="tempCreateTime[1]" type="date" />
+        <view v-if="visibleCreateTime[1]" class="yd-search-form-date-range-actions">
+          <wd-button size="small" plain @click="visibleCreateTime[1] = false">
+            取消
+          </wd-button>
+          <wd-button size="small" type="primary" @click="handleCreateTime1Confirm">
+            确定
+          </wd-button>
+        </view>
+      </view>
+      <view class="yd-search-form-actions">
+        <wd-button class="flex-1" plain @click="handleReset">
+          重置
+        </wd-button>
+        <wd-button class="flex-1" type="primary" @click="handleSearch">
+          搜索
+        </wd-button>
+      </view>
+    </view>
+  </wd-popup>
+</template>
+
+<script lang="ts" setup>
+import { computed, reactive, ref } from 'vue'
+import { getDictLabel, getIntDictOptions } from '@/hooks/useDict'
+import { getNavbarHeight } from '@/utils'
+import { DICT_TYPE } from '@/utils/constants'
+import { formatDate, formatDateRange } from '@/utils/date'
+
+const emit = defineEmits<{
+  search: [data: Record<string, any>]
+  reset: []
+}>()
+
+const visible = ref(false)
+const formData = reactive({
+  name: undefined as string | undefined,
+  code: undefined as string | undefined,
+  status: -1,
+  type: -1,
+  createTime: [undefined, undefined] as [number | undefined, number | undefined],
+})
+
+/** 搜索条件 placeholder 拼接 */
+const placeholder = computed(() => {
+  const conditions: string[] = []
+  if (formData.name) {
+    conditions.push(`名称:${formData.name}`)
+  }
+  if (formData.code) {
+    conditions.push(`编码:${formData.code}`)
+  }
+  if (formData.status !== -1) {
+    conditions.push(`状态:${getDictLabel(DICT_TYPE.COMMON_STATUS, formData.status)}`)
+  }
+  if (formData.type !== -1) {
+    conditions.push(`类型:${getDictLabel(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE, formData.type)}`)
+  }
+  if (formData.createTime?.[0] && formData.createTime?.[1]) {
+    conditions.push(`时间:${formatDate(formData.createTime[0])}~${formatDate(formData.createTime[1])}`)
+  }
+  return conditions.length > 0 ? conditions.join(' | ') : '搜索站内信模板'
+})
+
+// 时间范围选择器状态
+const visibleCreateTime = ref<[boolean, boolean]>([false, false])
+const tempCreateTime = ref<[number, number]>([Date.now(), Date.now()])
+
+/** 创建时间[0]确认 */
+function handleCreateTime0Confirm() {
+  formData.createTime = [tempCreateTime.value[0], formData.createTime?.[1]]
+  visibleCreateTime.value[0] = false
+}
+
+/** 创建时间[1]确认 */
+function handleCreateTime1Confirm() {
+  formData.createTime = [formData.createTime?.[0], tempCreateTime.value[1]]
+  visibleCreateTime.value[1] = false
+}
+
+/** 搜索 */
+function handleSearch() {
+  visible.value = false
+  emit('search', {
+    name: formData.name || undefined,
+    code: formData.code || undefined,
+    status: formData.status === -1 ? undefined : formData.status,
+    type: formData.type === -1 ? undefined : formData.type,
+    createTime: formatDateRange(formData.createTime),
+  })
+}
+
+/** 重置 */
+function handleReset() {
+  formData.name = undefined
+  formData.code = undefined
+  formData.status = -1
+  formData.type = -1
+  formData.createTime = [undefined, undefined]
+  visible.value = false
+  emit('reset')
+}
+</script>

+ 52 - 0
src/pages-system/notify/index.vue

@@ -0,0 +1,52 @@
+<template>
+  <view class="yd-page-container">
+    <!-- 顶部导航栏 -->
+    <wd-navbar
+      title="站内信管理"
+      left-arrow placeholder safe-area-inset-top fixed
+      @click-left="handleBack"
+    />
+
+    <!-- Tab 切换 -->
+    <view class="bg-white">
+      <wd-tabs v-model="tabIndex" shrink @change="handleTabChange">
+        <wd-tab title="站内信模板" />
+        <wd-tab title="站内信消息" />
+      </wd-tabs>
+    </view>
+    <!-- 列表内容 -->
+    <TemplateList v-show="tabType === 'template'" />
+    <MessageList v-show="tabType === 'message'" />
+  </view>
+</template>
+
+<script lang="ts" setup>
+import { computed, ref } from 'vue'
+import { navigateBackPlus } from '@/utils'
+import MessageList from './components/message-list.vue'
+import TemplateList from './components/template-list.vue'
+
+definePage({
+  style: {
+    navigationBarTitleText: '',
+    navigationStyle: 'custom',
+  },
+})
+
+const tabTypes: string[] = ['template', 'message']
+const tabIndex = ref(0)
+const tabType = computed<string>(() => tabTypes[tabIndex.value])
+
+/** Tab 切换 */
+function handleTabChange({ index }: { index: number }) {
+  tabIndex.value = index
+}
+
+/** 返回上一页 */
+function handleBack() {
+  navigateBackPlus()
+}
+</script>
+
+<style lang="scss" scoped>
+</style>

+ 96 - 0
src/pages-system/notify/message/detail/index.vue

@@ -0,0 +1,96 @@
+<template>
+  <view class="yd-page-container">
+    <!-- 顶部导航栏 -->
+    <wd-navbar
+      title="站内信详情"
+      left-arrow placeholder safe-area-inset-top fixed
+      @click-left="handleBack"
+    />
+
+    <!-- 详情内容 -->
+    <view>
+      <wd-cell-group border>
+        <wd-cell title="编号" :value="String(formData?.id ?? '-')" />
+        <wd-cell title="用户类型">
+          <dict-tag :type="DICT_TYPE.USER_TYPE" :value="formData?.userType" />
+        </wd-cell>
+        <wd-cell title="用户编号" :value="String(formData?.userId ?? '-')" />
+        <wd-cell title="模版编号" :value="String(formData?.templateId ?? '-')" />
+        <wd-cell title="模板编码" :value="String(formData?.templateCode ?? '-')" />
+        <wd-cell title="发送人名称" :value="String(formData?.templateNickname ?? '-')" />
+        <wd-cell title="模版内容" :value="String(formData?.templateContent ?? '-')" />
+        <wd-cell title="模版参数" :value="formatTemplateParams(formData?.templateParams)" />
+        <wd-cell title="模版类型">
+          <dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="formData?.templateType" />
+        </wd-cell>
+        <wd-cell title="是否已读">
+          <dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="formData?.readStatus" />
+        </wd-cell>
+        <wd-cell title="阅读时间" :value="formatDateTime(formData?.readTime) || '-'" />
+        <wd-cell title="创建时间" :value="formatDateTime(formData?.createTime) || '-'" />
+      </wd-cell-group>
+    </view>
+  </view>
+</template>
+
+<script lang="ts" setup>
+import type { NotifyMessage } from '@/api/system/notify/message'
+import { onMounted, ref } from 'vue'
+import { useToast } from 'wot-design-uni'
+import { getNotifyMessage } from '@/api/system/notify/message'
+import { navigateBackPlus } from '@/utils'
+import { DICT_TYPE } from '@/utils/constants'
+import { formatDateTime } from '@/utils/date'
+
+const props = defineProps<{
+  id?: number | any
+}>()
+
+definePage({
+  style: {
+    navigationBarTitleText: '',
+    navigationStyle: 'custom',
+  },
+})
+
+const toast = useToast()
+const formData = ref<NotifyMessage>()
+
+/** 返回上一页 */
+function handleBack() {
+  navigateBackPlus('/pages-system/notify/index')
+}
+
+/** 格式化模版参数 */
+function formatTemplateParams(params: any) {
+  if (!params) {
+    return '-'
+  }
+  try {
+    return typeof params === 'string' ? params : JSON.stringify(params)
+  } catch {
+    return '-'
+  }
+}
+
+/** 加载详情 */
+async function getDetail() {
+  if (!props.id) {
+    return
+  }
+  try {
+    toast.loading('加载中...')
+    formData.value = await getNotifyMessage(Number(props.id))
+  } finally {
+    toast.close()
+  }
+}
+
+/** 初始化 */
+onMounted(() => {
+  getDetail()
+})
+</script>
+
+<style lang="scss" scoped>
+</style>

+ 190 - 0
src/pages-system/notify/template/detail/components/send-form.vue

@@ -0,0 +1,190 @@
+<template>
+  <!-- TODO @芋艿:【优化】底部操作的样式 -->
+  <wd-popup v-model="visible" position="bottom" closable custom-style="border-radius: 16rpx 16rpx 0 0;">
+    <view class="p-24rpx">
+      <view class="mb-24rpx text-32rpx text-[#333] font-semibold">
+        发送测试站内信
+      </view>
+      <wd-form ref="sendFormRef" :model="sendFormData" :rules="sendFormRules">
+        <wd-cell-group border>
+          <wd-textarea
+            v-model="sendFormData.content"
+            label="模板内容"
+            label-width="180rpx"
+            disabled
+            :rows="3"
+          />
+          <!-- 用户类型 -->
+          <wd-cell title="用户类型" title-width="180rpx" prop="userType" center>
+            <wd-radio-group v-model="sendFormData.userType" shape="button">
+              <wd-radio
+                v-for="dict in getIntDictOptions(DICT_TYPE.USER_TYPE)"
+                :key="dict.value"
+                :value="dict.value"
+              >
+                {{ dict.label }}
+              </wd-radio>
+            </wd-radio-group>
+          </wd-cell>
+          <!-- 会员用户:输入用户编号 -->
+          <wd-input
+            v-if="sendFormData.userType === UserTypeEnum.MEMBER"
+            v-model="sendFormData.userId"
+            label="接收人 ID"
+            label-width="180rpx"
+            prop="userId"
+            clearable
+            placeholder="请输入用户编号"
+          />
+          <!-- 管理员用户:选择用户 -->
+          <wd-cell
+            v-if="sendFormData.userType === UserTypeEnum.ADMIN"
+            title="接收人"
+            title-width="180rpx"
+            prop="userId"
+            center
+          >
+            <wd-picker
+              v-model="sendFormData.userId"
+              :columns="userOptions"
+              placeholder="请选择接收人"
+            />
+          </wd-cell>
+          <!-- 动态参数 -->
+          <template v-for="param in template?.params" :key="param">
+            <wd-input
+              v-model="sendFormData.templateParams[param]"
+              :label="`参数 ${param}`"
+              label-width="180rpx"
+              :prop="`templateParams.${param}`"
+              clearable
+              :placeholder="`请输入参数 ${param}`"
+            />
+          </template>
+        </wd-cell-group>
+      </wd-form>
+      <view class="mt-24rpx">
+        <wd-button type="primary" block :loading="sendLoading" @click="handleSendSubmit">
+          发送
+        </wd-button>
+      </view>
+    </view>
+  </wd-popup>
+</template>
+
+<script lang="ts" setup>
+import type { NotifyTemplate } from '@/api/system/notify/template'
+import type { User } from '@/api/system/user'
+import { computed, ref, watch } from 'vue'
+import { useToast } from 'wot-design-uni'
+import { sendNotify } from '@/api/system/notify/template'
+import { getSimpleUserList } from '@/api/system/user'
+import { getIntDictOptions } from '@/hooks/useDict'
+import { DICT_TYPE, UserTypeEnum } from '@/utils/constants'
+
+const props = defineProps<{
+  modelValue: boolean
+  template?: NotifyTemplate
+}>()
+
+const emit = defineEmits<{
+  'update:modelValue': [value: boolean]
+  'success': []
+}>()
+
+const toast = useToast()
+
+const visible = computed({
+  get() {
+    return props.modelValue
+  },
+  set(value: boolean) {
+    emit('update:modelValue', value)
+  },
+})
+
+const sendLoading = ref(false)
+const sendFormRef = ref<any>()
+const sendFormData = ref({
+  content: '',
+  userType: UserTypeEnum.MEMBER,
+  userId: undefined as number | string | undefined,
+  templateParams: {} as Record<string, string>,
+})
+
+/** 用户列表 */
+const userList = ref<User[]>([])
+const userOptions = computed(() => {
+  return userList.value.map(item => ({
+    value: item.id,
+    label: item.nickname,
+  }))
+})
+
+/** 发送表单校验规则 */
+const sendFormRules = computed(() => {
+  const rules: Record<string, any> = {
+    userType: [{ required: true, message: '用户类型不能为空' }],
+    userId: [{ required: true, message: '接收人不能为空' }],
+  }
+  if (props.template?.params) {
+    props.template.params.forEach((param) => {
+      rules[`templateParams.${param}`] = [{ required: true, message: `参数 ${param} 不能为空` }]
+    })
+  }
+  return rules
+})
+
+/** 加载用户列表 */
+async function loadUserList() {
+  userList.value = await getSimpleUserList()
+}
+
+/** 初始化发送表单 */
+function initSendForm() {
+  sendFormData.value = {
+    content: props.template?.content || '',
+    userType: UserTypeEnum.MEMBER,
+    userId: undefined,
+    templateParams: {},
+  }
+  if (props.template?.params) {
+    props.template.params.forEach((param) => {
+      sendFormData.value.templateParams[param] = ''
+    })
+  }
+}
+
+watch(
+  () => props.modelValue,
+  (val) => {
+    if (val) {
+      initSendForm()
+      loadUserList()
+    }
+  },
+)
+
+/** 提交发送 */
+async function handleSendSubmit() {
+  const { valid } = await sendFormRef.value.validate()
+  if (!valid) {
+    return
+  }
+
+  sendLoading.value = true
+  try {
+    await sendNotify({
+      userId: Number(sendFormData.value.userId),
+      userType: sendFormData.value.userType,
+      templateCode: props.template?.code || '',
+      templateParams: sendFormData.value.templateParams,
+    })
+    toast.success('站内信发送成功')
+    emit('success')
+    visible.value = false
+  } finally {
+    sendLoading.value = false
+  }
+}
+</script>

+ 151 - 0
src/pages-system/notify/template/detail/index.vue

@@ -0,0 +1,151 @@
+<template>
+  <view class="yd-page-container">
+    <!-- 顶部导航栏 -->
+    <wd-navbar
+      title="站内信模板详情"
+      left-arrow placeholder safe-area-inset-top fixed
+      @click-left="handleBack"
+    />
+
+    <!-- 详情内容 -->
+    <view>
+      <wd-cell-group border>
+        <wd-cell title="模板编号" :value="String(formData?.id ?? '-')" />
+        <wd-cell title="模板名称" :value="String(formData?.name ?? '-')" />
+        <wd-cell title="模板编码" :value="String(formData?.code ?? '-')" />
+        <wd-cell title="发送人名称" :value="String(formData?.nickname ?? '-')" />
+        <wd-cell title="模板类型">
+          <dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="formData?.type" />
+        </wd-cell>
+        <wd-cell title="状态">
+          <dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="formData?.status" />
+        </wd-cell>
+        <wd-cell title="模板内容" :value="String(formData?.content ?? '-')" />
+        <wd-cell title="备注" :value="String(formData?.remark ?? '-')" />
+        <wd-cell title="创建时间" :value="formatDateTime(formData?.createTime) || '-'" />
+      </wd-cell-group>
+    </view>
+
+    <!-- 发送测试站内信弹窗 -->
+    <SendForm v-model="sendVisible" :template="formData" />
+
+    <!-- 底部操作按钮 -->
+    <view class="fixed bottom-0 left-0 right-0 bg-white p-24rpx">
+      <view class="w-full flex gap-24rpx">
+        <wd-button
+          v-if="hasAccessByCodes(['system:notify-template:send-notify'])"
+          class="flex-1" type="primary" @click="handleSendTest"
+        >
+          测试
+        </wd-button>
+        <wd-button
+          v-if="hasAccessByCodes(['system:notify-template:update'])"
+          class="flex-1" type="warning" @click="handleEdit"
+        >
+          编辑
+        </wd-button>
+        <wd-button
+          v-if="hasAccessByCodes(['system:notify-template:delete'])"
+          class="flex-1" type="error" :loading="deleting" @click="handleDelete"
+        >
+          删除
+        </wd-button>
+      </view>
+    </view>
+  </view>
+</template>
+
+<script lang="ts" setup>
+import type { NotifyTemplate } from '@/api/system/notify/template'
+import { onMounted, ref } from 'vue'
+import { useToast } from 'wot-design-uni'
+import { deleteNotifyTemplate, getNotifyTemplate } from '@/api/system/notify/template'
+import { useAccess } from '@/hooks/useAccess'
+import { navigateBackPlus } from '@/utils'
+import { DICT_TYPE } from '@/utils/constants'
+import { formatDateTime } from '@/utils/date'
+import SendForm from './components/send-form.vue'
+
+const props = defineProps<{
+  id?: number | any
+}>()
+
+definePage({
+  style: {
+    navigationBarTitleText: '',
+    navigationStyle: 'custom',
+  },
+})
+
+const { hasAccessByCodes } = useAccess()
+const toast = useToast()
+const formData = ref<NotifyTemplate>()
+const deleting = ref(false)
+
+// 发送测试站内信相关
+const sendVisible = ref(false)
+
+/** 返回上一页 */
+function handleBack() {
+  navigateBackPlus('/pages-system/notify/index')
+}
+
+/** 加载详情 */
+async function getDetail() {
+  if (!props.id) {
+    return
+  }
+  try {
+    toast.loading('加载中...')
+    formData.value = await getNotifyTemplate(props.id)
+  } finally {
+    toast.close()
+  }
+}
+
+/** 编辑 */
+function handleEdit() {
+  uni.navigateTo({
+    url: `/pages-system/notify/template/form/index?id=${props.id}`,
+  })
+}
+
+/** 删除 */
+function handleDelete() {
+  if (!props.id) {
+    return
+  }
+  uni.showModal({
+    title: '提示',
+    content: '确定要删除该站内信模板吗?',
+    success: async (res) => {
+      if (!res.confirm) {
+        return
+      }
+      deleting.value = true
+      try {
+        await deleteNotifyTemplate(props.id)
+        toast.success('删除成功')
+        setTimeout(() => {
+          handleBack()
+        }, 500)
+      } finally {
+        deleting.value = false
+      }
+    },
+  })
+}
+
+/** 打开发送测试站内信弹窗 */
+function handleSendTest() {
+  sendVisible.value = true
+}
+
+/** 初始化 */
+onMounted(() => {
+  getDetail()
+})
+</script>
+
+<style lang="scss" scoped>
+</style>

+ 186 - 0
src/pages-system/notify/template/form/index.vue

@@ -0,0 +1,186 @@
+<template>
+  <view class="yd-page-container">
+    <!-- 顶部导航栏 -->
+    <wd-navbar
+      :title="getTitle"
+      left-arrow placeholder safe-area-inset-top fixed
+      @click-left="handleBack"
+    />
+
+    <!-- 表单区域 -->
+    <view>
+      <wd-form ref="formRef" :model="formData" :rules="formRules">
+        <wd-cell-group border>
+          <wd-input
+            v-model="formData.name"
+            label="模板名称"
+            label-width="200rpx"
+            prop="name"
+            clearable
+            placeholder="请输入模板名称"
+          />
+          <wd-input
+            v-model="formData.code"
+            label="模板编码"
+            label-width="200rpx"
+            prop="code"
+            clearable
+            placeholder="请输入模板编码"
+          />
+          <wd-input
+            v-model="formData.nickname"
+            label="发送人名称"
+            label-width="200rpx"
+            prop="nickname"
+            clearable
+            placeholder="请输入发送人名称"
+          />
+          <wd-cell title="模板类型" title-width="200rpx" prop="type" center>
+            <wd-picker
+              v-model="formData.type"
+              :columns="templateTypeOptions"
+              placeholder="请选择模板类型"
+            />
+          </wd-cell>
+          <wd-cell title="状态" title-width="200rpx" prop="status" center>
+            <wd-radio-group v-model="formData.status" shape="button">
+              <wd-radio
+                v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)"
+                :key="dict.value"
+                :value="dict.value"
+              >
+                {{ dict.label }}
+              </wd-radio>
+            </wd-radio-group>
+          </wd-cell>
+          <wd-textarea
+            v-model="formData.content"
+            label="模板内容"
+            label-width="200rpx"
+            prop="content"
+            clearable
+            placeholder="请输入模板内容"
+            :rows="4"
+          />
+          <wd-textarea
+            v-model="formData.remark"
+            label="备注"
+            label-width="200rpx"
+            prop="remark"
+            clearable
+            placeholder="请输入备注"
+          />
+        </wd-cell-group>
+      </wd-form>
+    </view>
+
+    <!-- 底部保存按钮 -->
+    <view class="fixed bottom-0 left-0 right-0 bg-white p-24rpx">
+      <wd-button
+        type="primary"
+        block
+        :loading="formLoading"
+        @click="handleSubmit"
+      >
+        保存
+      </wd-button>
+    </view>
+  </view>
+</template>
+
+<script lang="ts" setup>
+import type { NotifyTemplate } from '@/api/system/notify/template'
+import { computed, onMounted, ref } from 'vue'
+import { useToast } from 'wot-design-uni'
+import { createNotifyTemplate, getNotifyTemplate, updateNotifyTemplate } from '@/api/system/notify/template'
+import { getIntDictOptions } from '@/hooks/useDict'
+import { navigateBackPlus } from '@/utils'
+import { DICT_TYPE } from '@/utils/constants'
+
+const props = defineProps<{
+  id?: number | any
+}>()
+
+definePage({
+  style: {
+    navigationBarTitleText: '',
+    navigationStyle: 'custom',
+  },
+})
+
+const toast = useToast()
+const getTitle = computed(() => props.id ? '编辑站内信模板' : '新增站内信模板')
+const formLoading = ref(false)
+const formData = ref<NotifyTemplate>({
+  id: undefined,
+  name: '',
+  code: '',
+  nickname: '',
+  content: '',
+  type: undefined,
+  status: 0,
+  remark: '',
+})
+const formRules = {
+  name: [{ required: true, message: '模板名称不能为空' }],
+  code: [{ required: true, message: '模板编码不能为空' }],
+  nickname: [{ required: true, message: '发送人名称不能为空' }],
+  type: [{ required: true, message: '模板类型不能为空' }],
+  status: [{ required: true, message: '状态不能为空' }],
+  content: [{ required: true, message: '模板内容不能为空' }],
+}
+const formRef = ref()
+
+/** 模板类型选项 */
+const templateTypeOptions = computed(() => {
+  return getIntDictOptions(DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE).map(item => ({
+    value: item.value,
+    label: item.label,
+  }))
+})
+
+/** 返回上一页 */
+function handleBack() {
+  navigateBackPlus('/pages-system/notify/index')
+}
+
+/** 加载详情 */
+async function getDetail() {
+  if (!props.id) {
+    return
+  }
+  formData.value = await getNotifyTemplate(props.id)
+}
+
+/** 提交表单 */
+async function handleSubmit() {
+  const { valid } = await formRef.value.validate()
+  if (!valid) {
+    return
+  }
+
+  formLoading.value = true
+  try {
+    if (props.id) {
+      await updateNotifyTemplate(formData.value)
+      toast.success('修改成功')
+    } else {
+      await createNotifyTemplate(formData.value)
+      toast.success('新增成功')
+    }
+    setTimeout(() => {
+      handleBack()
+    }, 500)
+  } finally {
+    formLoading.value = false
+  }
+}
+
+/** 初始化 */
+onMounted(() => {
+  getDetail()
+})
+</script>
+
+<style lang="scss" scoped>
+</style>

+ 8 - 0
src/pages/index/index.ts

@@ -109,6 +109,14 @@ const menuGroupsData: MenuGroup[] = [
         iconColor: '#40a9ff',
         permission: 'system:mail-account:query',
       },
+      {
+        key: 'notify',
+        name: '站内信管理',
+        icon: 'bell',
+        url: '/pages-system/notify/index',
+        iconColor: '#ff85c0',
+        permission: 'system:notify-template:query',
+      },
     ],
   },
   {

+ 1 - 1
src/pages/message/components/detail-popup.vue

@@ -58,7 +58,7 @@
 </template>
 
 <script lang="ts" setup>
-import type { NotifyMessage } from '@/api/system/notify'
+import type { NotifyMessage } from '@/api/system/notify/message'
 import { ref } from 'vue'
 import { getDictLabel } from '@/hooks/useDict'
 import { DICT_TYPE } from '@/utils/constants'

+ 2 - 2
src/pages/message/index.vue

@@ -76,7 +76,7 @@
 </template>
 
 <script lang="ts" setup>
-import type { NotifyMessage } from '@/api/system/notify'
+import type { NotifyMessage } from '@/api/system/notify/message'
 import type { LoadMoreState } from '@/http/types'
 import { onReachBottom } from '@dcloudio/uni-app'
 import { onMounted, ref } from 'vue'
@@ -85,7 +85,7 @@ import {
   getMyNotifyMessagePage,
   updateAllNotifyMessageRead,
   updateNotifyMessageRead,
-} from '@/api/system/notify'
+} from '@/api/system/notify/message'
 import { getDictLabel } from '@/hooks/useDict'
 import { DICT_TYPE } from '@/utils/constants'
 import { formatDateTime } from '@/utils/date'