ref: 重构日程

This commit is contained in:
lbw 2023-03-06 21:44:34 +08:00
parent 57e454476e
commit 99b5437d25
8 changed files with 114 additions and 72 deletions

10
src/views/home/i18n/en.ts Normal file
View File

@ -0,0 +1,10 @@
export default {
home: {
addFavoriteRoutesTip: 'no data , right click on the tab to favorite',
quickNavigationToolsTip: 'quick navigation bar',
systemLogsTip: 'system logs',
auditLogsTip: 'audit logs',
moreTip: 'more',
newsletterTip: 'news letter',
},
};

View File

@ -0,0 +1,10 @@
export default {
home: {
addFavoriteRoutesTip: '暂无数据,标签页右键收藏',
quickNavigationToolsTip: '快捷导航栏',
systemLogsTip: '系统日志',
auditLogsTip: '审计日志',
moreTip: '更多',
newsletterTip: '站内信',
},
};

View File

@ -3,6 +3,7 @@
<el-row :gutter="10"> <el-row :gutter="10">
<el-col :span="16"> <el-col :span="16">
<el-row :gutter="10"> <el-row :gutter="10">
<!-- 基本信息 -->
<el-col :span="24"> <el-col :span="24">
<div class="home-card-item" v-loading="userLoading"> <div class="home-card-item" v-loading="userLoading">
<el-row> <el-row>
@ -15,12 +16,12 @@
</el-col> </el-col>
<el-col :span="4" :offset="14"> {{ formatDate(date, 'YYYY-mm-dd HH:MM:SS') }} </el-col> <el-col :span="4" :offset="14"> {{ formatDate(date, 'YYYY-mm-dd HH:MM:SS') }} </el-col>
</el-row> </el-row>
<!-- {{ userData }}-->
</div> </div>
</el-col> </el-col>
<!-- 快捷导航栏 -->
<el-col :span="24"> <el-col :span="24">
<div class="home-card-item"> <div class="home-card-item">
<div class="home-card-item-title">快捷导航工具</div> <div class="home-card-item-title">{{ $t('home.quickNavigationToolsTip') }}</div>
<div class="home-monitor"> <div class="home-monitor">
<div class="flex-warp" v-if="favoriteRoutes.length > 0"> <div class="flex-warp" v-if="favoriteRoutes.length > 0">
<div class="flex-warp-item" v-for="(v, k) in favoriteRoutes" :key="k"> <div class="flex-warp-item" v-for="(v, k) in favoriteRoutes" :key="k">
@ -34,16 +35,17 @@
</div> </div>
</div> </div>
</div> </div>
<el-empty v-else /> <el-empty :description="$t('home.addFavoriteRoutesTip')" v-else />
</div> </div>
</div> </div>
</el-col> </el-col>
<!-- 系统日志 -->
<el-col :span="12"> <el-col :span="12">
<el-card class="box-card"> <el-card class="box-card">
<template #header> <template #header>
<div class="card-header"> <div class="card-header">
<span>系统日志</span> <span>{{ $t('home.systemLogsTip') }}</span>
<el-button link class="button" text @click="handleRoutr('log')">更多</el-button> <el-button link class="button" text @click="handleRoutr('log')">{{ $t('home.moreTip') }}</el-button>
</div> </div>
</template> </template>
<el-timeline v-if="logState.dataList.length > 0"> <el-timeline v-if="logState.dataList.length > 0">
@ -53,12 +55,13 @@
</el-timeline> </el-timeline>
</el-card> </el-card>
</el-col> </el-col>
<!-- 审计日志 -->
<el-col :span="12"> <el-col :span="12">
<el-card class="box-card"> <el-card class="box-card">
<template #header> <template #header>
<div class="card-header"> <div class="card-header">
<span>审计日志</span> <span>{{ $t('home.auditLogsTip') }}</span>
<el-button link class="button" text @click="handleRoutr('audit')">更多</el-button> <el-button link class="button" text @click="handleRoutr('audit')">{{ $t('home.moreTip') }}</el-button>
</div> </div>
</template> </template>
<el-timeline v-if="auditState.dataList.length > 0"> <el-timeline v-if="auditState.dataList.length > 0">
@ -73,38 +76,27 @@
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<el-row> <el-row>
<!-- 日程 -->
<el-col :span="24"> <el-col :span="24">
<el-card class="box-card"> <el-card class="box-card">
<el-calendar v-model="calendar"> <el-calendar v-model="calendar">
<template #date-cell="{ data }"> <template #date-cell="{ data }">
<div <div style="width: 100%; height: 100%" @click="handleSchedule(data)">
:class="data.isSelected ? 'is-selected' : ''" {{ data.day.split('-').slice(2).join('-') }}
style="width: 100%; height: 100%" <span v-if="filterCellSelected(data)">
@click="scheduleFormRef.openDialog(null, { date: formatDate(data.date, 'YYYY-mm-dd') })" <el-icon><BellFilled /></el-icon>
> </span>
{{ data.day.split('-').slice(1).join('-') }}
<ul class="events">
<li v-for="item in getListData(data.date)" :key="item.content">
<el-badge :value="item.title" :is-dot="true" />
{{ item.title }}
</li>
</ul>
</div> </div>
</template> </template>
</el-calendar> </el-calendar>
<el-timeline style="margin-top: 20px" v-if="scheduleDataList.length > 0">
<el-timeline-item v-for="(item, index) in scheduleDataList" :key="index" :timestamp="item.time">
{{ item.title }} - {{ item.createBy }}
</el-timeline-item>
</el-timeline>
<el-empty v-else />
</el-card> </el-card>
</el-col> </el-col>
<!-- -->
<el-col :span="24"> <el-col :span="24">
<el-card class="box-card"> <el-card class="box-card">
<template #header> <template #header>
<div class="card-header"> <div class="card-header">
<span>站内信</span> <span>{{ $t('home.newsletterTip') }}</span>
</div> </div>
</template> </template>
<el-timeline v-if="newsList.length > 0"> <el-timeline v-if="newsList.length > 0">
@ -118,13 +110,16 @@
</el-row> </el-row>
</el-col> </el-col>
</el-row> </el-row>
<schedule-form ref="scheduleFormRef" @refresh="() => {}"></schedule-form>
<!-- 新增日程的表单 -->
<schedule-form ref="scheduleFormRef" @refresh="initscheduleList(formatDate(calendar, 'YYYY-mm'))" />
<!-- 日程查询 -->
<schedule ref="scheduleRef" />
</div> </div>
</template> </template>
<script setup lang="ts" name="home"> <script setup lang="ts" name="home">
import { storeToRefs } from 'pinia'; import { storeToRefs } from 'pinia';
import { useThemeConfig } from '/@/stores/themeConfig';
import { useTagsViewRoutes } from '/@/stores/tagsViewRoutes'; import { useTagsViewRoutes } from '/@/stores/tagsViewRoutes';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { useUserInfo } from '/@/stores/userInfo'; import { useUserInfo } from '/@/stores/userInfo';
@ -132,16 +127,26 @@ import { useMsg } from '/@/stores/msg';
import { BasicTableProps, useTable } from '/@/hooks/table'; import { BasicTableProps, useTable } from '/@/hooks/table';
import { pageList } from '/@/api/admin/log'; import { pageList } from '/@/api/admin/log';
import { fetchList } from '/@/api/admin/audit'; import { fetchList } from '/@/api/admin/audit';
import { formatDate } from '/@/utils/formatTime'; import { formatDate, parseDate } from '/@/utils/formatTime';
import { getObj } from '/@/api/admin/user'; import { getObj } from '/@/api/admin/user';
import { list } from '/@/api/admin/schedule'; import { list } from '/@/api/admin/schedule';
const ScheduleForm = defineAsyncComponent(() => import('/@/views/home/schedule/form.vue'));
const Schedule = defineAsyncComponent(() => import('/@/views/home/schedule/index.vue'));
const router = useRouter(); const router = useRouter();
const storesTagsViewRoutes = useTagsViewRoutes(); const storesTagsViewRoutes = useTagsViewRoutes();
const storesThemeConfig = useThemeConfig(); const { favoriteRoutes } = storeToRefs(storesTagsViewRoutes);
const { themeConfig } = storeToRefs(storesThemeConfig); const userLoading = ref(false);
const { isTagsViewCurrenFull, favoriteRoutes } = storeToRefs(storesTagsViewRoutes); const date = ref(new Date());
const scheduleFormRef = ref();
const scheduleRef = ref();
const calendar = ref(new Date());
const userData = ref({} as any);
const scheduleDataList = ref([] as any);
const ScheduleForm = defineAsyncComponent(() => import('/@/views/admin/schedule/form.vue')); const newsList = computed(() => {
return useMsg().getAllMsg();
});
const HandleRoute = (item: any) => { const HandleRoute = (item: any) => {
router.push(item.path); router.push(item.path);
@ -151,11 +156,6 @@ const handleCloseFavorite = (item: any) => {
storesTagsViewRoutes.delFavoriteRoutes(item); storesTagsViewRoutes.delFavoriteRoutes(item);
}; };
const userLoading = ref(false);
const date = ref(new Date());
const scheduleFormRef = ref();
setInterval(() => { setInterval(() => {
date.value = new Date(); date.value = new Date();
}, 1000); }, 1000);
@ -172,17 +172,15 @@ const logState: BasicTableProps = reactive<BasicTableProps>({
}, },
}); });
useTable(logState);
const auditState: BasicTableProps = reactive<BasicTableProps>({ const auditState: BasicTableProps = reactive<BasicTableProps>({
queryForm: {}, queryForm: {},
pageList: fetchList, pageList: fetchList,
descs: ['create_time'], descs: ['create_time'],
}); });
useTable(auditState); useTable(logState);
const calendar = ref(new Date()); useTable(auditState);
watch(calendar, (val, oldval) => { watch(calendar, (val, oldval) => {
const newVal = formatDate(val, 'YYYY-mm'); const newVal = formatDate(val, 'YYYY-mm');
@ -192,12 +190,6 @@ watch(calendar, (val, oldval) => {
} }
}); });
//
const userData = ref({} as any);
const newsList = computed(() => {
return useMsg().getAllMsg();
});
onMounted(() => { onMounted(() => {
const data = useUserInfo().userInfos; const data = useUserInfo().userInfos;
initUserInfo(data.user.userId); initUserInfo(data.user.userId);
@ -216,20 +208,11 @@ const handleRoutr = (type) => {
} }
}; };
const getListData = (date: any) => {
console.log(date, 'dadadadad');
const dataTime = formatDate(date, 'YYYY-mm-dd');
return scheduleDataList.value.filter((item) => {
return item.date === dataTime;
});
};
const initUserInfo = (userId: any) => { const initUserInfo = (userId: any) => {
userLoading.value = true; userLoading.value = true;
getObj(userId) getObj(userId)
.then((res) => { .then((res) => {
userData.value = res.data; userData.value = res.data;
console.log(res.data, 'data');
userData.value.postName = res.data.postList userData.value.postName = res.data.postList
.map((item) => { .map((item) => {
return item.postName; return item.postName;
@ -241,8 +224,6 @@ const initUserInfo = (userId: any) => {
}); });
}; };
const scheduleDataList = ref([] as any);
const initscheduleList = (date) => { const initscheduleList = (date) => {
list({ list({
month: `${date}-01`, month: `${date}-01`,
@ -250,6 +231,23 @@ const initscheduleList = (date) => {
scheduleDataList.value = res.data; scheduleDataList.value = res.data;
}); });
}; };
const filterCellSelected = (data) => {
return (
scheduleDataList.value.filter((item) => {
return item.date.indexOf(data.day) >= 0;
}).length > 0
);
};
const handleSchedule = (data) => {
//form
if (filterCellSelected(data)) {
scheduleRef.value.open({ date: parseDate(data.date, null) });
} else {
scheduleFormRef.value.openDialog(null, { date: parseDate(data.date, null) });
}
};
</script> </script>
<style scoped lang="scss"> <style scoped lang="scss">

View File

@ -0,0 +1,3 @@
<template></template>
<script setup lang="ts" name="SysScheduleCakebdar"></script>

View File

@ -25,7 +25,7 @@
</el-col> </el-col>
<el-col :span="12" class="mb20"> <el-col :span="12" class="mb20">
<el-form-item :label="t('schedule.date')" prop="date"> <el-form-item :label="t('schedule.date')" prop="date">
<el-date-picker type="datetime" :placeholder="t('schedule.inputDateTip')" v-model="form.date" :value-format="dateStr"></el-date-picker> <el-date-picker type="date" :placeholder="t('schedule.inputDateTip')" v-model="form.date" :value-format="dateStr"></el-date-picker>
</el-form-item> </el-form-item>
</el-col> </el-col>
<el-col :span="12" class="mb20"> <el-col :span="12" class="mb20">

View File

@ -4,7 +4,7 @@ export default {
importsysScheduleTip: '导入日程', importsysScheduleTip: '导入日程',
id: 'id', id: 'id',
title: '标题', title: '标题',
type: '日程类型', type: '类型',
state: '状态', state: '状态',
content: '内容', content: '内容',
time: '时间', time: '时间',

View File

@ -1,17 +1,19 @@
<template> <template>
<div class="layout-padding"> <el-drawer v-model="visible" title="日程管理" size="80%">
<div class="layout-padding-auto layout-padding-view"> <div class="layout-padding-auto layout-padding-view">
<el-row v-show="showSearch" class="mb8"> <el-row v-show="showSearch" class="mb8">
<el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList"> <el-form :model="state.queryForm" ref="queryRef" :inline="true" @keyup.enter="getDataList">
<el-form-item :label="t('schedule.date')" prop="date">
<el-date-picker
type="date"
:placeholder="t('schedule.inputDateTip')"
v-model="state.queryForm.date"
:value-format="dateStr"
></el-date-picker>
</el-form-item>
<el-form-item :label="$t('schedule.title')" prop="title"> <el-form-item :label="$t('schedule.title')" prop="title">
<el-input :placeholder="t('schedule.inputTitleTip')" v-model="state.queryForm.title" style="max-width: 180px" /> <el-input :placeholder="t('schedule.inputTitleTip')" v-model="state.queryForm.title" style="max-width: 180px" />
</el-form-item> </el-form-item>
<el-form-item :label="$t('schedule.type')" prop="type">
<el-input :placeholder="t('schedule.inputTypeTip')" v-model="state.queryForm.type" style="max-width: 180px" />
</el-form-item>
<el-form-item :label="$t('schedule.createBy')" prop="createBy">
<el-input :placeholder="t('schedule.inputCreateByTip')" v-model="state.queryForm.createBy" style="max-width: 180px" />
</el-form-item>
<el-form-item class="ml2"> <el-form-item class="ml2">
<el-button formDialogRef icon="search" type="primary" @click="getDataList"> <el-button formDialogRef icon="search" type="primary" @click="getDataList">
{{ $t('common.queryBtn') }} {{ $t('common.queryBtn') }}
@ -22,7 +24,14 @@
</el-row> </el-row>
<el-row> <el-row>
<div class="mb8" style="width: 100%"> <div class="mb8" style="width: 100%">
<el-button formDialogRef icon="folder-add" type="primary" class="ml10" @click="formDialogRef.openDialog()" v-auth="'admin_schedule_add'"> <el-button
formDialogRef
icon="folder-add"
type="primary"
class="ml10"
@click="formDialogRef.openDialog(null, state.queryForm)"
v-auth="'admin_schedule_add'"
>
{{ $t('common.addBtn') }} {{ $t('common.addBtn') }}
</el-button> </el-button>
<el-button formDialogRef icon="Download" type="primary" class="ml10" @click="exportExcel" v-auth="'admin_schedule_export'"> <el-button formDialogRef icon="Download" type="primary" class="ml10" @click="exportExcel" v-auth="'admin_schedule_export'">
@ -85,7 +94,7 @@
<!-- 编辑新增 --> <!-- 编辑新增 -->
<form-dialog ref="formDialogRef" @refresh="getDataList(false)" /> <form-dialog ref="formDialogRef" @refresh="getDataList(false)" />
</div> </el-drawer>
</template> </template>
<script setup lang="ts" name="systemSysSchedule"> <script setup lang="ts" name="systemSysSchedule">
@ -100,10 +109,10 @@ const { schedule_type, schedule_status } = useDict('schedule_type', 'schedule_st
// //
const FormDialog = defineAsyncComponent(() => import('./form.vue')); const FormDialog = defineAsyncComponent(() => import('./form.vue'));
const { t } = useI18n(); const { t } = useI18n();
//
// //
const formDialogRef = ref(); const formDialogRef = ref();
const visible = ref(false);
// //
const queryRef = ref(); const queryRef = ref();
const showSearch = ref(true); const showSearch = ref(true);
@ -113,6 +122,7 @@ const multiple = ref(true);
const state: BasicTableProps = reactive<BasicTableProps>({ const state: BasicTableProps = reactive<BasicTableProps>({
queryForm: {}, queryForm: {},
createdIsNeed: false,
pageList: fetchList, pageList: fetchList,
}); });
@ -156,4 +166,15 @@ const handleDelete = (ids: string[]) => {
}); });
}); });
}; };
const open = (row: any) => {
state.queryForm.date = row.date;
getDataList();
visible.value = true;
};
//
defineExpose({
open,
});
</script> </script>