小区活动
parent
50fea92174
commit
594eff01cf
|
|
@ -0,0 +1,98 @@
|
|||
import request from '@/config/axios'
|
||||
|
||||
/** 小区活动信息 */
|
||||
export interface Activity {
|
||||
id?: number
|
||||
title?: string
|
||||
content?: string
|
||||
coverImage?: string
|
||||
bannerImages?: string[]
|
||||
serviceCategories?: number[]
|
||||
serviceTargets?: number[]
|
||||
registrationStartTime?: number
|
||||
registrationEndTime?: number
|
||||
activityStartTime?: number
|
||||
activityEndTime?: number
|
||||
location?: string
|
||||
maxParticipants?: number
|
||||
contactPerson?: string
|
||||
contactPhone?: string
|
||||
currentParticipants?: number
|
||||
status?: number
|
||||
viewCount?: number
|
||||
isDisplay?: boolean
|
||||
communityIds?: number[]
|
||||
communityNames?: string[]
|
||||
createTime?: string
|
||||
}
|
||||
|
||||
/** 小区活动报名记录 */
|
||||
export interface ActivityRegistration {
|
||||
id?: number
|
||||
activityId?: number
|
||||
memberId?: number
|
||||
memberName?: string
|
||||
memberPhone?: string
|
||||
registrationTime?: string
|
||||
status?: number
|
||||
remark?: string
|
||||
createTime?: string
|
||||
}
|
||||
|
||||
// 小区活动 API
|
||||
export const ActivityApi = {
|
||||
// 查询小区活动分页
|
||||
getActivityPage: async (params: any) => {
|
||||
return await request.get({ url: `/community/activity/page`, params })
|
||||
},
|
||||
|
||||
// 查询小区活动详情
|
||||
getActivity: async (id: number) => {
|
||||
return await request.get({ url: `/community/activity/get?id=` + id })
|
||||
},
|
||||
|
||||
// 新增小区活动
|
||||
createActivity: async (data: Activity) => {
|
||||
return await request.post({ url: `/community/activity/create`, data })
|
||||
},
|
||||
|
||||
// 修改小区活动
|
||||
updateActivity: async (data: Activity) => {
|
||||
return await request.put({ url: `/community/activity/update`, data })
|
||||
},
|
||||
|
||||
// 删除小区活动
|
||||
deleteActivity: async (id: number) => {
|
||||
return await request.delete({ url: `/community/activity/delete?id=` + id })
|
||||
},
|
||||
|
||||
/** 批量删除小区活动 */
|
||||
deleteActivityList: async (ids: number[]) => {
|
||||
return await request.delete({ url: `/community/activity/delete-list?ids=${ids.join(',')}` })
|
||||
},
|
||||
|
||||
// 导出小区活动 Excel
|
||||
exportActivity: async (params) => {
|
||||
return await request.download({ url: `/community/activity/export-excel`, params })
|
||||
},
|
||||
|
||||
// 发布小区活动
|
||||
publishActivity: async (id: number) => {
|
||||
return await request.put({ url: `/community/activity/publish?id=` + id })
|
||||
},
|
||||
|
||||
// 撤回小区活动
|
||||
revokeActivity: async (id: number) => {
|
||||
return await request.put({ url: `/community/activity/revoke?id=` + id })
|
||||
},
|
||||
|
||||
// 查询活动报名记录分页
|
||||
getRegistrationPage: async (params: any) => {
|
||||
return await request.get({ url: `/community/activity/registration/page`, params })
|
||||
},
|
||||
|
||||
// 审核报名
|
||||
auditRegistration: async (id: number, status: number) => {
|
||||
return await request.put({ url: `/community/activity/registration/audit?id=` + id + `&status=` + status })
|
||||
}
|
||||
}
|
||||
|
|
@ -214,4 +214,8 @@ export enum DICT_TYPE {
|
|||
COMM_POST_END_TYPE = 'comm_post_end_type',
|
||||
|
||||
COMM_KNOWLEDGE_CLASS_TYPE = 'comm_knowledge_class_type',
|
||||
|
||||
COMM_ACTIVITY_STATUS = 'comm_activity_status',
|
||||
COMM_ACTIVITY_SERVICE_TARGET = 'comm_activity_service_target',
|
||||
COMM_ACTIVITY_SERVICE_CATEGORY = 'comm_activity_service_category',
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,349 @@
|
|||
<template>
|
||||
<Dialog :title="dialogTitle" v-model="dialogVisible" width="900px">
|
||||
<el-form
|
||||
ref="formRef"
|
||||
:model="formData"
|
||||
:rules="formRules"
|
||||
label-width="100px"
|
||||
v-loading="formLoading"
|
||||
>
|
||||
<el-form-item label="活动标题" prop="title">
|
||||
<el-input v-model="formData.title" placeholder="请输入活动标题" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="活动简介" prop="content">
|
||||
<Editor v-model="formData.content" height="300px" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="封面图片" prop="coverImage">
|
||||
<UploadImg v-model="formData.coverImage" :limit="1" height="80px" width="120px" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="轮播图" prop="bannerImages">
|
||||
<UploadImgs v-model="formData.bannerImages" :limit="6" height="80px" width="120px" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="发布范围" prop="communityIds">
|
||||
<el-select
|
||||
v-model="formData.communityIds"
|
||||
placeholder="请选择小区"
|
||||
clearable
|
||||
filterable
|
||||
multiple
|
||||
collapse-tags
|
||||
collapse-tags-tooltip
|
||||
style="width: 100%"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in communityOptions"
|
||||
:key="item.id"
|
||||
:label="item.communityName"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="服务类别" prop="serviceCategories">
|
||||
<el-checkbox-group v-model="formData.serviceCategories">
|
||||
<el-checkbox
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.COMM_ACTIVITY_SERVICE_CATEGORY)"
|
||||
:key="dict.value"
|
||||
:value="dict.value"
|
||||
>
|
||||
{{ dict.label }}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="服务对象" prop="serviceTargets">
|
||||
<el-checkbox-group v-model="formData.serviceTargets">
|
||||
<el-checkbox
|
||||
v-for="dict in getIntDictOptions(DICT_TYPE.COMM_ACTIVITY_SERVICE_TARGET)"
|
||||
:key="dict.value"
|
||||
:value="dict.value"
|
||||
>
|
||||
{{ dict.label }}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="报名日期" prop="registrationStartTime" :rules="registrationDateRules">
|
||||
<el-date-picker
|
||||
v-model="registrationDateRange"
|
||||
type="datetimerange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="活动时间" prop="activityStartTime" :rules="activityDateRules">
|
||||
<el-date-picker
|
||||
v-model="activityDateRange"
|
||||
type="datetimerange"
|
||||
range-separator="至"
|
||||
start-placeholder="开始时间"
|
||||
end-placeholder="结束时间"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
style="width: 100%"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="活动地点" prop="location">
|
||||
<el-input v-model="formData.location" placeholder="请输入活动地点" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="人数上限" prop="maxParticipants">
|
||||
<el-input-number v-model="formData.maxParticipants" :min="0" :max="9999" placeholder="请输入人数上限" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="联系人" prop="contactPerson">
|
||||
<el-input v-model="formData.contactPerson" placeholder="请输入联系人" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="联系电话" prop="contactPhone">
|
||||
<el-input v-model="formData.contactPhone" placeholder="请输入联系电话" />
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item label="是否展示" prop="isDisplay">
|
||||
<el-switch v-model="formData.isDisplay" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
|
||||
<template #footer>
|
||||
<el-button @click="dialogVisible = false">取 消</el-button>
|
||||
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
|
||||
</template>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { ActivityApi, Activity } from '@/api/community/activity'
|
||||
import { CommunityApi, CommunitySimpleVO } from '@/api/community/community'
|
||||
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
|
||||
/** 小区活动 表单 */
|
||||
defineOptions({ name: 'ActivityForm' })
|
||||
|
||||
const { t } = useI18n()
|
||||
const message = useMessage()
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const dialogTitle = ref('')
|
||||
const formLoading = ref(false)
|
||||
const formType = ref('')
|
||||
const formData = ref({
|
||||
id: undefined,
|
||||
title: undefined,
|
||||
content: undefined,
|
||||
coverImage: undefined,
|
||||
bannerImages: [],
|
||||
serviceCategories: [],
|
||||
serviceTargets: [],
|
||||
registrationStartTime: undefined,
|
||||
registrationEndTime: undefined,
|
||||
activityStartTime: undefined,
|
||||
activityEndTime: undefined,
|
||||
location: undefined,
|
||||
maxParticipants: undefined,
|
||||
contactPerson: undefined,
|
||||
contactPhone: undefined,
|
||||
isDisplay: true,
|
||||
communityIds: []
|
||||
})
|
||||
|
||||
const registrationDateRange = ref<string[]>([])
|
||||
const activityDateRange = ref<string[]>([])
|
||||
|
||||
// 时间戳转日期字符串
|
||||
const timestampToDateStr = (timestamp: number | undefined) => {
|
||||
if (!timestamp) return ''
|
||||
const date = new Date(timestamp)
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
const hours = String(date.getHours()).padStart(2, '0')
|
||||
const minutes = String(date.getMinutes()).padStart(2, '0')
|
||||
const seconds = String(date.getSeconds()).padStart(2, '0')
|
||||
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
|
||||
}
|
||||
|
||||
// 日期字符串转时间戳
|
||||
const dateStrToTimestamp = (dateStr: string) => {
|
||||
if (!dateStr) return undefined
|
||||
return new Date(dateStr).getTime()
|
||||
}
|
||||
|
||||
const formRules = reactive({
|
||||
title: [{ required: true, message: '活动标题不能为空', trigger: 'blur' }],
|
||||
content: [{ required: true, message: '活动简介不能为空', trigger: 'blur' }],
|
||||
coverImage: [{ required: true, message: '封面图片不能为空', trigger: 'change' }],
|
||||
serviceCategories: [{ required: true, message: '请选择服务类别', trigger: 'change' }],
|
||||
serviceTargets: [{ required: true, message: '请选择服务对象', trigger: 'change' }],
|
||||
location: [{ required: true, message: '活动地点不能为空', trigger: 'blur' }],
|
||||
communityIds: [{ required: true, message: '请选择发布范围', trigger: 'change' }]
|
||||
})
|
||||
|
||||
// 报名日期验证规则(独立定义)
|
||||
const registrationDateRules = reactive({
|
||||
required: true,
|
||||
validator: (rule: any, value: any, callback: any) => {
|
||||
if (!registrationDateRange.value || registrationDateRange.value.length !== 2) {
|
||||
callback(new Error('请选择报名日期'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
trigger: 'change'
|
||||
})
|
||||
|
||||
// 活动时间验证规则(独立定义)
|
||||
const activityDateRules = reactive({
|
||||
required: true,
|
||||
validator: (rule: any, value: any, callback: any) => {
|
||||
if (!activityDateRange.value || activityDateRange.value.length !== 2) {
|
||||
callback(new Error('请选择活动时间'))
|
||||
} else {
|
||||
callback()
|
||||
}
|
||||
},
|
||||
trigger: 'change'
|
||||
})
|
||||
|
||||
const formRef = ref()
|
||||
const communityOptions = ref<CommunitySimpleVO[]>([])
|
||||
|
||||
const loadCommunityList = async () => {
|
||||
try {
|
||||
communityOptions.value = await CommunityApi.getCommunitySimpleList()
|
||||
} catch (error) {
|
||||
console.error('加载小区列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const open = async (type: string, id?: number) => {
|
||||
dialogVisible.value = true
|
||||
formType.value = type
|
||||
dialogTitle.value = type === 'create' ? '新增小区活动' : '编辑小区活动'
|
||||
|
||||
resetForm()
|
||||
|
||||
await loadCommunityList()
|
||||
|
||||
if (id) {
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = await ActivityApi.getActivity(id)
|
||||
formData.value = {
|
||||
id: data.id,
|
||||
title: data.title,
|
||||
content: data.content,
|
||||
coverImage: data.coverImage,
|
||||
bannerImages: data.bannerImages || [],
|
||||
serviceCategories: data.serviceCategories || [],
|
||||
serviceTargets: data.serviceTargets || [],
|
||||
registrationStartTime: data.registrationStartTime,
|
||||
registrationEndTime: data.registrationEndTime,
|
||||
activityStartTime: data.activityStartTime,
|
||||
activityEndTime: data.activityEndTime,
|
||||
location: data.location,
|
||||
maxParticipants: data.maxParticipants,
|
||||
contactPerson: data.contactPerson,
|
||||
contactPhone: data.contactPhone,
|
||||
isDisplay: data.isDisplay !== undefined ? data.isDisplay : true,
|
||||
communityIds: Array.isArray(data.communityIds) ? data.communityIds : []
|
||||
}
|
||||
|
||||
if (data.registrationStartTime && data.registrationEndTime) {
|
||||
registrationDateRange.value = [
|
||||
timestampToDateStr(data.registrationStartTime),
|
||||
timestampToDateStr(data.registrationEndTime)
|
||||
]
|
||||
}
|
||||
if (data.activityStartTime && data.activityEndTime) {
|
||||
activityDateRange.value = [
|
||||
timestampToDateStr(data.activityStartTime),
|
||||
timestampToDateStr(data.activityEndTime)
|
||||
]
|
||||
}
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
defineExpose({ open })
|
||||
|
||||
const emit = defineEmits(['success'])
|
||||
const submitForm = async () => {
|
||||
await formRef.value.validate()
|
||||
formLoading.value = true
|
||||
try {
|
||||
const data = {
|
||||
id: formData.value.id,
|
||||
title: formData.value.title,
|
||||
content: formData.value.content,
|
||||
coverImage: formData.value.coverImage,
|
||||
bannerImages: formData.value.bannerImages,
|
||||
serviceCategories: formData.value.serviceCategories,
|
||||
serviceTargets: formData.value.serviceTargets,
|
||||
registrationStartTime: registrationDateRange.value && registrationDateRange.value.length === 2
|
||||
? dateStrToTimestamp(registrationDateRange.value[0])
|
||||
: undefined,
|
||||
registrationEndTime: registrationDateRange.value && registrationDateRange.value.length === 2
|
||||
? dateStrToTimestamp(registrationDateRange.value[1])
|
||||
: undefined,
|
||||
activityStartTime: activityDateRange.value && activityDateRange.value.length === 2
|
||||
? dateStrToTimestamp(activityDateRange.value[0])
|
||||
: undefined,
|
||||
activityEndTime: activityDateRange.value && activityDateRange.value.length === 2
|
||||
? dateStrToTimestamp(activityDateRange.value[1])
|
||||
: undefined,
|
||||
location: formData.value.location,
|
||||
maxParticipants: formData.value.maxParticipants,
|
||||
contactPerson: formData.value.contactPerson,
|
||||
contactPhone: formData.value.contactPhone,
|
||||
isDisplay: formData.value.isDisplay,
|
||||
communityIds: formData.value.communityIds
|
||||
} as unknown as Activity
|
||||
|
||||
if (formType.value === 'create') {
|
||||
await ActivityApi.createActivity(data)
|
||||
message.success(t('common.createSuccess'))
|
||||
} else {
|
||||
await ActivityApi.updateActivity(data)
|
||||
message.success(t('common.updateSuccess'))
|
||||
}
|
||||
dialogVisible.value = false
|
||||
emit('success')
|
||||
} finally {
|
||||
formLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const resetForm = () => {
|
||||
formData.value = {
|
||||
id: undefined,
|
||||
title: undefined,
|
||||
content: undefined,
|
||||
coverImage: undefined,
|
||||
bannerImages: [],
|
||||
serviceCategories: [],
|
||||
serviceTargets: [],
|
||||
registrationStartTime: undefined,
|
||||
registrationEndTime: undefined,
|
||||
activityStartTime: undefined,
|
||||
activityEndTime: undefined,
|
||||
location: undefined,
|
||||
maxParticipants: undefined,
|
||||
contactPerson: undefined,
|
||||
contactPhone: undefined,
|
||||
isDisplay: true,
|
||||
communityIds: []
|
||||
}
|
||||
registrationDateRange.value = []
|
||||
activityDateRange.value = []
|
||||
formRef.value?.resetFields()
|
||||
}
|
||||
</script>
|
||||
|
|
@ -0,0 +1,121 @@
|
|||
<template>
|
||||
<Dialog :title="'活动报名记录'" v-model="dialogVisible" width="1000px">
|
||||
<el-table
|
||||
v-loading="loading"
|
||||
:data="list"
|
||||
:stripe="true"
|
||||
:show-overflow-tooltip="true"
|
||||
:header-cell-style="{
|
||||
background: '#1890ff',
|
||||
color: '#ffffff',
|
||||
textAlign: 'center',
|
||||
fontWeight: 'normal',
|
||||
fontSize: '14px',
|
||||
borderColor: '#1890ff'
|
||||
}"
|
||||
:cell-style="{
|
||||
textAlign: 'center',
|
||||
fontSize: '14px',
|
||||
color: '#333333',
|
||||
borderColor: '#ebeef5'
|
||||
}"
|
||||
>
|
||||
<el-table-column label="序号" align="center" type="index" width="80" />
|
||||
<el-table-column label="会员姓名" align="center" prop="memberName" min-width="120" />
|
||||
<el-table-column label="联系电话" align="center" prop="memberPhone" width="120" />
|
||||
<el-table-column label="报名时间" align="center" prop="registrationTime" width="180">
|
||||
<template #default="scope">
|
||||
{{ dateFormatter(scope.row, {}, scope.row.registrationTime) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="报名状态" align="center" prop="status" width="100">
|
||||
<template #default="scope">
|
||||
<dict-tag :type="DICT_TYPE.COMM_ACTIVITY_STATUS" :value="scope.row.status" />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column label="操作" align="center" width="150" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
v-if="scope.row.status === 0"
|
||||
link
|
||||
type="success"
|
||||
@click="handleAudit(scope.row.id, 1)"
|
||||
>
|
||||
通过
|
||||
</el-button>
|
||||
<el-button
|
||||
v-if="scope.row.status === 0"
|
||||
link
|
||||
type="danger"
|
||||
@click="handleAudit(scope.row.id, 2)"
|
||||
>
|
||||
拒绝
|
||||
</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<!-- 分页 -->
|
||||
<Pagination
|
||||
:total="total"
|
||||
v-model:page="queryParams.pageNo"
|
||||
v-model:limit="queryParams.pageSize"
|
||||
@pagination="getList"
|
||||
/>
|
||||
</Dialog>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import { ActivityApi, ActivityRegistration } from '@/api/community/activity'
|
||||
import { DICT_TYPE } from '@/utils/dict'
|
||||
|
||||
/** 活动报名记录弹窗 */
|
||||
defineOptions({ name: 'RegistrationDialog' })
|
||||
|
||||
const message = useMessage()
|
||||
|
||||
const dialogVisible = ref(false)
|
||||
const loading = ref(false)
|
||||
const list = ref<ActivityRegistration[]>([])
|
||||
const total = ref(0)
|
||||
const currentActivityId = ref<number>()
|
||||
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
activityId: undefined
|
||||
})
|
||||
|
||||
const getList = async () => {
|
||||
if (!currentActivityId.value) return
|
||||
loading.value = true
|
||||
try {
|
||||
queryParams.activityId = currentActivityId.value
|
||||
const data = await ActivityApi.getRegistrationPage(queryParams)
|
||||
list.value = data.list
|
||||
total.value = data.total
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const handleAudit = async (id: number, status: number) => {
|
||||
try {
|
||||
const auditText = status === 1 ? '通过' : '拒绝'
|
||||
await message.confirm(`确认${auditText}该报名记录吗?`)
|
||||
await ActivityApi.auditRegistration(id, status)
|
||||
message.success(`${auditText}成功`)
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
const open = async (activityId: number) => {
|
||||
dialogVisible.value = true
|
||||
currentActivityId.value = activityId
|
||||
queryParams.pageNo = 1
|
||||
await getList()
|
||||
}
|
||||
|
||||
defineExpose({ open })
|
||||
</script>
|
||||
|
|
@ -0,0 +1,329 @@
|
|||
<template>
|
||||
<ContentWrap>
|
||||
<!-- 搜索工作栏 -->
|
||||
<el-form
|
||||
class="-mb-15px"
|
||||
:model="queryParams"
|
||||
ref="queryFormRef"
|
||||
:inline="true"
|
||||
label-width="80px"
|
||||
>
|
||||
<el-form-item label="标题" prop="title">
|
||||
<el-input
|
||||
v-model="queryParams.title"
|
||||
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 label="草稿" :value="0" />
|
||||
<el-option label="报名中" :value="1" />
|
||||
<el-option label="报名截止" :value="2" />
|
||||
<el-option label="进行中" :value="3" />
|
||||
<el-option label="已结束" :value="4" />
|
||||
<el-option label="已撤回" :value="5" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item label="活动时间" prop="activityStartTime">
|
||||
<el-date-picker
|
||||
v-model="queryParams.activityStartTime"
|
||||
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 label="发布范围" prop="communityId">
|
||||
<el-select
|
||||
v-model="queryParams.communityId"
|
||||
placeholder="请选择小区"
|
||||
clearable
|
||||
filterable
|
||||
class="!w-240px"
|
||||
>
|
||||
<el-option
|
||||
v-for="item in communityOptions"
|
||||
:key="item.id"
|
||||
:label="item.communityName"
|
||||
:value="item.id"
|
||||
/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @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>
|
||||
<div class="mb-15px">
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
@click="openForm('create')"
|
||||
v-hasPermi="['community:activity:create']"
|
||||
>
|
||||
<Icon icon="ep:plus" class="mr-5px" /> 新建
|
||||
</el-button>
|
||||
<el-button
|
||||
type="primary"
|
||||
plain
|
||||
@click="handleExport"
|
||||
:loading="exportLoading"
|
||||
v-hasPermi="['community:activity:export']"
|
||||
>
|
||||
<Icon icon="ep:download" class="mr-5px" /> 导出
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
plain
|
||||
@click="handleDeleteBatch"
|
||||
:disabled="checkedIds.length === 0"
|
||||
v-hasPermi="['community:activity:delete']"
|
||||
>
|
||||
<Icon icon="ep:delete" class="mr-5px" /> 批量删除
|
||||
</el-button>
|
||||
</div>
|
||||
</ContentWrap>
|
||||
|
||||
<!-- 列表 -->
|
||||
<ContentWrap>
|
||||
<el-table
|
||||
row-key="id"
|
||||
v-loading="loading"
|
||||
:data="list"
|
||||
:stripe="true"
|
||||
:show-overflow-tooltip="true"
|
||||
@selection-change="handleRowCheckboxChange"
|
||||
:header-cell-style="{
|
||||
background: '#1890ff',
|
||||
color: '#ffffff',
|
||||
textAlign: 'center',
|
||||
fontWeight: 'normal',
|
||||
fontSize: '14px',
|
||||
borderColor: '#1890ff'
|
||||
}"
|
||||
:cell-style="{
|
||||
textAlign: 'center',
|
||||
fontSize: '14px',
|
||||
color: '#333333',
|
||||
borderColor: '#ebeef5'
|
||||
}"
|
||||
>
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="序号" align="center" type="index" width="80" />
|
||||
<el-table-column label="活动标题" align="center" prop="title" min-width="200" show-overflow-tooltip />
|
||||
<el-table-column label="服务类别" align="center" prop="serviceCategories" width="150" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
{{ formatServiceCategories(scope.row.serviceCategories) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="活动时间" align="center" min-width="180">
|
||||
<template #default="scope">
|
||||
<div v-if="scope.row.activityStartTime">
|
||||
{{ dateFormatter(scope.row, {}, scope.row.activityStartTime) }}
|
||||
</div>
|
||||
<div v-if="scope.row.activityEndTime" style="color: #999; font-size: 12px;">
|
||||
至 {{ dateFormatter(scope.row, {}, scope.row.activityEndTime) }}
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="活动地点" align="center" prop="location" min-width="150" show-overflow-tooltip />
|
||||
<el-table-column label="报名人数" align="center" width="100">
|
||||
<template #default="scope">
|
||||
{{ scope.row.currentParticipants || 0 }}{{ scope.row.maxParticipants ? '/' + scope.row.maxParticipants : '' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="发布范围" align="center" prop="communityNames" min-width="200" show-overflow-tooltip>
|
||||
<template #default="scope">
|
||||
{{ scope.row.communityNames ? scope.row.communityNames.join(' / ') : '-' }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="是否展示" align="center" prop="isDisplay" width="100">
|
||||
<template #default="scope">
|
||||
<el-switch v-model="scope.row.isDisplay" disabled />
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- <el-table-column label="浏览量" align="center" prop="viewCount" width="100" />-->
|
||||
<el-table-column label="操作" align="center" min-width="180px" fixed="right">
|
||||
<template #default="scope">
|
||||
<el-button
|
||||
link
|
||||
type="primary"
|
||||
@click="openForm('update', scope.row.id)"
|
||||
v-hasPermi="['community:activity:update']"
|
||||
>
|
||||
编辑
|
||||
</el-button>
|
||||
<!-- <el-button-->
|
||||
<!-- link-->
|
||||
<!-- type="success"-->
|
||||
<!-- @click="handleViewRegistrations(scope.row.id)"-->
|
||||
<!-- v-hasPermi="['community:activity:query']"-->
|
||||
<!-- >-->
|
||||
<!-- 报名-->
|
||||
<!-- </el-button>-->
|
||||
<el-button
|
||||
link
|
||||
type="danger"
|
||||
@click="handleDelete(scope.row.id)"
|
||||
v-hasPermi="['community:activity: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>
|
||||
|
||||
<!-- 表单弹窗:添加/修改 -->
|
||||
<ActivityForm ref="formRef" @success="getList" />
|
||||
|
||||
<!-- 报名记录弹窗 -->
|
||||
<RegistrationDialog ref="registrationDialogRef" />
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { dateFormatter } from '@/utils/formatTime'
|
||||
import download from '@/utils/download'
|
||||
import { ActivityApi, Activity } from '@/api/community/activity'
|
||||
import { CommunityApi, CommunitySimpleVO } from '@/api/community/community'
|
||||
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||
import ActivityForm from './ActivityForm.vue'
|
||||
import RegistrationDialog from './RegistrationDialog.vue'
|
||||
|
||||
/** 小区活动 列表 */
|
||||
defineOptions({ name: 'CommunityActivity' })
|
||||
|
||||
const message = useMessage()
|
||||
const { t } = useI18n()
|
||||
|
||||
const loading = ref(true)
|
||||
const list = ref<Activity[]>([])
|
||||
const total = ref(0)
|
||||
const queryParams = reactive({
|
||||
pageNo: 1,
|
||||
pageSize: 10,
|
||||
title: undefined,
|
||||
status: undefined,
|
||||
activityStartTime: [],
|
||||
communityId: undefined
|
||||
})
|
||||
const queryFormRef = ref()
|
||||
const exportLoading = ref(false)
|
||||
const communityOptions = ref<CommunitySimpleVO[]>([])
|
||||
|
||||
const loadCommunityList = async () => {
|
||||
try {
|
||||
communityOptions.value = await CommunityApi.getCommunitySimpleList()
|
||||
} catch (error) {
|
||||
console.error('加载小区列表失败:', error)
|
||||
}
|
||||
}
|
||||
|
||||
const getList = async () => {
|
||||
loading.value = true
|
||||
try {
|
||||
const data = await ActivityApi.getActivityPage(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 ActivityApi.deleteActivity(id)
|
||||
message.success(t('common.delSuccess'))
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
const handleDeleteBatch = async () => {
|
||||
try {
|
||||
await message.delConfirm()
|
||||
await ActivityApi.deleteActivityList(checkedIds.value)
|
||||
checkedIds.value = []
|
||||
message.success(t('common.delSuccess'))
|
||||
await getList()
|
||||
} catch {}
|
||||
}
|
||||
|
||||
const checkedIds = ref<number[]>([])
|
||||
const handleRowCheckboxChange = (records: Activity[]) => {
|
||||
checkedIds.value = records.map((item) => item.id!)
|
||||
}
|
||||
|
||||
const handleExport = async () => {
|
||||
try {
|
||||
await message.exportConfirm()
|
||||
exportLoading.value = true
|
||||
const data = await ActivityApi.exportActivity(queryParams)
|
||||
download.excel(data, '小区活动.xls')
|
||||
} catch {
|
||||
} finally {
|
||||
exportLoading.value = false
|
||||
}
|
||||
}
|
||||
|
||||
const registrationDialogRef = ref()
|
||||
const handleViewRegistrations = (activityId: number) => {
|
||||
registrationDialogRef.value.open(activityId)
|
||||
}
|
||||
|
||||
const formatServiceCategories = (categories?: number[]) => {
|
||||
if (!categories || categories.length === 0) {
|
||||
return '-'
|
||||
}
|
||||
const dictOptions = getIntDictOptions(DICT_TYPE.COMM_ACTIVITY_SERVICE_CATEGORY)
|
||||
return categories
|
||||
.map(c => dictOptions.find(d => d.value === c)?.label || '')
|
||||
.filter(Boolean)
|
||||
.join(', ')
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
loadCommunityList()
|
||||
getList()
|
||||
})
|
||||
</script>
|
||||
Loading…
Reference in New Issue