增加短信发送记录查询逻辑
This commit is contained in:
parent
da0340403b
commit
3983922683
|
|
@ -64,3 +64,30 @@ export function getSmsBalanceAPI() {
|
|||
})
|
||||
}
|
||||
|
||||
// 获取循环的发送记录
|
||||
export function getLoopSendRecordsAPI(data) {
|
||||
return request({
|
||||
url: '/msgJob/getMsgLoopData',
|
||||
method: 'GET',
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
// 获取单次循环发送记录的详情列表
|
||||
export function getLoopSendRecordDetailsAPI(data) {
|
||||
return request({
|
||||
url: '/msgJob/getOneLoopMsgData',
|
||||
method: 'GET',
|
||||
params: data,
|
||||
})
|
||||
}
|
||||
|
||||
// 单人重新发送
|
||||
export function resendOneLoopMsgAPI(data) {
|
||||
return request({
|
||||
url: '/msgJob/oneWorkerResend',
|
||||
method: 'POST',
|
||||
data,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,14 +11,7 @@
|
|||
:action-columns="actionColumns"
|
||||
>
|
||||
<template #toolbar>
|
||||
<ComButton
|
||||
type="primary"
|
||||
icon="Plus"
|
||||
@click="onHandleAdd"
|
||||
v-hasPermi="['group:group:add']"
|
||||
>
|
||||
新建分组
|
||||
</ComButton>
|
||||
<ComButton type="primary" icon="Plus" @click="onHandleAdd"> 新建分组 </ComButton>
|
||||
</template>
|
||||
</ComTable>
|
||||
|
||||
|
|
@ -76,7 +69,7 @@ const actionColumns = [
|
|||
label: '编辑',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
permission: ['group:group:edit'],
|
||||
|
||||
handler: (row) => {
|
||||
editId.value = row.id
|
||||
dialogConfig.outerTitle = '编辑分组'
|
||||
|
|
@ -101,7 +94,7 @@ const actionColumns = [
|
|||
label: '删除',
|
||||
type: 'danger',
|
||||
link: true,
|
||||
permission: ['group:group:remove'],
|
||||
|
||||
handler: (row) => {
|
||||
proxy.$modal.confirm('是否确认删除该分组?').then(async () => {
|
||||
const result = await delGroupAPI({ id: row.id })
|
||||
|
|
|
|||
|
|
@ -11,22 +11,9 @@
|
|||
:action-columns="actionColumns"
|
||||
>
|
||||
<template #toolbar>
|
||||
<ComButton
|
||||
type="primary"
|
||||
icon="Plus"
|
||||
@click="onHandleAdd"
|
||||
v-hasPermi="['person:person:add']"
|
||||
>
|
||||
新建人员
|
||||
</ComButton>
|
||||
<ComButton type="primary" icon="Plus" @click="onHandleAdd"> 新建人员 </ComButton>
|
||||
|
||||
<ComButton
|
||||
pain
|
||||
type="info"
|
||||
icon="Upload"
|
||||
@click="onHandleImport"
|
||||
v-hasPermi="['person:person:import']"
|
||||
>
|
||||
<ComButton pain type="info" icon="Upload" @click="onHandleImport">
|
||||
导入人员
|
||||
</ComButton>
|
||||
</template>
|
||||
|
|
@ -158,7 +145,7 @@ const actionColumns = [
|
|||
label: '编辑',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
permission: ['person:person:edit'], // 权限控制:使用 v-hasPermi 指令控制按钮显示
|
||||
|
||||
handler: (row) => {
|
||||
editId.value = row.id
|
||||
dialogConfig.outerTitle = '编辑人员'
|
||||
|
|
@ -180,7 +167,7 @@ const actionColumns = [
|
|||
label: '删除',
|
||||
type: 'danger',
|
||||
link: true,
|
||||
permission: ['person:person:remove'], // 权限控制:使用 v-hasPermi 指令控制按钮显示
|
||||
|
||||
handler: (row) => {
|
||||
proxy.$modal.confirm('是否确认删除该人员?').then(async () => {
|
||||
const result = await delPersonAPI({ id: row.id })
|
||||
|
|
|
|||
|
|
@ -205,6 +205,8 @@ import {
|
|||
addLoopSendAPI,
|
||||
updateLoopSendAPI,
|
||||
getLoopSendDetailAPI,
|
||||
getLoopSendRecordsAPI,
|
||||
getLoopSendRecordDetailsAPI,
|
||||
} from '@/api/sMsSendManage/loopSend.js'
|
||||
import ComButton from '@/components/ComButton/index.vue'
|
||||
import ComDialog from '@/components/ComDialog/index.vue'
|
||||
|
|
@ -402,6 +404,16 @@ const getDetail = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
// 查看详情
|
||||
const onHandleDetail = async (row) => {
|
||||
const result = await getLoopSendRecordDetailsAPI({ loopId: row.loopId })
|
||||
|
||||
if (result.code === 200 && result.data?.workerList) {
|
||||
recordsDetailList.value = result.data.workerList
|
||||
}
|
||||
console.log(result, 'result')
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
if (mode.value === 'edit' || mode.value === 'detail') {
|
||||
getDetail()
|
||||
|
|
|
|||
|
|
@ -12,14 +12,7 @@
|
|||
>
|
||||
<template #toolbar>
|
||||
<div class="toolbar-left">
|
||||
<ComButton
|
||||
type="primary"
|
||||
icon="Plus"
|
||||
@click="onHandleAdd"
|
||||
v-hasPermi="['sms:loopTask:add']"
|
||||
>
|
||||
新建
|
||||
</ComButton>
|
||||
<ComButton type="primary" icon="Plus" @click="onHandleAdd"> 新建 </ComButton>
|
||||
<span v-if="smsBalance !== null" class="sms-balance-text">
|
||||
短信余额剩余 {{ smsBalance }} 条
|
||||
<span v-if="smsBalance < 10000">,请及时充值!</span>
|
||||
|
|
@ -38,11 +31,21 @@
|
|||
/>
|
||||
</template>
|
||||
</ComTable>
|
||||
|
||||
<!-- 发送详情弹框 -->
|
||||
<ComDialog
|
||||
:dialog-config="sendDetailsDialogConfig"
|
||||
@closeDialogOuter="onCloseSendDetailsDialog"
|
||||
>
|
||||
<template #outerContent>
|
||||
<SendDetails ref="sendDetailsRef" :sendDetailsId="sendDetailsId" />
|
||||
</template>
|
||||
</ComDialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="LoopSend">
|
||||
import { ref, computed, getCurrentInstance, onMounted } from 'vue'
|
||||
import { ref, computed, getCurrentInstance, onMounted, reactive } from 'vue'
|
||||
import { useRouter } from 'vue-router'
|
||||
import { debounce } from 'lodash-es'
|
||||
import {
|
||||
|
|
@ -54,14 +57,27 @@ import {
|
|||
import config from './config'
|
||||
import ComTable from '@/components/ComTable/index.vue'
|
||||
import ComButton from '@/components/ComButton/index.vue'
|
||||
import ComDialog from '@/components/ComDialog/index.vue'
|
||||
import SendDetails from './sendDetails.vue'
|
||||
|
||||
const router = useRouter()
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const { tableColumns, buildFormColumns } = config
|
||||
const comTableRef = ref(null)
|
||||
const sendDetailsRef = ref(null)
|
||||
const smsBalance = ref(null) // 短信余额
|
||||
const switchLoadingMap = new Map() // 记录每个 switch 的 loading 状态
|
||||
const sendDetailsId = ref(null)
|
||||
|
||||
// 发送详情弹框配置
|
||||
const sendDetailsDialogConfig = reactive({
|
||||
outerVisible: false,
|
||||
outerTitle: '发送详情',
|
||||
outerWidth: '90%',
|
||||
minHeight: '500px',
|
||||
maxHeight: '90vh',
|
||||
})
|
||||
|
||||
// 根据配置构建搜索表单
|
||||
const formColumns = computed(() => buildFormColumns())
|
||||
|
|
@ -72,7 +88,7 @@ const actionColumns = [
|
|||
label: '详情',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
permission: ['sms:loopTask:detail'],
|
||||
|
||||
handler: (row) => {
|
||||
router.push({
|
||||
path: '/sms/loopSendEdit/index',
|
||||
|
|
@ -83,26 +99,23 @@ const actionColumns = [
|
|||
})
|
||||
},
|
||||
},
|
||||
// {
|
||||
// label: '编辑',
|
||||
// type: 'primary',
|
||||
// link: true,
|
||||
// permission: ['sms:loopTask:edit'],
|
||||
// handler: (row) => {
|
||||
// router.push({
|
||||
// path: '/sms/loopSendEdit/index',
|
||||
// query: {
|
||||
// id: row.id,
|
||||
// mode: 'edit',
|
||||
// },
|
||||
// })
|
||||
// },
|
||||
// },
|
||||
|
||||
{
|
||||
label: '发送详情',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
|
||||
handler: (row) => {
|
||||
sendDetailsDialogConfig.outerTitle = `发送详情 - ${row.taskName || ''}`
|
||||
sendDetailsId.value = row.id
|
||||
sendDetailsDialogConfig.outerVisible = true
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '删除',
|
||||
type: 'danger',
|
||||
link: true,
|
||||
permission: ['sms:loopTask:remove'],
|
||||
|
||||
handler: (row) => {
|
||||
proxy.$modal.confirm('是否确认删除该循环发送任务?').then(async () => {
|
||||
const result = await delLoopSendAPI({ id: row.id })
|
||||
|
|
@ -113,6 +126,20 @@ const actionColumns = [
|
|||
})
|
||||
},
|
||||
},
|
||||
// {
|
||||
// label: '编辑',
|
||||
// type: 'primary',
|
||||
// link: true,
|
||||
// handler: (row) => {
|
||||
// router.push({
|
||||
// path: '/sms/loopSendEdit/index',
|
||||
// query: {
|
||||
// id: row.id,
|
||||
// mode: 'edit',
|
||||
// },
|
||||
// })
|
||||
// },
|
||||
// },
|
||||
]
|
||||
|
||||
// 新增
|
||||
|
|
@ -204,6 +231,11 @@ const getSmsBalance = async () => {
|
|||
}
|
||||
}
|
||||
|
||||
// 关闭发送详情弹框
|
||||
const onCloseSendDetailsDialog = (visible) => {
|
||||
sendDetailsDialogConfig.outerVisible = visible
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getSmsBalance()
|
||||
})
|
||||
|
|
|
|||
|
|
@ -0,0 +1,243 @@
|
|||
<template>
|
||||
<div class="send-details-container">
|
||||
<!-- 第一层详情列表 -->
|
||||
<ComTable
|
||||
ref="recordsTableRef"
|
||||
:form-columns="formColumns"
|
||||
:table-columns="tableColumns"
|
||||
:load-data="loadRecordsData"
|
||||
:show-toolbar="false"
|
||||
:show-action="true"
|
||||
:default-query-params="{
|
||||
id: props.sendDetailsId,
|
||||
}"
|
||||
:action-columns="actionColumns"
|
||||
/>
|
||||
|
||||
<!-- 第二层详情弹框 - 显示每个人的发送记录 -->
|
||||
<ComDialog :dialog-config="detailDialogConfig" @closeDialogOuter="onCloseDetailDialog">
|
||||
<template #outerContent>
|
||||
<el-table
|
||||
v-loading="detailLoading"
|
||||
:data="detailList"
|
||||
border
|
||||
style="width: 100%"
|
||||
max-height="500px"
|
||||
>
|
||||
<el-table-column prop="workerName" label="姓名" align="center" width="120" />
|
||||
<el-table-column
|
||||
prop="orgName"
|
||||
label="部门"
|
||||
align="center"
|
||||
show-overflow-tooltip
|
||||
/>
|
||||
<el-table-column prop="phone" label="电话" align="center" width="130" />
|
||||
<el-table-column prop="sendTime" label="发送时间" align="center" width="180" />
|
||||
<el-table-column prop="submitStatus" label="提交状态" align="center" />
|
||||
<el-table-column label="发送状态" align="center" width="120">
|
||||
<template #default="{ row }">
|
||||
<el-tag :type="row.sendStatus === '发送成功' ? 'success' : 'danger'">
|
||||
{{ row.sendStatus === '发送成功' ? '发送成功' : '发送失败' }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" align="center" width="120" fixed="right">
|
||||
<template #default="{ row }">
|
||||
<el-button
|
||||
v-if="row.sendStatus !== '发送成功'"
|
||||
link
|
||||
type="primary"
|
||||
icon="Refresh"
|
||||
@click="handleResend(row)"
|
||||
>
|
||||
重新发送
|
||||
</el-button>
|
||||
<span v-else>--</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</template>
|
||||
</ComDialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="SendDetails">
|
||||
import { ref, reactive, computed } from 'vue'
|
||||
import { getCurrentInstance } from 'vue'
|
||||
import ComTable from '@/components/ComTable/index.vue'
|
||||
import ComDialog from '@/components/ComDialog/index.vue'
|
||||
import {
|
||||
getLoopSendRecordsAPI,
|
||||
getLoopSendRecordDetailsAPI,
|
||||
resendOneLoopMsgAPI,
|
||||
} from '@/api/sMsSendManage/loopSend.js'
|
||||
|
||||
const { proxy } = getCurrentInstance()
|
||||
|
||||
const recordsTableRef = ref(null)
|
||||
const detailLoading = ref(false)
|
||||
const detailList = ref([])
|
||||
const currentLoopId = ref(null) // 当前查看的 loopId
|
||||
const currentId = ref(null) // 当前查看的 id
|
||||
|
||||
const props = defineProps({
|
||||
sendDetailsId: {
|
||||
type: [String, Number],
|
||||
default: '',
|
||||
},
|
||||
})
|
||||
|
||||
// 查询表单配置
|
||||
const formColumns = computed(() => [
|
||||
{
|
||||
type: 'input',
|
||||
prop: 'taskName',
|
||||
placeholder: '请输入任务名称',
|
||||
},
|
||||
{
|
||||
type: 'select',
|
||||
prop: 'msgType',
|
||||
placeholder: '请选择短信类型',
|
||||
options: [
|
||||
{ label: '通知', value: '1' },
|
||||
{ label: '计划', value: '2' },
|
||||
],
|
||||
},
|
||||
])
|
||||
|
||||
// 表格列配置
|
||||
const tableColumns = [
|
||||
{
|
||||
prop: 'taskName',
|
||||
label: '任务名称',
|
||||
},
|
||||
{
|
||||
prop: 'msgType',
|
||||
label: '短信类型',
|
||||
formatter: (row) => {
|
||||
const typeMap = {
|
||||
1: '通知',
|
||||
2: '计划',
|
||||
}
|
||||
return typeMap[row.msgType] || '-'
|
||||
},
|
||||
},
|
||||
{
|
||||
prop: 'remark',
|
||||
label: '备注',
|
||||
showOverflowTooltip: true,
|
||||
},
|
||||
]
|
||||
|
||||
// 操作列配置
|
||||
const actionColumns = [
|
||||
{
|
||||
label: '详情',
|
||||
type: 'primary',
|
||||
link: true,
|
||||
handler: (row) => {
|
||||
handleViewDetail(row)
|
||||
},
|
||||
},
|
||||
]
|
||||
|
||||
// 第二层详情弹框配置
|
||||
const detailDialogConfig = reactive({
|
||||
outerVisible: false,
|
||||
outerTitle: '发送记录详情',
|
||||
outerWidth: '1000px',
|
||||
minHeight: '400px',
|
||||
maxHeight: '80vh',
|
||||
})
|
||||
|
||||
// 加载第一层列表数据
|
||||
const loadRecordsData = async (params) => {
|
||||
try {
|
||||
const result = await getLoopSendRecordsAPI(params)
|
||||
if (result.code === 200) {
|
||||
return {
|
||||
rows: result.rows || result.data || [],
|
||||
total: result.total || 0,
|
||||
}
|
||||
}
|
||||
return { rows: [], total: 0 }
|
||||
} catch (error) {
|
||||
console.error('加载发送记录失败:', error)
|
||||
return { rows: [], total: 0 }
|
||||
}
|
||||
}
|
||||
|
||||
// 查看详情(打开第二层弹框)
|
||||
const handleViewDetail = async (row) => {
|
||||
detailDialogConfig.outerTitle = `发送记录详情 - ${row.taskName || ''}`
|
||||
detailDialogConfig.outerVisible = true
|
||||
detailLoading.value = true
|
||||
detailList.value = []
|
||||
currentLoopId.value = row.loopId // 保存当前 loopId
|
||||
currentId.value = row.id // 保存当前 id
|
||||
|
||||
try {
|
||||
const result = await getLoopSendRecordDetailsAPI({ loopId: row.loopId, id: row.id })
|
||||
if (result.code === 200) {
|
||||
detailList.value = result.data || result.rows || []
|
||||
} else {
|
||||
proxy.$modal.msgError(result.msg || '获取详情失败')
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('获取发送记录详情失败:', error)
|
||||
proxy.$modal.msgError('获取详情失败')
|
||||
} finally {
|
||||
detailLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭第二层弹框
|
||||
const onCloseDetailDialog = (visible) => {
|
||||
detailDialogConfig.outerVisible = visible
|
||||
}
|
||||
|
||||
// 重新发送
|
||||
const handleResend = async (row) => {
|
||||
try {
|
||||
await proxy.$modal.confirm('确认要重新发送给该人员吗?')
|
||||
const result = await resendOneLoopMsgAPI({
|
||||
id: row.id,
|
||||
phone: row.phone,
|
||||
taskId: row.taskId,
|
||||
})
|
||||
if (result.code === 200) {
|
||||
proxy.$modal.msgSuccess('重新发送成功')
|
||||
// 重新获取详情数据以刷新列表
|
||||
if (currentLoopId.value) {
|
||||
const detailResult = await getLoopSendRecordDetailsAPI({
|
||||
loopId: currentLoopId.value,
|
||||
id: currentId.value,
|
||||
})
|
||||
if (detailResult.code === 200) {
|
||||
detailList.value = detailResult.data || detailResult.rows || []
|
||||
}
|
||||
}
|
||||
} else {
|
||||
proxy.$modal.msgError(result.msg || '重新发送失败')
|
||||
}
|
||||
} catch (error) {
|
||||
if (error !== 'cancel') {
|
||||
console.error('重新发送失败:', error)
|
||||
proxy.$modal.msgError('重新发送失败')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 暴露刷新方法
|
||||
defineExpose({
|
||||
refresh: () => {
|
||||
recordsTableRef.value?.refresh()
|
||||
},
|
||||
})
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.send-details-container {
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
Loading…
Reference in New Issue