社区动态
parent
26fab5c858
commit
9dd73025f5
|
|
@ -1,5 +1,4 @@
|
||||||
import request from '@/config/axios'
|
import request from '@/config/axios'
|
||||||
import type {Dayjs} from 'dayjs';
|
|
||||||
|
|
||||||
/** 通知公告信息 */
|
/** 通知公告信息 */
|
||||||
export interface Notice {
|
export interface Notice {
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,59 @@
|
||||||
|
import request from '@/config/axios'
|
||||||
|
|
||||||
|
/** 社区动态信息 */
|
||||||
|
export interface CommunityPost {
|
||||||
|
id: number; // 动态编号
|
||||||
|
title?: string; // 动态标题
|
||||||
|
content?: string; // 动态内容
|
||||||
|
author?: string; // 发布方
|
||||||
|
coverImage?: string; // 封面图片URL
|
||||||
|
postType?: number; // 动态类型(1-物业,2-业委会,3-社区)
|
||||||
|
publishType?: number; // 发布类型(1-立即发布,2-定时发布)
|
||||||
|
publishTime?: string; // 发布时间(毫秒时间戳)
|
||||||
|
endType?: number; // 结束类型(1-长期有效,2-定时结束)
|
||||||
|
endTime?: string; // 结束时间(毫秒时间戳)
|
||||||
|
pushEnabled?: boolean; // 是否消息推送
|
||||||
|
status?: number; // 状态(0-草稿,1-已发布,2-已下线,3-已撤回)
|
||||||
|
viewCount?: number; // 浏览次数
|
||||||
|
communityIds?: number[]; // 小区ID列表
|
||||||
|
communityNames?: string[]; // 小区名称列表
|
||||||
|
createTime?: string; // 创建时间(毫秒时间戳)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 社区动态 API
|
||||||
|
export const CommunityPostApi = {
|
||||||
|
// 查询社区动态分页
|
||||||
|
getCommunityPostPage: async (params: any) => {
|
||||||
|
return await request.get({ url: `/community/post/page`, params })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 查询社区动态详情
|
||||||
|
getCommunityPost: async (id: number) => {
|
||||||
|
return await request.get({ url: `/community/post/get?id=` + id })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 新增社区动态
|
||||||
|
createCommunityPost: async (data: CommunityPost) => {
|
||||||
|
return await request.post({ url: `/community/post/create`, data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 修改社区动态
|
||||||
|
updateCommunityPost: async (data: CommunityPost) => {
|
||||||
|
return await request.put({ url: `/community/post/update`, data })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 删除社区动态
|
||||||
|
deleteCommunityPost: async (id: number) => {
|
||||||
|
return await request.delete({ url: `/community/post/delete?id=` + id })
|
||||||
|
},
|
||||||
|
|
||||||
|
/** 批量删除社区动态 */
|
||||||
|
deleteCommunityPostList: async (ids: number[]) => {
|
||||||
|
return await request.delete({ url: `/community/post/delete-list?ids=${ids.join(',')}` })
|
||||||
|
},
|
||||||
|
|
||||||
|
// 导出社区动态 Excel
|
||||||
|
exportCommunityPost: async (params) => {
|
||||||
|
return await request.download({ url: `/community/post/export-excel`, params })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -207,4 +207,9 @@ export enum DICT_TYPE {
|
||||||
COMM_NOTICE_PUBLISH_TYPE = 'comm_notice_publish_type',
|
COMM_NOTICE_PUBLISH_TYPE = 'comm_notice_publish_type',
|
||||||
COMM_NOTICE_END_TYPE = 'comm_notice_end_type',
|
COMM_NOTICE_END_TYPE = 'comm_notice_end_type',
|
||||||
COMM_NOTICE_STATUS = 'comm_notice_status',
|
COMM_NOTICE_STATUS = 'comm_notice_status',
|
||||||
|
|
||||||
|
COMM_POST_TYPE = 'comm_post_type',
|
||||||
|
COMM_POST_PUBLISH_TYPE = 'comm_post_publish_type',
|
||||||
|
COMM_POST_STATUS = 'comm_post_status',
|
||||||
|
COMM_POST_END_TYPE = 'comm_post_end_type',
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -117,7 +117,7 @@ const formData = ref({
|
||||||
endType: 1,
|
endType: 1,
|
||||||
endTime: undefined,
|
endTime: undefined,
|
||||||
communityIds: [],
|
communityIds: [],
|
||||||
pushEnabled: true
|
pushEnabled: false
|
||||||
})
|
})
|
||||||
const formRules = reactive({
|
const formRules = reactive({
|
||||||
title: [{ required: true, message: '公告标题不能为空', trigger: 'blur' }],
|
title: [{ required: true, message: '公告标题不能为空', trigger: 'blur' }],
|
||||||
|
|
@ -165,7 +165,7 @@ const open = async (type: string, id?: number) => {
|
||||||
endType: data.endType || 1,
|
endType: data.endType || 1,
|
||||||
endTime: data.endTime,
|
endTime: data.endTime,
|
||||||
communityIds: Array.isArray(data.communityIds) ? data.communityIds : [],
|
communityIds: Array.isArray(data.communityIds) ? data.communityIds : [],
|
||||||
pushEnabled: data.pushEnabled !== undefined ? data.pushEnabled : true
|
pushEnabled: data.pushEnabled !== undefined ? data.pushEnabled : false
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
formLoading.value = false
|
formLoading.value = false
|
||||||
|
|
@ -223,7 +223,7 @@ const resetForm = () => {
|
||||||
endType: 1,
|
endType: 1,
|
||||||
endTime: undefined,
|
endTime: undefined,
|
||||||
communityIds: [],
|
communityIds: [],
|
||||||
pushEnabled: true
|
pushEnabled: false
|
||||||
}
|
}
|
||||||
formRef.value?.resetFields()
|
formRef.value?.resetFields()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,247 @@
|
||||||
|
<template>
|
||||||
|
<Dialog :title="dialogTitle" v-model="dialogVisible" width="800px">
|
||||||
|
<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="200px" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="发布方" prop="author">
|
||||||
|
<el-input v-model="formData.author" placeholder="请输入发布方" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="封面图片" prop="coverImage">
|
||||||
|
<UploadImg v-model="formData.coverImage" :limit="1" />
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="动态类型" prop="postType">
|
||||||
|
<el-select v-model="formData.postType" placeholder="请选择动态类型" style="width: 100%">
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.COMM_POST_TYPE)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-divider content-position="left">
|
||||||
|
<el-icon><InfoFilled /></el-icon>
|
||||||
|
发布信息
|
||||||
|
</el-divider>
|
||||||
|
|
||||||
|
<el-form-item label="发布时间" prop="publishType">
|
||||||
|
<el-radio-group v-model="formData.publishType">
|
||||||
|
<el-radio :value="1">立即发布</el-radio>
|
||||||
|
<el-radio :value="2">定时发布</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
<el-date-picker
|
||||||
|
v-if="formData.publishType === 2"
|
||||||
|
v-model="formData.publishTime"
|
||||||
|
type="datetime"
|
||||||
|
placeholder="选择发布时间"
|
||||||
|
value-format="x"
|
||||||
|
style="margin-left: 12px"
|
||||||
|
/>
|
||||||
|
</el-form-item>
|
||||||
|
|
||||||
|
<el-form-item label="结束时间" prop="endType">
|
||||||
|
<el-radio-group v-model="formData.endType">
|
||||||
|
<el-radio :value="1">长期有效</el-radio>
|
||||||
|
<el-radio :value="2">定时结束</el-radio>
|
||||||
|
</el-radio-group>
|
||||||
|
<el-date-picker
|
||||||
|
v-if="formData.endType === 2"
|
||||||
|
v-model="formData.endTime"
|
||||||
|
type="datetime"
|
||||||
|
placeholder="选择结束时间"
|
||||||
|
value-format="x"
|
||||||
|
style="margin-left: 12px"
|
||||||
|
/>
|
||||||
|
</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="pushEnabled">
|
||||||
|
<el-switch v-model="formData.pushEnabled" />
|
||||||
|
</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 { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||||
|
import { CommunityPostApi, CommunityPost } from '@/api/community/post'
|
||||||
|
import { CommunityApi, CommunitySimpleVO } from '@/api/community/community'
|
||||||
|
import { InfoFilled } from '@element-plus/icons-vue'
|
||||||
|
|
||||||
|
/** 社区动态 表单 */
|
||||||
|
defineOptions({ name: 'CommunityPostForm' })
|
||||||
|
|
||||||
|
const { t } = useI18n() // 国际化
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
|
||||||
|
const dialogVisible = ref(false) // 弹窗的是否展示
|
||||||
|
const dialogTitle = ref('') // 弹窗的标题
|
||||||
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
||||||
|
const formType = ref('') // 表单的类型:create - 新增;update - 修改
|
||||||
|
const formData = ref({
|
||||||
|
id: undefined,
|
||||||
|
title: undefined,
|
||||||
|
content: undefined,
|
||||||
|
author: undefined,
|
||||||
|
coverImage: undefined,
|
||||||
|
postType: undefined,
|
||||||
|
publishType: 1,
|
||||||
|
publishTime: undefined,
|
||||||
|
endType: 1,
|
||||||
|
endTime: undefined,
|
||||||
|
communityIds: [],
|
||||||
|
pushEnabled: false
|
||||||
|
})
|
||||||
|
const formRules = reactive({
|
||||||
|
title: [{ required: true, message: '动态标题不能为空', trigger: 'blur' }],
|
||||||
|
content: [{ required: true, message: '动态内容不能为空', trigger: 'blur' }],
|
||||||
|
author: [{ required: true, message: '发布方不能为空', trigger: 'blur' }],
|
||||||
|
postType: [{ required: true, message: '动态类型不能为空', trigger: 'change' }],
|
||||||
|
publishType: [{ required: true, message: '发布类型不能为空', trigger: 'change' }],
|
||||||
|
endType: [{ required: true, message: '结束类型不能为空', trigger: 'change' }],
|
||||||
|
communityIds: [{ required: true, message: '请选择发布范围', trigger: 'change' }]
|
||||||
|
})
|
||||||
|
const formRef = ref() // 表单 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
|
||||||
|
dialogTitle.value = t('action.' + type)
|
||||||
|
formType.value = type
|
||||||
|
resetForm()
|
||||||
|
|
||||||
|
// 加载小区列表
|
||||||
|
await loadCommunityList()
|
||||||
|
|
||||||
|
// 修改时,设置数据
|
||||||
|
if (id) {
|
||||||
|
formLoading.value = true
|
||||||
|
try {
|
||||||
|
const data = await CommunityPostApi.getCommunityPost(id)
|
||||||
|
formData.value = {
|
||||||
|
id: data.id,
|
||||||
|
title: data.title,
|
||||||
|
content: data.content,
|
||||||
|
author: data.author,
|
||||||
|
coverImage: data.coverImage,
|
||||||
|
postType: data.postType,
|
||||||
|
publishType: data.publishType || 1,
|
||||||
|
publishTime: data.publishTime,
|
||||||
|
endType: data.endType || 1,
|
||||||
|
endTime: data.endTime,
|
||||||
|
communityIds: Array.isArray(data.communityIds) ? data.communityIds : [],
|
||||||
|
pushEnabled: data.pushEnabled !== undefined ? data.pushEnabled : false
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
formLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
|
||||||
|
|
||||||
|
/** 提交表单 */
|
||||||
|
const emit = defineEmits(['success']) // 定义 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,
|
||||||
|
author: formData.value.author,
|
||||||
|
coverImage: formData.value.coverImage,
|
||||||
|
postType: formData.value.postType,
|
||||||
|
publishType: formData.value.publishType,
|
||||||
|
publishTime: formData.value.publishType === 1 ? undefined : formData.value.publishTime,
|
||||||
|
endType: formData.value.endType,
|
||||||
|
endTime: formData.value.endType === 1 ? undefined : formData.value.endTime,
|
||||||
|
communityIds: formData.value.communityIds,
|
||||||
|
pushEnabled: formData.value.pushEnabled
|
||||||
|
} as unknown as CommunityPost
|
||||||
|
if (formType.value === 'create') {
|
||||||
|
await CommunityPostApi.createCommunityPost(data)
|
||||||
|
message.success(t('common.createSuccess'))
|
||||||
|
} else {
|
||||||
|
await CommunityPostApi.updateCommunityPost(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,
|
||||||
|
author: undefined,
|
||||||
|
coverImage: undefined,
|
||||||
|
postType: undefined,
|
||||||
|
publishType: 1,
|
||||||
|
publishTime: undefined,
|
||||||
|
endType: 1,
|
||||||
|
endTime: undefined,
|
||||||
|
communityIds: [],
|
||||||
|
pushEnabled: false
|
||||||
|
}
|
||||||
|
formRef.value?.resetFields()
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
@ -0,0 +1,333 @@
|
||||||
|
<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="postType">
|
||||||
|
<el-select
|
||||||
|
v-model="queryParams.postType"
|
||||||
|
placeholder="请选择动态类型"
|
||||||
|
clearable
|
||||||
|
class="!w-240px"
|
||||||
|
>
|
||||||
|
<el-option
|
||||||
|
v-for="dict in getIntDictOptions(DICT_TYPE.COMM_POST_TYPE)"
|
||||||
|
:key="dict.value"
|
||||||
|
:label="dict.label"
|
||||||
|
:value="dict.value"
|
||||||
|
/>
|
||||||
|
</el-select>
|
||||||
|
</el-form-item>
|
||||||
|
<el-form-item label="发布时间" prop="publishTime">
|
||||||
|
<el-date-picker
|
||||||
|
v-model="queryParams.publishTime"
|
||||||
|
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:post:create']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:plus" class="mr-5px" /> 新建
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
type="primary"
|
||||||
|
plain
|
||||||
|
@click="handleExport"
|
||||||
|
:loading="exportLoading"
|
||||||
|
v-hasPermi="['community:post:export']"
|
||||||
|
>
|
||||||
|
<Icon icon="ep:download" 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="coverImage" width="120">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-image
|
||||||
|
v-if="scope.row.coverImage"
|
||||||
|
:src="scope.row.coverImage"
|
||||||
|
fit="cover"
|
||||||
|
style="width: 60px; height: 60px; border-radius: 4px; cursor: pointer"
|
||||||
|
@click="handlePreviewImage(scope.row.coverImage)"
|
||||||
|
/>
|
||||||
|
<span v-else>-</span>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="动态标题" align="center" prop="title" min-width="200" show-overflow-tooltip />
|
||||||
|
<el-table-column label="发布方" align="center" prop="author" width="120" />
|
||||||
|
<el-table-column label="动态类型" align="center" prop="postType" width="120">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.COMM_POST_TYPE" :value="scope.row.postType" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="发布类型" align="center" prop="publishType" width="120">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.COMM_POST_PUBLISH_TYPE" :value="scope.row.publishType" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="发布时间"
|
||||||
|
align="center"
|
||||||
|
prop="publishTime"
|
||||||
|
:formatter="dateFormatter"
|
||||||
|
width="180px"
|
||||||
|
/>
|
||||||
|
<el-table-column label="结束时间类型" align="center" prop="endType" width="120">
|
||||||
|
<template #default="scope">
|
||||||
|
<dict-tag :type="DICT_TYPE.COMM_POST_END_TYPE" :value="scope.row.endType" />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column
|
||||||
|
label="结束时间"
|
||||||
|
align="center"
|
||||||
|
prop="endTime"
|
||||||
|
:formatter="dateFormatter"
|
||||||
|
width="180px"
|
||||||
|
/>
|
||||||
|
<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="pushEnabled" width="100">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-switch v-model="scope.row.pushEnabled" disabled />
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" align="center" min-width="120px" fixed="right">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="primary"
|
||||||
|
@click="openForm('update', scope.row.id)"
|
||||||
|
v-hasPermi="['community:post:update']"
|
||||||
|
>
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-button
|
||||||
|
link
|
||||||
|
type="danger"
|
||||||
|
@click="handleDelete(scope.row.id)"
|
||||||
|
v-hasPermi="['community:post: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>
|
||||||
|
|
||||||
|
<!-- 表单弹窗:添加/修改 -->
|
||||||
|
<CommunityPostForm ref="formRef" @success="getList" />
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
|
||||||
|
import { dateFormatter } from '@/utils/formatTime'
|
||||||
|
import download from '@/utils/download'
|
||||||
|
import { CommunityPostApi, CommunityPost } from '@/api/community/post'
|
||||||
|
import { CommunityApi, CommunitySimpleVO } from '@/api/community/community'
|
||||||
|
import CommunityPostForm from './CommunityPostForm.vue'
|
||||||
|
import { createImageViewer } from '@/components/ImageViewer'
|
||||||
|
|
||||||
|
/** 社区动态 列表 */
|
||||||
|
defineOptions({ name: 'CommunityPost' })
|
||||||
|
|
||||||
|
const message = useMessage() // 消息弹窗
|
||||||
|
const { t } = useI18n() // 国际化
|
||||||
|
|
||||||
|
const loading = ref(true) // 列表的加载中
|
||||||
|
const list = ref<CommunityPost[]>([]) // 列表的数据
|
||||||
|
const total = ref(0) // 列表的总页数
|
||||||
|
const queryParams = reactive({
|
||||||
|
pageNo: 1,
|
||||||
|
pageSize: 10,
|
||||||
|
title: undefined,
|
||||||
|
postType: undefined,
|
||||||
|
publishTime: [],
|
||||||
|
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 CommunityPostApi.getCommunityPostPage(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 CommunityPostApi.deleteCommunityPost(id)
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 批量删除社区动态 */
|
||||||
|
const handleDeleteBatch = async () => {
|
||||||
|
try {
|
||||||
|
await message.delConfirm()
|
||||||
|
await CommunityPostApi.deleteCommunityPostList(checkedIds.value)
|
||||||
|
checkedIds.value = []
|
||||||
|
message.success(t('common.delSuccess'))
|
||||||
|
await getList()
|
||||||
|
} catch {}
|
||||||
|
}
|
||||||
|
|
||||||
|
const checkedIds = ref<number[]>([])
|
||||||
|
const handleRowCheckboxChange = (records: CommunityPost[]) => {
|
||||||
|
checkedIds.value = records.map((item) => item.id!)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 导出按钮操作 */
|
||||||
|
const handleExport = async () => {
|
||||||
|
try {
|
||||||
|
await message.exportConfirm()
|
||||||
|
exportLoading.value = true
|
||||||
|
const data = await CommunityPostApi.exportCommunityPost(queryParams)
|
||||||
|
download.excel(data, '社区动态.xls')
|
||||||
|
} catch {
|
||||||
|
} finally {
|
||||||
|
exportLoading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 预览图片 */
|
||||||
|
const handlePreviewImage = (url: string) => {
|
||||||
|
createImageViewer({
|
||||||
|
urlList: [url],
|
||||||
|
zIndex: 3000,
|
||||||
|
hideOnClickModal: true,
|
||||||
|
teleported: true
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/** 初始化 **/
|
||||||
|
onMounted(() => {
|
||||||
|
loadCommunityList()
|
||||||
|
getList()
|
||||||
|
})
|
||||||
|
|
||||||
|
</script>
|
||||||
Loading…
Reference in New Issue