mirror of
https://shylinux.com/x/volcanos
synced 2025-04-26 01:04:06 +08:00
opt some
This commit is contained in:
parent
85521f7dd1
commit
ff625f8782
16
lib/user.js
16
lib/user.js
@ -267,10 +267,12 @@ Volcanos("user", {help: "用户操作", info: {}, agent: {
|
|||||||
|
|
||||||
input: function(event, can, form, cb, button) { if (!form || form.length == 0) { return cb() }
|
input: function(event, can, form, cb, button) { if (!form || form.length == 0) { return cb() }
|
||||||
var msg = can.request(event); event = event._event||event
|
var msg = can.request(event); event = event._event||event
|
||||||
|
var need = {}
|
||||||
var ui = can.page.Append(can, document.body, [{view: [html.INPUT], style: {left: 0, top: 0}, list: [
|
var ui = can.page.Append(can, document.body, [{view: [html.INPUT], style: {left: 0, top: 0}, list: [
|
||||||
{view: "content", list: [{view: [html.OPTION, html.TABLE], list: can.core.List(form, function(item) {
|
{view: "content", list: [{view: [html.OPTION, html.TABLE], list: can.core.List(form, function(item) {
|
||||||
item = can.base.isString(item)? {type: html.TEXT, name: item}: item.length > 0? {type: html.SELECT, name: item[0], values: item.slice(1)}: item
|
item = can.base.isString(item)? {type: html.TEXT, name: item}: item.length > 0? {type: html.SELECT, name: item[0], values: item.slice(1)}: item
|
||||||
item.type = item.type||(item.values? html.SELECT: item.name == html.TEXT? html.TEXTAREA: html.TEXT)
|
item.type = item.type||(item.values? html.SELECT: item.name == html.TEXT? html.TEXTAREA: html.TEXT)
|
||||||
|
need[item.name] = item.need
|
||||||
|
|
||||||
item._init = function(target) {
|
item._init = function(target) {
|
||||||
item.run = function(event, cmds, cb) {
|
item.run = function(event, cmds, cb) {
|
||||||
@ -291,7 +293,8 @@ Volcanos("user", {help: "用户操作", info: {}, agent: {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// return {type: html.TR, list: [{type: html.TD, list: [{text: item._trans||can.user.trans(can, item.name)||""}]}, {type: html.TD, list: [can.page.input(can, item)]} ]}
|
// return {type: html.TR, list: [{type: html.TD, list: [{text: item._trans||can.user.trans(can, item.name)||""}]}, {type: html.TD, list: [can.page.input(can, item)]} ]}
|
||||||
return {type: html.TR, list: [{type: html.TD, list: [{text: item.name||""}]}, {type: html.TD, list: [can.page.input(can, item)]} ]}
|
return {type: html.TR, list: [{type: html.TD, list: [{text: item.name||""}, {text: item.need == "must"? "*": "", style: {color: "red"}}]},
|
||||||
|
{type: html.TD, list: [can.page.input(can, item)]} ]}
|
||||||
})}]}, {view: html.ACTION},
|
})}]}, {view: html.ACTION},
|
||||||
]}])
|
]}])
|
||||||
|
|
||||||
@ -302,15 +305,20 @@ Volcanos("user", {help: "用户操作", info: {}, agent: {
|
|||||||
focus: function(event) { can.page.Select(can, ui.first, html.INPUT_ARGS)[0].focus() },
|
focus: function(event) { can.page.Select(can, ui.first, html.INPUT_ARGS)[0].focus() },
|
||||||
cancel: function(event) { can.page.Remove(can, ui._target) },
|
cancel: function(event) { can.page.Remove(can, ui._target) },
|
||||||
_engine: function(event, can, button) { action.submit(event, can, button) },
|
_engine: function(event, can, button) { action.submit(event, can, button) },
|
||||||
submit: function(event, can, button) { var data = {}, args = [], list = []
|
submit: function(event, can, button) { var data = {}, args = [], list = [], err = false
|
||||||
list = can.page.Select(can, ui.table, html.OPTION_ARGS, function(item) {
|
list = can.page.Select(can, ui.table, html.OPTION_ARGS, function(item) {
|
||||||
// return item.name && item.value && args.push(item.name, item.value), data[item.name] = item.value
|
if (item.value == "" && need[item.name] == "must") {
|
||||||
|
err = true, item.focus(), can.user.toast(can, item.name+" 是必选字段, 请重新输入")
|
||||||
|
}
|
||||||
return item.name && args.push(item.name, item.value||""), data[item.name] = item.value||""
|
return item.name && args.push(item.name, item.value||""), data[item.name] = item.value||""
|
||||||
})
|
// return item.name && item.value && args.push(item.name, item.value), data[item.name] = item.value
|
||||||
|
}); if (err) { return }
|
||||||
|
|
||||||
var msg = can.request(event, {_handle: ice.TRUE})
|
var msg = can.request(event, {_handle: ice.TRUE})
|
||||||
!can.core.CallFunc(cb, {event: event, button: button, data: data, list: list, args: args}) && action.cancel()
|
!can.core.CallFunc(cb, {event: event, button: button, data: data, list: list, args: args}) && action.cancel()
|
||||||
// can.base.isFunc(cb) && !cb(event, button, data, list, args) && action.cancel()
|
// can.base.isFunc(cb) && !cb(event, button, data, list, args) && action.cancel()
|
||||||
can.onkeymap.prevent(event)
|
can.onkeymap.prevent(event)
|
||||||
|
return err
|
||||||
}, _target: ui._target,
|
}, _target: ui._target,
|
||||||
})
|
})
|
||||||
if (button === true) { return action.submit(event, can, "submit"), action }
|
if (button === true) { return action.submit(event, can, "submit"), action }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user