diff --git a/src/api/daily-plan.ts b/src/api/daily-plan.ts new file mode 100644 index 0000000..c0a216d --- /dev/null +++ b/src/api/daily-plan.ts @@ -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); + }) + }) +} \ No newline at end of file diff --git a/src/api/patient.ts b/src/api/patient.ts index 1adaa35..2913f63 100644 --- a/src/api/patient.ts +++ b/src/api/patient.ts @@ -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) - }).catch(error => { - reject(error) - }) + }).then((res: any) => { + resolve(res.data); + }).catch(error => { + reject(error); + }); + }); } \ No newline at end of file diff --git a/src/utils/date-util.ts b/src/utils/date-util.ts index bcf51e1..666f5ec 100644 --- a/src/utils/date-util.ts +++ b/src/utils/date-util.ts @@ -22,55 +22,68 @@ export function dateFormater(formater: string, time?: any) { /** * 获取指定月份天数 - * @param {*} time - * @returns + * @param {*} time + * @returns */ export function getMonthDays(time: any) { - if (!time) time = new Date(); - const now = new Date(time); - const year = now.getFullYear(); - const month = now.getMonth() + 1; + if (!time) time = new Date(); + const now = new Date(time); + const year = now.getFullYear(); + const month = now.getMonth() + 1; - const isLeapYear = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; + const isLeapYear = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; - const daysInMonth = month === 2 - ? isLeapYear ? 29 : 28 - : month === 4 || month === 6 || month === 9 || month === 11 - ? 30 - : 31; + const daysInMonth = month === 2 + ? isLeapYear ? 29 : 28 + : month === 4 || month === 6 || month === 9 || month === 11 + ? 30 + : 31; - return daysInMonth; + return daysInMonth; } /** * 获取当前日期的周几 i:1,2,3,4,5,6,7 * @returns */ -export function getFirstDayOfWeek(date: Date, i: number) { - if (i < 1 || i > 7) { - return null; - } - const day = date.getDay() || 7; - return new Date(date.getFullYear(), date.getMonth(), date.getDate() + i - day); +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 = 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) { - if (date instanceof Date) { - myDate = date; - } else { - date = date.replace(/-/g, '/'); - myDate = new Date(date); - } - } - const days = myDate.getDay(); - return weekArray[days]; +export function getCurrentDate(date: any) { + let myDate = new Date(); + if (date) { + if (date instanceof Date) { + myDate = date; + } else { + date = date.replace(/-/g, '/'); + myDate = new Date(date); + } + } + + const days = myDate.getDay(); + return weekArray[days]; } /** @@ -78,17 +91,20 @@ export function getCurrentDate(date: any) { * @returns */ export function getDays(date: any, days: number) { - if (date) { - if (!(date instanceof Date)) { - date = date.replace(/-/g, '/'); - date = new Date(date); - } + if (date) { + let temp: any; + if (!(date instanceof Date)) { + date = date.replace(/-/g, '/'); + temp = new Date(date); + } else { + temp = new Date(date.getTime()); + } - const time = date.setDate(date.getDate() + days); // 天数 - return new Date(time); - } + const time = temp.setDate(temp.getDate() + days); + return new Date(time); + } } export function getEndOfMonth(year: number, month: number) { - return new Date(year, month, 0).getDate() + return new Date(year, month, 0).getDate() } \ No newline at end of file diff --git a/src/views/home/index.vue b/src/views/home/index.vue index 400e49b..56283d7 100644 --- a/src/views/home/index.vue +++ b/src/views/home/index.vue @@ -1,66 +1,67 @@ diff --git a/src/views/home/record-form.vue b/src/views/home/record-form.vue index 60a963a..7a4f508 100644 --- a/src/views/home/record-form.vue +++ b/src/views/home/record-form.vue @@ -1,146 +1,147 @@ diff --git a/src/views/home/week-calendar.vue b/src/views/home/week-calendar.vue index 50bb104..3369b91 100644 --- a/src/views/home/week-calendar.vue +++ b/src/views/home/week-calendar.vue @@ -1,304 +1,332 @@