|
@@ -0,0 +1,367 @@
|
|
|
+<template>
|
|
|
+ <div class="daily_notify_box">
|
|
|
+ <div class="top_box">
|
|
|
+ <div class="filter_tags">
|
|
|
+ <span
|
|
|
+ v-for="(item, index) in tabs"
|
|
|
+ :key="index"
|
|
|
+ :class="{ active: currentTab === item['index'] }"
|
|
|
+ @click="switchTabHandle(item)"
|
|
|
+ >{{ item['title'] }}({{ item['num'] }})</span
|
|
|
+ >
|
|
|
+ </div>
|
|
|
+ <el-button type="primary" @click="onOperateHandle('add')">新增</el-button>
|
|
|
+ </div>
|
|
|
+ <div class="table" ref="tableRef">
|
|
|
+ <el-table
|
|
|
+ stripe
|
|
|
+ :data="tableData"
|
|
|
+ :header-cell-style="{
|
|
|
+ background: '#E5F0FB',
|
|
|
+ color: '#233755',
|
|
|
+ height: '50px'
|
|
|
+ }"
|
|
|
+ >
|
|
|
+ <el-table-column label="序号" width="80">
|
|
|
+ <template #default="scope">{{ scope.$index + 1 }}</template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="nickname" label="发布人" width="320" />
|
|
|
+ <el-table-column prop="createTime" label="发布时间" width="280">
|
|
|
+ <template #default="scope">
|
|
|
+ <span>{{ scope.row.createTime }}</span>
|
|
|
+ <span class="news" v-if="currentTab !== '1' && scope.row['isToday']"
|
|
|
+ ><img src="../../../../assets/imgs/OA/news_icon.png"
|
|
|
+ /></span>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ <el-table-column prop="content" label="发布内容" />
|
|
|
+
|
|
|
+ <el-table-column label="操作" width="180" align="center">
|
|
|
+ <template #default="scope">
|
|
|
+ <div class="operateBtn">
|
|
|
+ <span @click="onOperateHandle('look', scope.row)">查看</span>
|
|
|
+ <span v-if="currentTab === '3'" @click="onOperateHandle('editor', scope.row)"
|
|
|
+ >编辑</span
|
|
|
+ >
|
|
|
+ <dialog-confirm
|
|
|
+ title="确定要删除该条数据?"
|
|
|
+ width="280px"
|
|
|
+ v-if="currentTab === '3'"
|
|
|
+ @confirm="onDeleteHandle(scope.row)"
|
|
|
+ >
|
|
|
+ <template #reference>
|
|
|
+ <span class="delete">删除</span>
|
|
|
+ </template>
|
|
|
+ </dialog-confirm>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+ </div>
|
|
|
+ <div class="pageBox" v-if="currentTab == '2'">
|
|
|
+ <el-pagination
|
|
|
+ v-model:current-page="pageData.pageNo"
|
|
|
+ :page-size="pageData.pageSize"
|
|
|
+ background
|
|
|
+ layout="total, prev, pager, next, jumper"
|
|
|
+ :total="pageData.total"
|
|
|
+ @current-change="handleCurrentChange"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <el-dialog
|
|
|
+ v-model="dialogVisible"
|
|
|
+ width="600px"
|
|
|
+ :close-on-click-modal="false"
|
|
|
+ :title="
|
|
|
+ (operateType === 'add' ? '新增' : operateType === 'editor' ? '编辑' : '查看') + '速递'
|
|
|
+ "
|
|
|
+ >
|
|
|
+ <el-form :model="formData" label-width="96px" :rules="rules" ref="formRef">
|
|
|
+ <el-form-item label="发布人:">
|
|
|
+ <span>{{ formData.nickname }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <el-form-item v-if="operateType === 'look'" label="发布时间:">
|
|
|
+ <span>{{ formData.createTime }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ <template v-if="operateType !== 'look'">
|
|
|
+ <el-form-item label="发布内容:" prop="content">
|
|
|
+ <el-input
|
|
|
+ v-if="operateType !== 'look'"
|
|
|
+ v-model="formData.content"
|
|
|
+ maxlength="200"
|
|
|
+ placeholder="请输入您的发布内容,最多200字"
|
|
|
+ show-word-limit
|
|
|
+ :rows="8"
|
|
|
+ type="textarea"
|
|
|
+ />
|
|
|
+ <span v-else>{{ formData.content }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ <template v-else>
|
|
|
+ <el-form-item label="发布内容:">
|
|
|
+ <span>{{ formData.content }}</span>
|
|
|
+ </el-form-item>
|
|
|
+ </template>
|
|
|
+ </el-form>
|
|
|
+ <template #footer>
|
|
|
+ <div class="dialog-footer">
|
|
|
+ <el-button type="primary" @click="onSubmitHandle" v-if="operateType !== 'look'">
|
|
|
+ 保存
|
|
|
+ </el-button>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
+</template>
|
|
|
+<script setup lang="ts">
|
|
|
+import { useRouter } from 'vue-router'
|
|
|
+import request from '@/config/axios'
|
|
|
+import { ElMessage } from 'element-plus'
|
|
|
+import { CACHE_KEY, useCache } from '@/hooks/web/useCache'
|
|
|
+
|
|
|
+defineOptions({ name: 'ProjectBook' })
|
|
|
+const tableRef: any = ref(null)
|
|
|
+
|
|
|
+interface TabType {
|
|
|
+ title: string
|
|
|
+ index: string
|
|
|
+ num: number
|
|
|
+}
|
|
|
+const currentTab = ref<string>('0')
|
|
|
+const switchTabHandle = (item: TabType) => {
|
|
|
+ currentTab.value = item.index
|
|
|
+ if (currentTab.value === '2') {
|
|
|
+ queryDailyNotifyByPage()
|
|
|
+ } else {
|
|
|
+ tableData.value = listMap.value[currentTab.value]
|
|
|
+ }
|
|
|
+}
|
|
|
+const tabs = ref<TabType[]>([
|
|
|
+ {
|
|
|
+ title: '近三日',
|
|
|
+ index: '0',
|
|
|
+ num: 0
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '今日',
|
|
|
+ index: '1',
|
|
|
+ num: 0
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '所有',
|
|
|
+ index: '2',
|
|
|
+ num: 0
|
|
|
+ },
|
|
|
+ {
|
|
|
+ title: '我的',
|
|
|
+ index: '3',
|
|
|
+ num: 0
|
|
|
+ }
|
|
|
+])
|
|
|
+const queryDailyNotifyTotal = async () => {
|
|
|
+ const sendData = {
|
|
|
+ type: 3,
|
|
|
+ readType: 2
|
|
|
+ }
|
|
|
+ const urlApi = `/adm/noticeAndLearn/query/total`
|
|
|
+ const result = await request.post({ url: urlApi, data: sendData })
|
|
|
+ tabs.value = result
|
|
|
+}
|
|
|
+const pageData = ref<{
|
|
|
+ pageNo: number
|
|
|
+ pageSize: number
|
|
|
+ total?: number
|
|
|
+}>({
|
|
|
+ pageNo: 1,
|
|
|
+ pageSize: 10,
|
|
|
+ total: 0
|
|
|
+})
|
|
|
+const tableData = ref<Array<any>>([])
|
|
|
+const total = ref<number>()
|
|
|
+const queryDailyNotifyByPage = async (): Promise<void> => {
|
|
|
+ const urlApi = `/adm/noticeAndLearn/query/page`
|
|
|
+ const sendData = {
|
|
|
+ type: 3,
|
|
|
+ readType: 2,
|
|
|
+ ...pageData.value
|
|
|
+ }
|
|
|
+ const result = await request.post({ url: urlApi, data: sendData })
|
|
|
+ tableData.value = result['list']
|
|
|
+ total.value = result['total']
|
|
|
+}
|
|
|
+const handleCurrentChange = () => {}
|
|
|
+/**
|
|
|
+ * 数据列表分组
|
|
|
+ */
|
|
|
+const listMap = ref<any>({})
|
|
|
+const queryDailyNotifyGroup = async () => {
|
|
|
+ const sendData = {
|
|
|
+ type: 3,
|
|
|
+ readType: 2
|
|
|
+ }
|
|
|
+ const result = await request.post({
|
|
|
+ url: '/adm/noticeAndLearn/query/group',
|
|
|
+ data: sendData
|
|
|
+ })
|
|
|
+ const resultData = result
|
|
|
+ if (resultData) {
|
|
|
+ listMap.value = resultData
|
|
|
+ }
|
|
|
+}
|
|
|
+const initDailyNotifyData = () => {
|
|
|
+ currentTab.value = '0'
|
|
|
+ queryDailyNotifyGroup()
|
|
|
+ queryDailyNotifyByPage()
|
|
|
+ queryDailyNotifyTotal()
|
|
|
+}
|
|
|
+initDailyNotifyData()
|
|
|
+/**
|
|
|
+ * 速递查看、编辑、删除
|
|
|
+ */
|
|
|
+const dialogVisible = ref<boolean>(false)
|
|
|
+const formData = ref({
|
|
|
+ id: '',
|
|
|
+ nickname: '',
|
|
|
+ createTime: '',
|
|
|
+ content: ''
|
|
|
+})
|
|
|
+const { wsCache } = useCache()
|
|
|
+const user = wsCache.get(CACHE_KEY.USER)
|
|
|
+const operateType = ref('add')
|
|
|
+const onOperateHandle = (type: string, item = null): void => {
|
|
|
+ dialogVisible.value = true
|
|
|
+ operateType.value = type
|
|
|
+ formData.value['id'] = ''
|
|
|
+ if (type !== 'add' && item) {
|
|
|
+ formData.value['id'] = item['id']
|
|
|
+ formData.value['nickname'] = item?.['nickname']
|
|
|
+ formData.value['createTime'] = item?.['createTime']
|
|
|
+ formData.value['content'] = item?.['content']
|
|
|
+ } else {
|
|
|
+ formData.value['nickname'] = `${user.user.deptName}-${user.user.nickname}`
|
|
|
+ formData.value['content'] = ''
|
|
|
+ formData.value['createTime'] = ''
|
|
|
+ }
|
|
|
+}
|
|
|
+const isDisabled = ref(false)
|
|
|
+const rules = reactive({
|
|
|
+ content: [{ required: true, message: '内容不能为空!', trigger: 'blur' }]
|
|
|
+})
|
|
|
+const formRef = ref<any>(null)
|
|
|
+const onSubmitHandle = async () => {
|
|
|
+ if (!formRef.value) return
|
|
|
+ await formRef.value.validate(async (valid, fields) => {
|
|
|
+ if (valid) {
|
|
|
+ const urlApi = formData.value.id ? '/adm/noticeAndLearn/update' : '/adm/noticeAndLearn/add'
|
|
|
+ const sendData = {
|
|
|
+ type: '3',
|
|
|
+ nickname: formData.value.nickname,
|
|
|
+ content: formData.value.content
|
|
|
+ }
|
|
|
+ if (formData.value.id) {
|
|
|
+ sendData['id'] = formData.value.id
|
|
|
+ }
|
|
|
+ isDisabled.value = true
|
|
|
+ const result = await request.post({ url: urlApi, data: sendData })
|
|
|
+ if (result) {
|
|
|
+ ElMessage({
|
|
|
+ type: 'success',
|
|
|
+ message: '保存成功!'
|
|
|
+ })
|
|
|
+ initDailyNotifyData()
|
|
|
+ isDisabled.value = false
|
|
|
+ dialogVisible.value = false
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ console.log('error submit!', fields)
|
|
|
+ }
|
|
|
+ })
|
|
|
+}
|
|
|
+const onDeleteHandle = async (item: any) => {
|
|
|
+ const result = await request.get({ url: `/adm/noticeAndLearn/delete?id=${item.id}` })
|
|
|
+ if (result) {
|
|
|
+ initDailyNotifyData()
|
|
|
+ }
|
|
|
+}
|
|
|
+</script>
|
|
|
+
|
|
|
+<style lang="scss" scoped>
|
|
|
+.daily_notify_box {
|
|
|
+ height: 100%;
|
|
|
+ display: flex;
|
|
|
+ margin-top: 20px;
|
|
|
+ padding: 20px;
|
|
|
+ flex-direction: column;
|
|
|
+ background: #fff;
|
|
|
+ > .top_box {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ margin-bottom: 15px;
|
|
|
+ > .filter_tags {
|
|
|
+ display: inline-block;
|
|
|
+ background-color: #fff;
|
|
|
+ border: 1px solid #dfe0e4;
|
|
|
+ border-radius: 4px;
|
|
|
+ width: max-content;
|
|
|
+ margin-right: 10px;
|
|
|
+ > span {
|
|
|
+ display: inline-block;
|
|
|
+ color: #111;
|
|
|
+ font-size: 13px;
|
|
|
+ padding: 8px 15px;
|
|
|
+ cursor: pointer;
|
|
|
+ &:not(:first-child) {
|
|
|
+ border-left: 1px solid #dfe0e4;
|
|
|
+ border-right: 1px solid transparent;
|
|
|
+ }
|
|
|
+ &:first-child {
|
|
|
+ border-left: 1px solid transparent;
|
|
|
+ }
|
|
|
+ &.active {
|
|
|
+ color: #2b82f1;
|
|
|
+ border: 1px solid #2b82f1;
|
|
|
+ border-radius: 4px;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ > .table {
|
|
|
+ width: 100%;
|
|
|
+ flex: 1;
|
|
|
+ > .table {
|
|
|
+ width: 100%;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ > .pageBox {
|
|
|
+ padding: 20px 0px 10px 0px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: right;
|
|
|
+ }
|
|
|
+}
|
|
|
+.operateBtn {
|
|
|
+ > span {
|
|
|
+ margin: 0px 10px;
|
|
|
+ cursor: pointer;
|
|
|
+ &:nth-child(1),
|
|
|
+ &:nth-child(2) {
|
|
|
+ color: #2e77e6;
|
|
|
+ }
|
|
|
+ &:nth-child(3) {
|
|
|
+ color: red;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+.news {
|
|
|
+ > img {
|
|
|
+ height: 20px;
|
|
|
+ margin-left: 4px;
|
|
|
+ margin-top: -2px;
|
|
|
+ vertical-align: middle;
|
|
|
+ }
|
|
|
+}
|
|
|
+:deep(.el-radio) {
|
|
|
+ margin-right: 10px;
|
|
|
+}
|
|
|
+</style>
|