Public
Edited
Aug 18, 2023
Insert cell
Insert cell
today = new Date()
Insert cell
day = today.getDay()
Insert cell
today.getTime()
Insert cell
function getDate(i) {
const date = new Date(today.getTime() + (i - day) * 1000 * 60 * 60 * 24);
return String(date.getMonth() + 1).padStart(2, '0') + '-' + String(date.getDate()).padStart(2, '0')
}
Insert cell
getDate(1)
Insert cell
{
return {
title: '周一 ' + getDate(1),
dataIndex: 'monday',
}
}
Insert cell
data = [
{
date: "2023-08-11",
period: {
morning: ["李四"],
afternoon: ["张隽丹"]
}
},
{
date: "2023-08-12",
period: {
afternoon: ["张隽丹", "李四"]
}
}
]
Insert cell
{
let res = [{
key: '1',
period: '上午',
},
{
key: '2',
period: '下午',
},];

data.forEach((item) => {
if (Object.hasOwn(item.period, "morning")) {
res[0][item.date] = item.period.morning;
}

if (Object.hasOwn(item.period, "afternoon")) {
res[1][item.date] = item.period.afternoon;
}
});

return res;
}
Insert cell
{
let res = [];
data.forEach((item) => {
if (Object.prototype.hasOwnProperty.call(item.period, 'morning')) {
item.period.morning.forEach((doctorName) => {
res.push({name: doctorName})

res[res.length-1][item.date] = "上午"
})
}

if (Object.prototype.hasOwnProperty.call(item.period, 'afternoon')) {
item.period.afternoon.forEach((doctorName) => {
res.push({name: doctorName})

res[res.length-1][item.date] += "下午"
})
}
});

return res;
}
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more