日常计划添加

This commit is contained in:
zhaoyz 2024-04-23 18:31:46 +08:00
parent e674cf8cd8
commit 7273a85503
6 changed files with 650 additions and 578 deletions

13
src/api/daily-plan.ts Normal file
View File

@ -0,0 +1,13 @@
import request from "@/utils/request";
const addDailyPlanUrl = "/admin/dailyPlan/addDailyPlan";
export function addDailyPlan(param: any) {
return new Promise((resolve, reject) => {
request.postForm(addDailyPlanUrl, param).then((res: any) => {
resolve(res.data);
}).catch(err => {
reject(err);
})
})
}

View File

@ -8,10 +8,10 @@ export function getPatientInfo(name: string, id: string, date: string) {
patientName: name,
idNum: id,
date: date
})
}).then((res: any) => {
console.log(res.data)
resolve(res.data);
}).catch(error => {
reject(error)
})
reject(error);
});
});
}

View File

@ -46,18 +46,31 @@ export function getMonthDays(time: any) {
* i:1,2,3,4,5,6,7
* @returns
*/
export function getFirstDayOfWeek(date: Date, i: number) {
export function getFirstDayOfWeek(date: string | Date | number, i: number) {
let temp: any;
if (!(date instanceof Date)) {
if (typeof date == "number") {
temp = new Date(date);
} else {
const s = date.replace(/-/g, "/");
temp = new Date(s);
}
} else {
temp = new Date(date.getTime())
}
if (i < 1 || i > 7) {
return null;
}
const day = date.getDay() || 7;
return new Date(date.getFullYear(), date.getMonth(), date.getDate() + i - day);
const day = temp.getDay() || 7;
return new Date(temp.getFullYear(), temp.getMonth(), temp.getDate() + i - day);
}
/**
*
* @returns
*/
const weekArray = ['周天', '周一', '周二', '周三', '周四', '周五', '周六'];
export function getCurrentDate(date: any) {
let myDate = new Date();
if (date) {
@ -79,12 +92,15 @@ export function getCurrentDate(date: any) {
*/
export function getDays(date: any, days: number) {
if (date) {
let temp: any;
if (!(date instanceof Date)) {
date = date.replace(/-/g, '/');
date = new Date(date);
temp = new Date(date);
} else {
temp = new Date(date.getTime());
}
const time = date.setDate(date.getDate() + days); // 天数
const time = temp.setDate(temp.getDate() + days);
return new Date(time);
}
}

View File

@ -5,7 +5,8 @@
<div class="message-box">
<el-carousel height="32px" direction="vertical" indicator-position="none" autoplay>
<el-carousel-item v-for="(item, index) in messages" :key="'message-' + index">
<p class="text-row-1" style="line-height: 32px;" :class="{'is-link': item.link}" @click="() => {item.link && router.push(item.link)}">{{ item.type }} {{ item.content }}</p>
<p class="text-row-1" style="line-height: 32px;" :class="{'is-link': item.link}"
@click="() => {item.link && router.push(item.link)}">{{ item.type }} {{ item.content }}</p>
</el-carousel-item>
</el-carousel>
</div>
@ -16,7 +17,7 @@
</div>
<div class="header-item">
<el-icon class="text1-color" style="font-size: 26px;margin-right: 20px;">
<Calendar />
<Calendar/>
</el-icon>
<div>
<p class="text1-color f14">待办任务</p>
@ -26,22 +27,22 @@
</div>
<div class="echart-box">
<div class="echart-item">
<NumberChart />
<NumberChart/>
</div>
<div class="echart-item">
<NumberPieChart />
<NumberPieChart/>
</div>
<div class="echart-item">
<TimeChart />
<TimeChart/>
</div>
<div class="echart-item">
<TimeBarChart />
<TimeBarChart/>
</div>
</div>
</div>
<div class="right-content">
<div class="week-calendar">
<WeekCalendar />
<WeekCalendar/>
</div>
<div class="system-logs">
<div class="title">
@ -49,7 +50,7 @@
<span class="f14" style="cursor: pointer;" @click="router.push('./logs-manage/logs-manage')">更多</span>
</div>
<div class="content">
<SystemLogs />
<SystemLogs/>
</div>
</div>
</div>
@ -58,9 +59,9 @@
</template>
<script lang='ts' setup>
import { onMounted, reactive, ref, toRefs, watch } from 'vue'
import { useRouter } from 'vue-router'
import { useLoginStore } from '@/stores/user-info-store'
import {onMounted, reactive, ref, toRefs, watch} from 'vue'
import {useRouter} from 'vue-router'
import {useLoginStore} from '@/stores/user-info-store'
import NumberChart from "./number-chart.vue";
import NumberPieChart from "./number-pie-chart.vue";
import TimeChart from "./time-chart.vue";
@ -75,8 +76,15 @@ const userInfo = useLoginStore().getlogin()
const messages = ref([] as any)
const total = ref(0) //
messages.value.push({type: '通知', content: '测试测试测试测试测试测试测试测试测试测试', link: '/system-manage/system-home'})
messages.value.push({type: '公告', content: '公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试'})
messages.value.push({
type: '通知',
content: '测试测试测试测试测试测试测试测试测试测试',
link: '/system-manage/system-home'
})
messages.value.push({
type: '公告',
content: '公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试公告测试'
})
</script>
<style lang='scss' scoped>
@ -100,6 +108,7 @@ messages.value.push({type: '公告', content: '公告测试公告测试公告测
.left-content {
width: calc(100% - 350px);
height: 100%;
.message-box {
height: 34px;
background: #f8f8f8;
@ -107,11 +116,13 @@ messages.value.push({type: '公告', content: '公告测试公告测试公告测
padding: 0 30px;
border: 1px solid $border1-color;
margin-bottom: 20px;
.is-link {
cursor: pointer;
color: $main-color;
}
}
.header-box {
width: 100%;
height: 90px;
@ -130,7 +141,7 @@ messages.value.push({type: '公告', content: '公告测试公告测试公告测
flex-direction: column;
justify-content: center;
&~.header-item {
& ~ .header-item {
width: 40%;
flex-direction: row;
justify-content: flex-start;
@ -158,6 +169,7 @@ messages.value.push({type: '公告', content: '公告测试公告测试公告测
&:nth-child(even) {
width: 40%;
}
&:nth-child(n + 3) {
margin-top: 20px;
}
@ -168,10 +180,12 @@ messages.value.push({type: '公告', content: '公告测试公告测试公告测
.right-content {
width: 330px;
height: 100%;
.week-calendar {
width: 100%;
height: 50%;
}
.system-logs {
width: 100%;
height: calc(50% - 20px);

View File

@ -5,124 +5,124 @@
</el-form-item>
<el-form-item label="类型" prop="type">
<el-select v-model="formData.type" placeholder="请选择类型">
<el-option v-for="item in typeOption" :key="item.value" :label="item.label" :value="item.value" />
<el-option v-for="item in typeOption" :key="item.value" :label="item.label" :value="item.value"/>
</el-select>
</el-form-item>
<el-form-item label="状态" prop="state" placeholder="请选择状态">
<el-select v-model="formData.state">
<el-option v-for="item in stateOption" :key="item.value" :label="item.label" :value="item.value" />
<el-form-item label="状态" prop="status" placeholder="请选择状态">
<el-select v-model="formData.status">
<el-option v-for="item in stateOption" :key="item.value" :label="item.label" :value="item.value"/>
</el-select>
</el-form-item>
<el-row>
<el-col :span="12">
<el-form-item label="日期" prop="date">
<el-date-picker v-model="formData.date" type="date" placeholder="请输入日期" />
<el-date-picker v-model="formData.date" type="date" placeholder="请输入日期"/>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="时间" prop="time">
<el-time-picker v-model="formData.time" placeholder="请输入时间" />
<el-time-picker v-model="formData.time" placeholder="请输入时间"/>
</el-form-item>
</el-col>
</el-row>
<el-form-item label="内容" prop="content">
<el-input v-model="formData.content" type="textarea" :rows="10" placeholder="请输入内容"></el-input>
</el-form-item>
<div style="text-align: right;" >
<el-button v-if="formData.isSaveBtn" class="f18" type="primary" @click="saveData">保存</el-button>
<el-button v-if="formData.isRemoveBtn" class="f18" @click="removeData">删除</el-button>
<div style="text-align: right;">
<el-button v-if="isSaveBtn" class="f18" type="primary" @click="saveData">保存</el-button>
<el-button v-if="isRemoveBtn" class="f18" @click="removeData">删除</el-button>
</div>
</el-form>
</template>
<script lang='ts' setup>
import { onMounted, reactive, ref, toRefs, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import {onMounted, reactive, ref} from 'vue'
import {ElMessage, ElMessageBox} from 'element-plus'
import {dateFormater} from "@/utils/date-util";
const emit = defineEmits(['close', 'saveData'])
const typeOption = [
{ label: '手术', value: '手术' },
{ label: '会议', value: '会议' },
{label: '手术', value: '手术'},
{label: '会议', value: '会议'},
]
const stateOption = [
{ label: '已处理', value: '已处理' },
{ label: '未处理', value: '未处理' },
{label: '已处理', value: '已处理'},
{label: '未处理', value: '未处理'},
]
const rules = reactive({
title: [
{ required: true, message: '请输入标题', trigger: 'blur' },
{required: true, message: '请输入标题', trigger: 'blur'},
],
type: [
{ required: true, message: '请选择类型', trigger: 'blur' },
{required: true, message: '请选择类型', trigger: 'blur'},
],
state: [
{ required: true, message: '请选择状态', trigger: 'blur' },
status: [
{required: true, message: '请选择状态', trigger: 'blur'},
],
date: [
{ required: true, message: '请输入日期', trigger: 'blur' },
{required: true, message: '请输入日期', trigger: 'blur'},
],
time: [
{ required: true, message: '请输入时间', trigger: 'blur' },
{required: true, message: '请输入时间', trigger: 'blur'},
],
content: [
{ required: true, message: '请输入内容', trigger: 'blur' },
{required: true, message: '请输入内容', trigger: 'blur'},
]
})
const formRef = ref()
const formData = ref({
id: '',
title: '',
type: '',
state: '',
status: '',
date: '',
time: '',
content: '',
isSaveBtn: true,
isRemoveBtn: true
})
const isSaveBtn = ref(true);
const isRemoveBtn = ref(true);
defineExpose({
resetData
})
onMounted(() => {
formData.value = {
id: '',
title: '',
type: '',
state: '',
status: '',
date: '',
time: '',
content: '',
isSaveBtn: true,
isRemoveBtn: true
}
})
defineExpose({
formData,
resetData,
})
function close() {
emit('close')
}
function resetData() {
function resetData(hasRmBtn: boolean, date?: string) {
formRef.value.resetFields()
Object.assign(formData.value, {
id: '',
title: '',
type: '',
state: '',
date: '',
status: '',
date: date ? date : '',
time: '',
content: ''
})
isRemoveBtn.value = hasRmBtn;
}
const saveData = async () => {
await formRef.value.validate((valid: any, fields: any) => {
const saveData = () => {
formRef.value.validate((valid: any, fields: any) => {
if (valid) {
ElMessage.success('保存成功!')
emit('saveData', formData.value)
close()
ElMessage.success('保存成功!');
const form = JSON.parse(JSON.stringify(formData.value));
form.time = dateFormater("HH:mm:ss", new Date(form.time));
emit('saveData', form);
close();
} else {
// console.log('error submit!', fields)
}
@ -140,7 +140,8 @@ const removeData = () => {
).then(() => {
ElMessage.success('删除成功!')
close()
}).catch(() => { })
}).catch(() => {
})
}
</script>

View File

@ -1,22 +1,26 @@
<template>
<div class="week-calendar-part">
<div class="header-box">
<el-icon @click="setWeek('up')">
<ArrowLeft />
<el-icon @click="minusWeek()">
<ArrowLeft/>
</el-icon>
<div class="date-block">
<span @click="handleOpen">{{ formatDate(month) }}</span>
<el-date-picker ref="datePicker" popper-class="week-calendar-picker" class="month-date-pick" v-model="month"
type="month" @change="setWeek()" />
<span @click="handleDatePickerOpen">{{ getMonthTitle() }}</span>
<el-date-picker ref="datePickerRef"
popper-class="week-calendar-picker"
class="month-date-pick"
v-model="month"
type="month"
@change="setMonthWeek()"/>
</div>
<el-icon @click="setWeek('down')">
<ArrowRight />
<el-icon @click="addWeek()">
<ArrowRight/>
</el-icon>
</div>
<div class="week-box">
<table>
<tr class="text1-color">
<th v-for="item in weekEn" :key="item">{{ item }}</th>
<th v-for="item in weekCn" :key="item">{{ item }}</th>
</tr>
<tr v-if="week.length > 0" class="">
<td v-for="item in week" :key="item" :class="{
@ -32,64 +36,93 @@
</div>
<el-button text icon="Plus" style="width: 100%;margin-bottom: 5px;" @click="addRecord()">新建</el-button>
<div class="record-box ">
<el-empty v-if="record.length < 1" :description="dateFormater('MM月dd日', currentDate) + '没有任何记录'" style="padding: 0;" />
<el-empty v-if="record.length < 1" :description="dateFormater('MM月dd日', currentDate) + '没有任何记录'"
style="padding: 0;"/>
<div class="record-item" v-for="(item, index) in record" :key="'record-' + index" @click="viewRecord(item)">
<div class="icon-box">
<i class="icon-RectangleCopy"></i>
</div>
<div class="text-box">
<p class="main-color" style="font-weight: 600;cursor: pointer;">{{
item.title }}</p>
item.title
}}</p>
<p p class=" text2-color font14">{{ dateFormater('yyyy-MM-dd HH:mm:ss', item.time) }}</p>
</div>
<el-icon class="remove-icon" @click.stop="remoteRecord(item, index)">
<Close />
<Close/>
</el-icon>
</div>
</div>
<el-dialog v-model="isRecordDialog" title="详情">
<RecordForm ref="recordFormRef" @close="isRecordDialog = false" @saveData="saveData" />
<RecordForm ref="recordFormRef" @close="isRecordDialog = false" @saveData="saveData"/>
</el-dialog>
</div>
</template>
<script lang='ts' setup>
import { onMounted, reactive, ref, toRefs, watch } from 'vue'
import {onMounted, ref} from 'vue'
import RecordForm from './record-form.vue'
import { ElMessage, ElMessageBox } from 'element-plus'
import { dateFormater, getFirstDayOfWeek, getDays } from '@/utils/date-util'
import {ElMessage, ElMessageBox} from 'element-plus'
import {dateFormater, getDays, getFirstDayOfWeek} from '@/utils/date-util'
const monthCn = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二'];
const weekCn = ['周一', '周二', '周三', '周四', '周五', '周六', '周日'];
const datePickerRef = ref();
const recordFormRef = ref();
const isRecordDialog = ref(false);
const month = ref(new Date());
const week = ref([] as any);
const recordWeek = ref([] as any);
const record = ref([] as any);
const currentDate = ref<Date>(new Date());
const monthEn = ['一', '二', '三', '四', '五', '六', '七', '八', '九', '十', '十一', '十二']
const weekEn = ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
onMounted(init)
const datePicker = ref()
const recordFormRef = ref()
const isRecordDialog = ref(false)
const month = ref(new Date())
const week = ref([] as any)
const recordWeek = ref([] as any)
const record = ref([] as any)
const currentDate = ref<Date>(new Date())
setWeek()
function formatDate(date: any) {
return monthEn[new Date(date).getMonth()] + '月 ' + new Date(date).getFullYear()
function init() {
setMonthWeek();
}
function getMonthTitle() {
return monthCn[new Date(month.value).getMonth()] + '月 ' + new Date(month.value).getFullYear();
}
function addWeek() {
const date: any = getDays(month.value, 7);
month.value = date;
setWeek(date);
}
function minusWeek() {
const date: any = getDays(month.value, -7);
month.value = date;
setWeek(date);
}
function setMonthWeek() {
setWeek(month.value);
setDate(month.value);
}
/**
* 设置周
* @param type
* 获取一周的数据然后给每天打 record-mark 标记
*/
function setWeek(type?: 'up' | 'down') {
const date = (type && getDays(month.value, type === 'up' ? -7 : 7)) || month.value
currentDate.value = date
const e = date
week.value = []
function setWeek(date: any) {
getWeekPlanList();
week.value = [];
setTimeout(() => {
for (let i = 0; i < 7; i++) {
week.value.push(getFirstDayOfWeek(date, i + 1));
}
}, 0)
}
function getWeekPlanList() {
recordWeek.value = []
recordWeek.value = [
/*recordWeek.value = [
{
id: '1',
title: '月度会议',
@ -108,38 +141,32 @@ function setWeek(type?: 'up' | 'down') {
time: getFirstDayOfWeek(e, 4),
content: '测试测试'
}
]
//
setTimeout(() => {
for (let i = 0; i < 7; i++) {
week.value.push(getFirstDayOfWeek(date, i + 1))
}
}, 0)
setDate(currentDate.value)
]*/
}
const handleOpen = () => {
datePicker.value.handleOpen()
const handleDatePickerOpen = () => {
datePickerRef.value.handleOpen();
}
function setDate(e: Date) {
currentDate.value = e
record.value = recordWeek.value.filter((r: any) => dateFormater('yyyy-MM-dd', r.date) === dateFormater('yyyy-MM-dd', e))
getDatePlanList();
}
function getDatePlanList() {}
const addRecord = () => {
const e = currentDate.value || new Date()
isRecordDialog.value = true
setTimeout(() => {
recordFormRef.value.resetData()
recordFormRef.value.formData.date = e
recordFormRef.value.formData.isRemoveBtn = false
recordFormRef.value.resetData(false, dateFormater("yyyy-MM-dd", e));
}, 0)
}
const viewRecord = (e: any) => {
isRecordDialog.value = true
setTimeout(() => {
recordFormRef.value.resetData()
recordFormRef.value.resetData(true)
recordFormRef.value.formData = Object.assign({}, recordFormRef.value.formData, e)
recordFormRef.value.formData.isRemoveBtn = true
// console.log(recordFormRef.value.formData)
}, 0)
}
@ -156,11 +183,12 @@ const remoteRecord = (item: any, index: number) => {
ElMessage.success('删除成功!')
recordWeek.value = recordWeek.value.filter((r: any) => r.id !== item.id)
setDate(item.date)
}).catch(() => { })
}).catch(() => {
})
}
const saveData = (e: any) => {
recordWeek.value.push(e)
setDate(e.date)
recordWeek.value.push(e);
setDate(new Date(e.date));
}
</script>
@ -184,7 +212,7 @@ const saveData = (e: any) => {
.date-block {
position: relative;
&>span {
& > span {
cursor: pointer;
}