📄 newfunc.js
字号:
function SwitchPage() {};
/**
* 通用的执行Action中的方法
* @params requrl 请求的相对路径URL
* @params method action中的方法
*/
SwitchPage.doExecute = function (requrl, method) {
var url = SwitchPage.addParam(contextPath + requrl, 'METHOD', method);
formUnify.action = url;
formUnify.submit();
}
SwitchPage.doReturn = function () {
var url = SwitchPage.addParam(contextPath + cmdReturn, 'METHOD', 'doQuery');
if( document.all.pagesize == undefined ||
document.all.pagesize == null ||
document.all.pagesize == "" ||
document.all.pagesize == "0" ) {
url = SwitchPage.addParam(url, 'pagesize', '20');
// alert(url);
}
formUnify.action = url;
formUnify.submit();
}
SwitchPage.doReset = function () {
formUnify.reset();
}
SwitchPage.doView = function () {
if( !SwitchPage.hasCheck() ) return;
var url = SwitchPage.addParam(contextPath + cmdView, 'ISEDIT', 'FALSE');
url = SwitchPage.addParam(url, 'METHOD', 'doView');
formUnify.action = url;
formUnify.submit();
}
SwitchPage.doDetail = function (obj) {
var allchk = document.all('pks');
if( allchk.length != null && allchk.length != undefined ) {
for(var i = 0; i < allchk.length; i++ ) {
if( allchk[i].value == obj.value ) {
allchk[i].checked = true;
}
}
}else {
allchk.checked = true;
}
var url = SwitchPage.addParam(contextPath + cmdView, 'ISEDIT', 'FALSE');
url = SwitchPage.addParam(url, 'METHOD', 'doView');
formUnify.action = url;
formUnify.submit();
}
SwitchPage.doEdit = function () {
SwitchPage.enable();
var url = SwitchPage.addParam(contextPath + cmdEdit, 'ISEDIT', 'TRUE');
url = SwitchPage.addParam(url, 'METHOD', 'doEdit');
formUnify.action = url;
formUnify.submit();
}
SwitchPage.doNew = function() {
var url = SwitchPage.addParam(contextPath + cmdNew, 'ISEDIT', 'TRUE');
url = SwitchPage.addParam(url, 'METHOD', 'doNew');
formUnify.action = url;
formUnify.submit();
}
SwitchPage.doQuery = function() {
var url = SwitchPage.addParam(contextPath + cmdQuery, 'METHOD', 'doQuery');
formUnify.action = url;
formUnify.submit();
}
SwitchPage.doDelete = function() {
var TO = true;
var sis = formUnify.all("pks");
if (SwitchPage.forincheck(TO,sis)){
var url = SwitchPage.addParam(contextPath + cmdDelete, 'METHOD', 'doDelete');
formUnify.action = url;
formUnify.submit();
}
}
SwitchPage.doSave = function () {
if (check_value()) {
SwitchPage.enable();
var url = SwitchPage.addParam(contextPath + cmdSave, 'METHOD', 'doSave');
formUnify.action = url;
formUnify.submit();
}
return false;
}
SwitchPage.enable = function (form) {
if (form == null) {
form = document.all("formUnify");
}
for (var i = 0; i < form.elements.length; i++) {
var aaa = form.elements(i);
if( aaa.name == undefined ) continue;
if( aaa.value == undefined ) continue;
if( aaa.value == 'null' ) continue;
if( aaa.value == null ) continue;
if( aaa.value == '' ) continue;
if( aaa.name.length > 7 &&
aaa.name.substr(0,8) == '_button_' ) continue;
if( aaa.name.length > 7 &&
aaa.name.substr(0,8) == '_nosend_' ) continue;
if (aaa.disabled == false ) continue;
form.elements(i).disabled = false;
}
}
SwitchPage.doOrderby = function (field) {
if( document.formUnify.all.orderby == undefined ||
document.formUnify.all.orderby == null ) {
alert( "not defined orderby " ) ;
return ;
}
if ( document.formUnify.orderby.value.indexOf(field) >= 0 ) {
if( document.formUnify.orderby.value.indexOf(" desc") > 0 ) {
document.formUnify.orderby.value = field + " asc ";
}else {
document.formUnify.orderby.value = "";
}
}
else { // don't order
document.formUnify.orderby.value = field + " desc ";
}
SwitchPage.doQuery();
}
SwitchPage.addParam = function (url, name, val) {
if (url != null && name != null) {
if (url.indexOf('?') == -1) {
url = url + '?' + name + '=' + val;
}
else {
url = url + '&' + name + '=' + val;
}
}
return url;
}
SwitchPage.hasCheckMutil = function (){
var TO = true;
var sis = formUnify.all("pks");
var cnt = 0;
if (sis != null) {
if (sis.length != null) {
for (var i = 0; i < sis.length; i++) {
var e = sis[i];
if (e.type == 'checkbox') {
if (e.checked) cnt = cnt + 1;
}
}
} else {
var e = sis;
if (e.type == 'checkbox') {
if (e.checked) cnt = cnt + 1;
}
}
}
if ( cnt == 0 ) {
alert(Inter.getMessage("JS_JS_COMMON_NEWFUNC_SWITCHPAGE_FORINCHECK_MSG_M1"));
return false;
}
return true;
}
SwitchPage.forincheck = function (TO,sis){
if (sis != null) {
if (sis.length != null) {
for (var i = 0; i < sis.length; i++) {
var e = sis[i];
if (e.type == 'checkbox') {
if (e.checked)
TO = false;
}
}
} else {
var e = sis;
if (e.type == 'checkbox') {
if (e.checked)
TO = false;
}
}
}
if (TO) {
alert(Inter.getMessage("JS_JS_COMMON_NEWFUNC_SWITCHPAGE_FORINCHECK_MSG_M1"));
return false;
}
if (!confirm(Inter.getMessage("JS_JS_COMMON_NEWFUNC_SWITCHPAGE_FORINCHECK_MSG_M2"))) {
return false;
}
return true;
}
SwitchPage.hasCheck = function (){
var TO = true;
var sis = formUnify.all("pks");
var cnt = 0;
if (sis != null) {
if (sis.length != null) {
for (var i = 0; i < sis.length; i++) {
var e = sis[i];
if (e.type == 'checkbox') {
if (e.checked) cnt = cnt + 1;
}
}
} else {
var e = sis;
if (e.type == 'checkbox') {
if (e.checked) cnt = cnt + 1;
}
}
}
if ( cnt == 0 ) {
alert(Inter.getMessage("JS_JS_COMMON_NEWFUNC_SWITCHPAGE_FORINCHECK_MSG_M1"));
return false;
}else if ( cnt > 1 ) {
alert(Inter.getMessage("JS_JS_COMMON_NEWFUNC_SWITCHPAGE_HASCHECK_MSG_M1"));
return false;
}
return true;
}
SwitchPage.getCheckValue = function (){
if(!SwitchPage.hasCheck()) return "";
var sis = formUnify.all("pks");
var value="";
if (sis.length != null) {
for (var i = 0; i < sis.length; i++) {
var e = sis[i];
if (e.type == 'checkbox') {
if (e.checked) value = e.value;
}
}
} else {
var e = sis;
if (e.type == 'checkbox') {
if (e.checked) value = e.value;
}
}
return value ;
}
SwitchPage.selectAll = function (obj){
// alert( obj.checked );
var sis = document.all("pks");
if (sis != null) {
if (sis.length != null) {
for (var i = 0; i < sis.length; i++) {
var e = sis[i];
if (e.type == 'checkbox') {
e.checked = obj.checked;
}
}
} else {
var e = sis;
if (e.type == 'checkbox') {
e.checked = obj.checked;
}
}
}
}
/**
* 点击LIST页面表头排序方法
* 与SwitchPage.doOrderby(field)方法的区别:
* doOrderby方法默认调用cmdQuery和doQuery方法
* doOrderbyMethod方法可以指定URL和METHOD方法
*/
SwitchPage.doOrderbyMethod = function (field ,requrl, method) {
if( document.formUnify.all.orderby == undefined ||
document.formUnify.all.orderby == null ) {
alert( "not defined orderby " ) ;
return ;
}
if ( document.formUnify.orderby.value.indexOf(field) >= 0 ) {
if( document.formUnify.orderby.value.indexOf(" desc") > 0 ) {
document.formUnify.orderby.value = field + " asc ";
}else {
document.formUnify.orderby.value = "";
}
}
else { // don't order
document.formUnify.orderby.value = field + " desc ";
}
SwitchPage.doExecute(requrl, method);
}
SwitchPage.reverseAll = function (obj){
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -