1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 08:48:06 +08:00
This commit is contained in:
shaoying 2020-06-11 14:54:55 +08:00
parent d9dc8a8183
commit 8412958e44
15 changed files with 315 additions and 503 deletions

View File

@ -521,7 +521,6 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) { met
}, true);
})
},
modify: function(can, target, cb) { var back = target.innerHTML
var ui = can.page.Appends(can, target, [{type: "input", value: back, onkeydown: function(event) {
switch (event.key) {

View File

@ -2,10 +2,10 @@
"manifest_version": 2,
"name": "volcanos",
"version": "0.0.1",
"background": {"page": "/plugin/chrome/chrome.html"},
"background": {"page": "/chrome/chrome.html"},
"browser_action": {
"default_icon": "/favicon.ico",
"default_popup": "/plugin/chrome/popup.html"
"default_popup": "/chrome/popup.html"
},
"content_scripts": [
{
@ -16,7 +16,7 @@
"/lib/misc.js",
"/lib/page.js",
"/lib/user.js",
"/plugin/chrome/contexts.js"]
"/chrome/contexts.js"]
}
],
"permissions": [

View File

@ -1,32 +0,0 @@
fieldset.dialog.Carte {
padding:0;
border:solid 2px red;
/* background-color:greenyellow; */
position:absolute;
display:none;
z-index:200;
}
fieldset.dialog.Carte>div.action {
padding:0;
}
fieldset.dialog.Carte>div.output {
padding:0;
}
fieldset.dialog.Carte>div.output button {
display:block;
}
fieldset.dialog.Carte>div.output select {
display:block;
}
fieldset.dialog.Carte>div.output div.layout>div {
float:left;
}
fieldset.dialog.Carte>div.output div.item {
padding:0px 6px;
}
fieldset.dialog.Carte>div.output div.space {
border:solid 1px gray;
margin-top:8px;
clear:both;
}

View File

@ -1,11 +0,0 @@
Volcanos("onimport", {help: "导入数据", list: [],
_init: function(can, conf, output, action, option, field) {
},
})
Volcanos("onaction", {help: "组件交互", list: [],
onmouseleave: function(event, can) {can.Hide()},
})
Volcanos("onchoice", {help: "组件菜单", list: []})
Volcanos("ondetail", {help: "组件详情", list: []})
Volcanos("onexport", {help: "导出数据", list: []})

View File

@ -68,7 +68,7 @@ Volcanos("onimport", {help: "导入数据", _init: function(can, msg, list, cb,
}} ])
}) }, true)
},
}, ["/plugin/inner.css"])
}, ["/plugin/local/code/inner.css"])
Volcanos("onsyntax", {help: "语法高亮", list: ["keyword", "prefix", "line"], _init: function(can, msg) { can._msg = msg
// action
can.page.Select(can, can._action, "div.file", function(item) {

View File

@ -1,32 +0,0 @@
fieldset.plan>div.output table.project {
float:left;
}
fieldset.plan>div.output table.content {
float:left;
}
fieldset.plan>div.output table.profile {
float:left;
}
fieldset.plan>div.output table.content div.prepare {
background-color:blue;
}
fieldset.plan>div.output table.content div.process {
/* background-color:yellow; */
}
fieldset.plan>div.output table.content div.finish {
background-color:green;
}
fieldset.plan>div.output table.content div.cancel {
background-color:red;
}
fieldset.plan>div.output table.content td {
vertical-align:top;
}
fieldset.plan>div.output table.content td div.date {
color:gray;
}
fieldset.plan>div.output table.content td.over {
border:solid 2px red;
}

View File

@ -1,298 +0,0 @@
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) { can._target.innerHTML = ""
can._name = "plan", can.ui = can.page.Append(can, can._target, [
{view: ["project", "table"], style: {display: can.user.Searchs(can, "project")||"none"}},
{view: ["content", "table"]},
{view: ["profile", "table"], style: {display: can.user.Searchs(can, "profile")||"none"}},
])
can.onimport[can.Option("scale")](can, msg)
can.Timer(10, function() { can.onimport._stat(can, msg)
can.page.Select(can, can.ui.content, "div.item.id"+can.user.Searchs(can, "id"), function(item) {
item.click()
})
can.onaction.view({}, can, "view", can.user.Search(can, "view"))
})
},
_stat: function(can, msg) {
var stat = {
l1: 0, l2: 0, l3: 0, l4: 0, l5: 0,
prepare: 0, process: 0, cancel: 0, finish: 0,
s1: 0, s2: 0, s3: 0, s4: 0, s5: 0,
count: 0,
}
msg.Table(function(value) {
stat["l"+(value.level||"3")]++
stat["s"+(value.score||"3")]++
stat[value.status]++
stat.count++
})
can.Status("count", stat.process+"/"+stat.count)
can.page.Append(can, can.ui.project, [ {th: ["key", "value"]} ])
can.core.List(["prepare", "process", "cancel", "finish"], function(item) {
can.page.Append(can, can.ui.project, [{td: [item, stat[item]], onclick: function(event) {
can.onaction._filter(event, can, "status", item)
} }])
})
can.core.List(["1", "2", "3", "4", "5"], function(item) {
stat["l"+item] > 0 && can.page.Append(can, can.ui.project, [
{td: ["level-"+item, stat["l"+item]], onclick: function(event) {
can.onaction._filter(event, can, "level", "l"+item)
}}
])
})
can.core.List(["1", "2", "3", "4", "5"], function(item) {
stat["s"+item] > 0 && can.page.Append(can, can.ui.project, [
{td: ["score-"+item, stat["s"+item]], onclick: function(event) {
can.onaction._filter(event, can, "score", "s"+item)
}}
])
})
},
_task: function(can, msg, time, list, view) {
return {text: ["", "td"],
ondragover: function(event) { event.preventDefault()
can.page.Select(can, can.ui.content, "td", function(item) {
can.page.ClassList.del(can, item, "over")
}), can.page.ClassList.add(can, event.target, "over")
},
ondrop: function(event) { event.preventDefault()
can.drop(event, event.target, time)
},
list: can.core.List(list, function(task) {
return typeof task == "string"? {view: ["date", "div", task]}: {view: [can.onexport.style(can, task), "div",
can.onexport[can.Action("view")||view||"name"](can, task)],
title: can.onexport.title(can, task), draggable: true,
ondragstart: function(event) { var target = event.target; can.drop = function(event, td, time) { td.append(target)
can.onaction.modifyTask(event, can, task, "begin_time", time, task.begin_time)
} }, onclick: function(event) {
can.onimport._profile(can, msg, task)
}, oncontextmenu: function(event) { var target = event.target
can.onappend.carte(can, can.ondetail, can.ondetail.list, function(event, item) {
can.onaction.modifyTask(event, can, task, "status", item)
})
}}
}) }
},
_profile: function(can, msg, task) { can.ui.profile.innerHTML = ""
can.Status(task)
can.page.Append(can, can.ui.profile, [{th: ["key", "value"]}])
can.core.Item(task, function(key, value) {
can.page.Append(can, can.ui.profile, [{td: [key, value], ondblclick: function(event) {
can.onappend.modify(can, event.target, function(ev, value, old) {
can.onaction.modifyTask(event, can, task, key, value)
})
}, oncontextmenu: function(event) { var target = event.target
can.onappend.carte(can, can.ondetail, ["编辑"].concat(can.ondetail.list), function(event, item, meta) {
switch (item) {
case "编辑":
can.onappend.modify(can, target, function(ev, value, old) {
can.onaction.modifyTask(event, can, task, key, value)
})
break
default:
can.onaction.modifyTask(event, can, task, "status", item)
}
})
}}])
})
},
day: function(can, msg) { var begin_time = new Date(can.base.Time(can.Option("begin_time")))
function key(time) { return time.getHours() }
var hash = {}; msg.Table(function(value) {
var k = key(new Date(value.begin_time)); hash[k] = (hash[k]||[]).concat([value])
})
var head = ["hour", "task"]
var list = [0]; for (var i = 6; i < 24; i++) { list.push(i) }
function set(hour) { return can.base.Time(can.base.TimeAdd(begin_time, hour/24)) }
var table = can.page.Append(can, can.ui.content, [{type: "table", list:
can.core.List(list, function(hour, row) {
if (row == 0) { return {type: "tr", list: can.core.List(head, function(head) { return {text: [head, "th"]} })} }
return {type: "tr", list: [{text: [can.base.Number(hour), "td"]}, can.onimport._task(can, msg, set(hour), hash[hour], "text")]}
})
}]).table
},
week: function(can, msg) { var begin_time = new Date(can.base.Time(can.Option("begin_time")))
function key(time) { return time.getDay()+" "+time.getHours() }
var hash = {}; msg.Table(function(value) {
var k = key(new Date(value.begin_time)); hash[k] = (hash[k]||[]).concat([value])
})
var head = ["hour"].concat(["周日", "周一", "周二", "周三", "周四", "周五", "周六"]);
var list = [0]; for (var i = 6; i < 24; i++) { list.push(i) }
function set(week, hour) { return can.base.Time(can.base.TimeAdd(begin_time, week-begin_time.getDay()+hour/24)) }
var table = can.page.Append(can, can.ui.content, [{type: "table", list:
can.core.List(list, function(hour, row) {
if (row == 0) { return {type: "tr", list: can.core.List(head, function(head) { return {text: [head, "th"]} })} }
return {type: "tr", list: can.core.List(head, function(head, index) {
if (index == 0) { return {text: [hour, "td"]} }
return can.onimport._task(can, msg, set(index-1, hour), hash[index-1+" "+hour])
})}
})
}]).table
},
month: function(can, msg) { var begin_time = new Date(can.base.Time(can.Option("begin_time")))
function key(time) { return can.base.Time(time, "%y-%m-%d") }
var hash = {}; msg.Table(function(value) {
var k = key(new Date(value.begin_time)); hash[k] = (hash[k]||[]).concat([value])
})
var head = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]
var list = [0]; for (var i = 1; i < 6; i++) { list.push(i) }
var begin = can.base.TimeAdd(begin_time, -(begin_time.getDate()-1))
var last = can.base.TimeAdd(begin_time, -(begin_time.getDate()-1)-begin.getDay())
var table = can.page.Append(can, can.ui.content, [{type: "table", list:
can.core.List(list, function(date, row) {
if (row == 0) { return {type: "tr", list: can.core.List(head, function(head) { return {text: [head, "th"]} })} }
return {type: "tr", list: can.core.List(head, function(head, col) {
var day = can.base.TimeAdd(last, (row-1)*7+col+1);
var list = [day.getDate()+""].concat(hash[key(day)]||[])
return can.onimport._task(can, msg, key(day)+can.base.Time(" %H:%M:%S"), list)
})}
})
}]).table
},
year: function(can, msg) { var begin_time = new Date(can.base.Time(can.Option("begin_time")))
function key(time) { return can.base.Time(time, "%y-%m") }
var hash = {}; msg.Table(function(value) {
var k = key(new Date(value.begin_time)); hash[k] = (hash[k]||[]).concat([value])
})
var head = ["month", "task"]
var list = [0]; for (var i = 1; i < 13; i++) { list.push(i) }
function set(month) { return begin_time.getFullYear()+"-"+can.base.Number(month, 2) }
var table = can.page.Append(can, can.ui.content, [{type: "table", list:
can.core.List(list, function(date, row) {
if (row == 0) { return {type: "tr", list: can.core.List(head, function(head) { return {text: [head, "th"]} })} }
return {type: "tr", list: can.core.List(head, function(head, col) {
if (col == 0) { return {text: [row+"", "td"]} }
return can.onimport._task(can, msg, set(row)+can.base.Time(begin_time, "-%d %H:%M:%S"), hash[set(row)], "text")
})}
})
}]).table
},
long: function(can, msg) { var begin_time = new Date(can.base.Time(can.Option("begin_time")))
function key(time) { return can.base.Time(time, "%y-%m") }
var hash = {}; msg.Table(function(value) {
var k = key(new Date(value.begin_time)); hash[k] = (hash[k]||[]).concat([value])
})
var head = ["month"]; for (var i = -5; i < 5; i++) { head.push(begin_time.getFullYear()+i) }
var list = [0]; for (var i = 1; i < 13; i++) { list.push(i) }
function set(month) { return begin_time.getFullYear()+"-"+can.base.Number(month, 2) }
var table = can.page.Append(can, can.ui.content, [{type: "table", list:
can.core.List(list, function(date, row) {
if (row == 0) { return {type: "tr", list: can.core.List(head, function(head) { return {text: [head, "th"]} })} }
return {type: "tr", list: can.core.List(head, function(head, col) {
if (col == 0) { return {text: [row+"", "td"]} }
var key = head+"-"+can.base.Number(row, 2)
return can.onimport._task(can, msg, key+can.base.Time(begin_time, "-%d %H:%M:%S"), hash[key])
})}
})
}]).table
},
}, ["/plugin/local/team/miss.css"])
Volcanos("onaction", {help: "组件交互", list: ["统计","详情", "",
["level", "all", "l1", "l2", "l3", "l4", "l5"],
["status", "all", "prepare", "process", "cancel", "finish"],
["score", "all", "s1", "s2", "s3", "s4", "s5"],
["view", "", "name", "text", "level", "score"],
"添加", "导出", "导入",
],
modifyTask: function(event, can, task, key, value) {
var msg = can.request(event); msg.Option(task)
can.run(event, ["action", "modify", key, value, task[key]], function(msg) {
task[key] = value, can.onimport._profile(can, can._msg, task)
can.onappend.toast(can, "修改成功")
}, true)
},
_filter: function(event, can, key, value) { var count = 0
if (value == "all") {
can.page.Select(can, can.ui.content, "div.item", function(item) {
can.page.ClassList.del(can, item, "hidden")
count++
})
can.Status("count", count)
return
}
can.page.Select(can, can.ui.content, "div.item", function(item) {
can.page.ClassList.add(can, item, "hidden")
})
can.page.Select(can, can.ui.content, "div."+value, function(item) {
can.page.ClassList.del(can, item, "hidden")
count++
})
can.Status("count", count)
can.Action(key, value)
},
level: function(event, can, key, value) { can.onaction._filter(event, can, key, value) },
status: function(event, can, key, value) { can.onaction._filter(event, can, key, value) },
score: function(event, can, key, value) { can.onaction._filter(event, can, key, value) },
view: function(event, can, key, value) { can.ui.content.innerHTML = ""
can.Action(key, value), can.onimport[can.Option("scale")](can, can._msg)
},
"统计": function(event, can, key) {
can.page.Modify(can, can.ui.project, {style: {display: can.ui.project.style.display=="none"? "table": "none"}})
},
"详情": function(event, can, key) {
can.page.Modify(can, can.ui.profile, {style: {display: can.ui.profile.style.display=="none"? "table": "none"}})
},
"添加": function(event, can, key) {
var now = new Date(); can.require(["/plugin/input/date"]); function date(event) {
can.onfigure.date.onclick(event, can, {}, event.target)
}
can.user.input(event, can, [
["zone", "工作", "学习"], ["type", "项目开发", "项目测试"], "name", "text",
{name: "begin_time", type: "input", value: can.base.Time(can.base.TimeAdd(now, now.getHours()/24)), onclick: date},
{name: "end_time", type: "input", value: can.base.Time(can.base.TimeAdd(now, (now.getHours()+1)/24)), onclick: date},
], function(event, button, data, list) {
can.run(event, ["action", "insert"].concat(list), function(msg) {
}, true)
return true
})
},
})
Volcanos("ondetail", {help: "菜单交互", list: ["prepare", "process", "finish", "cancel"],
})
Volcanos("onexport", {help: "导出数据", list: ["count", "begin_time", "zone", "id", "type", "name"],
name: function(can, task) {
return task.name
},
text: function(can, task) {
return task.name+": "+(task.text||"")
},
level: function(can, task) {
return "l-"+(task.level||3)+": "+(task.name||"")
},
score: function(can, task) {
return "s-"+(task.level||3)+": "+(task.name||"")
},
title: function(can, task) {
return task.zone+": "+(task.type||"")
},
style: function(can, task) {
return ["item", task.status, "id"+task.id, "l"+(task.level||""), "s"+(task.score||"")].join(" ")
},
key: function(can, msg) {
msg.Option("project", can.ui.project.style.display)
msg.Option("profile", can.ui.profile.style.display)
msg.Option("id", can.Status("id"))
msg.Option("view", can.Action("view"))
},
})

View File

@ -1,22 +1,32 @@
fieldset.item.plan div.output td {
vertical-align:top;
fieldset.plan>div.output table.project {
float:left;
}
fieldset.item.plan div.output td.over {
border:solid 2px red;
fieldset.plan>div.output table.content {
float:left;
}
fieldset.plan>div.output table.profile {
float:left;
}
fieldset.item.plan div.output div.task.finish {
color:red;
fieldset.plan>div.output table.content div.prepare {
background-color:blue;
}
fieldset.item.plan div.output div.task.finish:hover {
color:white;
fieldset.plan>div.output table.content div.process {
/* background-color:yellow; */
}
fieldset.item.plan div.output div.task.process {
color:green;
fieldset.plan>div.output table.content div.finish {
background-color:green;
}
fieldset.item.plan div.output div.task.process:hover {
color:white;
fieldset.plan>div.output table.content div.cancel {
background-color:red;
}
fieldset.item.plan div.output div.task.cancel {
color:yellow;
fieldset.plan>div.output table.content td {
vertical-align:top;
}
fieldset.plan>div.output table.content td div.date {
color:gray;
}
fieldset.plan>div.output table.content td.over {
border:solid 2px red;
}

View File

@ -1,127 +1,303 @@
Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, list, cb, target) { can._target.innerHTML = ""
var table = can.onappend.table(can, target, "table", msg)
table.onclick = function(event) {switch (event.target.tagName) {
case "SPAN":
case "TD":
var input = can.user.input(event, can, ["zone", "type", "name", "text"], function(event, value, data) {
switch (value) {
case "提交":
// 创建任务
can.run(event, ["action", "insert", data.zone, data.type, data.name, data.text, "begin_time", can.base.Time()], function(msg) {
can.page.Remove(can, input.first)
can.user.toast("添加成功")
can.Runs(event)
return true
}, true)
break
case "关闭": return true;
}
})
break
case "TH":
break
case "TR":
case "TABLE":
}}
can._name = "plan", can.ui = can.page.Append(can, can._target, [
{view: ["project", "table"], style: {display: can.user.Searchs(can, "project")||"none"}},
{view: ["content", "table"]},
{view: ["profile", "table"], style: {display: can.user.Searchs(can, "profile")||"none"}},
])
table.oncontextmenu = function(event) {var target = event.target;
switch (event.target.tagName) {
case "DIV":
// 任务操作
var data = target.dataset;
can.user.carte(event, shy("", can.ondetail, can.feature.detail || can.ondetail.list, function(event, cmd, meta) {var cb = meta[cmd];
typeof cb == "function"? cb(event, can, msg, data.id, data.zone, cmd, target):
can.run(event, ["action", typeof cb == "string"? cb: cmd, data.id, data.zone], function(msg) {
can.user.toast("修改成功")
}, true)
}))
event.stopPropagation()
event.preventDefault()
break
case "TD":
break
case "TH":
case "TR":
case "TABLE":
}
}
can.page.Select(can, table, "div.task", function(item) {
// 拖动排期
item.setAttribute("draggable", true)
item.ondragstart = function(event) {can.drag = event.target}
item.ondragover = function(event) {event.preventDefault()}
item.ondrop = function(event) {
event.preventDefault()
can.preview.insertBefore(can.drag, item)
}
can.onimport[can.Option("scale")](can, msg), can.Timer(10, function() { can.onimport._stat(can, msg)
can.page.Select(can, can.ui.content, "div.item.id"+can.user.Searchs(can, "id"), function(item) {
item.click()
})
can.onaction.view({}, can, "view", can.user.Searchs(can, "view")||"")
})
},
_stat: function(can, msg) {
var stat = {
l1: 0, l2: 0, l3: 0, l4: 0, l5: 0,
prepare: 0, process: 0, cancel: 0, finish: 0,
s1: 0, s2: 0, s3: 0, s4: 0, s5: 0,
count: 0,
}; msg.Table(function(value) {
stat["l"+(value.level||"3")]++
stat["s"+(value.score||"3")]++
stat[value.status]++
stat.count++
})
can.Status("count", stat.process+"/"+stat.count)
can.page.Select(can, table, "tr", function(tr) {tr.list = [];
can.page.Select(can, tr, "td", function(item, index) {tr.list.push(item);
item.ondragover = function(event) {event.preventDefault(), can.page.Select(can, table, "td.over", function(item) {
can.page.ClassList.del(can, item, "over")
}), can.page.ClassList.add(can, item, "over")}
can.page.Append(can, can.ui.project, [ {th: ["key", "value"]} ])
can.core.List(["1", "2", "3", "4", "5"], function(item) {
stat["l"+item] > 0 && can.page.Append(can, can.ui.project, [
{td: ["level-"+item, stat["l"+item]], onclick: function(event) {
can.onaction._filter(event, can, "level", "l"+item)
}}
])
})
can.core.List(["prepare", "process", "cancel", "finish"], function(item) {
can.page.Append(can, can.ui.project, [{td: [item, stat[item]], onclick: function(event) {
can.onaction._filter(event, can, "status", item)
} }])
})
can.core.List(["1", "2", "3", "4", "5"], function(item) {
stat["s"+item] > 0 && can.page.Append(can, can.ui.project, [
{td: ["score-"+item, stat["s"+item]], onclick: function(event) {
can.onaction._filter(event, can, "score", "s"+item)
}}
])
})
},
_task: function(can, msg, time, list, view) { return {text: ["", "td"],
ondragover: function(event) { event.preventDefault()
can.page.Select(can, can.ui.content, "td", function(item) {
can.page.ClassList.del(can, item, "over")
}), can.page.ClassList.add(can, event.target, "over")
},
ondrop: function(event) { event.preventDefault()
can.drop(event, event.target, time)
},
ondblclick: function(event) {
can.onaction.insertTask(event, can, new Date(time))
},
list: can.core.List(list, function(task) { return typeof task == "string"? {view: ["date", "div", task]}:
{view: [can.onexport.style(can, task), "div", can.onexport[can.Action("view")||view||"name"](can, task)],
draggable: true, title: can.onexport.title(can, task),
ondragstart: function(event) { var target = event.target; can.drop = function(event, td, time) { td.append(target)
can.onaction.modifyTask(event, can, task, "begin_time", time, task.begin_time)
} },
onclick: function(event) {
can.onimport._profile(can, msg, task)
},
oncontextmenu: function(event) { var target = event.target
can.onappend.carte(can, can.ondetail, can.ondetail.list, function(event, item) {
can.onaction.modifyTask(event, can, task, "status", item)
})
},
}
}),
} },
_profile: function(can, msg, task) { can.ui.profile.innerHTML = ""
can.Status(task)
item.ondrop = function(event) {event.preventDefault()
item.append(can.drag)
// 任务排期
var data = can.drag.dataset;
var begin_time = new Date(data.begin_time);
switch (can.Option("scale")) {
case "long":
begin_time.setYear(parseInt(tr.list[0].innerText));
break
case "year":
begin_time.setMonth(parseInt(tr.list[0].innerText)-1);
break
case "month":
can.page.Select(can, item, "span", function(item) {var data = item.dataset
begin_time.setYear(parseInt(data.year))
begin_time.setMonth(parseInt(data.month)-1)
begin_time.setDate(parseInt(data.day))
can.page.Append(can, can.ui.profile, [{th: ["key", "value"]}])
can.core.Item(task, function(key, value) { can.page.Append(can, can.ui.profile, [{td: [key, value],
ondblclick: function(event) {
can.onappend.modify(can, event.target, function(ev, value, old) {
can.onaction.modifyTask(event, can, task, key, value)
})
},
oncontextmenu: function(event) { var target = event.target
can.onappend.carte(can, can.ondetail, ["编辑"].concat(can.ondetail.list), function(event, item, meta) {
switch (item) {
case "编辑":
can.onappend.modify(can, target, function(ev, value, old) {
can.onaction.modifyTask(event, can, task, key, value)
})
break
case "week":
begin_time.setDate(begin_time.getDate() - (begin_time.getDay() - index + 1))
case "day":
begin_time.setHours(parseInt(tr.list[0].innerText));
begin_time.setMinutes(0);
begin_time.setSeconds(0);
default:
can.onaction.modifyTask(event, can, task, "status", item)
}
})
},
}]) })
},
can.run(event, ["action", "modify", "begin_time", can.base.Time(begin_time), data.begin_time, data.id, data.zone], function(msg) {
can.user.toast("修改成功")
}, true);
}
})
day: function(can, msg) { var begin_time = new Date(can.base.Time(can.Option("begin_time")))
function key(time) { return time.getHours() }
var hash = {}; msg.Table(function(value) {
var k = key(new Date(value.begin_time)); hash[k] = (hash[k]||[]).concat([value])
})
return typeof cb == "function" && cb(msg), table;
},
which: function(event, table, list, cb) {if (event.target == table) {return cb(-1, "")}
can.page.Select(can, table, "tr", function(tr, index) {if (event.target == tr) {return cb(index-1, "")}
can.page.Select(can, tr, "th,td", function(td, order) {
if (event.target == td) {return cb(index-1, list[order])}
var head = ["hour", "task"]
var list = [0]; for (var i = 6; i < 24; i++) { list.push(i) }
function set(hour) { return can.base.Time(can.base.TimeAdd(begin_time, hour/24)) }
var table = can.page.Append(can, can.ui.content, [{type: "table", list:
can.core.List(list, function(hour, row) {
if (row == 0) { return {type: "tr", list: can.core.List(head, function(head) { return {text: [head, "th"]} })} }
return {type: "tr", list: [{text: [can.base.Number(hour), "td"]}, can.onimport._task(can, msg, set(hour), hash[hour], "text")]}
})
}]).table
},
week: function(can, msg) { var begin_time = new Date(can.base.Time(can.Option("begin_time")))
function key(time) { return time.getDay()+" "+time.getHours() }
var hash = {}; msg.Table(function(value) {
var k = key(new Date(value.begin_time)); hash[k] = (hash[k]||[]).concat([value])
})
var head = ["hour"].concat(["周日", "周一", "周二", "周三", "周四", "周五", "周六"]);
var list = [0]; for (var i = 6; i < 24; i++) { list.push(i) }
function set(week, hour) { return can.base.Time(can.base.TimeAdd(begin_time, week-begin_time.getDay()+hour/24)) }
var table = can.page.Append(can, can.ui.content, [{type: "table", list:
can.core.List(list, function(hour, row) {
if (row == 0) { return {type: "tr", list: can.core.List(head, function(head) { return {text: [head, "th"]} })} }
return {type: "tr", list: can.core.List(head, function(head, index) {
if (index == 0) { return {text: [hour, "td"]} }
return can.onimport._task(can, msg, set(index-1, hour), hash[index-1+" "+hour])
})}
})
}]).table
},
month: function(can, msg) { var begin_time = new Date(can.base.Time(can.Option("begin_time")))
function key(time) { return can.base.Time(time, "%y-%m-%d") }
var hash = {}; msg.Table(function(value) {
var k = key(new Date(value.begin_time)); hash[k] = (hash[k]||[]).concat([value])
})
var head = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"]
var list = [0]; for (var i = 1; i < 6; i++) { list.push(i) }
var begin = can.base.TimeAdd(begin_time, -(begin_time.getDate()-1))
var last = can.base.TimeAdd(begin_time, -(begin_time.getDate()-1)-begin.getDay())
var table = can.page.Append(can, can.ui.content, [{type: "table", list:
can.core.List(list, function(date, row) {
if (row == 0) { return {type: "tr", list: can.core.List(head, function(head) { return {text: [head, "th"]} })} }
return {type: "tr", list: can.core.List(head, function(head, col) {
var day = can.base.TimeAdd(last, (row-1)*7+col+1);
var list = [day.getDate()+""].concat(hash[key(day)]||[])
return can.onimport._task(can, msg, key(day)+can.base.Time(" %H:%M:%S"), list)
})}
})
}]).table
},
year: function(can, msg) { var begin_time = new Date(can.base.Time(can.Option("begin_time")))
function key(time) { return can.base.Time(time, "%y-%m") }
var hash = {}; msg.Table(function(value) {
var k = key(new Date(value.begin_time)); hash[k] = (hash[k]||[]).concat([value])
})
var head = ["month", "task"]
var list = [0]; for (var i = 1; i < 13; i++) { list.push(i) }
function set(month) { return begin_time.getFullYear()+"-"+can.base.Number(month, 2) }
var table = can.page.Append(can, can.ui.content, [{type: "table", list:
can.core.List(list, function(date, row) {
if (row == 0) { return {type: "tr", list: can.core.List(head, function(head) { return {text: [head, "th"]} })} }
return {type: "tr", list: can.core.List(head, function(head, col) {
if (col == 0) { return {text: [row+"", "td"]} }
return can.onimport._task(can, msg, set(row)+can.base.Time(begin_time, "-%d %H:%M:%S"), hash[set(row)], "text")
})}
})
}]).table
},
long: function(can, msg) { var begin_time = new Date(can.base.Time(can.Option("begin_time")))
function key(time) { return can.base.Time(time, "%y-%m") }
var hash = {}; msg.Table(function(value) {
var k = key(new Date(value.begin_time)); hash[k] = (hash[k]||[]).concat([value])
})
var head = ["month"]; for (var i = -5; i < 5; i++) { head.push(begin_time.getFullYear()+i) }
var list = [0]; for (var i = 1; i < 13; i++) { list.push(i) }
function set(month) { return begin_time.getFullYear()+"-"+can.base.Number(month, 2) }
var table = can.page.Append(can, can.ui.content, [{type: "table", list:
can.core.List(list, function(date, row) {
if (row == 0) { return {type: "tr", list: can.core.List(head, function(head) { return {text: [head, "th"]} })} }
return {type: "tr", list: can.core.List(head, function(head, col) {
if (col == 0) { return {text: [row+"", "td"]} }
var key = head+"-"+can.base.Number(row, 2)
return can.onimport._task(can, msg, key+can.base.Time(begin_time, "-%d %H:%M:%S"), hash[key])
})}
})
}]).table
},
}, ["/plugin/local/team/plan.css"])
Volcanos("onaction", {help: "组件交互", list: ["统计","详情", "",
["level", "all", "l1", "l2", "l3", "l4", "l5"],
["status", "all", "prepare", "process", "cancel", "finish"],
["score", "all", "s1", "s2", "s3", "s4", "s5"],
["view", "", "name", "text", "level", "score"],
"", "导出", "导入",
],
insertTask: function(event, can, now) { now = now || new Date()
can.require(["/plugin/input/date"]); function date(event) {
can.onfigure.date.onclick(event, can, {}, event.target)
}
can.user.input(event, can, [
["zone", "工作", "学习"], ["type", "项目开发", "项目测试"], "name", "text",
{name: "begin_time", type: "input", value: can.base.Time(can.base.TimeAdd(now, now.getHours()/24)), onclick: date},
{name: "end_time", type: "input", value: can.base.Time(can.base.TimeAdd(now, (now.getHours()+1)/24)), onclick: date},
], function(event, button, data, list) {
can.run(event, ["action", "insert"].concat(list), function(msg) {
can.onappend.toast(can, "添加成功")
}, true)
return true
})
},
}, ["plugin/local/team/plan.css"])
Volcanos("onaction", {help: "组件交互", list: []})
Volcanos("onchoice", {help: "组件菜单", list: ["返回", "清空"],
"返回": function(event, can, msg, cmd, target) {
can.run(event, ["", "Last"])
modifyTask: function(event, can, task, key, value) {
var msg = can.request(event); msg.Option(task)
can.run(event, ["action", "modify", key, value, task[key]], function(msg) {
task[key] = value, can.onimport._profile(can, can._msg, task)
can.onappend.toast(can, "修改成功")
}, true)
},
"清空": function(event, can, msg, cmd, target) {
can.target.innerHTML = "";
},
})
Volcanos("ondetail", {help: "组件详情", list: ["开始", "完成", "取消"],
"开始": "process",
"完成": "finish",
"取消": "cancel",
})
Volcanos("onexport", {help: "导出数据", list: []})
_filter: function(event, can, key, value) { var count = 0
if (value == "all") {
can.page.Select(can, can.ui.content, "div.item", function(item) {
can.page.ClassList.del(can, item, "hidden")
count++
})
can.Status("count", count)
return
}
can.page.Select(can, can.ui.content, "div.item", function(item) {
can.page.ClassList.add(can, item, "hidden")
})
can.page.Select(can, can.ui.content, "div."+value, function(item) {
can.page.ClassList.del(can, item, "hidden")
count++
})
can.Status("count", count)
can.Action(key, value)
},
level: function(event, can, key, value) { can.onaction._filter(event, can, key, value) },
status: function(event, can, key, value) { can.onaction._filter(event, can, key, value) },
score: function(event, can, key, value) { can.onaction._filter(event, can, key, value) },
view: function(event, can, key, value) { can.ui.content.innerHTML = ""
can.Action(key, value), can.onimport[can.Option("scale")](can, can._msg)
},
"统计": function(event, can, key) {
can.page.Modify(can, can.ui.project, {style: {display: can.ui.project.style.display=="none"? "table": "none"}})
},
"详情": function(event, can, key) {
can.page.Modify(can, can.ui.profile, {style: {display: can.ui.profile.style.display=="none"? "table": "none"}})
},
"添加": function(event, can, key) {
can.onaction.insertTask(event, can)
},
})
Volcanos("ondetail", {help: "菜单交互", list: ["prepare", "process", "finish", "cancel"],
})
Volcanos("onexport", {help: "导出数据", list: ["count", "begin_time", "zone", "id", "type", "name"],
name: function(can, task) {
return task.name
},
text: function(can, task) {
return task.name+": "+(task.text||"")
},
level: function(can, task) {
return "l-"+(task.level||3)+": "+(task.name||"")
},
score: function(can, task) {
return "s-"+(task.level||3)+": "+(task.name||"")
},
title: function(can, task) {
return task.zone+": "+(task.type||"")
},
style: function(can, task) {
return ["item", task.status, "id"+task.id, "l"+(task.level||""), "s"+(task.score||"")].join(" ")
},
key: function(can, msg) {
msg.Option("project", can.ui.project.style.display)
msg.Option("profile", can.ui.profile.style.display)
msg.Option("view", can.Action("view"))
msg.Option("id", can.Status("id"))
},
})