|
|
|
|
|
String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); }
|
|
|
|
|
|
|
|
|
Date.prototype.format = function (fmt) {
|
|
|
var o = {
|
|
|
"M+": this.getmonth() + 1, //月份
|
|
|
"d+": this.getDate(), //日
|
|
|
"h+": this.getHours(), //小时
|
|
|
"m+": this.getMinutes(), //分
|
|
|
"s+": this.getSeconds(), //秒
|
|
|
"q+": Math.floor((this.getMonth() + 3) / 3), //季度
|
|
|
"S": this.getMilliseconds() //毫秒
|
|
|
};
|
|
|
if (/(y+)/.test(fmt)) {
|
|
|
fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
|
|
|
}
|
|
|
for (var k in o) {
|
|
|
if (new RegExp("(" + k + ")").test(fmt)) {
|
|
|
fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
|
|
|
}
|
|
|
}
|
|
|
return fmt;
|
|
|
}
|
|
|
|
|
|
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, 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 DsOpenEditWin_NoUrl(url, caption, height, width, top, left) {
|
|
|
var pageinfo = "height=";
|
|
|
|
|
|
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.concat(",location=no");
|
|
|
|
|
|
return window.open(url, _caption, pageinfo);
|
|
|
}
|
|
|
function DsOpenEditWin_FullUrl(url, caption, height, width, top, left) {
|
|
|
var pageinfo = "height=";
|
|
|
|
|
|
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.concat(",location=no");
|
|
|
|
|
|
return window.open("http://" + url, _caption, pageinfo);
|
|
|
|
|
|
}
|
|
|
/*
|
|
|
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");
|
|
|
}*/
|
|
|
|
|
|
|
|
|
function DsOpenAtMain(url, caption, MainCenter) {
|
|
|
var finded = false;
|
|
|
// var MainCenter = Ext.getCmp('MainCenter');
|
|
|
|
|
|
if (MainCenter != NaN && MainCenter != null) {
|
|
|
var children = MainCenter.items;
|
|
|
if (children) {
|
|
|
for (var i = 0, len = children.length; i < len; i++) {
|
|
|
if (children.items[i].id) {
|
|
|
if (children.items[i].id == 'pnl' + caption) {
|
|
|
MainCenter.setActiveTab(i);
|
|
|
finded = true;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
if (finded == false) {
|
|
|
var paneltabitems = new Ext.Panel({
|
|
|
id: 'pnl' + caption,
|
|
|
layout: "fit",
|
|
|
region: "center",
|
|
|
autoScroll: true,
|
|
|
frame: false,
|
|
|
closable: true,
|
|
|
bodyStyle: {
|
|
|
// background: 'rgba(0, 0, 0, 1) none repeat scroll 0 0 !important'
|
|
|
},
|
|
|
title: caption,
|
|
|
html: ' <iframe scrolling="auto" frameborder="0" width="100%" height="100%" src="' + url + '"> </iframe>'
|
|
|
});
|
|
|
MainCenter.add(paneltabitems);
|
|
|
MainCenter.setActiveTab(paneltabitems);
|
|
|
MainCenter.doLayout();
|
|
|
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
function FindAtMain(pnlid, MainCenter) {
|
|
|
var finded =null;
|
|
|
// var MainCenter = Ext.getCmp('MainCenter');
|
|
|
|
|
|
if (MainCenter != NaN && MainCenter != null) {
|
|
|
var children = MainCenter.items;
|
|
|
if (children) {
|
|
|
for (var i = 0, len = children.length; i < len; i++) {
|
|
|
if (children.items[i].id) {
|
|
|
if (children.items[i].id == pnlid) {
|
|
|
finded = children.items[i];
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return finded;
|
|
|
}
|
|
|
|
|
|
|
|
|
//combox的前台模糊查询过滤
|
|
|
function FilterCombox(e, limit = 1) {
|
|
|
|
|
|
if(e.query.length < limit) return;
|
|
|
|
|
|
var combo = e.combo;
|
|
|
if (!e.forceAll) {
|
|
|
var value = e.query.replace(/^\s*|\s*$/g, "").toUpperCase();
|
|
|
combo.store.filterBy(function (record, id) {
|
|
|
var text = record.get(combo.displayField).toUpperCase();
|
|
|
return (text.indexOf(value) != -1);
|
|
|
});
|
|
|
var field = combo.displayField;
|
|
|
combo.store.sort({
|
|
|
property: field,
|
|
|
//direction: state,
|
|
|
direction: "ASC",
|
|
|
//排序规则(重点)
|
|
|
sorterFn: function (v1, v2) {
|
|
|
v1 = v1.get(field);
|
|
|
v2 = v2.get(field);
|
|
|
|
|
|
return v1.indexOf(value) > v2.indexOf(value) ? 1 : (v1.indexOf(value) < v2.indexOf(value) ? -1 : 0);
|
|
|
}
|
|
|
});
|
|
|
|
|
|
combo.expand();
|
|
|
//e.combo.select(combo.store.data.items[0]);
|
|
|
//if (combo.store.data.length > 0) {
|
|
|
// var firstvalue = combo.store.data.items[0].get(combo.valueField);
|
|
|
// e.combo.value=firstvalue;
|
|
|
//}
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function GetComboxFirstValueOnTableClick(combo,e) {
|
|
|
//var combo = e.combo;
|
|
|
if (e.getKey() == e.ENTER) {
|
|
|
e.keyCode = 9;
|
|
|
}
|
|
|
if (e.keyCode == 9) {
|
|
|
//将combo
|
|
|
//alert(field.value);
|
|
|
if (combo.value == null) {
|
|
|
_name = combo.store.data.keys[0];
|
|
|
combo.setValue(_name);
|
|
|
} else {
|
|
|
if (combo.value.replace(/\s*/g, "") == "") {
|
|
|
_name = combo.store.data.keys[0];
|
|
|
combo.setValue(_name);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function GetComboxFirstValueOnTableClick_RefTable(combo, e,VALUEFIELDNAME) {
|
|
|
//var combo = e.combo;
|
|
|
if (e.getKey() == e.ENTER) {
|
|
|
e.keyCode = 9;
|
|
|
}
|
|
|
if (e.keyCode == 9) {
|
|
|
//将combo
|
|
|
//alert(field.value);
|
|
|
if (combo.value == null) {
|
|
|
_name = combo.store.data.items[0].get(VALUEFIELDNAME);
|
|
|
combo.setValue(_name);
|
|
|
} else {
|
|
|
if (combo.value.replace(/\s*/g, "") == "") {
|
|
|
_name = combo.store.data.keys[0];
|
|
|
combo.setValue(_name);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//获取目前表最大的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;
|
|
|
}
|
|
|
|
|
|
//获取目前新SerialNo
|
|
|
function DsGetNewSerialNo(store, serialno) {
|
|
|
var result = DsGetCurSerialNo(store,serialno) + 1;
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//获取字段名为fieldname字段值为value记录集合
|
|
|
function DsStoreQueryBy(store, fieldname, value) {
|
|
|
return store.queryBy(function (rec) {
|
|
|
if (rec.get(fieldname) == value) {
|
|
|
return true;
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
//获取字段名为fieldname字段值like为value记录集合
|
|
|
function DsStoreQueryLikeBy(store, fieldname,num,value) {
|
|
|
return store.queryBy(function (rec) {
|
|
|
var str = rec.get(fieldname);
|
|
|
if (str.substring(0,num) == value) {
|
|
|
return true;
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
function DsStoreQueryBy2(store, fieldname, value, fieldname2, value2) {
|
|
|
return store.queryBy(function (rec) {
|
|
|
if (rec.get(fieldname) == value && rec.get(fieldname2) == value2) {
|
|
|
return true;
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
String.prototype.replaceAll = function (s1, s2) {
|
|
|
return this.replace(new RegExp(s1, "gm"), s2);
|
|
|
}
|
|
|
|
|
|
//#region 结果无错的加减乘除 Add Cut Mul Div
|
|
|
Number.prototype.toFixed = function (len) {
|
|
|
var add = 0;
|
|
|
var s, temp;
|
|
|
var s1 = this + "";
|
|
|
var start = s1.indexOf(".");
|
|
|
if (start >= 0) {
|
|
|
s1 = s1 + "0";
|
|
|
if (s1.substr(start + len + 1, 1) >= 5) add = 1;
|
|
|
var temp = Math.pow(10, len);
|
|
|
s = Math.floor(this.mul(temp)) + add;
|
|
|
return s / temp;
|
|
|
} else return this;
|
|
|
}
|
|
|
|
|
|
function accDiv(arg1, arg2) {
|
|
|
var t1 = 0, t2 = 0, r1, r2;
|
|
|
try { t1 = arg1.toString().split(".")[1].length } catch (e) { }
|
|
|
try { t2 = arg2.toString().split(".")[1].length } catch (e) { }
|
|
|
with (Math) {
|
|
|
r1 = Number(arg1.toString().replace(".", ""))
|
|
|
r2 = Number(arg2.toString().replace(".", ""))
|
|
|
return (r1 / r2) * pow(10, t2 - t1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
Number.prototype.div = function (arg) {
|
|
|
return accDiv(this, arg);
|
|
|
|
|
|
}
|
|
|
|
|
|
function parseFloatDef(num, defnum) {
|
|
|
if (num == '') return defnum;
|
|
|
var anum = parseFloat(num);
|
|
|
if (anum == NaN)
|
|
|
return defnum
|
|
|
else
|
|
|
return anum
|
|
|
|
|
|
}
|
|
|
|
|
|
function accMul(arg1, arg2) {
|
|
|
var m = 0, s1 = arg1.toString(), s2 = arg2.toString();
|
|
|
try { m += s1.split(".")[1].length } catch (e) { }
|
|
|
try { m += s2.split(".")[1].length } catch (e) { }
|
|
|
return Number(s1.replace(".", "")) * Number(s2.replace(".", "")) / Math.pow(10, m)
|
|
|
}
|
|
|
|
|
|
Number.prototype.mul = function (arg) {
|
|
|
|
|
|
return accMul(arg, this);
|
|
|
}
|
|
|
|
|
|
//function accAdd(arg1, arg2) {
|
|
|
// var r1, r2, m;
|
|
|
// try { r1 = arg1.toString().split(".")[1].length } catch (e) { r1 = 0 }
|
|
|
// try { r2 = arg2.toString().split(".")[1].length } catch (e) { r2 = 0 }
|
|
|
// m = Math.pow(10, Math.max(r1, r2))
|
|
|
// return (arg1 * m + arg2 * m) / m
|
|
|
//}
|
|
|
|
|
|
function accAdd(arg1, arg2) {
|
|
|
if (isNaN(arg1)) {
|
|
|
arg1 = 0;
|
|
|
}
|
|
|
if (isNaN(arg2)) {
|
|
|
arg2 = 0;
|
|
|
}
|
|
|
arg1 = Number(arg1);
|
|
|
arg2 = Number(arg2);
|
|
|
var r1, r2, m, c;
|
|
|
try {
|
|
|
r1 = arg1.toString().split(".")[1].length;
|
|
|
}
|
|
|
catch (e) {
|
|
|
r1 = 0;
|
|
|
}
|
|
|
try {
|
|
|
r2 = arg2.toString().split(".")[1].length;
|
|
|
}
|
|
|
catch (e) {
|
|
|
r2 = 0;
|
|
|
}
|
|
|
c = Math.abs(r1 - r2);
|
|
|
m = Math.pow(10, Math.max(r1, r2));
|
|
|
if (c > 0) {
|
|
|
var cm = Math.pow(10, c);
|
|
|
if (r1 > r2) {
|
|
|
arg1 = Number(arg1.toString().replace(".", ""));
|
|
|
arg2 = Number(arg2.toString().replace(".", "")) * cm;
|
|
|
} else {
|
|
|
arg1 = Number(arg1.toString().replace(".", "")) * cm;
|
|
|
arg2 = Number(arg2.toString().replace(".", ""));
|
|
|
}
|
|
|
} else {
|
|
|
arg1 = Number(arg1.toString().replace(".", ""));
|
|
|
arg2 = Number(arg2.toString().replace(".", ""));
|
|
|
}
|
|
|
return (arg1 + arg2) / m;
|
|
|
}
|
|
|
|
|
|
Number.prototype.add = function (arg) {
|
|
|
return accAdd(arg, this);
|
|
|
}
|
|
|
|
|
|
function Add(a, b, length) {
|
|
|
if ((typeof (length) == undefined) || (length == null)) {
|
|
|
length = 2;
|
|
|
}
|
|
|
var _r = parseFloat(a).add(parseFloat(b)).toFixed(parseInt(length));
|
|
|
return parseFloat(_r);
|
|
|
}
|
|
|
function Cut(a, b, length) {
|
|
|
if ((typeof (length) == undefined) || (length == null)) {
|
|
|
length = 2;
|
|
|
}
|
|
|
var _r = parseFloat(a).add(parseFloat(0) - parseFloat(b)).toFixed(parseInt(length));
|
|
|
return parseFloat(_r);
|
|
|
}
|
|
|
function Mul(a, b, length) {
|
|
|
if ((typeof (length) == undefined) || (length == null)) {
|
|
|
length = 2;
|
|
|
}
|
|
|
|
|
|
var isnnumber = 0;
|
|
|
|
|
|
if (a < 0 || b < 0) {
|
|
|
if (b > 0) {
|
|
|
var _r = (Math.abs(parseFloat(a)).mul(parseFloat(b)))
|
|
|
isnnumber = 1;
|
|
|
}
|
|
|
else if (a > 0) {
|
|
|
var _r = (parseFloat(a).mul(Math.abs(parseFloat(b))))
|
|
|
isnnumber = 1;
|
|
|
}
|
|
|
else
|
|
|
var _r = parseFloat(a).mul(parseFloat(b));
|
|
|
} else
|
|
|
var _r = parseFloat(a).mul(parseFloat(b))
|
|
|
|
|
|
var _r2 = _r.toFixed(parseInt(length));
|
|
|
if (isnnumber == 1) _r2 = -_r2;
|
|
|
return parseFloat(_r2);
|
|
|
}
|
|
|
|
|
|
function Mul3(a, b, c, length) {
|
|
|
if ((typeof (length) == undefined) || (length == null)) {
|
|
|
length = 2;
|
|
|
}
|
|
|
var _r = (parseFloat(a).mul(parseFloat(b)).mul(parseFloat(c))).toFixed(parseInt(length));
|
|
|
return parseFloat(_r);
|
|
|
}
|
|
|
function Mul4(a, b, c, d, length) {
|
|
|
if ((typeof (length) == undefined) || (length == null)) {
|
|
|
length = 2;
|
|
|
}
|
|
|
var _r = (parseFloat(a).mul(parseFloat(b)).mul(parseFloat(c)).mul(parseFloat(d))).toFixed(parseInt(length));
|
|
|
return parseFloat(_r);
|
|
|
}
|
|
|
function Mul5(a, b, c, d, e, length) {
|
|
|
if ((typeof (length) == undefined) || (length == null)) {
|
|
|
length = 2;
|
|
|
}
|
|
|
var _r = (parseFloat(a).mul(parseFloat(b)).mul(parseFloat(c)).mul(parseFloat(d)).mul(parseFloat(e))).toFixed(parseInt(length));
|
|
|
return parseFloat(_r);
|
|
|
}
|
|
|
function Div(a, b, length) {
|
|
|
if ((typeof (length) == undefined) || (length == null)) {
|
|
|
length = 2;
|
|
|
}
|
|
|
var _r = parseFloat(a).div(parseFloat(b)).toFixed(parseInt(length));
|
|
|
return parseFloat(_r);
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
function returnfloat(value) {
|
|
|
if (value=="***") return value;
|
|
|
|
|
|
var value = Math.round(parseFloat(value) * 100) / 100;
|
|
|
var xsd = value.toString().split(".");
|
|
|
if (xsd.length == 1) {
|
|
|
value = value.toString() + ".00";
|
|
|
return value;
|
|
|
}
|
|
|
if (xsd.length > 1) {
|
|
|
if (xsd[1].length < 2) {
|
|
|
value = value.toString() + "0";
|
|
|
}
|
|
|
return value;
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
function English(a) {
|
|
|
var arr1 = new Array("", " thousand", " million", " billion"),
|
|
|
arr2 = new Array("zero", "ten", "twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"),
|
|
|
arr3 = new Array("zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"),
|
|
|
arr4 = new Array("ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen");
|
|
|
|
|
|
|
|
|
strRet = "";
|
|
|
if (a.length == 3 && a.substr(0, 3) != "000") {
|
|
|
if (a.substr(0, 1) != "0") {
|
|
|
strRet += arr3[a.substr(0, 1)] + " hundred";
|
|
|
if (a.substr(1, 2) != "00") strRet += " and "
|
|
|
} else {
|
|
|
strRet += " and "
|
|
|
}
|
|
|
a = a.substring(1)
|
|
|
}
|
|
|
if (a.length == 2) if (a.substr(0, 1) == "0") a = a.substring(1);
|
|
|
else if (a.substr(0, 1) == "1") strRet += arr4[a.substr(1, 2)];
|
|
|
else {
|
|
|
strRet += arr2[a.substr(0, 1)];
|
|
|
if (a.substr(1, 1) != "0") strRet += "-";
|
|
|
a = a.substring(1)
|
|
|
}
|
|
|
if (a.length == 1 && a.substr(0, 1) != "0") strRet += arr3[a.substr(0, 1)];
|
|
|
return strRet
|
|
|
};
|
|
|
|
|
|
function ToEn(a) {
|
|
|
var arr1 = new Array("", " thousand", " million", " billion");
|
|
|
var b = a.length,
|
|
|
f,
|
|
|
h = 0,
|
|
|
g = "",
|
|
|
e = Math.ceil(b / 3),
|
|
|
k = b - e * 3;
|
|
|
g = "";
|
|
|
for (f = k; f < b; f += 3) {
|
|
|
++h;
|
|
|
num3 = f >= 0 ? a.substring(f, f + 3) : a.substring(0, k + 3);
|
|
|
strEng = English(num3);
|
|
|
if (strEng != "") {
|
|
|
if (g != "") g += " ";
|
|
|
g += English(num3) + arr1[e - h]
|
|
|
}
|
|
|
}
|
|
|
return g
|
|
|
}
|
|
|
|
|
|
//#region 合并单元格
|
|
|
/**
|
|
|
* Kunoy
|
|
|
* 合并单元格
|
|
|
* @param {} grid 要合并单元格的grid对象
|
|
|
* @param {} cols 要合并哪几列 [1,2,4]。另外,如果有check列需要合并,则放到最后[1,2,4,0]
|
|
|
*/
|
|
|
var mergeCells = function (grid, cols) {
|
|
|
var arrayTr = document.getElementById(grid.getId() + "-body").firstChild.firstChild.firstChild.getElementsByTagName('tr');
|
|
|
var trCount = arrayTr.length;
|
|
|
var arrayTd;
|
|
|
var td;
|
|
|
var merge = function (rowspanObj, removeObjs) { //定义合并函数
|
|
|
if (rowspanObj.rowspan != 1) {
|
|
|
arrayTd = arrayTr[rowspanObj.tr].getElementsByTagName("td"); //合并行
|
|
|
td = arrayTd[rowspanObj.td - 1];
|
|
|
td.rowSpan = rowspanObj.rowspan;
|
|
|
td.vAlign = "middle";
|
|
|
Ext.each(removeObjs, function (obj) { //隐身被合并的单元格
|
|
|
arrayTd = arrayTr[obj.tr].getElementsByTagName("td");
|
|
|
arrayTd[obj.td - 1].style.display = 'none';
|
|
|
});
|
|
|
}
|
|
|
};
|
|
|
var rowspanObj = {}; //要进行跨列操作的td对象{tr:1,td:2,rowspan:5}
|
|
|
var removeObjs = []; //要进行删除的td对象[{tr:2,td:2},{tr:3,td:2}]
|
|
|
var col;
|
|
|
var lastCol = 0;
|
|
|
Ext.each(cols, function (colIndex) { //逐列去操作tr
|
|
|
var rowspan = 1;
|
|
|
var divHtml = null; //单元格内的数值
|
|
|
var isCF = "";
|
|
|
for (var i = 1; i < trCount; i++) { //i=0表示表头等没用的行
|
|
|
arrayTd = arrayTr[i].getElementsByTagName("td");
|
|
|
var cold = 0;
|
|
|
Ext.each(arrayTd, function (Td) { //获取RowNumber列和check列
|
|
|
if (Td.getAttribute("class").indexOf("x-grid-cell-special") != -1)
|
|
|
cold++;
|
|
|
});
|
|
|
col = colIndex + cold; //跳过RowNumber列和check列
|
|
|
if (!divHtml) {
|
|
|
if (col == 0) {
|
|
|
divHtml = arrayTd[col].innerHTML;
|
|
|
}
|
|
|
else {
|
|
|
divHtml = arrayTd[col - 1].innerHTML;
|
|
|
}
|
|
|
rowspanObj = { tr: i, td: col, rowspan: rowspan }
|
|
|
} else {
|
|
|
var cellText = arrayTd[col].innerHTML;
|
|
|
if (col != 0) {
|
|
|
cellText = arrayTd[col - 1].innerHTML;
|
|
|
}
|
|
|
var addf = function () {
|
|
|
rowspanObj["rowspan"] = rowspanObj["rowspan"] + 1;
|
|
|
removeObjs.push({ tr: i, td: col });
|
|
|
if (i == trCount - 1)
|
|
|
merge(rowspanObj, removeObjs); //执行合并函数
|
|
|
};
|
|
|
var mergef = function () {
|
|
|
merge(rowspanObj, removeObjs); //执行合并函数
|
|
|
divHtml = cellText;
|
|
|
rowspanObj = { tr: i, td: col, rowspan: rowspan }
|
|
|
removeObjs = [];
|
|
|
};
|
|
|
if (cellText == divHtml) {
|
|
|
if (colIndex != cols[0]) {
|
|
|
//取得上一个合并的列号
|
|
|
//var iCol = col;
|
|
|
//if (colIndex != lastCol) {
|
|
|
// iCol = lastCol;
|
|
|
//}
|
|
|
|
|
|
var iCol = lastCol + 1; //取得第一个合并的列号
|
|
|
var leftDisplay = arrayTd[iCol - 1].style.display; //判断左边单元格值是否已display
|
|
|
if (iCol >= 2) {
|
|
|
leftDisplay = arrayTd[iCol - 2].style.display; //判断左边单元格值是否已display
|
|
|
}
|
|
|
if (leftDisplay == 'none')
|
|
|
addf();
|
|
|
else
|
|
|
mergef();
|
|
|
} else {
|
|
|
addf();
|
|
|
lastCol = col; //取得第一个合并的列号;
|
|
|
}
|
|
|
} else {
|
|
|
mergef();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
//lastCol = col; //取得上一个合并的列号
|
|
|
});
|
|
|
};
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
//#region 获取某日之后days天数的日期
|
|
|
function getAfterDATE(startdate,days) {
|
|
|
|
|
|
var myDate = new Date(Date.parse(startdate.toString()));
|
|
|
|
|
|
myDate.setDate(myDate.getDate() + (parseInt(days) -1));
|
|
|
var lsDate = Ext.util.Format.date(myDate, 'Y-m-d');
|
|
|
if (lsDate.indexOf("-00-") > -1) {
|
|
|
lsDate = (myDate.getFullYear() - 1) + "-12-" + myDate.getDate();
|
|
|
}
|
|
|
return lsDate;
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
//#region 获取两个日期的天数间隔,只考虑日期差。1月1日与1月2日差为1.
|
|
|
function datediff(data1str, data2str) {
|
|
|
if (isNullorEmpty(data1str) || isNullorEmpty(data2str))
|
|
|
return 0;
|
|
|
|
|
|
data1 = new Date(data1str);
|
|
|
data2 = new Date(data2str);
|
|
|
aDay = 24 * 60 * 60 * 1000;
|
|
|
diffDay = (data2 - data1) / aDay;
|
|
|
if (diffDay < 0) diffDay = -diffDay;
|
|
|
return diffDay;
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
//#region 数字转化为指定金额格式
|
|
|
//数值添加小数位数后的“.00”
|
|
|
function usMoney(v) {
|
|
|
if (v == null || v == "" || v == NaN) {
|
|
|
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; //"$"
|
|
|
};
|
|
|
|
|
|
//下面函数的使用例子
|
|
|
// a=1234.567
|
|
|
|
|
|
// usMoney(a,4,"$",true) => $1,234.5670
|
|
|
|
|
|
//数值添加小数位数后的“.0”、货币“符号”、“,”分隔符;v:数值,dl:小数位数,symbol:符号,isComma:是否用“,”分隔数值
|
|
|
function usMoney(v, dl, symbol, isComma) {
|
|
|
if (v == null || 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
|
|
|
|
|
|
//#region 返回一个store的一个字段值为value的记录 其“ISSTOP”值是否为 true/1
|
|
|
function CheckISSTOP(_store, _fieldname, _value) {
|
|
|
var field = DsStoreQueryBy(_store, 'name', _value);
|
|
|
if (field.getCount() > 0) {
|
|
|
var fielddata = field.getAt(0).data;
|
|
|
if (isTrue(fielddata.ISSTOP)) {
|
|
|
return true;
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
};
|
|
|
//#endregion
|
|
|
|
|
|
//#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 集成的grid内combox选择后事件
|
|
|
//获取store内,字段名为fieldname,字段值为value 的 记录集合
|
|
|
function StoreQueryBy(store, fieldname, value) {
|
|
|
return store.queryBy(function (rec) {//此处rec表示store内的记录
|
|
|
if (rec.get(fieldname) == value) {
|
|
|
return true;
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
//为列表中的下拉菜单设定选择后的值。
|
|
|
function SetComboxValue(combox, currrecord, REFFieldname) {
|
|
|
//combox的store;grid的当前行record;combox的valuefieldname;combox当前的valuefield值,grid此列的名字
|
|
|
var comboxrecords = StoreQueryBy(combox.store, combox.valueField, currrecord.value);
|
|
|
if (comboxrecords.getCount() > 0) {
|
|
|
var ForeignData = comboxrecords.getAt(0);
|
|
|
currrecord.record.set(REFFieldname, ForeignData.get(combox.displayField));
|
|
|
} else {
|
|
|
currrecord.record.set(REFFieldname, '');
|
|
|
}
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
//#region 令指定combox的store按照params:condition重新加载
|
|
|
function LoadCombox(combox, condition) {
|
|
|
|
|
|
combox.store.load({
|
|
|
async: false,
|
|
|
params: { condition: condition }
|
|
|
});
|
|
|
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
function ImgWindow(url) {
|
|
|
if (url !== null || typeof (url) == "undefined" || 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;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//#region 主要用于文本框的鼠标指向浮起说明
|
|
|
/* 用法
|
|
|
* 在文本框控件内,
|
|
|
listeners: {
|
|
|
// 鼠标移动到文本框显示悬浮框
|
|
|
render: function (p) {
|
|
|
p.getEl().on('mouseover',
|
|
|
function (p1) {
|
|
|
updateTip(p, '目前纸票和电票的票号都不可以指定\r\n\n纸票需要开出后自动生成发票号,\n然后根据这个发票号放置相应票号的空白发票进行打印');
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
*/
|
|
|
|
|
|
var updateTip = function (field, t) {
|
|
|
Ext.QuickTips.init();
|
|
|
var showtip = "";
|
|
|
if (isNullorEmpty(t)) {
|
|
|
showtip = field.getValue();
|
|
|
}
|
|
|
else {
|
|
|
showtip = t;
|
|
|
}
|
|
|
Ext.QuickTips.register({
|
|
|
target: field.el,
|
|
|
text: showtip
|
|
|
})
|
|
|
};
|
|
|
//#endregion
|
|
|
|
|
|
//#region 判断对象是否为空或空白
|
|
|
|
|
|
function isNullorEmpty(exp) {
|
|
|
////var a = !exp;
|
|
|
//var b = typeof (exp);
|
|
|
|
|
|
////if (a == true) return true;
|
|
|
|
|
|
//if (exp == null) return true;
|
|
|
|
|
|
//if (b == "object") return false;
|
|
|
|
|
|
//if (typeof (exp) == "undefined") return true;
|
|
|
|
|
|
//if (exp == true || exp == false)
|
|
|
//{
|
|
|
// try {
|
|
|
// //在这里运行代码
|
|
|
// if ((exp + "").replace(" ", "") == "") return true;
|
|
|
// }
|
|
|
// catch (err) {
|
|
|
// //在这里处理错误
|
|
|
// }
|
|
|
// return false;
|
|
|
//}
|
|
|
//if (isRealNum(exp)) return false;
|
|
|
//if ((exp+"").replace(" ", "") == "") return true;
|
|
|
//return false;
|
|
|
|
|
|
if (typeof (exp) == "undefined"||exp === undefined) {
|
|
|
return true;
|
|
|
}
|
|
|
else if (exp == null) {
|
|
|
return true;
|
|
|
} else {
|
|
|
var reg = /^\s*$/;
|
|
|
return reg.test(exp);
|
|
|
}
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
//#region 对象是否为false
|
|
|
function isFalse(str) {
|
|
|
if (str == '0' || str == '' || str == false || str == 'false' || str == 'False' || isNullorEmpty(str)) {
|
|
|
return true;
|
|
|
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
//#region 对象是否为true
|
|
|
function isTrue(str) {
|
|
|
if (str == false||(isNullorEmpty(str))) return false;
|
|
|
if (str == true || str.toUpperCase() == 'true'.toUpperCase() || str.toUpperCase()== "true".toUpperCase() || str == '1' || str == "1" || str == 1) {
|
|
|
return true;
|
|
|
|
|
|
} else {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
//#region 验证字符串是否为电话号码(只包含0-9,和-_—~ 空格)
|
|
|
function isPhoneNumber(str) {
|
|
|
//return /^[0-9]*$/.test(str);
|
|
|
|
|
|
//return /^[0-9\-\—\_\ \~]*$/.test(str);
|
|
|
return /^[0-9\-\—\_\~]*$/.test(str);
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
//#region 从字符串末尾获得电话号码(可能包括-)
|
|
|
function getEndTel(str)
|
|
|
{
|
|
|
if (isNullorEmpty(str)) return "";
|
|
|
_L = str.length;
|
|
|
beforetelstr = "";
|
|
|
for (_i = 1; _i < str.length; _i++) {
|
|
|
telstr = str.substring(_L - _i, _L);
|
|
|
if (isPhoneNumber(telstr)) {
|
|
|
beforetelstr = telstr;
|
|
|
} else {
|
|
|
return beforetelstr;
|
|
|
}
|
|
|
}
|
|
|
return beforetelstr;
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
//#region 判断参数是否为数字
|
|
|
function isRealNum(val) {
|
|
|
// isNaN()函数 把空串 空格 以及NUll 按照0来处理 所以先去除,
|
|
|
|
|
|
if (val === "" || val == null) {
|
|
|
return false;
|
|
|
}
|
|
|
if (!isNaN(val)) {
|
|
|
//对于空数组和只有一个数值成员的数组或全是数字组成的字符串,isNaN返回false,例如:'123'、[]、[2]、['123'],isNaN返回false,
|
|
|
//所以如果不需要val包含这些特殊情况,则这个判断改写为if(!isNaN(val) && typeof val === 'number' )
|
|
|
return true;
|
|
|
}
|
|
|
|
|
|
else {
|
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
//#region 用于获取一个url的父节点 ;也就是去掉一个字符串当中,最后一个/后面的部分
|
|
|
function GetParentUrl() {
|
|
|
//http://localhost:10200/Account/Chfee_invoice_HangXin/BLEdit
|
|
|
str = window.location.href;
|
|
|
let index = str.lastIndexOf("/") + 1;
|
|
|
str = str.substring(0, index);
|
|
|
//去掉最后一个/后面的部分
|
|
|
return str;
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
//#region 获得大简云接口地址
|
|
|
function GetHangXinRedirectUrl() {
|
|
|
//大简云的开票应用 接口地址
|
|
|
return "http://47.104.90.170:5200/fp/callback";
|
|
|
//return "http://118.190.106.151:5200/fp/callback/";
|
|
|
//沙盒模式
|
|
|
//return "http://47.104.90.170:5200/cs/callback/";
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
//#region 计算一个指定store当中,字段ConditionField的值为ConditionValue的 ,字段Fieldname列的和
|
|
|
//如ConditionField和ConditionValue为空
|
|
|
function sumFieldValue(storeList,Fieldname,ConditionField,ConditionValue) {
|
|
|
var result = 0;
|
|
|
|
|
|
for (i = 0; i < storeList.getCount(); i += 1) {
|
|
|
var memberyf = storeList.getAt(i);
|
|
|
if (isNullorEmpty(ConditionField) && isNullorEmpty(ConditionValue)) {
|
|
|
result = Add(result, memberyf.get(Fieldname));
|
|
|
}
|
|
|
else
|
|
|
if (memberyf.get(ConditionField) == ConditionValue) {
|
|
|
result = Add(result, memberyf.get(Fieldname));
|
|
|
}
|
|
|
};
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
//#region 将一个store转化成一个array
|
|
|
function GetStoreDataArray(store) {
|
|
|
var storedatas = [];
|
|
|
for (var i = 0; i < store.getCount(); i += 1) {
|
|
|
var member = store.getAt(i);
|
|
|
storedatas.push(member);
|
|
|
}
|
|
|
return storedatas;
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
//#region 将数字结尾补充成固定小数位长度 并转换为文本
|
|
|
//用于截单的数据比较
|
|
|
function getFloat (number, n) {
|
|
|
n = n ? parseInt(n) : 0;
|
|
|
if (n <= 0) {
|
|
|
return Math.round(number);
|
|
|
}
|
|
|
number = Math.round(number * Math.pow(10, n)) / Math.pow(10, n); //四舍五入
|
|
|
number = Number(number).toFixed(n); //补足位数
|
|
|
result = number + "";
|
|
|
if (result.indexOf(".") < 0 && n > 0) result += ".";
|
|
|
while (result.indexOf(".") != result.length - n-1) {
|
|
|
result += "0";
|
|
|
}
|
|
|
return result;
|
|
|
};
|
|
|
//#endregion
|
|
|
|
|
|
//#region 获取几位小数 结尾不补0 转换为文本
|
|
|
//用于截单的数据比较
|
|
|
function getFloatNoZero(number, n) {
|
|
|
n = n ? parseInt(n) : 0;
|
|
|
if (n <= 0) {
|
|
|
return Math.round(number);
|
|
|
}
|
|
|
number = Math.round(number * Math.pow(10, n)) / Math.pow(10, n); //四舍五入
|
|
|
result = number + "";
|
|
|
return result;
|
|
|
};
|
|
|
//#endregion
|
|
|
|
|
|
//#region 获取mainform 利用递归方式 有局限性 需要确保初始参数处于可以递归到main的位置
|
|
|
function getMainForm(window) {
|
|
|
if (window.IsMainForm) {
|
|
|
return window;
|
|
|
} else {
|
|
|
return getMainForm(window.parent);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
function getMainForm_Opener(window) {
|
|
|
|
|
|
var _mainform = window.parent.opener;
|
|
|
if (_mainform == undefined) {
|
|
|
return getMainForm_Opener(window.parent);
|
|
|
}
|
|
|
|
|
|
return getMainForm(_mainform);
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
//#region 获得一个store的复制
|
|
|
//参数为来源store,返回值为一个 model相同 data相同的新store
|
|
|
function getstoreCopy(store) {
|
|
|
|
|
|
result = Ext.create('DsExt.ux.RefTableStore', {
|
|
|
model: store.model,
|
|
|
proxy: { url: '' }
|
|
|
});
|
|
|
result.loadData(store.data.items);
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
//#region 将参数txt写入剪贴板 如果需要的话还可以弹出告警窗口
|
|
|
|
|
|
function copyToClipboard(txt) {
|
|
|
let transfer = document.createElement('input');
|
|
|
document.body.appendChild(transfer);
|
|
|
transfer.value = txt; // 这里表示想要复制的内容
|
|
|
transfer.focus();
|
|
|
transfer.select();
|
|
|
if (document.execCommand('copy')) {
|
|
|
document.execCommand('copy');
|
|
|
}
|
|
|
//transfer.blur();
|
|
|
|
|
|
//alert("复制成功");
|
|
|
MsgTip("提示", "复制成功");
|
|
|
document.body.removeChild(transfer);
|
|
|
|
|
|
}
|
|
|
|
|
|
function getGridCopyButton(txt) {
|
|
|
return "<button class=\"button_grid tip tip-right\" data-tip=\"\" onclick=\"copyToClipboard('" + txt + "',this)\"></button>";
|
|
|
//<img src='../../../../images/cmd-copy.gif'>
|
|
|
}
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
//#region 自动消失的提示窗
|
|
|
|
|
|
MsgTip = function (title,info) {
|
|
|
Ext.Msg.show({
|
|
|
title: title,
|
|
|
msg: info,
|
|
|
modal: false,
|
|
|
buttons: Ext.MessageBox.OK,
|
|
|
icon: Ext.MessageBox.INFO
|
|
|
});
|
|
|
setTimeout(function () {
|
|
|
Ext.Msg.hide();
|
|
|
}, 400);
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
//#region 用于给一个store的格增加tip [tip内容来源是store当中的一列]
|
|
|
|
|
|
//keyfield是store的主键名字;idname是增加tip的格的dataindex;columnname是盛放store当中盛放tip内容的字段,用分号换行
|
|
|
//,//在store的grid的column当中
|
|
|
//renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {
|
|
|
// return '<div id="【idname】' + record.data.【keyfield】 + '" class="TipDiv">' + value + '</div>';
|
|
|
//}
|
|
|
//调用时 SetGridTip(store,【keyfield】,【idname】,"xxxxStr")
|
|
|
SetGridTip= function (store, keyfield, idname, columnname) {
|
|
|
store.each(function (record) {
|
|
|
_id = idname + record.get(keyfield);
|
|
|
_html = truntohtml(record.get(columnname));
|
|
|
_delay = 4000 + 400 * patch(_html,'<br />')
|
|
|
Ext.create('Ext.tip.ToolTip', {
|
|
|
target: _id,
|
|
|
html: _html,
|
|
|
title: '',
|
|
|
//autoHide: false,
|
|
|
dismissDelay: _delay
|
|
|
//closable: true,
|
|
|
//draggable: true //可以允许被拖动
|
|
|
});
|
|
|
});
|
|
|
}
|
|
|
|
|
|
truntohtml= function (str) {
|
|
|
if (isNullorEmpty(str)) return "";
|
|
|
var arr = str.split(';');
|
|
|
var result = "";
|
|
|
if (arr.length > 0)
|
|
|
for (_i = 0; _i < arr.length; _i++) {
|
|
|
if (!isNullorEmpty(arr[_i]))
|
|
|
result += arr[_i] + '<br />';
|
|
|
}
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
//#region str字符串中出现了几次split
|
|
|
function patch(str, split) {
|
|
|
result = (str.split(split)).length - 1;
|
|
|
return result;
|
|
|
}
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
//#region 测试一个公用方法
|
|
|
|
|
|
|
|
|
//HaveLoad = false;
|
|
|
|
|
|
//GetCustomer = function (type) {
|
|
|
// //
|
|
|
// let _this = this;
|
|
|
// if (window.storeCustomerAll.getCount() <= 0 && !HaveLoad) {
|
|
|
// HaveLoad = true;
|
|
|
// window.storeCustomerAll.load(
|
|
|
// {
|
|
|
// callback: function (r, options, success) {
|
|
|
// if (success) {
|
|
|
// return window.storeCustomerAll;
|
|
|
// }
|
|
|
// }
|
|
|
// }
|
|
|
// );
|
|
|
|
|
|
// } else {
|
|
|
// return window.storeCustomerAll;
|
|
|
// }
|
|
|
//}
|
|
|
|
|
|
LoadLogic = function (BSNO, PROPNAME) {
|
|
|
Ext.Ajax.request({
|
|
|
waitMsg: '正在查询数据...',
|
|
|
url: '/CommMng/BasicDataRef/GetLogicInfo',
|
|
|
async: false,
|
|
|
params: {
|
|
|
BSNO: BSNO,
|
|
|
PROPNAME: PROPNAME
|
|
|
},
|
|
|
callback: function (options, success, response) {
|
|
|
if (success) {
|
|
|
var result = Ext.JSON.decode(response.responseText);
|
|
|
if (!result.Success) {
|
|
|
// Ext.Msg.show({
|
|
|
// title: '提示',
|
|
|
// msg: result.Message,
|
|
|
// icon: Ext.MessageBox.ERROR,
|
|
|
// buttons: Ext.Msg.OK
|
|
|
// });
|
|
|
return "";
|
|
|
} else {
|
|
|
return result.Data;
|
|
|
//alert(result.data);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
} else {
|
|
|
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
|
|
|
}
|
|
|
},
|
|
|
scope: this
|
|
|
});
|
|
|
}
|
|
|
|
|
|
LoadLogic_SaleMailInfo = function (storeList) {
|
|
|
//var recdata = LoadLogic(this.editRecord.get('BSNO'), "销售邮件");
|
|
|
|
|
|
var BSNOListStr = "";
|
|
|
for (i = 0; i < storeList.getCount(); i += 1) {
|
|
|
|
|
|
var memberyf = storeList.getAt(i);
|
|
|
if (BSNOListStr != "") BSNOListStr += ",";
|
|
|
BSNOListStr += memberyf.data.BSNO;
|
|
|
};
|
|
|
if (BSNOListStr != "") {
|
|
|
|
|
|
let PROPNAME = "销售邮件";
|
|
|
Ext.Ajax.request({
|
|
|
waitMsg: '正在查询数据...',
|
|
|
url: '/CommMng/BasicDataRef/GetLogicInfoList',
|
|
|
async: false,
|
|
|
params: {
|
|
|
BSNOListStr: BSNOListStr,
|
|
|
PROPNAME: PROPNAME
|
|
|
},
|
|
|
callback: function (options, success, response) {
|
|
|
if (success) {
|
|
|
var result = Ext.JSON.decode(response.responseText);
|
|
|
if (!result.Success) {
|
|
|
|
|
|
} else {
|
|
|
|
|
|
var _data = result.Data;
|
|
|
|
|
|
for (var i = 0; i < storeList.getCount(); i += 1) {
|
|
|
|
|
|
var rec = storeList.getAt(i).data;
|
|
|
//var bsno = rec.get("BSNO");
|
|
|
_data.forEach((x) => {
|
|
|
if (x.BSNO == rec.BSNO && x.PROPNAME == PROPNAME)
|
|
|
storeList.getAt(i).set("SaleMailInfo", x.PROPVALUE.replace("::", ":").replace(";;", ";"));
|
|
|
})
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
} else {
|
|
|
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
|
|
|
}
|
|
|
},
|
|
|
scope: this
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
|
|
|
SaveLogic = function (BSNO, PROPNAME, NAME, VALUE) {
|
|
|
Ext.Ajax.request({
|
|
|
url: '/CommMng/BasicDataRef/SetLogicInfo',
|
|
|
cors: true,
|
|
|
params: {
|
|
|
BSNO: BSNO,//值
|
|
|
PROPNAME: PROPNAME,
|
|
|
NAME: NAME,
|
|
|
VALUE: VALUE
|
|
|
},
|
|
|
|
|
|
//method: 'post',
|
|
|
success: function (response) {
|
|
|
var resultData = eval('(' + response.responseText + ')');//JSON字符串=>JSON对象
|
|
|
if (!resultData.success) {
|
|
|
//失败
|
|
|
alert(resultData);
|
|
|
}
|
|
|
else {
|
|
|
alert(resultData);
|
|
|
}
|
|
|
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
///显示一个小列表 内容是业务的操作 揽货人 客服 单证 的联系方式
|
|
|
ShowOPUSERINFO = function (BSNO) {
|
|
|
|
|
|
storeUserInfo = Ext.create('DsExt.ux.RefTableStore', {
|
|
|
model: 'OPUserInfo',
|
|
|
proxy: { url: '/CommMng/BasicDataRef/GetOPUSERINFO' }
|
|
|
});
|
|
|
|
|
|
gridUserInfoList = new Ext.grid.GridPanel({
|
|
|
store: storeUserInfo,
|
|
|
height: 200,
|
|
|
width: 540,
|
|
|
enableHdMenu: false,
|
|
|
region: 'center',
|
|
|
loadMask: { msg: "数据加载中,请稍等..." },
|
|
|
trackMouseOver: true,
|
|
|
disableSelection: false,
|
|
|
singleSelect: true,
|
|
|
selType: 'cellmodel',
|
|
|
columns: [{
|
|
|
sortable: true,
|
|
|
dataIndex: 'BSNO',
|
|
|
header: '编号',
|
|
|
hidden: true,
|
|
|
width: 0
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'USERTYPE',
|
|
|
header: '角色',
|
|
|
width: 60
|
|
|
|
|
|
}, {
|
|
|
dataIndex: 'USERNAME', //CTNEXHIBIT
|
|
|
header: '姓名',
|
|
|
width: 140
|
|
|
}
|
|
|
, {
|
|
|
dataIndex: 'MOBILE',
|
|
|
header: '手机',
|
|
|
width: 120,
|
|
|
renderer: function (value, meta) {
|
|
|
|
|
|
meta.tdCls = 'mblno';
|
|
|
|
|
|
btnurl = getGridCopyButton(value);
|
|
|
|
|
|
return btnurl + value;
|
|
|
}
|
|
|
}, {
|
|
|
dataIndex: 'EMAIL1',
|
|
|
header: '邮箱',
|
|
|
width: 200,
|
|
|
renderer: function (value, meta) {
|
|
|
|
|
|
meta.tdCls = 'mblno';
|
|
|
|
|
|
btnurl = getGridCopyButton(value);
|
|
|
|
|
|
return btnurl + value;
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
});
|
|
|
me = this;
|
|
|
winUserInfoShow = Ext.create('Ext.window.Window', {
|
|
|
title: "联系方式",
|
|
|
width: 550,
|
|
|
//height : 120,
|
|
|
//plain : true,
|
|
|
iconCls: "addicon",
|
|
|
resizable: false,
|
|
|
// 是否可以拖动
|
|
|
// draggable:false,
|
|
|
collapsible: true, // 允许缩放条
|
|
|
closeAction: 'close',
|
|
|
closable: true,
|
|
|
modal: 'true',
|
|
|
buttonAlign: "center",
|
|
|
bodyStyle: "padding:0 0 0 0",
|
|
|
items: [gridUserInfoList],
|
|
|
buttons: [ {
|
|
|
text: "关闭",
|
|
|
minWidth: 70,
|
|
|
handler: function () {
|
|
|
me.winUserInfoShow.close();
|
|
|
}
|
|
|
}]
|
|
|
});
|
|
|
|
|
|
|
|
|
storeUserInfo.load({
|
|
|
params: { BSNO: BSNO },
|
|
|
callback: function (r, options, success) {
|
|
|
if (success) {
|
|
|
me.winUserInfoShow.show();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
ShowSeaeSaleOrderUSERINFO = function (BSNO) {
|
|
|
|
|
|
storeUserInfo = Ext.create('DsExt.ux.RefTableStore', {
|
|
|
model: 'OPUserInfo',
|
|
|
proxy: { url: '/CommMng/BasicDataRef/GetSeaeSaleOrderUSERINFO' }
|
|
|
});
|
|
|
|
|
|
gridUserInfoList = new Ext.grid.GridPanel({
|
|
|
store: storeUserInfo,
|
|
|
height: 200,
|
|
|
width: 540,
|
|
|
enableHdMenu: false,
|
|
|
region: 'center',
|
|
|
loadMask: { msg: "数据加载中,请稍等..." },
|
|
|
trackMouseOver: true,
|
|
|
disableSelection: false,
|
|
|
singleSelect: true,
|
|
|
selType: 'cellmodel',
|
|
|
columns: [{
|
|
|
sortable: true,
|
|
|
dataIndex: 'BSNO',
|
|
|
header: '编号',
|
|
|
hidden: true,
|
|
|
width: 0
|
|
|
}, {
|
|
|
sortable: true,
|
|
|
dataIndex: 'USERTYPE',
|
|
|
header: '角色',
|
|
|
width: 60
|
|
|
|
|
|
}, {
|
|
|
dataIndex: 'USERNAME', //CTNEXHIBIT
|
|
|
header: '姓名',
|
|
|
width: 140
|
|
|
}
|
|
|
, {
|
|
|
dataIndex: 'MOBILE',
|
|
|
header: '手机',
|
|
|
width: 120,
|
|
|
renderer: function (value, meta) {
|
|
|
|
|
|
meta.tdCls = 'mblno';
|
|
|
|
|
|
btnurl = getGridCopyButton(value);
|
|
|
|
|
|
return btnurl + value;
|
|
|
}
|
|
|
}, {
|
|
|
dataIndex: 'EMAIL1',
|
|
|
header: '邮箱',
|
|
|
width: 200,
|
|
|
renderer: function (value, meta) {
|
|
|
|
|
|
meta.tdCls = 'mblno';
|
|
|
|
|
|
btnurl = getGridCopyButton(value);
|
|
|
|
|
|
return btnurl + value;
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
});
|
|
|
me = this;
|
|
|
winUserInfoShow = Ext.create('Ext.window.Window', {
|
|
|
title: "联系方式",
|
|
|
width: 550,
|
|
|
//height : 120,
|
|
|
//plain : true,
|
|
|
iconCls: "addicon",
|
|
|
resizable: false,
|
|
|
// 是否可以拖动
|
|
|
// draggable:false,
|
|
|
collapsible: true, // 允许缩放条
|
|
|
closeAction: 'close',
|
|
|
closable: true,
|
|
|
modal: 'true',
|
|
|
buttonAlign: "center",
|
|
|
bodyStyle: "padding:0 0 0 0",
|
|
|
items: [gridUserInfoList],
|
|
|
buttons: [{
|
|
|
text: "关闭",
|
|
|
minWidth: 70,
|
|
|
handler: function () {
|
|
|
me.winUserInfoShow.close();
|
|
|
}
|
|
|
}]
|
|
|
});
|
|
|
|
|
|
|
|
|
storeUserInfo.load({
|
|
|
params: { BSNO: BSNO },
|
|
|
callback: function (r, options, success) {
|
|
|
if (success) {
|
|
|
me.winUserInfoShow.show();
|
|
|
}
|
|
|
}
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
//#endregion
|
|
|
|
|
|
|
|
|
|
|
|
function GetPublicStore(pubstorename) {
|
|
|
|
|
|
this.storeResult = Ext.create('DsExt.ux.RefTableStore', {
|
|
|
model: 'DsTruckMng.ux.GeneralValue',
|
|
|
proxy: { url: '/CommMng/BasicDataRef/GeneralSelect' }
|
|
|
});
|
|
|
|
|
|
if (pubstorename == "ISEI") {
|
|
|
this.storeResult.add({ GID: '海运进口', GVALUE: '海运进口' });
|
|
|
this.storeResult.add({ GID: '海运出口', GVALUE: '海运出口' });
|
|
|
return this.storeResult;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//(function (s) {
|
|
|
// //参数
|
|
|
// var NumtoEnglish = {},
|
|
|
// n = "",
|
|
|
// xiao = "",
|
|
|
// zheng = "",
|
|
|
// regxinteger = /^([0-9]{1,}([.][0-9]*)?)$/;
|
|
|
// //数字英文写法
|
|
|
// NumtoEnglish.tally = {
|
|
|
// arr1: ["zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"],
|
|
|
// arr2: ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"],
|
|
|
// arr3: ["twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"],
|
|
|
// arr4: ["hundred", "thousand", "million", "billion", "trillion", "quadrillion"]
|
|
|
// }
|
|
|
// //转换整数部分
|
|
|
// NumtoEnglish.Convert_integer = function (n) {
|
|
|
// try {
|
|
|
// var fenge = this.toThousands(n).split(',');
|
|
|
// result = "";
|
|
|
// for (var i = 0; i < fenge.length; i++) {
|
|
|
// if (fenge[i].length == 3) {
|
|
|
// result += this.tally.arr1[fenge[i].substring(0, 1)] + " "; //百位
|
|
|
// result += this.tally.arr4[0];
|
|
|
// if (this.doubledight(fenge[i].substring(1)) != "") {
|
|
|
// result += " and " + this.doubledight(fenge[i].substring(1));
|
|
|
// }
|
|
|
// } else if (fenge[i].length == 2) {
|
|
|
// result += this.doubledight(fenge[i]) //十位
|
|
|
// } else if (fenge[i].length == 1) {
|
|
|
// result += this.tally.arr1[fenge[i]]; //个位
|
|
|
// }
|
|
|
// //添加千分位单位(数字超过1000,每三位数字分配一个单位)
|
|
|
// if (i < fenge.length - 1) {
|
|
|
// result += " " + this.tally.arr4[fenge.length - 1 - i] + " ";
|
|
|
// }
|
|
|
// }
|
|
|
// return result;
|
|
|
// } catch (ex) {
|
|
|
// console.error(ex);
|
|
|
// }
|
|
|
// }
|
|
|
// //转换小数部分
|
|
|
// NumtoEnglish.Convert_decimal = function (n) {
|
|
|
// var d = n.split('');
|
|
|
// var result = '';
|
|
|
// if (d.length > 0) {
|
|
|
// d.forEach(a => {
|
|
|
// result += this.Convert_integer(a) + " ";
|
|
|
// });
|
|
|
// }
|
|
|
// return result;
|
|
|
// }
|
|
|
// //组合两位数
|
|
|
// NumtoEnglish.doubledight = function (n) {
|
|
|
// var result = "";
|
|
|
// if (parseInt(n) != 0) {
|
|
|
// var dd = n.split('');
|
|
|
// if (dd[0] < 1) {
|
|
|
// result = this.tally.arr1[dd[1]];
|
|
|
// } else if (dd[0] == 1) {
|
|
|
// result = this.tally.arr2[dd[1]];
|
|
|
// } else {
|
|
|
// result = this.tally.arr3[dd[0] - 2] + "-" + this.tally.arr1[dd[1]];
|
|
|
// }
|
|
|
// }
|
|
|
// return result;
|
|
|
// }
|
|
|
|
|
|
// //转换千分位显示,例:1000000 = 1,000,000
|
|
|
// NumtoEnglish.toThousands = function (num) {
|
|
|
// var num = (num || 0).toString(),
|
|
|
// result = '';
|
|
|
// while (num.length > 3) {
|
|
|
// result = ',' + num.slice(-3) + result;
|
|
|
// num = num.slice(0, num.length - 3);
|
|
|
// }
|
|
|
// if (num) {
|
|
|
// result = num + result;
|
|
|
// }
|
|
|
// return result;
|
|
|
// }
|
|
|
|
|
|
// //扩展String方法
|
|
|
// s.prototype.toEnglish = function () {
|
|
|
// n = this;
|
|
|
// if (!regxinteger.test(parseInt(n))) {
|
|
|
// return "Error:Must in digital format";
|
|
|
// }
|
|
|
|
|
|
// //分割整数和小数(如果有小数的话)
|
|
|
// var NumList = n.toString().split('.'),
|
|
|
// zheng = NumtoEnglish.Convert_integer(NumList[0]); //整数部分
|
|
|
// //如果分割长度是2,说明是小数
|
|
|
// if (NumList.length == 2) {
|
|
|
// if (NumList[1].length <= 2) {
|
|
|
// xiao = NumtoEnglish.Convert_decimal(NumList[1]);
|
|
|
// } else {
|
|
|
// //如果小数超过2位,不转换,返回原数据
|
|
|
// return n;
|
|
|
// }
|
|
|
// }
|
|
|
// //返回转换结果
|
|
|
// return zheng + (xiao == "" ? "" : " point " + xiao);
|
|
|
// }
|
|
|
//})(String)
|
|
|
|
|
|
|
|
|
function ListToSqlStr(list) {
|
|
|
|
|
|
//var selectedList = this.getValue();
|
|
|
selectedList = list;
|
|
|
var result = "";
|
|
|
for (var i = 0; i < selectedList.length; i++) {
|
|
|
if (result == "") { result = "'" + selectedList[i] + "'"; }
|
|
|
else { result = result + ",'" + selectedList[i] + "'"; }
|
|
|
}
|
|
|
return result;
|
|
|
|
|
|
}
|
|
|
|