提交 | 用户 | 时间
|
820397
|
1 |
<template> |
H |
2 |
<!-- 搜索工作栏 --> |
|
3 |
<ContentWrap> |
|
4 |
<el-form |
|
5 |
class="-mb-15px" |
|
6 |
:model="queryParams" |
|
7 |
ref="queryFormRef" |
|
8 |
:inline="true" |
|
9 |
label-width="68px" |
|
10 |
> |
|
11 |
<el-form-item label="模板名称" prop="name"> |
|
12 |
<el-input |
|
13 |
v-model="queryParams.name" |
|
14 |
placeholder="请输入模板名称" |
|
15 |
clearable |
|
16 |
@keyup.enter="handleQuery" |
|
17 |
class="!w-240px" |
|
18 |
/> |
|
19 |
</el-form-item> |
|
20 |
<el-form-item label="模板编号" prop="code"> |
|
21 |
<el-input |
|
22 |
v-model="queryParams.code" |
|
23 |
placeholder="请输入模版编码" |
|
24 |
clearable |
|
25 |
@keyup.enter="handleQuery" |
|
26 |
class="!w-240px" |
|
27 |
/> |
|
28 |
</el-form-item> |
|
29 |
<el-form-item label="状态" prop="status"> |
|
30 |
<el-select |
|
31 |
v-model="queryParams.status" |
|
32 |
placeholder="请选择开启状态" |
|
33 |
clearable |
|
34 |
class="!w-240px" |
|
35 |
> |
|
36 |
<el-option |
|
37 |
v-for="dict in getIntDictOptions(DICT_TYPE.COMMON_STATUS)" |
|
38 |
:key="dict.value" |
|
39 |
:label="dict.label" |
|
40 |
:value="dict.value" |
|
41 |
/> |
|
42 |
</el-select> |
|
43 |
</el-form-item> |
|
44 |
<el-form-item label="创建时间" prop="createTime"> |
|
45 |
<el-date-picker |
|
46 |
v-model="queryParams.createTime" |
|
47 |
value-format="YYYY-MM-DD HH:mm:ss" |
|
48 |
type="daterange" |
|
49 |
start-placeholder="开始日期" |
|
50 |
end-placeholder="结束日期" |
|
51 |
:default-time="[new Date('1 00:00:00'), new Date('1 23:59:59')]" |
|
52 |
class="!w-240px" |
|
53 |
/> |
|
54 |
</el-form-item> |
|
55 |
<el-form-item> |
|
56 |
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> |
|
57 |
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> |
|
58 |
<el-button |
|
59 |
type="primary" |
|
60 |
plain |
|
61 |
@click="openForm('create')" |
|
62 |
v-hasPermi="['system:notify-template:create']" |
|
63 |
> |
|
64 |
<Icon icon="ep:plus" class="mr-5px" />新增 |
|
65 |
</el-button> |
|
66 |
</el-form-item> |
|
67 |
</el-form> |
|
68 |
</ContentWrap> |
|
69 |
|
|
70 |
<!-- 列表 --> |
|
71 |
<ContentWrap> |
|
72 |
<el-table v-loading="loading" :data="list"> |
|
73 |
<el-table-column |
|
74 |
label="模板编码" |
|
75 |
align="center" |
|
76 |
prop="code" |
|
77 |
width="120" |
|
78 |
:show-overflow-tooltip="true" |
|
79 |
/> |
|
80 |
<el-table-column |
|
81 |
label="模板名称" |
|
82 |
align="center" |
|
83 |
prop="name" |
|
84 |
width="120" |
|
85 |
:show-overflow-tooltip="true" |
|
86 |
/> |
|
87 |
<el-table-column label="类型" align="center" prop="type"> |
|
88 |
<template #default="scope"> |
|
89 |
<dict-tag :type="DICT_TYPE.SYSTEM_NOTIFY_TEMPLATE_TYPE" :value="scope.row.type" /> |
|
90 |
</template> |
|
91 |
</el-table-column> |
|
92 |
<el-table-column label="发送人名称" align="center" prop="nickname" /> |
|
93 |
<el-table-column |
|
94 |
label="模板内容" |
|
95 |
align="center" |
|
96 |
prop="content" |
|
97 |
width="200" |
|
98 |
:show-overflow-tooltip="true" |
|
99 |
/> |
|
100 |
<el-table-column label="开启状态" align="center" prop="status" width="80"> |
|
101 |
<template #default="scope"> |
|
102 |
<dict-tag :type="DICT_TYPE.COMMON_STATUS" :value="scope.row.status" /> |
|
103 |
</template> |
|
104 |
</el-table-column> |
|
105 |
<el-table-column label="备注" align="center" prop="remark" /> |
|
106 |
<el-table-column |
|
107 |
label="创建时间" |
|
108 |
align="center" |
|
109 |
prop="createTime" |
|
110 |
width="180" |
|
111 |
:formatter="dateFormatter" |
|
112 |
/> |
|
113 |
<el-table-column label="操作" align="center" width="210" fixed="right"> |
|
114 |
<template #default="scope"> |
|
115 |
<el-button |
|
116 |
link |
|
117 |
type="primary" |
|
118 |
@click="openForm('update', scope.row.id)" |
|
119 |
v-hasPermi="['system:notify-template:update']" |
|
120 |
> |
|
121 |
修改 |
|
122 |
</el-button> |
|
123 |
<el-button |
|
124 |
link |
|
125 |
type="primary" |
|
126 |
@click="openSendForm(scope.row)" |
|
127 |
v-hasPermi="['system:notify-template:send-notify']" |
|
128 |
> |
|
129 |
测试 |
|
130 |
</el-button> |
|
131 |
<el-button |
|
132 |
link |
|
133 |
type="danger" |
|
134 |
@click="handleDelete(scope.row.id)" |
|
135 |
v-hasPermi="['system:notify-template:delete']" |
|
136 |
> |
|
137 |
删除 |
|
138 |
</el-button> |
|
139 |
</template> |
|
140 |
</el-table-column> |
|
141 |
</el-table> |
|
142 |
<!-- 分页 --> |
|
143 |
<Pagination |
|
144 |
:total="total" |
|
145 |
v-model:page="queryParams.pageNo" |
|
146 |
v-model:limit="queryParams.pageSize" |
|
147 |
@pagination="getList" |
|
148 |
/> |
|
149 |
</ContentWrap> |
|
150 |
|
|
151 |
<!-- 表单弹窗:添加/修改 --> |
|
152 |
<NotifyTemplateForm ref="formRef" @success="getList" /> |
|
153 |
<!-- 表单弹窗:测试发送 --> |
|
154 |
<NotifyTemplateSendForm ref="sendFormRef" /> |
|
155 |
</template> |
|
156 |
<script lang="ts" setup> |
|
157 |
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' |
|
158 |
import { dateFormatter } from '@/utils/formatTime' |
|
159 |
import * as NotifyTemplateApi from '@/api/system/notify/template' |
|
160 |
import NotifyTemplateForm from './NotifyTemplateForm.vue' |
|
161 |
import NotifyTemplateSendForm from './NotifyTemplateSendForm.vue' |
|
162 |
|
|
163 |
defineOptions({ name: 'NotifySmsTemplate' }) |
|
164 |
|
|
165 |
const message = useMessage() // 消息弹窗 |
|
166 |
|
|
167 |
const loading = ref(false) // 列表的加载中 |
|
168 |
const total = ref(0) // 列表的总页数 |
|
169 |
const list = ref([]) // 列表的数据 |
|
170 |
const queryParams = reactive({ |
|
171 |
pageNo: 1, |
|
172 |
pageSize: 10, |
|
173 |
name: undefined, |
|
174 |
status: undefined, |
|
175 |
code: undefined, |
|
176 |
createTime: [] |
|
177 |
}) |
|
178 |
const queryFormRef = ref() // 搜索的表单 |
|
179 |
|
|
180 |
/** 查询列表 */ |
|
181 |
const getList = async () => { |
|
182 |
loading.value = true |
|
183 |
try { |
|
184 |
const data = await NotifyTemplateApi.getNotifyTemplatePage(queryParams) |
|
185 |
list.value = data.list |
|
186 |
total.value = data.total |
|
187 |
} finally { |
|
188 |
loading.value = false |
|
189 |
} |
|
190 |
} |
|
191 |
|
|
192 |
/** 搜索按钮操作 */ |
|
193 |
const handleQuery = () => { |
|
194 |
queryParams.pageNo = 1 |
|
195 |
getList() |
|
196 |
} |
|
197 |
|
|
198 |
/** 重置按钮操作 */ |
|
199 |
const resetQuery = () => { |
|
200 |
queryFormRef.value.resetFields() |
|
201 |
handleQuery() |
|
202 |
} |
|
203 |
|
|
204 |
/** 添加/修改操作 */ |
|
205 |
const formRef = ref() |
|
206 |
const openForm = (type: string, id?: number) => { |
|
207 |
formRef.value.open(type, id) |
|
208 |
} |
|
209 |
|
|
210 |
/** 删除按钮操作 */ |
|
211 |
const handleDelete = async (id: number) => { |
|
212 |
try { |
|
213 |
// 删除的二次确认 |
|
214 |
await message.delConfirm() |
|
215 |
// 发起删除 |
|
216 |
await NotifyTemplateApi.deleteNotifyTemplate(id) |
|
217 |
message.success('删除成功') |
|
218 |
// 刷新列表 |
|
219 |
await getList() |
|
220 |
} catch {} |
|
221 |
} |
|
222 |
|
|
223 |
/** 发送站内信按钮 */ |
|
224 |
const sendFormRef = ref() // 表单 Ref |
|
225 |
const openSendForm = (row: NotifyTemplateApi.NotifyTemplateVO) => { |
|
226 |
sendFormRef.value.open(row.id) |
|
227 |
} |
|
228 |
|
|
229 |
/** 初始化 **/ |
|
230 |
onMounted(() => { |
|
231 |
getList() |
|
232 |
}) |
|
233 |
</script> |