1
0
mirror of https://shylinux.com/x/volcanos synced 2025-04-25 16:58:06 +08:00

add table

This commit is contained in:
shaoying 2020-09-13 00:11:21 +08:00
parent 263a9793e7
commit c076d39e88
4 changed files with 88 additions and 34 deletions

View File

@ -371,6 +371,11 @@ Volcanos("onappend", {help: "渲染引擎", list: [], _init: function(can, meta,
})
},
_output: function(can, meta, event, cmds, cb, silent) {
var msg = can.request(event)
can.page.Select(can, can._output, "div.control .args", function(item) {
item.name && item.value && msg.Option(item.name, item.value)
})
return can.run(event, cmds||[], function(msg) {
typeof cb == "function" && cb(msg)
if (silent) { return }

View File

@ -110,18 +110,22 @@ var page = Volcanos("page", {help: "网页模块",
item.list = list[0].slice(1).map(function(value) {
return {type: "option", value: value, inner: value};
})
data.className = list[0][0] || "";
data.className = data.className || list[0][0] || "";
data.title = data.title || name;
data.name = name;
} else if (item.input) {var list = can.core.List(item.input);
type = "input", name = name || list[0] || "";
data.name = data.name || name;
data.className = data.className || data.name;
data.placeholder = data.placeholder || data.name;
data.title = data.title || data.placeholder;
} else if (item.input) {var list = can.core.List(item.input)
type = "input", name = name || list[0] || ""
data.name = data.name || name
data.className = data.className || data.name
data.placeholder = data.placeholder || data.name
data.placeholder = data.placeholder.split(".").pop()
data.title = data.title || data.placeholder
data.autocomplete = "none"
data.onfocus = data.onfocus || function(event) {
event.target.setSelectionRange(0, -1)
}
data.onkeydown = function(event) {
typeof list[1] == "function" && list[1](event);
}

View File

@ -56,6 +56,7 @@ Volcanos("onimport", {help: "导入数据", _init: function(can, msg, list, cb,
var width = can._target.offsetWidth - can.ui.project.offsetWidth - can.ui.preview.offsetWidth - 30
can.Status("当前行", can.onexport.position(can, parseInt(can.Option("line")))-1)
can.page.Modify(can, can.ui.content, {style: {"max-width": width+"px"}})
can.page.Modify(can, can.ui.profile, {style: {width: width+60+"px"}})
}
if (can.tabview[path+file]) { return show() }

View File

@ -3,9 +3,10 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
return typeof cb == "function" && cb(msg)
}
can.ui = can.page.Appends(can, target, [
{view: ["content", "div"]}, {view: ["display", "pre"]},
])
can.ui = can.page.Appends(can, target, [can.onimport._control(can, msg)].concat([
{view: ["content", "div"]},
{view: ["display", "pre"]},
]))
can.onappend.table(can, can.ui.content, "table", msg, function(value, key, index, line, array) {
return can.onimport._table(can, value, key, index, line, array)
})
@ -14,31 +15,48 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
can.onimport._board(can, msg)
return typeof cb == "function" && cb(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)
},
_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) {
if (td.innerText == msg.Option("name")) {
can.page.Modify(can, td, {style: {"background-color": "green"}})
_control: function(can, msg) {
return msg.Option("_control") == "page" && {view: ["control", "div"], list: [
{button: ["上一页", function(event) {
if (can.ui["cache.begin"].value == "") {
can.ui["cache.begin"].value = msg.Option("cache.count") - can.ui["cache.limit"].value
}
})
return true
}
},
_refresh: function(can, msg) {
var refresh = msg.Option("_refresh") || can.Conf("feature")["_refresh"]
can.Timer({interval: 500, length: parseInt(refresh)}, function(timer) {
can.run({})
})
can.ui["cache.begin"].value = can.ui["cache.begin"].value - can.ui["cache.limit"].value
if (can.ui["cache.begin"].value < 0) { can.ui["cache.begin"].value = 0}
can.run(event)
}]},
{input: ["cache.begin", function(event) {
event.key == "Enter" && can.run(event)
}], style: {width: 50}, _init: function(item) {
item.value = msg.Option("cache.begin")
}, data: {"className": "args"}},
{select: [["cache.limit", 10, 30, 100, 1000], function(event) {
can.run(event)
}], _init: function(item) {
item.value = msg.Option("cache.limit")
}, data: {"className": "args"}},
{button: ["下一页", function(event) {
can.ui["cache.begin"].value = parseInt(can.ui["cache.begin"].value||parseInt(m.Option("cache.count"))-parseInt(can.ui["cache.limit"].value)) + parseInt(can.ui["cache.limit"].value)
if (can.ui["cache.begin"].value != "" && parseInt(can.ui["cache.begin"].value) < parseInt(msg.Option("cache.count"))) { can.ui["cache.begin"].value = msg.Option("cache.count") }
can.run(event)
}]},
{select: [["cache.field"].concat(msg["append"]||can.core.Split(msg.Option("fields"), {simple: true})), function(event) {
can.run(event)
}], _init: function(item) {
item.value = msg.Option("cache.field") || item.value
}, data: {"className": "args"}},
{input: ["cache.value", function(event) {
event.key == "Enter" && can.run(event)
}], style: {width: 50}, _init: function(item) {
item.value = msg.Option("cache.value")
}, data: {"className": "args"}},
]}
},
_table: function(can, value, key, index, line, array) {
return {type: "td", inner: value, click: function(event) {
@ -67,6 +85,32 @@ Volcanos("onimport", {help: "导入数据", list: [], _init: function(can, msg,
can.page.Modify(can, item, {style: can.base.Obj(data.style)})
})
},
_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)
},
_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) {
if (td.innerText == msg.Option("name")) {
can.page.Modify(can, td, {style: {"background-color": "green"}})
}
})
return true
}
},
_refresh: function(can, msg) {
var refresh = msg.Option("_refresh") || can.Conf("feature")["_refresh"]
can.Timer({interval: 500, length: parseInt(refresh)}, function(timer) {
can.run({})
})
},
spark: function(can, list, target) {
if (list["name"] == "inner") {