You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/CommMng/Viewsjs/Comm/DsComm.js

406 lines
14 KiB
JavaScript

2 years ago
function NewGuid() {
var guid = "";
for (var i = 1; i <= 32; i++) {
var n = Math.floor(Math.random() * 16.0).toString(16);
guid += n;
if ((i == 8) || (i == 12) || (i == 16) || (i == 20))
guid += "-";
}
return guid.toUpperCase();
}
function DsOpenEditWin(url, caption, height, width) {
var pageinfo = "height=";
/*
if (typeof caption == undefined) { var _caption = "添加提单"; }
else { var _caption = caption; }
if (typeof height == undefined) { var _height = "650"; }
else { var _height = height; }
if (typeof width == undefined) { var _width = "1000"; }
else { var _width = width; }*/
if (caption == undefined) { var _caption = "添加提单"; }
else { var _caption = caption; }
//alert(height);
if (height == undefined) {pageinfo = pageinfo.concat("650"); }
else {
pageinfo = pageinfo.concat(height);
//alert(height);
}
pageinfo = pageinfo.concat("px, width=");
if (width == undefined) { pageinfo = pageinfo.concat("900"); }
else { pageinfo = pageinfo.concat(width); }
pageinfo = pageinfo.concat("px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no");
//alert(pageinfo);
return window.open(url, _caption, pageinfo);
// return window.open(url, "添加提单", "height=600px, width=900px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no");
}
function DsOpenEditWin2(url, caption, height, width, top, left) {
var pageinfo = "height=";
/*
if (typeof caption == undefined) { var _caption = "添加提单"; }
else { var _caption = caption; }
if (typeof height == undefined) { var _height = "650"; }
else { var _height = height; }
if (typeof width == undefined) { var _width = "1000"; }
else { var _width = width; }*/
if (caption == undefined) { var _caption = "添加提单"; }
else { var _caption = caption; }
// //alert(height);
if (height == undefined || height == "") { pageinfo = pageinfo.concat("" + (window.screen.availHeight - 50) + ""); } //"650"
else { pageinfo = pageinfo.concat(height); }
pageinfo = pageinfo.concat("px, width=");
if (width == undefined || width == "") { pageinfo = pageinfo.concat("" + (window.screen.availWidth - 10) + ""); } //"900"
else { pageinfo = pageinfo.concat(width); }
pageinfo = pageinfo.concat("px, top=");
if (top == undefined || top == "") { pageinfo = pageinfo.concat("0"); }
else { pageinfo = pageinfo.concat(top); }
pageinfo = pageinfo.concat("px, left=");
if (left == undefined || left == "") { pageinfo = pageinfo.concat("0"); }
else { pageinfo = pageinfo.concat(left); }
pageinfo = pageinfo.concat("px,center:yes,resizable=yes,status=yes,menubar=no,scrollbars=yes");
//pageinfo = pageinfo.concat("width=" + (window.screen.availWidth - 10) + ",height=" + (window.screen.availHeight - 30) + ",top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes");
//alert(pageinfo);
return window.open(url, _caption, pageinfo);
//return window.open(url, _caption, 'width=' + (window.screen.availWidth - 10) + ',height=' + (window.screen.availHeight - 55) + ',top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes');
// return window.open(url, "添加提单", "height=600px, width=900px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no");
}
function DsOpenMultiEditWin(url, caption, height, width, top, left) {
var pageinfo = "height=";
if (caption == undefined) { var _caption = "添加提单"; }
else { var _caption = caption; }
if (height == undefined || height == "") { pageinfo = pageinfo.concat("" + (window.screen.availHeight - 50) + ""); } //"650"
else { pageinfo = pageinfo.concat(height); }
pageinfo = pageinfo.concat("px, width=");
if (width == undefined || width == "") { pageinfo = pageinfo.concat("" + (window.screen.availWidth - 10) + ""); } //"900"
else { pageinfo = pageinfo.concat(width); }
pageinfo = pageinfo.concat("px, top=");
if (top == undefined || top == "") { pageinfo = pageinfo.concat("0"); }
else { pageinfo = pageinfo.concat(top); }
pageinfo = pageinfo.concat("px, left=");
if (left == undefined || left == "") { pageinfo = pageinfo.concat("0"); }
else { pageinfo = pageinfo.concat(left); }
pageinfo = pageinfo.concat("px,center:yes,resizable=yes,status=yes,menubar=no,scrollbars=yes");
//pageinfo = pageinfo.concat("width=" + (window.screen.availWidth - 10) + ",height=" + (window.screen.availHeight - 30) + ",top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes");
//alert(pageinfo);
return window.open(url, null, pageinfo, null);
//return window.open(url, _caption, 'width=' + (window.screen.availWidth - 10) + ',height=' + (window.screen.availHeight - 55) + ',top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes');
// return window.open(url, "添加提单", "height=600px, width=900px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no");
}
function DsOpenEditWinAll(url, caption, height, width, top, left) {
var pageinfo = "height=";
/*
if (typeof caption == undefined) { var _caption = "添加提单"; }
else { var _caption = caption; }
if (typeof height == undefined) { var _height = "650"; }
else { var _height = height; }
if (typeof width == undefined) { var _width = "1000"; }
else { var _width = width; }*/
if (caption == undefined) { var _caption = "添加提单"; }
else { var _caption = caption; }
// //alert(height);
if (height == undefined || height == "") { pageinfo = pageinfo.concat("" + (window.screen.availHeight - 50) + ""); } //"650"
else { pageinfo = pageinfo.concat(height); }
pageinfo = pageinfo.concat("px, width=");
if (width == undefined || width == "") { pageinfo = pageinfo.concat("" + (window.screen.availWidth - 10) + ""); } //"900"
else { pageinfo = pageinfo.concat(width); }
pageinfo = pageinfo.concat("px, top=");
if (top == undefined || top == "") { pageinfo = pageinfo.concat("0"); }
else { pageinfo = pageinfo.concat(top); }
pageinfo = pageinfo.concat("px, left=");
if (left == undefined || left == "") { pageinfo = pageinfo.concat("0"); }
else { pageinfo = pageinfo.concat(left); }
pageinfo = pageinfo.concat("px,center:yes,resizable=yes,status=yes,menubar=no,scrollbars=yes");
//pageinfo = pageinfo.concat("width=" + (window.screen.availWidth - 10) + ",height=" + (window.screen.availHeight - 30) + ",top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes");
//alert(pageinfo);
return window.open(url, _caption, pageinfo);
//return window.open(url, _caption, 'width=' + (window.screen.availWidth - 10) + ',height=' + (window.screen.availHeight - 55) + ',top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes');
// return window.open(url, "添加提单", "height=600px, width=900px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no");
}
/*
function DsOpenEditWin(url, caption) {
return window.open(url, caption, "height=650px, width=900px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no");
}
function DsOpenEditWin(url) {
return window.open(url, "添加提单", "height=600px, width=900px,center:yes,help:no,toolbar=no,menubar=no,scrollbars=no,resizable=0,location=no,status=no");
}*/
//#region 获取目前store当中最大的Serialno序号
function DsGetCurSerialNo(store,serialno) {
var result = serialno;
if (result == 0) {
for (var i = 0; i < store.getCount(); i += 1) {
var member = store.getAt(i);
if (member.data.SerialNo > result) {
result = member.data.SerialNo;
}
}
}
return result;
}
//#endregion
//#region 获取目前新SerialNo (目前最大值+1
function DsGetNewSerialNo(store, serialno) {
var result = DsGetCurSerialNo(store,serialno) + 1;
return result;
}
//#endregion
//#region 获取字段名为fieldname字段值为value记录集合
function DsStoreQueryBy(store, fieldname, value) {
return store.queryBy(function (rec) {
if (rec.get(fieldname) == value) {
return true;
} else {
return false;
}
});
}
//#endregion
//#region 数字转化为指定金额格式
//数值添加小数位数后的“.00”
function usMoney(v) {
if (v == null || v == "") {
v = 0;
}
v = (Math.round((v - 0) * 100)) / 100;
v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
v = String(v);
var ps = v.split('.');
var whole = ps[0];
var sub = ps[1] ? '.' + ps[1] : '.00';
var r = /(\d+)(\d{3})/;
while (r.test(whole)) {
whole = whole.replace(r, '$1' + ',' + '$2');
}
v = whole + sub;
if (v.charAt(0) == '-') {
return '-' + v.substr(1); //'-$'
}
return v; //"$"
}
//数值添加小数位数后的“.0”、货币“符号”、“,”分隔符参数说明v数值dl小数位数symbol符号isComma是否用“,”分隔数值
function usMoney(v, dl, symbol, isComma) {
if (isNullorEmpty(v)) {
v = 0;
}
//数值添加小数位数后的“0”
var iChengShu = 1;
var sXiaoShu = ".";
for (var n = 1; n <= dl; n++) {
iChengShu = Math.pow(10, n);
sXiaoShu += "0";
}
v = (Math.round((v - 0) * iChengShu)) / iChengShu;
//v = (v == Math.floor(v)) ? v + ".00" : ((v * 10 == Math.floor(v * 10)) ? v + "0" : v);
if (v == Math.floor(v)) {
v = v + sXiaoShu;
}
else {
var sValue = v.toString();
sValue = sValue.substr(sValue.indexOf(".") + 1);
var iVLength = sValue.length;
var iChengShu2 = 1;
for (var k = (1 + iVLength); k <= dl; k++) {
iChengShu2 = iChengShu2 * Math.pow(10, k);
if ((v * iChengShu2) == Math.floor(v * iChengShu2)) {
v = v + "0";
}
}
}
//是否用“,”分隔数值
v = String(v);
if (isComma) {
//第一种方法
var ps = v.split('.');
var whole = ps[0];
var sub = ps[1] ? '.' + ps[1] : sXiaoShu;
var r = /(\d+)(\d{3})/;
while (r.test(whole)) {
whole = whole.replace(r, '$1' + ',' + '$2');
}
v = whole + sub;
//第二种方法
//var zhs = v.substr(v, v.indexOf("."));
//if (v.indexOf(".") > -1) {
// zhs = v.substr(v, v.indexOf("."));
//}
//var iLength = zhs.length / 3;
//var iLengthC = zhs.length / 3;
//var zhs2 = "";
//for (var i = 1; i <= iLengthC; i++) {
// zhs2 = "," + zhs.substring((iLength - 3*i),3);
//}
}
//添加符号
if (v.charAt(0) == '-') {
return '-' + symbol + v.substr(1); //'-$'
}
return symbol + v; //"$"
};
//#endregion
function CheckISSTOP(_store, _fieldname, _value) {
var field = DsStoreQueryBy(_store, 'name', _value);
if (field.getCount() > 0) {
var fielddata = field.getAt(0).data;
if (fielddata.ISSTOP == "True") {
return true;
} else {
return false;
}
}
}
//#region 用于多重排序列
//最初用在importTrade模块上
//http://dev.sencha.com/deploy/ext-4.0.2a/examples/grid/multiple-sorting.html
function doSort() {
store.sort(getSorters());
}
function changeSortDirection(button, changeDirection) {
var sortData = button.sortData,
iconCls = button.iconCls;
if (sortData) {
if (changeDirection !== false) {
button.sortData.direction = Ext.String.toggle(button.sortData.direction, "ASC", "DESC");
button.setIconCls(Ext.String.toggle(iconCls, "sort-asc", "sort-desc"));
}
store.clearFilter();
doSort();
}
}
function getSorters() {
var sorters = [];
Ext.each(tbar.query('button'), function (button) {
sorters.push(button.sortData);
}, this);
return sorters;
}
function createSorterButtonConfig(config) {
config = config || {};
Ext.applyIf(config, {
listeners: {
click: function (button, e) {
changeSortDirection(button, true);
}
},
iconCls: 'sort-' + config.sortData.direction.toLowerCase(),
reorderable: true,
xtype: 'button'
});
return config;
}
//#endregion
//#region 令指定combox的store按照paramscondition重新加载
function LoadCombox(combox, condition) {
combox.store.load({
async: false,
params: { condition: condition }
});
}
//#endregion
function ImgWindow(url) {
if (url !== null || typeof (url) == "undefined" || url !== "" || url !== '')
{
if (Ext.getCmp("pic_i")) { Ext.getCmp("pic_i").close(); }
if (Ext.getCmp("pic_p")) { Ext.getCmp("pic_p").close(); }
var height = 0;
var width = 0;
var a = new Image();
a.src = url;
a.onload = function () {
height = a.height;
width = a.width;
c = Ext.getCmp("pic_i");
c.width = getwidth(width);
c.height = getheight(height);
c.doLayout();
d = Ext.getCmp("pic_p");
d.width = getwidth(width) + 33;
d.height = getheight(height) + 50;
d.doLayout();
};
new Ext.Window({
id: "pic_p",
//renderTo: Ext.getBody(),
bodyStyle: 'padding:10px;', //加个内边框好看一点
items: [{
id: "pic_i",
width: 200,
height: 200,
html: '<image src="' + url + '"></image>'
}]
}).show();
}
function getwidth(width) {
if (width > window.screen.availWidth - 50)
return window.screen.availWidth - 50;
if (width < 50) return 50;
return width;
}
function getheight(height) {
if (height > window.screen.availHeight - 50)
return window.screen.availHeight - 50;
if (height < 50) return 50;
return height;
}
2 years ago
}