2歳以上日誌データ連携
This commit is contained in:
58
src/utils.js
58
src/utils.js
@@ -18,7 +18,7 @@ const classItems = [
|
||||
{ label: "ゆり", value: "ゆり" },
|
||||
]
|
||||
|
||||
let errorEl;
|
||||
let notificationEl;
|
||||
let loadingEl;
|
||||
|
||||
function getHeaderSpace(className, isDetailPage) {
|
||||
@@ -135,7 +135,7 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
|
||||
function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, classElId }) {
|
||||
const year = yearElId && map[yearElId].value;
|
||||
const month = monthElId && map[monthElId].value;
|
||||
const date = dateElId && map[dateElId].value;
|
||||
const date = dateElId && (map[dateElId].value === 'end' ? getLastDate(year, month) : map[dateElId].value);
|
||||
const className = classElId && map[classElId].value;
|
||||
|
||||
const errorMsgs = [];
|
||||
@@ -168,6 +168,10 @@ function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, classElI
|
||||
}
|
||||
}
|
||||
|
||||
function getLastDate(year, month) {
|
||||
return new Date(year, month, 0).getDate();
|
||||
}
|
||||
|
||||
function createBtn(id, label, onClick) {
|
||||
const btnEl = new Kuc.Button({
|
||||
text: label,
|
||||
@@ -225,12 +229,18 @@ function convertToWesternYear(year, era) {
|
||||
return warekiStartYear[era] + year - 1;
|
||||
}
|
||||
|
||||
function getFormatDateString(date) {
|
||||
const year = date.getFullYear();
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
||||
const day = String(date.getDate()).padStart(2, '0');
|
||||
function getFormatDateString(dateObjOrYear, month, date) {
|
||||
let year = dateObjOrYear;
|
||||
if (typeof dateObjOrYear === "object") {
|
||||
year = dateObjOrYear.getFullYear();
|
||||
month = dateObjOrYear.getMonth() + 1;
|
||||
date = dateObjOrYear.getDate();
|
||||
}
|
||||
const formatY = year;
|
||||
const formatM = String(month).padStart(2, '0');
|
||||
const formatD = String(date).padStart(2, '0');
|
||||
|
||||
return `${year}-${month}-${day}`;
|
||||
return `${formatY}-${formatM}-${formatD}`;
|
||||
}
|
||||
|
||||
function loading(show, text) {
|
||||
@@ -249,17 +259,33 @@ function loading(show, text) {
|
||||
}
|
||||
|
||||
function showError(show, text) {
|
||||
if (!errorEl) {
|
||||
errorEl = new Kuc.Notification({
|
||||
type: 'danger',
|
||||
if (show) {
|
||||
buildNotification('danger', text);
|
||||
notificationEl.open();
|
||||
console.error(text);
|
||||
} else {
|
||||
notificationEl && notificationEl.close();
|
||||
}
|
||||
}
|
||||
|
||||
function showSuccess(show, text) {
|
||||
if (show) {
|
||||
buildNotification('success', text);
|
||||
notificationEl.open();
|
||||
} else {
|
||||
notificationEl && notificationEl.close();
|
||||
}
|
||||
}
|
||||
|
||||
function buildNotification(type, text) {
|
||||
if (!notificationEl) {
|
||||
notificationEl = new Kuc.Notification({
|
||||
type,
|
||||
text
|
||||
});
|
||||
} else {
|
||||
errorEl.close();
|
||||
errorEl.text = text;
|
||||
}
|
||||
if (show) {
|
||||
errorEl.open();
|
||||
console.error(text);
|
||||
notificationEl.close();
|
||||
notificationEl.type = type;
|
||||
notificationEl.text = text;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user