From fdeae811931f128dbf433a27913ca25598f49227 Mon Sep 17 00:00:00 2001 From: shaoying Date: Tue, 18 Feb 2020 19:31:52 +0800 Subject: [PATCH] opt some --- frame.js | 22 ++++++-- lib/user.js | 2 +- order.js | 1 + page/black.css | 4 ++ page/chat.js | 2 +- pane/Action.js | 126 +++++++++++++++++++++---------------------- pane/River.css | 5 +- pane/Steam.js | 54 +++++++++++-------- pane/Storm.css | 5 +- plugin/input.js | 1 + plugin/state.js | 21 +++++--- plugin/table.js | 9 ++-- plugin/team/plan.css | 15 ++++++ plugin/team/plan.js | 124 +++++++++++++++--------------------------- proto.js | 5 ++ style.css | 4 -- 16 files changed, 204 insertions(+), 196 deletions(-) create mode 100644 plugin/team/plan.css diff --git a/frame.js b/frame.js index 4bf1149b..f80ce197 100644 --- a/frame.js +++ b/frame.js @@ -60,8 +60,8 @@ var can = Volcanos("chat", { field.style.height = height + "px" } else if (height == -1) { field.style.height = document.body.offsetHeight + "px" - } else if (width == -2) { - field.style.width = "" + } else if (height == -2) { + field.style.height = "" } typeof cb == "function" && cb(event, pane, {width: width, height: height}, "size", pane.output) @@ -112,7 +112,7 @@ var can = Volcanos("chat", { var history = [] - var args = meta.args || []; + var args = typeof meta.args == "string"? JSON.parse(meta.args): meta.args || []; var feature = JSON.parse(meta.feature||'{}'); var exports = JSON.parse(meta.exports||'""')||feature.exports||[]; var plugin = Volcanos(name, {_type: "local", _local: {}, target: field, @@ -124,6 +124,11 @@ var can = Volcanos("chat", { key && plugin[key] && plugin[key].target && plugin[key].Import(event, value, key) }, + Rename: function(event) {var meta = field.Meta; + meta.help = can.user.prompt("", function(help) { + meta.help = help + }, meta.help) + }, Remove: function(event) {var list = can.page.Select(can, option, "input.temp") list.length > 0 && list[list.length-1].parentNode.removeChild(list[list.length-1]) }, @@ -178,6 +183,11 @@ var can = Volcanos("chat", { })) can.Export(event, 1, "ncmd") + var msg = can.Event(event); + can.page.Select(can, option, ".opts", function(item) { + item.name && item.value && msg.Option(item.name, item.value) + }) + for (var i = args.length-1; i >= 0; i--) {if (args[i] == "") {args = args.slice(0, i)} else {break}} show && plugin.Timer(1000, function() {show && plugin.user.toast(can.base.Format(args||["running..."]), meta.name, -1)}); run(event, args, function(msg) {if (silent) {return typeof cb == "function" && cb(msg)} @@ -190,9 +200,10 @@ var can = Volcanos("chat", { return plugin._output = plugin._local[type] = plugin[type] = can.Output(plugin, feature, type, msg, cb, output, action, option, status) }, Clone: function(event, cb) {meta.nick = meta.name + can.ID() + meta.msg = plugin.msg meta.args = can.page.Select(can, plugin.option, ".args", function(item) {return item.value}) can._plugins.push(can.Plugin(can, meta.nick, meta, run, - can.page.AppendField(can, field.parentNode, "item "+meta.group+" "+meta.nick, meta), cb)) + can.page.AppendField(can, field.parentNode, "item "+meta.name+" "+meta.nick, meta), cb)) }, Delete: function(event) {field.parentNode.removeChild(field)}, }, Config.libs.concat(["plugin/"+(meta.type||feature.active||"state")]), function(plugin) {plugin.Conf(meta); @@ -201,6 +212,7 @@ var can = Volcanos("chat", { can.core.Next(list.length>0? list: [{type: "text"}, {type: "button", value: "执行"}], plugin.Append, function() { typeof cb == "function" && cb(plugin) }) + meta.msg && plugin.Show(feature.display || "table", meta.msg) }, meta) field.Check = plugin.Check return plugin @@ -259,7 +271,7 @@ var can = Volcanos("chat", { }, run: function(event, cmd, cb, silent) {var msg = can.Event(event); - cmd = cmd || can.Option(), can.page.Select(can, option, "input,select", function(item) { + cmd = cmd || can.Option(), can.page.Select(can, option, ".args", function(item) { item.name && item.value && msg.Option(item.name, item.value) }); (output[cmd[1]] || can[cmd[1]] || can.Run)(event, cmd, cb, silent); diff --git a/lib/user.js b/lib/user.js index 748b4dc2..7dac6f0c 100644 --- a/lib/user.js +++ b/lib/user.js @@ -26,7 +26,7 @@ Volcanos("user", {help: "用户模块", can.page.Remove(can, view.first) } }]}, {button: ["关闭", function(event, value) { - if (typeof cb == "function" && cb(event, value)) { + if (typeof cb == "function" && cb(event, value, {}, [])) { can.page.Remove(can, view.first) } }]}]}, diff --git a/order.js b/order.js index 84756fd6..ef56b08b 100644 --- a/order.js +++ b/order.js @@ -34,6 +34,7 @@ var Config = {iceberg: "/chat/", volcano: "/static/volcanos/", "工作": {head: 30, foot: 30, left: 0, right: 100, bottom: -1, center: 0, top: 0}, "办公": {head: 30, foot: 30, left: 100, right: 100, bottom: -1, center: 0, top: 0}, "聊天": {head: 30, foot: 30, left: 100, right: 100, bottom: 300, center: 40, top: -2}, + "最长": {head: 30, foot: 30, left: 0, right: 0, bottom: -2, center: 0, top: 0}, "全屏": {head: 0, foot: 0, left: 0, right: 0, bottom: -1, center: 0, top: 0}, }, border: 4, }, diff --git a/page/black.css b/page/black.css index e9720c12..63de8905 100644 --- a/page/black.css +++ b/page/black.css @@ -2,6 +2,10 @@ body, fieldset { color: white; background-color:black; } +fieldset.item { + border:ridge 1px cyan; + margin:2px; +} fieldset.item:hover { /* background-color:gold; */ diff --git a/page/chat.js b/page/chat.js index 6dbc1065..931658b6 100644 --- a/page/chat.js +++ b/page/chat.js @@ -58,7 +58,7 @@ Volcanos("onlayout", {help: "组件布局", list: ["刷新"], layout.bottom == undefined && (layout.bottom = can.bottom.target.offsetHeight-conf.layout.border) layout.center == undefined && (layout.center = can.center.target.clientHeight) layout.top == undefined && (layout.top = can.top.target.clientHeight) - layout.center == 0 && layout.top == 0 && !can.user.isMobile && (layout.bottom = height) + layout.center == 0 && layout.top == 0 && !can.user.isMobile && layout.bottom != -2 && (layout.bottom = height) can.bottom.Size(event, width, layout.bottom) can.center.Size(event, width, layout.center) diff --git a/pane/Action.js b/pane/Action.js index 78b151c5..96429989 100644 --- a/pane/Action.js +++ b/pane/Action.js @@ -13,21 +13,10 @@ Volcanos("onimport", {help: "导入数据", list: [], return can._plugins.push(plugin), plugin }) }, - layout: function(event, can, value, cmd, target) {can.layout = value; - can.page.Select(can, can.action, "select.layout", function(item) { - item.value = value - }) - }, - scroll: function(event, can, value, cmd, target) {can.layout = value; - can.output.parentElement.scrollBy(value.x, value.y) - }, river: function(event, can, value, cmd, target) { if (value == "update") {return} can.Conf("temp_river", value) }, - you: function(event, can, value, cmd, target) { - can.user.title(value) - }, storm: function(event, can, value, cmd, target) { can.Cache(can.Conf("river")+"."+can.Conf("storm"), can.output, "some"); @@ -39,6 +28,19 @@ Volcanos("onimport", {help: "导入数据", list: [], }) } }, + + layout: function(event, can, value, cmd, target) {can.layout = value; + can.page.Select(can, can.action, "select.layout", function(item) { + item.value = value + }) + }, + scroll: function(event, can, value, cmd, target) {can.layout = value; + can.output.parentElement.scrollBy(value.x, value.y) + }, + + you: function(event, can, value, cmd, target) { + can.user.title(value) + }, favor: function(event, can, msg, cmd, target) {var key = msg.detail[0]; if (msg._hand) {return} var cb = can.onaction[key]; if (typeof cb == "function") {cb(event, can, msg, cmd, can.output); return msg.Echo(can._name, " onaction ", key), msg._hand = true} @@ -49,18 +51,65 @@ Volcanos("onimport", {help: "导入数据", list: [], can._plugin && can._plugin.Import(event, msg, cmd) }, }) -Volcanos("onaction", {help: "组件交互", list: [["layout", "工作", "办公", "聊天"], "刷新", "清屏", "并行","串行", +Volcanos("onaction", {help: "组件交互", list: [["layout", "工作", "办公", "聊天", "最长"], "刷新", "清屏", "并行","串行", ["action", "正常", "编辑", "编排", "定位"], {input: "pod"}, {input: "you"}, {input: "hot"}, {input: "top"}, ], onmousemove: function(event, can, msg, cmd, target) { can.resize && can.resize(event) }, + + layout: function(event, can, value, cmd, target) {can.Export(event, value, cmd)}, + + "保存": function(event, can, msg, cmd, target) { + var list = [] + can.page.Select(can, target, "fieldset", function(item) {var meta = item.Meta + can.page.Select(can, item, "form.option", function(option) { + meta.args = can.page.Select(can, option, ".args", function(item) {return item.value}) + }) + list.push(meta.node||"", meta.group, meta.index, meta.help, JSON.stringify(meta.args||[])) + }) + can.run(event, [can.Conf("river"), can.Conf("storm"), "save"].concat(list), function(msg) { + can.user.toast("保存成功") + }) + }, + "刷新": function(event, can, msg, cmd, target) { + can.page.Select(can, can.output, "fieldset.item>div.output", function(item) { + item.innerHTML = ""; + }) + can.run(event, [can.Conf("river"), can.Conf("storm")], function(msg) { + can.onimport.init(event, can, msg, cmd, can.output) + }) + }, + "清屏": function(event, can, msg, cmd, target) { + can.page.Select(can, can.output, "fieldset.item>div.output", function(item) { + item.innerHTML = ""; + }) + }, + "并行": function(event, can, msg, cmd, target) { + can.page.Select(can, target, "fieldset.item", function(field) { + can.page.Select(can, field, "input[type=button]", function(input, index) { + index == 0 && field.Check(event, input, function() {}) + }) + }) + }, + "串行": function(event, can, msg, cmd, target) { + can.core.Next(can.page.Select(can, target, "fieldset.item", function(field) { + return field + }), function(field, cb) { + can.page.Select(can, field, "input[type=button]", function(input, index) { + index == 0 && field.Check(event, input, cb) + }) + }) + }, action: function(event, can, value, cmd, target) { switch (value) { case "正常": can.page.Select(can, target, "fieldset.item", function(item) { item.setAttribute("draggable", false) + item.style.position = "" + item.style.left = "" + item.style.top = "" }) break case "编排": @@ -103,59 +152,8 @@ Volcanos("onaction", {help: "组件交互", list: [["layout", "工作", "办公" break } }, - layout: function(event, can, value, cmd, target) { - can.Export(event, value, cmd) - }, - "刷新": function(event, can, msg, cmd, target) { - can.page.Select(can, can.output, "fieldset.item>div.output", function(item) { - item.innerHTML = ""; - }) - can.run(event, [can.Conf("river"), can.Conf("storm")], function(msg) { - can.onimport.init(event, can, msg, cmd, can.output) - }) - }, - "清屏": function(event, can, msg, cmd, target) { - can.page.Select(can, can.output, "fieldset.item>div.output", function(item) { - item.innerHTML = ""; - }) - }, - "并行": function(event, can, msg, cmd, target) { - can.page.Select(can, target, "fieldset.item", function(field) { - can.page.Select(can, field, "input[type=button]", function(input, index) { - index == 0 && field.Check(event, input, function() {}) - }) - }) - }, - "串行": function(event, can, msg, cmd, target) { - can.core.Next(can.page.Select(can, target, "fieldset.item", function(field) { - return field - }), function(field, cb) { - can.page.Select(can, field, "input[type=button]", function(input, index) { - index == 0 && field.Check(event, input, cb) - }) - }) - }, -}) -Volcanos("onchoice", {help: "组件菜单", list: [["layout", "工作", "办公", "聊天"], "保存"], - "工作": function(event, can, msg, cmd, target) { - can.Export(event, cmd, "layout") - }, - "办公": function(event, can, msg, cmd, target) { - can.Export(event, cmd, "layout") - }, - "聊天": function(event, can, msg, cmd, target) { - can.Export(event, cmd, "layout") - }, - "保存": function(event, can, msg, cmd, target) { - var list = [] - can.page.Select(can, target, "fieldset", function(item) {var meta = item.Meta - list.push(meta.node||"", meta.group, meta.index, meta.index) - }) - can.run(event, [can.Conf("river"), can.Conf("storm"), "save"].concat(list), function(msg) { - can.user.toast("保存成功") - }) - }, }) +Volcanos("onchoice", {help: "组件菜单", list: ["保存", "刷新"]}) Volcanos("ondetail", {help: "组件详情", list: []}) Volcanos("onexport", {help: "导出数据", list: []}) diff --git a/pane/River.css b/pane/River.css index f34292ed..5dec11b0 100644 --- a/pane/River.css +++ b/pane/River.css @@ -7,4 +7,7 @@ fieldset.River>div.output { fieldset.River>div.output>div.item { padding-left:6px; } - +fieldset.River>div.output>div.item.select { + background-color:red; + border:ridge 2px yellow; +} diff --git a/pane/Steam.js b/pane/Steam.js index 9d8aee22..5f33e56a 100644 --- a/pane/Steam.js +++ b/pane/Steam.js @@ -1,22 +1,33 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, conf, output, action, option, field) {output.innerHTML = ""; + function create(event, cmd) { + if (!ui.name.value) {ui.name.focus(); can.user.toast("请输入群名"); return} + + var list = [] + can.page.Select(can, ui.list, "tr", function(item, index) {if (index > 0) { + list.push(item.dataset.pod) + list.push(item.dataset.key) + list.push(item.dataset.index) + list.push(item.dataset.help) + }}) + + var name = ui.name.value; + switch (event.target.value) { + case "创建应用": cmd = "spawn"; break + case "追加应用": cmd = "append", name = can.Conf("storm"); break + } + + can.run(event, [can.Conf("river"), cmd, name].concat(list), function(msg) { + can.Hide(), can.Export(event, "update", "storm"); + }) + } + var device = can.page.Append(can, field, [{"view": ["device", "table"]}]).last var ui = can.page.Append(can, field, [{view: ["create"], list: [ - {input: "name", value: can.Conf("def_name"), title: "应用名称"}, {button: ["创建应用", function(event) { - if (!ui.name.value) {ui.name.focus(); can.user.toast("请输入群名"); return} - - var list = [] - can.page.Select(can, ui.list, "tr", function(item, index) {if (index > 0) { - list.push(item.dataset.pod) - list.push(item.dataset.key) - list.push(item.dataset.index) - list.push(item.dataset.name) - }}) - - can.run(event, [can.Conf("river"), "spawn", ui.name.value].concat(list), function(msg) { - can.Hide(), can.Export(event, "update", "storm"); - }) - }]}, {name: "list", view: ["list", "table"], list: [ + {input: "name", value: can.Conf("def_name"), title: "应用名称"}, + {button: ["创建应用", create]}, + {button: ["追加应用", create]}, + {name: "list", view: ["list", "table"], list: [ {text: ["3. 已选命令列表", "caption"]}, {row: ["ctx", "cmd", "name", "help"], sub: "th"}, ]}, @@ -63,6 +74,10 @@ Volcanos("onimport", {help: "导入数据", list: [], if (value == "update") {return} can.Conf("river", value) }, + storm: function(event, can, value, key, output) { + if (value == "update") {return} + can.Conf("storm", value) + }, }) Volcanos("onaction", {help: "组件交互", list: ["关闭", "刷新"], "关闭": function(event, can, meta, key, output) { @@ -74,14 +89,7 @@ Volcanos("onaction", {help: "组件交互", list: ["关闭", "刷新"], }) }, }) -Volcanos("onchoice", {help: "组件菜单", list: ["关闭", "刷新"], - "关闭": function(event, can, msg, key, target) { - can.onaction[key](event, can, key, can.output) - }, - "刷新": function(event, can, msg, key, target) { - can.onaction[key](event, can, key, can.output) - }, -}) +Volcanos("onchoice", {help: "组件菜单", list: ["关闭", "刷新"]}) Volcanos("ondetail", {help: "组件详情", list: ["创建", "删除", "共享"], "创建": function(event, can, msg, value, key, index, td) { can.run(event, [can.Conf("river"), "spawn", msg.key[index]], function(msg) { diff --git a/pane/Storm.css b/pane/Storm.css index 0ce4b2b6..79d0d5bf 100644 --- a/pane/Storm.css +++ b/pane/Storm.css @@ -7,5 +7,8 @@ fieldset.Storm>div.output { fieldset.Storm>div.output>div.item { padding-left:6px; } - +fieldset.Storm>div.output>div.item.select { + background-color:red; + border:ridge 2px yellow; +} diff --git a/plugin/input.js b/plugin/input.js index d4f0569f..991fe8f2 100644 --- a/plugin/input.js +++ b/plugin/input.js @@ -38,6 +38,7 @@ Volcanos("onimport", {help: "导入数据", list: [], item.type == "text" && !target.title && (target.title = item.placeholder || item.name || ""); item.type == "button" && item.action == "auto" && can.run && can.run({}); item.type == "textarea" && can.page.Append(can, option, [{type: "br"}]) + item.type == "select" && (target.value = item.value) return target; }), path: function(event, can, value, cmd, target) { diff --git a/plugin/state.js b/plugin/state.js index 5481a992..f21c6dd7 100644 --- a/plugin/state.js +++ b/plugin/state.js @@ -8,15 +8,20 @@ Volcanos("onimport", {help: "导入数据", list: [], }, }) Volcanos("onaction", {help: "组件交互", list: []}) -Volcanos("onchoice", {help: "组件菜单", list: [["display", "表格", "文档", "相册"], - "执行", "返回", "加参", "减参", "克隆", "删除"], - - "表格": function(event, can, msg, cmd, field) {can.Show("table", can.msg)}, - "文档": function(event, can, msg, cmd, field) {can.Show("inner", can.msg)}, - "相册": function(event, can, msg, cmd, field) {can.Show("media", can.msg)}, - - "返回": function(event, can, msg, cmd, field) {can.Last(event)}, +Volcanos("onchoice", {help: "组件菜单", list: ["执行", "返回", "重命名", "选项", "加参", "减参", "克隆", "删除"], "执行": function(event, can, msg, cmd, field) {can.Runs(event)}, + "返回": function(event, can, msg, cmd, field) {can.Last(event)}, + "重命名": function(event, can, msg, cmd, field) {can.Rename(event)}, + "选项": function(event, can, msg, cmd, field) { + can.user.input(event, can, ["name", "value"], function(event, cmd, meta, list) { + var data = {type: "text", value: meta.value||""} + can.page.ClassList.add(can, data, "opts"); + + var input = {type: "input", name: meta.name, data: data}; + var target = can.Dream(can.option, "option", input)[input.name]; + return true + }) + }, "加参": function(event, can, msg, cmd, field) {can.Append()}, "减参": function(event, can, msg, cmd, field) {can.Remove(event)}, "克隆": function(event, can, msg, cmd, field) {can.Clone(event)}, diff --git a/plugin/table.js b/plugin/table.js index eeabcecf..ba5749fd 100644 --- a/plugin/table.js +++ b/plugin/table.js @@ -27,8 +27,7 @@ Volcanos("onimport", {help: "导入数据", list: [], var sub = can.Event(event); msg.append.forEach(function(key) {sub.Option(key, msg[key][index].trim())}) typeof cb == "function"? cb(event, can, msg, index, key, cmd, target): - // can.run(event, [id, typeof cb == "string"? cb: cmd, key, target.innerHTML], function(msg) { - can.run(event, ["action", typeof cb == "string"? cb: cmd, key, target.innerHTML], function(msg) { + can.run(event, ["action", typeof cb == "string"? cb: cmd, key, target.innerHTML, id], function(msg) { can.onimport.init(can, msg, cb, output, option) }, true) })) @@ -44,9 +43,9 @@ Volcanos("onimport", {help: "导入数据", list: [], 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, table, "tr", function(tr, index) {if (event.target == tr) {return cb(tr.dataset.index, "")} can.page.Select(can, tr, "th,td", function(td, order) { - if (event.target == td) {return cb(index-1, list[order])} + if (event.target == td) {return cb(tr.dataset.index, list[order])} }) }) }, @@ -80,10 +79,8 @@ Volcanos("ondetail", {help: "组件详情", list: ["选择", "编辑", "删除", "编辑": function(event, can, msg, index, key, cmd, td) { var text = td.innerHTML; var input = can.page.Appends(can, td, [{type: "input", value: text, style: {width: td.clientWidth+"px"}, data: {onkeydown: function(event) { - if (event.key == " ") {return event.stopPropagation()} if (event.key != "Enter") {return} if (key == "value" && msg.key) {key = msg.key[index]} - // can.run(event, [msg.Ids(index), "modify", key, event.target.value, text], function(msg) { can.run(event, ["action", "modify", key, event.target.value, text, msg.Ids(index)], function(msg) { td.innerHTML = event.target.value; can.user.toast("修改成功") diff --git a/plugin/team/plan.css b/plugin/team/plan.css new file mode 100644 index 00000000..e4b8ac0f --- /dev/null +++ b/plugin/team/plan.css @@ -0,0 +1,15 @@ +fieldset.item.plan div.output div.task.finish { + color:red; +} +fieldset.item.plan div.output div.task.finish:hover { + color:white; +} +fieldset.item.plan div.output div.task.process { + color:green; +} +fieldset.item.plan div.output div.task.process:hover { + color:white; +} +fieldset.item.plan div.output div.task.cancel { + color:yellow; +} diff --git a/plugin/team/plan.js b/plugin/team/plan.js index 77860b81..fe42ab7f 100644 --- a/plugin/team/plan.js +++ b/plugin/team/plan.js @@ -1,25 +1,20 @@ Volcanos("onimport", {help: "导入数据", list: [], init: function(can, msg, cb, output, action, option) {output.innerHTML = ""; - if (!msg.append || msg.append.length == 0) { - var code = can.page.Append(can, output, [{view: ["code", "div", msg.Result()]}]).code; - return typeof cb == "function" && cb(msg), code; - } - var table = can.page.AppendTable(can, output, msg, msg.append); table.onclick = function(event) {switch (event.target.tagName) { case "TD": - var input = can.user.input(event, can, ["group", "type", "name", "text"], function(event, value, data) { + var input = can.user.input(event, can, ["zone", "type", "name", "text"], function(event, value, data) { switch (value) { case "提交": - can.run(event, ["action", "insert", data.group, data.type, data.name, data.text, "begin_time", can.base.Time()], function(msg) { + // 创建任务 + 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) - console.log(data) break - case "取消": return true; + case "关闭": return true; } }) break @@ -28,26 +23,22 @@ Volcanos("onimport", {help: "导入数据", list: [], case "TR": case "TABLE": }} + table.oncontextmenu = function(event) {var target = event.target; switch (event.target.tagName) { case "DIV": - break - case "TD": - can.onimport.which(event, table, msg.append, function(index, key) { - can.user.carte(event, shy("", can.ondetail, can.feature.detail || can.ondetail.list, function(event, cmd, meta) {var cb = meta[cmd]; - var id = msg.Ids(index); - var sub = can.Event(event); - msg.append.forEach(function(key) {sub.Option(key, msg[key][index].trim())}) - typeof cb == "function"? cb(event, can, msg, index, key, cmd, target): - // can.run(event, [id, typeof cb == "string"? cb: cmd, key, target.innerHTML], function(msg) { - can.run(event, ["action", typeof cb == "string"? cb: cmd, key, target.innerHTML], function(msg) { - can.onimport.init(can, msg, cb, output, option) - }, true) - })) - }) + // 任务操作 + 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) { + }, true) + })) event.stopPropagation() event.preventDefault() break + case "TD": + break case "TH": case "TR": case "TABLE": @@ -65,23 +56,35 @@ Volcanos("onimport", {help: "导入数据", list: [], can.page.Select(can, table, "tr", function(tr) {tr.list = []; can.page.Select(can, tr, "td", function(item, index) {tr.list.push(item); - // item.setAttribute("draggable", true) - // item.ondragstart = function(event) {can.drag = event.target} 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")} + item.ondrop = function(event) {event.preventDefault() item.append(can.drag) + // 任务排期 var data = can.drag.dataset; var begin_time = new Date(data.begin_time); - begin_time.setHours(parseInt(tr.list[0].innerText)); - begin_time.setMinutes(0); - begin_time.setSeconds(0); - if (can.Option("scale") == "week") { - begin_time.setDate(begin_time.getDate() - (begin_time.getDay() - index + 1)) + + 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": + 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); } - can.run(event, ["action", "modify", "begin_time", can.base.Time(begin_time), data.begin_time, data.id, data.name], function(msg) { + + 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); } @@ -97,65 +100,22 @@ Volcanos("onimport", {help: "导入数据", list: [], }) }) }, - - favor: function(event, can, msg, cmd, output) {var key = msg.detail[0]; - var cb = can.onaction[key]; if (typeof cb == "function") {cb(event, can, msg, cmd, output); return msg.Echo(can._name, " onaction ", key), msg._hand = true} - var cb = can.onchoice[key]; if (typeof cb == "function") {cb(event, can, msg, cmd, output); return msg.Echo(can._name, " onchoice ", key), msg._hand = true} - }, -}) -Volcanos("onaction", {help: "组件交互", list: [], -}) -Volcanos("onchoice", {help: "组件菜单", list: ["返回", "清空", "复制", "下载"], +}, ["plugin/team/plan.css"]) +Volcanos("onaction", {help: "组件交互", list: []}) +Volcanos("onchoice", {help: "组件菜单", list: ["返回", "清空"], "返回": function(event, can, msg, cmd, target) { can.run(event, ["", "Last"]) }, "清空": function(event, can, msg, cmd, target) { can.target.innerHTML = ""; }, - "复制": function(event, can, msg, cmd, target) { - var list = can.onexport.Format(can, msg, "data"); - can.user.toast(can.page.CopyText(can, list[2]), "复制成功") - }, - "下载": function(event, can, msg, cmd, target) {msg = msg || can.msg; - var list = can.onexport.Format(can, msg, msg._plugin_name||"data"); - can.page.Download(can, list[0]+list[1], list[2]); - }, }) -Volcanos("ondetail", {help: "组件详情", list: ["选择", "编辑", "删除", "复制", "下载"], - "选择": "select", - "删除": "delete", - "编辑": function(event, can, msg, index, key, cmd, td) { - var text = td.innerHTML; - var input = can.page.Appends(can, td, [{type: "input", value: text, style: {width: td.clientWidth+"px"}, data: {onkeydown: function(event) { - if (event.key == " ") {return event.stopPropagation()} - if (event.key != "Enter") {return} - if (key == "value" && msg.key) {key = msg.key[index]} - // can.run(event, [msg.Ids(index), "modify", key, event.target.value, text], function(msg) { - can.run(event, ["action", "modify", key, event.target.value, text, msg.Ids(index)], function(msg) { - td.innerHTML = event.target.value; - can.user.toast("修改成功") - }, true) - }}}]).first; - input.focus(); - input.setSelectionRange(0, input.value.length); - }, - "复制": function(event, can, msg, index, key, cmd, target) { - can.user.toast(can.page.CopyText(can, target.innerHTML), "复制成功") - }, - "下载": function(event, can, msg, index, key, cmd, target) { - can.page.Download(can, key, target.innerHTML); - }, -}) -Volcanos("onexport", {help: "导出数据", list: [], - Format: function(can, msg, name) { - var ext = ".csv", txt = can.page.Select(can, can.target, "tr", function(tr) { - return can.page.Select(can, tr, "td,th", function(td) {return td.innerText}).join(",") - }).join("\n"); - - !txt && (ext = ".txt", txt = msg.result && msg.result.join("") || ""); - return [name, ext, txt] - }, +Volcanos("ondetail", {help: "组件详情", list: ["开始", "完成", "取消"], + "开始": "process", + "完成": "finish", + "取消": "cancel", }) +Volcanos("onexport", {help: "导出数据", list: []}) diff --git a/proto.js b/proto.js index ec574f87..f92643b4 100644 --- a/proto.js +++ b/proto.js @@ -97,6 +97,9 @@ function Volcanos(name, can, libs, cb, msg) { // 封装模块 }) }), Timer: shy("定时器", function(interval, cb, cbs) {interval = typeof interval == "object"? interval || []: [interval]; + // value + // [1,2,3,4] + // {value, length} var timer = {stop: false}; function loop(i) {if (timer.stop || i >= interval.length && interval.length >= 0) {return typeof cbs == "function" && cbs(interval)} return typeof cb == "function" && cb(interval.value||interval[i], i, interval)? @@ -197,6 +200,8 @@ function Volcanos(name, can, libs, cb, msg) { // 封装模块 } var text = line, list = [], item = false, style = "" switch (type) { + case "option": + list.push({text: line.name+": "}) case "input": style = " "+line.type list.push(line) diff --git a/style.css b/style.css index 0ded58bd..f407a4aa 100644 --- a/style.css +++ b/style.css @@ -88,10 +88,6 @@ fieldset>div.output div.item:hover { background-color:red; border:ridge 2px yellow; } -fieldset>div.output div.item.select { - background-color:red; - border:ridge 2px yellow; -} fieldset>div.output table td { /* word-break:break-word; */ }