2023-12-25 17:57:18 +08:00
|
|
|
<template>
|
2023-12-26 17:11:15 +08:00
|
|
|
<div class="table-page custom-table-table">
|
|
|
|
<h3 class="main-color" style="font-size: 24px;line-height: 1;padding: 28px 0;">消息管理</h3>
|
|
|
|
<div class="search-part ">
|
2023-12-25 17:57:18 +08:00
|
|
|
<div class="search-cell">
|
2023-12-26 17:11:15 +08:00
|
|
|
<span class="label">消息类型</span>
|
|
|
|
<el-select v-model="queryParams.type" placeholder="请选择消息类型">
|
|
|
|
<el-option v-for="item in getMessageType()" :key="item.value" :label="item.label"
|
2023-12-25 17:57:18 +08:00
|
|
|
:value="item.value" />
|
|
|
|
</el-select>
|
|
|
|
</div>
|
2023-12-26 17:11:15 +08:00
|
|
|
<div class="search-cell">
|
|
|
|
<span class="label">消息内容</span>
|
|
|
|
<el-input v-model="queryParams.content" placeholder="请输入消息内容"></el-input>
|
|
|
|
</div>
|
2023-12-25 17:57:18 +08:00
|
|
|
<el-button type="primary" icon="Search" @click="queryData(queryParams)">查询</el-button>
|
2023-12-26 17:11:15 +08:00
|
|
|
<!-- <el-button icon="Refresh" @click="queryParams = {}">重置</el-button> -->
|
2023-12-25 17:57:18 +08:00
|
|
|
</div>
|
|
|
|
<div class="button-part" style="justify-content: space-between;">
|
2023-12-26 17:11:15 +08:00
|
|
|
<el-button type="primary" icon="FirstAidKit" @click="addData">新增</el-button>
|
2023-12-25 17:57:18 +08:00
|
|
|
</div>
|
|
|
|
<div class="table-part">
|
2023-12-26 17:11:15 +08:00
|
|
|
<el-table ref="tableRef" :data="tableData" height="100%" border show-overflow-tooltip>
|
|
|
|
<el-table-column property="type" label="消息类型" width="120" align="center" />
|
|
|
|
<el-table-column property="content" label="消息内容" width="120" align="center" />
|
|
|
|
<el-table-column property="creator" label="创建人" width="120" align="center" />
|
|
|
|
<el-table-column label="创建时间" width="220" align="center">
|
|
|
|
<template #default="scope">{{ dateFormater('yyyy-MM-dd HH:mm:ss', scope.row.creatTime) }}</template>
|
|
|
|
</el-table-column>
|
|
|
|
<el-table-column property="editor" label="修改人" width="120" align="center" />
|
|
|
|
<el-table-column label="修改时间" width="220" align="center">
|
|
|
|
<template #default="scope">{{ dateFormater('yyyy-MM-dd HH:mm:ss', scope.row.editTime) }}</template>
|
2023-12-25 17:57:18 +08:00
|
|
|
</el-table-column>
|
2023-12-26 17:11:15 +08:00
|
|
|
<el-table-column label="操作" align="center">
|
2023-12-25 17:57:18 +08:00
|
|
|
<template #default="scope">
|
2023-12-26 17:11:15 +08:00
|
|
|
<span @click.stop>
|
|
|
|
<el-button link icon="EditPen" @click="editData(scope.row)">修改</el-button>
|
|
|
|
<el-button type="danger" link icon="Delete" @click="removeData(scope.row)">删除</el-button>
|
2023-12-25 17:57:18 +08:00
|
|
|
</span>
|
|
|
|
</template>
|
|
|
|
</el-table-column>
|
|
|
|
</el-table>
|
|
|
|
</div>
|
|
|
|
<div class="pagination-part">
|
|
|
|
<CommonPagination :total="100" @paginationChange="paginationChange" />
|
|
|
|
</div>
|
|
|
|
</div>
|
2023-12-26 17:11:15 +08:00
|
|
|
<el-dialog v-model="isFormDialog" :title="formDialogTitle" width="40%"><MessageForm ref="messageFormRef" :type="formDialogTitle === '新增消息' ? 'add' : 'edit'" @close="isFormDialog = false" /></el-dialog>
|
2023-12-25 17:57:18 +08:00
|
|
|
</template>
|
|
|
|
|
|
|
|
<script lang='ts' setup>
|
|
|
|
import { onMounted, reactive, ref, toRefs, watch } from 'vue'
|
|
|
|
import { ElMessage, ElMessageBox } from 'element-plus'
|
|
|
|
import { useRouter, useRoute } from 'vue-router'
|
|
|
|
import CommonPagination from '@/components/common-pagination.vue'
|
2023-12-26 17:11:15 +08:00
|
|
|
import MessageForm from './form/message-form.vue'
|
|
|
|
import { tableRemoveRow } from '@/utils/table-util'
|
|
|
|
import { getMessageType } from '@/static-data/core'
|
|
|
|
import { dateFormater } from '@/utils/date-util'
|
2023-12-25 17:57:18 +08:00
|
|
|
|
|
|
|
const router = useRouter()
|
|
|
|
const route = useRoute()
|
|
|
|
|
|
|
|
const tableRef = ref()
|
2023-12-26 17:11:15 +08:00
|
|
|
const messageFormRef = ref()
|
2023-12-25 17:57:18 +08:00
|
|
|
const isFormDialog = ref(false)
|
|
|
|
const formDialogTitle = ref('')
|
2023-12-26 17:11:15 +08:00
|
|
|
const queryParams = ref({} as any)
|
2023-12-25 17:57:18 +08:00
|
|
|
const tableData = ref([] as any)
|
|
|
|
|
2023-12-26 17:11:15 +08:00
|
|
|
queryData({type: '公告', content: '测试测试测试'})
|
2023-12-25 17:57:18 +08:00
|
|
|
|
|
|
|
function queryData (e: any) {
|
|
|
|
tableData.value = []
|
|
|
|
while (tableData.value.length < 10) {
|
|
|
|
tableData.value.push({
|
2023-12-26 17:11:15 +08:00
|
|
|
type: e.type,
|
|
|
|
content: e.content,
|
|
|
|
creator: 'admin',
|
|
|
|
creatTime: new Date(),
|
|
|
|
editor: 'admin',
|
|
|
|
editTime: new Date(),
|
|
|
|
hospital: '',
|
|
|
|
showDept: '',
|
|
|
|
permissions: '',
|
|
|
|
link: '',
|
|
|
|
isHot: true,
|
2023-12-25 17:57:18 +08:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
const addData = () => {
|
|
|
|
isFormDialog.value = true
|
2023-12-26 17:11:15 +08:00
|
|
|
formDialogTitle.value = '新增消息'
|
2023-12-25 17:57:18 +08:00
|
|
|
setTimeout(() => {
|
2023-12-26 17:11:15 +08:00
|
|
|
messageFormRef.value.resetData()
|
2023-12-25 17:57:18 +08:00
|
|
|
}, 0)
|
|
|
|
}
|
2023-12-26 17:11:15 +08:00
|
|
|
const editData = (e: any) => {
|
|
|
|
isFormDialog.value = true
|
|
|
|
formDialogTitle.value = '修改'
|
2023-12-25 17:57:18 +08:00
|
|
|
setTimeout(() => {
|
2023-12-26 17:11:15 +08:00
|
|
|
messageFormRef.value.resetData()
|
|
|
|
messageFormRef.value.formData = JSON.parse(JSON.stringify(e))
|
|
|
|
}, 0)
|
2023-12-25 17:57:18 +08:00
|
|
|
}
|
|
|
|
const removeData = (e?: any) => {
|
|
|
|
const selectRow = e || tableRef.value.getSelectionRows()
|
|
|
|
tableRemoveRow({ data: selectRow }, (res: boolean) => {
|
|
|
|
if (res) {
|
|
|
|
console.log('调用删除', selectRow)
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
const paginationChange = (page: number, size: number) => {
|
|
|
|
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang='scss' scoped>
|
2023-12-26 17:11:15 +08:00
|
|
|
.table-page.custom-table-table {
|
|
|
|
.search-part {
|
|
|
|
padding: 40px 30px;
|
|
|
|
border: 1px solid $border-color;
|
|
|
|
&>.search-cell ~ .search-cell {
|
|
|
|
margin-left: 50px;
|
|
|
|
}
|
|
|
|
.search-cell {
|
|
|
|
flex-grow: 1;
|
|
|
|
}
|
|
|
|
&>.el-button {
|
|
|
|
margin-left: 100px;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
.table-part {
|
|
|
|
height: calc(100% - 292px);
|
|
|
|
}
|
|
|
|
}
|
2023-12-25 17:57:18 +08:00
|
|
|
|
|
|
|
</style>
|