|
1 | 1 | <template>
|
2 | 2 | <ContentWrap>
|
3 |
| - <doc-alert title="公众号消息" url="https://doc.iocoder.cn/mp/message/" /> |
4 |
| - |
5 | 3 | <!-- 搜索工作栏 -->
|
6 | 4 | <el-form
|
| 5 | + class="-mb-15px" |
7 | 6 | :model="queryParams"
|
8 | 7 | ref="queryFormRef"
|
9 |
| - size="small" |
10 | 8 | :inline="true"
|
11 |
| - v-show="showSearch" |
12 | 9 | label-width="68px"
|
13 | 10 | >
|
14 | 11 | <el-form-item label="公众号" prop="accountId">
|
15 |
| - <el-select v-model="queryParams.accountId" placeholder="请选择公众号"> |
| 12 | + <el-select v-model="queryParams.accountId" placeholder="请选择公众号" class="!w-240px"> |
16 | 13 | <el-option
|
17 |
| - v-for="item in accounts" |
| 14 | + v-for="item in accountList" |
18 | 15 | :key="parseInt(item.id)"
|
19 | 16 | :label="item.name"
|
20 | 17 | :value="parseInt(item.id)"
|
21 | 18 | />
|
22 | 19 | </el-select>
|
23 | 20 | </el-form-item>
|
24 | 21 | <el-form-item label="消息类型" prop="type">
|
25 |
| - <el-select v-model="queryParams.type" placeholder="请选择消息类型" clearable size="small"> |
| 22 | + <el-select v-model="queryParams.type" placeholder="请选择消息类型" class="!w-240px"> |
26 | 23 | <el-option
|
27 |
| - v-for="dict in getDictOptions(DICT_TYPE.MP_MESSAGE_TYPE)" |
| 24 | + v-for="dict in getStrDictOptions(DICT_TYPE.MP_MESSAGE_TYPE)" |
28 | 25 | :key="dict.value"
|
29 | 26 | :label="dict.label"
|
30 | 27 | :value="dict.value"
|
|
37 | 34 | placeholder="请输入用户标识"
|
38 | 35 | clearable
|
39 | 36 | :v-on="handleQuery"
|
| 37 | + class="!w-240px" |
40 | 38 | />
|
41 | 39 | </el-form-item>
|
42 | 40 | <el-form-item label="创建时间" prop="createTime">
|
|
49 | 47 | start-placeholder="开始日期"
|
50 | 48 | end-placeholder="结束日期"
|
51 | 49 | :default-time="['00:00:00', '23:59:59']"
|
| 50 | + class="!w-240px" |
52 | 51 | />
|
53 | 52 | </el-form-item>
|
54 | 53 | <el-form-item>
|
55 |
| - <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button> |
56 |
| - <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button> |
| 54 | + <el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button> |
| 55 | + <el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button> |
57 | 56 | </el-form-item>
|
58 | 57 | </el-form>
|
| 58 | + </ContentWrap> |
59 | 59 |
|
60 |
| - <!--todo 操作工具栏 --> |
61 |
| - <!-- <el-row :gutter="10" class="mb8">--> |
62 |
| - <!-- <right-toolbar v-model:showSearch="showSearch" @queryTable="getList" />--> |
63 |
| - <!-- </el-row>--> |
64 |
| - |
65 |
| - <!-- 列表 --> |
| 60 | + <!-- 列表 --> |
| 61 | + <ContentWrap> |
66 | 62 | <el-table v-loading="loading" :data="list">
|
67 | 63 | <el-table-column label="发送时间" align="center" prop="createTime" width="180">
|
68 | 64 | <template #default="scope">
|
|
81 | 77 | <template #default="scope">
|
82 | 78 | <!-- 【事件】区域 -->
|
83 | 79 | <div v-if="scope.row.type === 'event' && scope.row.event === 'subscribe'">
|
84 |
| - <el-tag type="success" size="mini">关注</el-tag> |
| 80 | + <el-tag type="success">关注</el-tag> |
85 | 81 | </div>
|
86 | 82 | <div v-else-if="scope.row.type === 'event' && scope.row.event === 'unsubscribe'">
|
87 |
| - <el-tag type="danger" size="mini">取消关注</el-tag> |
| 83 | + <el-tag type="danger">取消关注</el-tag> |
88 | 84 | </div>
|
89 | 85 | <div v-else-if="scope.row.type === 'event' && scope.row.event === 'CLICK'">
|
90 |
| - <el-tag size="mini">点击菜单</el-tag>【{{ scope.row.eventKey }}】 |
| 86 | + <el-tag>点击菜单</el-tag>【{{ scope.row.eventKey }}】 |
91 | 87 | </div>
|
92 | 88 | <div v-else-if="scope.row.type === 'event' && scope.row.event === 'VIEW'">
|
93 |
| - <el-tag size="mini">点击菜单链接</el-tag>【{{ scope.row.eventKey }}】 |
| 89 | + <el-tag>点击菜单链接</el-tag>【{{ scope.row.eventKey }}】 |
94 | 90 | </div>
|
95 | 91 | <div v-else-if="scope.row.type === 'event' && scope.row.event === 'scancode_waitmsg'">
|
96 |
| - <el-tag size="mini">扫码结果</el-tag>【{{ scope.row.eventKey }}】 |
| 92 | + <el-tag>扫码结果</el-tag>【{{ scope.row.eventKey }}】 |
97 | 93 | </div>
|
98 | 94 | <div v-else-if="scope.row.type === 'event' && scope.row.event === 'scancode_push'">
|
99 |
| - <el-tag size="mini">扫码结果</el-tag>【{{ scope.row.eventKey }}】 |
| 95 | + <el-tag>扫码结果</el-tag>【{{ scope.row.eventKey }}】 |
100 | 96 | </div>
|
101 | 97 | <div v-else-if="scope.row.type === 'event' && scope.row.event === 'pic_sysphoto'">
|
102 |
| - <el-tag size="mini">系统拍照发图</el-tag> |
| 98 | + <el-tag>系统拍照发图</el-tag> |
103 | 99 | </div>
|
104 | 100 | <div v-else-if="scope.row.type === 'event' && scope.row.event === 'pic_photo_or_album'">
|
105 |
| - <el-tag size="mini">拍照或者相册</el-tag> |
| 101 | + <el-tag>拍照或者相册</el-tag> |
106 | 102 | </div>
|
107 | 103 | <div v-else-if="scope.row.type === 'event' && scope.row.event === 'pic_weixin'">
|
108 |
| - <el-tag size="mini">微信相册</el-tag> |
| 104 | + <el-tag>微信相册</el-tag> |
109 | 105 | </div>
|
110 | 106 | <div v-else-if="scope.row.type === 'event' && scope.row.event === 'location_select'">
|
111 |
| - <el-tag size="mini">选择地理位置</el-tag> |
| 107 | + <el-tag>选择地理位置</el-tag> |
112 | 108 | </div>
|
113 | 109 | <div v-else-if="scope.row.type === 'event'">
|
114 |
| - <el-tag type="danger" size="mini">未知事件类型</el-tag> |
| 110 | + <el-tag type="danger">未知事件类型</el-tag> |
115 | 111 | </div>
|
116 | 112 | <!-- 【消息】区域 -->
|
117 | 113 | <div v-else-if="scope.row.type === 'text'">{{ scope.row.content }}</div>
|
|
127 | 123 | <wx-video-player :url="scope.row.mediaUrl" style="margin-top: 10px" />
|
128 | 124 | </div>
|
129 | 125 | <div v-else-if="scope.row.type === 'link'">
|
130 |
| - <el-tag size="mini">链接</el-tag>: |
| 126 | + <el-tag>链接</el-tag>: |
131 | 127 | <a :href="scope.row.url" target="_blank">{{ scope.row.title }}</a>
|
132 | 128 | </div>
|
133 | 129 | <div v-else-if="scope.row.type === 'location'">
|
|
150 | 146 | <wx-news :articles="scope.row.articles" />
|
151 | 147 | </div>
|
152 | 148 | <div v-else>
|
153 |
| - <el-tag type="danger" size="mini">未知消息类型</el-tag> |
| 149 | + <el-tag type="danger">未知消息类型</el-tag> |
154 | 150 | </div>
|
155 | 151 | </template>
|
156 | 152 | </el-table-column>
|
157 | 153 | <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
158 | 154 | <template #default="scope">
|
159 | 155 | <el-button
|
160 |
| - size="mini" |
161 |
| - type="text" |
162 |
| - icon="el-icon-edit" |
| 156 | + link |
| 157 | + type="primary" |
163 | 158 | @click="handleSend(scope.row)"
|
164 | 159 | v-hasPermi="['mp:message:send']"
|
165 |
| - >消息 |
| 160 | + > |
| 161 | + 消息 |
166 | 162 | </el-button>
|
167 | 163 | </template>
|
168 | 164 | </el-table-column>
|
|
182 | 178 | </el-dialog>
|
183 | 179 | </ContentWrap>
|
184 | 180 | </template>
|
185 |
| - |
186 | 181 | <script setup lang="ts" name="MpMessage">
|
187 |
| -import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue' |
188 |
| -import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue' |
| 182 | +import { DICT_TYPE, getStrDictOptions } from '@/utils/dict' |
| 183 | +// import WxVideoPlayer from '@/views/mp/components/wx-video-play/main.vue' |
| 184 | +// import WxVoicePlayer from '@/views/mp/components/wx-voice-play/main.vue' |
189 | 185 | // import WxMsg from '@/views/mp/components/wx-msg/main.vue'
|
190 |
| -import WxLocation from '@/views/mp/components/wx-location/main.vue' |
191 |
| -import WxMusic from '@/views/mp/components/wx-music/main.vue' |
192 |
| -import WxNews from '@/views/mp/components/wx-news/main.vue' |
193 |
| -import { getMessagePage } from '@/api/mp/message' |
194 |
| -import { getSimpleAccounts } from '@/api/mp/account' |
195 |
| -import { DICT_TYPE, getDictOptions } from '@/utils/dict' |
| 186 | +// import WxLocation from '@/views/mp/components/wx-location/main.vue' |
| 187 | +// import WxMusic from '@/views/mp/components/wx-music/main.vue' |
| 188 | +// import WxNews from '@/views/mp/components/wx-news/main.vue' |
196 | 189 | import { parseTime } from '@/utils/formatTime'
|
197 |
| -
|
198 |
| -// ========== CRUD 相关 ========== |
199 |
| -const loading = ref(false) // 遮罩层 |
200 |
| -const showSearch = ref(true) // 显示搜索条件 |
201 |
| -const total = ref(0) // 总条数 |
202 |
| -const list = ref([]) // 粉丝消息列表 |
203 |
| -const accounts = ref([]) // 公众号账号列表 |
204 |
| -const open = ref(false) // 是否显示弹出层 |
205 |
| -const userId = ref(0) // 操作的用户编号 |
| 190 | +import * as MpAccountApi from '@/api/mp/account' |
| 191 | +import * as MpMessageApi from '@/api/mp/message' |
206 | 192 | const message = useMessage() // 消息弹窗
|
207 |
| -const queryFormRef = ref() // 搜索的表单 |
208 | 193 |
|
| 194 | +const loading = ref(true) // 列表的加载中 |
| 195 | +const total = ref(0) // 列表的总页数 |
| 196 | +const list = ref([]) // 列表的数据 |
209 | 197 | const queryParams = reactive({
|
210 | 198 | pageNo: 1,
|
211 | 199 | pageSize: 10,
|
212 | 200 | openid: null,
|
213 | 201 | accountId: null,
|
214 | 202 | type: null,
|
215 | 203 | createTime: []
|
216 |
| -}) // 是否显示弹出层 |
| 204 | +}) |
| 205 | +const queryFormRef = ref() // 搜索的表单 |
| 206 | +// TODO 芋艿:下面应该移除 |
| 207 | +const open = ref(false) // 是否显示弹出层 |
| 208 | +const userId = ref(0) // 操作的用户编号 |
| 209 | +const accountList = ref<MpAccountApi.AccountVO[]>([]) // 公众号账号列表 |
217 | 210 |
|
| 211 | +/** 查询参数列表 */ |
218 | 212 | const getList = async () => {
|
219 | 213 | // 如果没有选中公众号账号,则进行提示。
|
220 | 214 | if (!queryParams.accountId) {
|
221 |
| - message.error('未选中公众号,无法查询消息') |
222 |
| - return false |
| 215 | + await message.error('未选中公众号,无法查询消息') |
| 216 | + return |
223 | 217 | }
|
224 |
| -
|
225 |
| - loading.value = true |
226 |
| - // 执行查询 |
227 |
| - getMessagePage(queryParams).then((data) => { |
228 |
| - console.log(data) |
| 218 | + try { |
| 219 | + loading.value = true |
| 220 | + const data = await MpMessageApi.getMessagePage(queryParams) |
229 | 221 | list.value = data.list
|
230 | 222 | total.value = data.total
|
| 223 | + } finally { |
231 | 224 | loading.value = false
|
232 |
| - }) |
| 225 | + } |
233 | 226 | }
|
234 | 227 |
|
235 |
| -const handleQuery = async () => { |
| 228 | +/** 搜索按钮操作 */ |
| 229 | +const handleQuery = () => { |
236 | 230 | queryParams.pageNo = 1
|
237 | 231 | getList()
|
238 | 232 | }
|
| 233 | +
|
| 234 | +/** 重置按钮操作 */ |
239 | 235 | const resetQuery = async () => {
|
240 | 236 | queryFormRef.value.resetFields()
|
241 | 237 | // 默认选中第一个
|
242 |
| - if (accounts.value.length > 0) { |
243 |
| - queryParams.accountId = accounts[0].id |
| 238 | + if (accountList.value.length > 0) { |
| 239 | + // @ts-ignore |
| 240 | + queryParams.accountId = accountList.value[0].id |
244 | 241 | }
|
245 | 242 | handleQuery()
|
246 | 243 | }
|
247 | 244 | const handleSend = async (row) => {
|
248 | 245 | userId.value = row.userId
|
249 | 246 | open.value = true
|
250 | 247 | }
|
251 |
| -onMounted(() => { |
252 |
| - getSimpleAccounts().then((response) => { |
253 |
| - accounts.value = response |
254 |
| - // 默认选中第一个 |
255 |
| - if (accounts.value.length > 0) { |
256 |
| - queryParams.accountId = accounts.value[0]['id'] |
257 |
| - } |
258 |
| - // 加载数据 |
259 |
| - getList() |
260 |
| - }) |
| 248 | +
|
| 249 | +/** 初始化 **/ |
| 250 | +onMounted(async () => { |
| 251 | + accountList.value = await MpAccountApi.getSimpleAccountList() |
| 252 | + // 选中第一个 |
| 253 | + if (accountList.value.length > 0) { |
| 254 | + // @ts-ignore |
| 255 | + queryParams.accountId = accountList.value[0].id |
| 256 | + } |
| 257 | + await getList() |
261 | 258 | })
|
262 | 259 | </script>
|
0 commit comments