From d0044e0b432a8ab39f10fc17e6d115c8e0038c99 Mon Sep 17 00:00:00 2001 From: shaoying Date: Wed, 16 Sep 2020 10:20:04 +0800 Subject: [PATCH] opt progress --- index.css | 3 +++ pane/Action.js | 11 +++++++++-- plugin/table.js | 8 ++------ 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/index.css b/index.css index ff893038..eb1c5fd0 100644 --- a/index.css +++ b/index.css @@ -157,6 +157,9 @@ table td { max-width:1200px; padding: 0 10px; } +table td.done { + background-color:green; +} table td:hover { background-color:red; } diff --git a/pane/Action.js b/pane/Action.js index 03731aa8..47f547c2 100644 --- a/pane/Action.js +++ b/pane/Action.js @@ -12,17 +12,24 @@ Volcanos("onaction", {help: "交互操作", list: [], _init: function(can, msg, can.run(msg._event, ["search", "Footer.onaction.ncmd"]) }, _progress: function(can, sub, conf, msg, cmds, cb, silent) { - if (msg.Append("size") != "" && msg.Append("size") == msg.Append("total")) { + var size = msg.Append("size") || msg.Append("count") + if (size != "" && size == msg.Append("total")) { return typeof cb == "function" && cb(msg) } can.user.toast(can, { width: 400, title: conf.name+" "+msg.Append("step")+"% ", duration: 1100, - text: "执行进度: "+can.base.Size(msg.Append("size")||0)+"/"+can.base.Size(msg.Append("total")||"1000")+"\n"+msg.Append("name"), + text: "执行进度: "+can.base.Size(size||0)+"/"+can.base.Size(msg.Append("total")||"1000")+"\n"+msg.Append("name"), progress: parseInt(msg.Append("step")), }) + can.page.Select(can, sub._output, "td", function(td) { + if (td.innerText == msg.Option("name")) { + can.page.ClassList.add(can, td, "done") + } + }) can.Timer(1000, function() { var res = sub.request({}) + res.Option("_progress", msg.Option("_progress")) sub.run(res._event, cmds, cb, silent) }) }, diff --git a/plugin/table.js b/plugin/table.js index 797116db..40dce412 100644 --- a/plugin/table.js +++ b/plugin/table.js @@ -87,14 +87,9 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, }, _process: function(can, msg) { var process = msg.Option("_process") || can.Conf("feature")["_process"] - var cb = can.onaction[process]; typeof cb == "function" && cb(can, msg) - return - if (can.onimport._progress(can, msg)) { - return true - }; can.onimport._refresh(can, msg) + var cb = can.onaction[process]; return typeof cb == "function" && cb(can, msg) }, _progress: function(can, msg) { - return var progress = msg.Option("_progress") || can.Conf("feature")["_progress"] if (progress) { can.page.Select(can, can._output, "td", function(td) { @@ -102,6 +97,7 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg, can.page.Modify(can, td, {style: {"background-color": "green"}}) } }) + // can.Timer(1000, function() { can.run() }) return true } },