今日任务动态
const raw = dv.current()["journal-date"];
const dateStr = typeof raw?.toFormat === "function" ? raw.toFormat("yyyy-MM-dd") : String(raw);
const start = dv.date(dateStr);
const end = start.plus({ days: 1 });
function renderTasks(tasks, depth = 0) {
let lines = [];
for (const t of tasks) {
const indent = "\t".repeat(depth);
const checkbox = t.completed ? "- [x] " : "- [ ] ";
lines.push(indent + checkbox + t.text);
if (t.subtasks?.length > 0) {
lines = lines.concat(renderTasks(t.subtasks, depth + 1));
}
}
return lines;
}
function getRootTasks(allTasks) {
const subLines = new Set();
for (const t of allTasks) {
if (t.subtasks) for (const s of t.subtasks) subLines.add(s.line);
}
return allTasks.filter(t => !subLines.has(t.line));
}
dv.table(["任务", "待办项"],
dv.pages('"CYG-Works/需求任务-Tasks"')
.where(p => {
if (p.file.cday >= start && p.file.cday < end) return true;
return p.file.tasks.some(item => item.text.includes(dateStr));
})
.sort(p => p.file.mday, "desc")
.map(p => [
p.file.link,
renderTasks(getRootTasks(p.file.tasks)).join("\n")
])
);工作日志
const raw = dv.current()["journal-date"];
const dateStr = typeof raw?.toFormat === "function" ? raw.toFormat("yyyy-MM-dd") : String(raw);
function collectChildren(item, depth = 0) {
let lines = [];
for (const child of (item.children || [])) {
const prefix = depth > 0 ? " ".repeat(depth) : " ";
// 用 child.symbol 替代 item.symbol,更准确地反映子项类型
lines.push(prefix + (child.symbol || item.symbol) + " " + child.text);
lines = lines.concat(collectChildren(child, depth + 1));
}
return lines;
}
const rows = [];
const pages = dv.pages('"CYG-Works/需求任务-Tasks"').sort(p => p.file.name, "desc");
for (const page of pages) {
const entries = page.file.lists.where(item => {
if (item.task) return false;
// 找到日期在文本中的位置,要求在前面(前30个字符内)
const idx = item.text.indexOf(dateStr);
return idx >= 0 && idx < 30;
});
//const entries = page.file.lists.where(item => !item.task && item.text.includes(dateStr));
let first = true;
for (const entry of entries) {
const time = entry.text.trim();
const content = collectChildren(entry).join("\n");
rows.push([first ? page.file.link : "", time, content]);
first = false;
}
}
dv.table(["任务", "时间", "内容"], rows);备注
停用账号:罗浩洋 >> 营销人员(深瑞),【功能权限】所有人,深瑞业绩列表(普通),报表查看者,常规外购价格库-查看,营销省区经理【费用】(深瑞),营销人员【费用】(深瑞)