diff --git a/frame.js b/frame.js index 0959ceec..4a2a4a18 100644 --- a/frame.js +++ b/frame.js @@ -116,7 +116,7 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) { met _target: field, _inputs: {}, _outputs: [], _history: [], _option: option, _action: action, _output: output, Option: function(key, value) { - if (typeof key == "object") { return sub.core.Item(key, can.Option), key } + if (typeof key == "object") { return sub.core.Item(key, sub.Option), key } if (key == undefined) { value = {} sub.page.Select(sub, option, "select.args,input.args", function(item) { value[item.name] = item.value @@ -229,8 +229,7 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) { met _option: option, _action: action, _output: output, }, Volcanos.meta.libs.concat(["/frame.js", display]), function(table) { table.Conf(sub.Conf()) table.onimport && table.onimport._init && table.onimport._init(table, msg, msg.result||[], function() {}, output) - - table.run = function(event, cmds, cb, silent) { cmds = cmds || [] + table._msg = msg, table.run = function(event, cmds, cb, silent) { cmds = cmds || [] var last = sub._history[sub._history.length-1]; !can.core.Eq(last, cmds) && !silent && sub._history.push(cmds) return run(event, cmds, cb, silent) } @@ -263,7 +262,7 @@ Volcanos("onappend", { _init: function(can, meta, list, cb, target, field) { met typeof item == "string"? can.onappend.input(can, action, "input", {type: "button", value: item, onclick: function(event) { (can.onaction[item] || can.onkeymap && can.onkeymap._remote)(event, can, item) }}): item.length > 0? can.onappend.input(can, action, "input", {type: "select", values: item.slice(1), name: item[0], onchange: function(event) { - can.onaction[item[0]](event, can, msg, item[event.target.selectedIndex+1]) + can.onaction[item[0]](event, can, item[0], item[event.target.selectedIndex+1]) }}): typeof item == "object" && can.onappend.input(can, action, "input", item) }) }, diff --git a/index.css b/index.css index dfd26255..8a43ed2b 100644 --- a/index.css +++ b/index.css @@ -227,6 +227,7 @@ div.upload div.item { } fieldset.input { + background-color:black; position:absolute; left:0; top:0; } diff --git a/lib/base.js b/lib/base.js index e3e06014..5c0b15b9 100644 --- a/lib/base.js +++ b/lib/base.js @@ -40,6 +40,9 @@ var base = Volcanos("base", {help: "基础模块", fmt = fmt.replace("%S", this.Number(now.getSeconds(), 2)) return fmt }), + TimeAdd: shy("时间格式化", function(t, d) { + return new Date(t - t%(24*3600*1000) - 8*3600*1000 + d*24*3600*1000) + }), Duration: function(n) {var res = "", h = 0; h = parseInt(n/3600000/24), h > 0 && (res += h+"d"), n = n % (3600000*24); h = parseInt(n/3600000), h > 0 && (res += h+"h"), n = n % 3600000; diff --git a/plugin/inner.js b/plugin/inner.js index 08595bac..8fa73c6c 100644 --- a/plugin/inner.js +++ b/plugin/inner.js @@ -51,6 +51,7 @@ Volcanos("onimport", {help: "导入数据", _init: function(can, msg, list, cb, msg.Option({path: can.Option("path"), name: can.Option("name")}) can.page.Append(can, can._action, [{view: ["file", "div", name], onclick: function(event) { can.onsyntax._init(can, can.tabview[path+name] = msg) + can.Option({path: path, name: name, key: ""}) }, oncontextmenu: function(event) { can.onappend.carte(can, null, ["保存", "运行"]) }}]).first.click() diff --git a/plugin/input/date.js b/plugin/input/date.js index 9278f5f6..b29a54ce 100644 --- a/plugin/input/date.js +++ b/plugin/input/date.js @@ -3,7 +3,7 @@ Volcanos("onfigure", {help: "控件详情", list: [], can._figure && can.page.Remove(can, can._figure.fieldset) can._figure = can.onappend.field(can, can._target, "input date", {}) // 设置输入 - target.style.width = "120px"; function set(now) { + function set(now) { target.value = can.base.Time(now); item.action == "auto" && can.run({}); } @@ -16,7 +16,7 @@ Volcanos("onfigure", {help: "控件详情", list: [], // 添加控件 var now = target.value? new Date(target.value): new Date(); - var control = can.page.AppendAction(can, figure.action, ["今天", "随机", + var control = can.page.AppendAction(can, figure.action, ["今天", ["hour"].concat(can.core.List(24)), ["minute"].concat(can.core.List(0, 60, 5)), ["second"].concat(can.core.List(0, 60, 5)), {view: ["", "br"]}, "关闭", {type: "hr", style: {margin: 0}}, "上一月", ["year"].concat(can.core.List(now.getFullYear() - 20, now.getFullYear() + 20)), diff --git a/plugin/local/team/miss.js b/plugin/local/team/miss.js index 4ab6d167..96f29f9e 100644 --- a/plugin/local/team/miss.js +++ b/plugin/local/team/miss.js @@ -17,24 +17,14 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, can.drop(event, event.target, time) }, list: can.core.List(list, function(task) { - return {view: [task.status, "div", view!="detail"? task.name: task.name+": "+task.text], title: task.text, draggable: true, - ondragstart: function(event) { var target = event.target; can.drop = function(event, td, time) { - var msg = can.request(event); msg.Option(task) - td.append(target), can.run(event, ["action", "modify", "begin_time", time, task.begin_time], function(msg) { - task.begin_time = time, can.onimport._display(can, msg, task) - can.onappend.toast(can, "修改成功") - }, true) + return {view: [["item", task.status, "l"+task.level, "s"+task.score].join(" "), "div", can.onexport[can.Action("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._display(can, msg, task) }, oncontextmenu: function(event) { var target = event.target can.onappend.carte(can, can.ondetail, can.ondetail.list, function(event, item) { - var msg = can.request(event); msg.Option(task) - can.run(event, ["action", "modify", "status", item, task.status], function(msg) { - target.className = task.status = item - can.onimport._display(can, msg, task) - can.onappend.toast(can, "修改成功") - }, true) }) }} }) } @@ -44,80 +34,163 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, can.page.Append(can, can.ui.display, [{th: ["key", "value"]}]) can.core.Item(task, function(key, value) { - can.page.Append(can, can.ui.display, [{td: [key, value], oncontextmenu: function(event) { var target = event.target + can.page.Append(can, can.ui.display, [{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) { - var res = can.request(event); res.Option(task) switch (item) { case "编辑": can.onappend.modify(can, target, function(ev, value, old) { - can.run(event, ["action", "modify", key, value, old], function(res) { - task[key] = value - can.onimport._display(can, msg, task) - can.onappend.toast(can, "修改成功") - }, true) + can.onaction.modifyTask(event, can, task, key, value) }) break default: - can.run(event, ["action", "modify", "status", item, task.status], function(res) { - task.status = item - can.onimport._display(can, msg, task) - can.onappend.toast(can, "修改成功") - }, true) + 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 set(hour) { - return can.base.Time(new Date(begin_time-((begin_time.getHours()-hour))*60*60*1000)) - } - var hash = {}; msg.Table(function(value) { var time = new Date(value.begin_time) - var key = time.getHours(); hash[key] = (hash[key]||[]).concat([value]) + 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, index) { - if (index == 0) { return {type: "tr", list: [{text: ["time", "th"]}, {text: ["text", "th"]}]} } + 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], "detail")]} }) }]).table }, week: function(can, msg) { var begin_time = new Date(can.base.Time(can.Option("begin_time"))) - function set(week, hour) { - return can.base.Time(new Date(begin_time-((begin_time.getDay()-week)*24+(begin_time.getHours()-hour))*60*60*1000)) - } - - var hash = {}; msg.Table(function(value) { var time = new Date(value.begin_time) - var key = time.getDay()+" "+time.getHours() - hash[key] = (hash[key]||[]).concat([value]) + 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 = ["time"].concat(["周日", "周一", "周二", "周三", "周四", "周五", "周六"]); + 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, index) { - if (index == 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"]} } + 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) { + 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 = [{name: day.getDate()+""}].concat(hash[key(day)]||[]) + return can.onimport._task(can, msg, key(day)+can.base.Time(" %H:%M:%S"), list) + })} + }) + }]).table }, - months: function(can, msg) { + 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)]) + })} + }) + }]).table }, - year: function(can, msg) { - }, - long: function(can, msg) { + 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: ["添加"], +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"], +], + 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._display(can, can._msg, task) + can.onappend.toast(can, "修改成功") + }, true) + }, + + _filter: function(event, can, key, value) { + if (value == "all") { + can.page.Select(can, can.ui.content, "div.item", function(item) { + can.page.ClassList.del(can, item, "hidden") + }) + 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") + }) + }, + 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.onimport[can.Option("scale")](can, can._msg) + }, + "添加": function(event, can, key) { can.require(["/plugin/input/date"], function(can) { console.log("waht") @@ -126,7 +199,7 @@ Volcanos("onaction", {help: "组件交互", list: ["添加"], can.onfigure.date.onclick(event, can, {}, event.target) } can.user.input(event, can, [ - "zone", "type", "name", "text", + ["zone", "工作", "学习"], ["type", "项目开发", "项目测试"], "name", "text", {name: "begin_time", type: "input", value: can.base.Time(), onclick: time}, {name: "end_timem", type: "input", value: can.base.Time(), onclick: time}, ], function(event, button, data, list) { @@ -140,5 +213,14 @@ Volcanos("onaction", {help: "组件交互", list: ["添加"], Volcanos("ondetail", {help: "菜单交互", list: ["prepare", "process", "finish", "cancel"], }) Volcanos("onexport", {help: "导出数据", list: ["begin_time", "zone", "id", "type", "name"], + name: function(can, task) { + return task.name + }, + text: function(can, task) { + return task.name+": "+(task.text||"") + }, + title: function(can, task) { + return task.zone+": "+(task.type||"") + }, })