BPM实例分享,H3BPM实例分享

by admin on 2018年12月14日

 金额规则大写

 

 

  以圈这一个的时候,我想念起码小白会和本人同样吧,老鸟勿喷,我是菜鸟。下边说自遇上的状:

于关乎金额之流程中时会碰着需要充足写金额数和小写金额匹配,怎么样促成输入数字后活动转换为?

  给小写金额加加onchange事件怎么加加我无晤面了。于是便改变了原先的法子:

初级用法

  直接叫小写控件加onchange=”chineseNumber(this.value)”;

1.于默认表单基本性能javascript
中加进如下金额转换方法

  然后将chineseNumber()中之return去丢改吧
$.MvcSheetUI.SetControlValue(“daxiejine”, resAIW);

/** 数字金额大写转换(可以处理整数,小数,负数) */

function chineseNumber(dValue) {

var maxDec = 2;

// 验证输入金额数值或数值字符串:

dValue = dValue.toString().replace(/,/g, "");

dValue = dValue.replace(/^0+/, ""); // 金额数值转字符、移除逗号、移除前导零

if (dValue == "") {

return "零元整";

} // (错误:金额为空!)

else if (isNaN(dValue)) {

return "错误:金额不是合法的数值!";

}

var minus = ""; // 负数的符号“-”的大写:“负”字。可自定义字符,如“(负)”。

var CN_SYMBOL = ""; // 币种名称(如“人民币”,默认空)

if (dValue.length > 1) {

if (dValue.indexOf(‘-‘) == 0) {

dValue = dValue.replace("-", "");

minus = "负";

} // 处理负数符号“-”

if (dValue.indexOf(‘+’) == 0) {

dValue = dValue.replace("+", "");

} // 处理前导正数符号“+”(无实际意义)

}

// 变量定义:

var vInt = "";

var vDec = ""; // 字符串:金额的整数部分、小数部分

var resAIW; // 字符串:要输出的结果

var parts; // 数组(整数部分.小数部分),length=1时则仅为整数。

var digits, radices, bigRadices, decimals; // 数组:数字(0~9——零~玖);基(十进制记数系统中每个数字位的基是10——拾,佰,仟);大基(万,亿,兆,京,垓,杼,穰,沟,涧,正);辅币(元以下,角/分/厘/毫/丝)。

var zeroCount; // 零计数

var i, p, d; // 循环因子;前一位数字;当前位数字。

var quotient, modulus; // 整数部分计算用:商数、模数。

// 金额数值转换为字符,分割整数部分和小数部分:整数、小数分开来搞(小数部分有可能四舍五入后对整数部分有进位)。

var NoneDecLen = (typeof (maxDec) == "undefined" || maxDec == null || Number(maxDec) < 0 || Number(maxDec) > 5); // 是否未指定有效小数位(true/false)

parts = dValue.split(‘.’); // 数组赋值:(整数部分.小数部分),Array的length=1则仅为整数。

if (parts.length > 1) {

vInt = parts[0];

vDec = parts[1]; // 变量赋值:金额的整数部分、小数部分

if (NoneDecLen) {

maxDec = vDec.length > 5 ? 5 : vDec.length;

} // 未指定有效小数位参数值时,自动取实际小数位长但不超5。

var rDec = Number("0." + vDec);

rDec *= Math.pow(10, maxDec);

rDec = Math.round(Math.abs(rDec));

rDec /= Math.pow(10, maxDec); // 小数四舍五入

var aIntDec = rDec.toString().split(‘.’);

if (Number(aIntDec[0]) == 1) {

vInt = (Number(vInt) + 1).toString();

} // 小数部分四舍五入后有可能向整数部分的个位进位(值1)

if (aIntDec.length > 1) {

vDec = aIntDec[1];

} else {

vDec = "";

}

} else {

vInt = dValue;

vDec = "";

if (NoneDecLen) {

maxDec = 0;

}

}

if (vInt.length > 44) {

return "错误:金额值太大了!整数位长【" + vInt.length.toString() + "】超过了上限——44位/千正/10^43(注:1正=1万涧=1亿亿亿亿亿,10^40)!";

}

// 准备各字符数组 Prepare the characters corresponding to the digits:

digits = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"); // 零~玖

radices = new Array("", "拾", "佰", "仟"); // 拾,佰,仟

bigRadices = new Array("", "万", "亿", "兆", "京", "垓", "杼", "穰", "沟", "涧", "正"); // 万,亿,兆,京,垓,杼,穰,沟,涧,正

decimals = new Array("角", "分", "厘", "毫", "丝"); // 角/分/厘/毫/丝

resAIW = ""; // 开始处理

// 处理整数部分(如果有)

if (Number(vInt) > 0) {

zeroCount = 0;

for (i = 0; i < vInt.length; i++) {

p = vInt.length – i – 1;

d = vInt.substr(i, 1);

quotient = p / 4;

modulus = p % 4;

if (d == "0") {

zeroCount++;

} else {

if (zeroCount > 0) {

resAIW += digits[0];

}

zeroCount = 0;

resAIW += digits[Number(d)] + radices[modulus];

}

if (modulus == 0 && zeroCount < 4) {

resAIW += bigRadices[quotient];

}

}

resAIW += "元";

}

// 处理小数部分(如果有)

for (i = 0; i < vDec.length; i++) {

d = vDec.substr(i, 1);

if (d != "0") {

resAIW += digits[Number(d)] + decimals[i];

}

}

// 处理结果

if (resAIW == "") {

resAIW = "零" + "元";

} // 零元

if (vDec == "") {

resAIW += "整";

} // …元整

resAIW = CN_SYMBOL + minus + resAIW; // 人民币/负……元角分/整

return resAIW;

}

  注意:在动高级道的时候,修改了js文件,所以假使破除一下缓存,不然浏览器有缓存,会看不到效果。

 

 

2.每当表单“小写金额”控件扩展onchange事件

 

$.MvcSheetUI.MvcRuntime.setDataFieldControlValue($(this),’jinedaxie’,chineseNumber($("input[data-datafield=’jinexiaoxie’]").val()));

官网的章程:

   
金额(小写)数据项编码:jinexiaoxie

亚洲必赢手机,Ø  金额规则大写

金额(大写)数据项编码:jinedaxie

以论及金额之流水线中平时会合境遇需要特别写金额多少与略微写金额匹配,怎么样兑现输入数字后自行转换为?

 

起码用法

高档用法

1.于默认表单基本特性javascript 中增如下金额转换方法

表单文本控件“ComputationRule”属性加大写总计函数。

/** 数字金额大写转换(可以处理整数,小数,负数) */

function chineseNumber(dValue) {

var maxDec = 2;

// 验证输入金额数值或数值字符串:

dValue = dValue.toString().replace(/,/g, "");

dValue = dValue.replace(/^0+/, ""); // 金额数值转字符、移除逗号、移除前导零

if (dValue == "") {

return "零元整";

} // (错误:金额为空!)

else if (isNaN(dValue)) {

return "错误:金额不是合法的数值!";

}

var minus = ""; // 负数的符号“-”的大写:“负”字。可自定义字符,如“(负)”。

var CN_SYMBOL = ""; // 币种名称(如“人民币”,默认空)

if (dValue.length > 1) {

if (dValue.indexOf(‘-‘) == 0) {

dValue = dValue.replace("-", "");

minus = "负";

} // 处理负数符号“-”

if (dValue.indexOf(‘+’) == 0) {

dValue = dValue.replace("+", "");

} // 处理前导正数符号“+”(无实际意义)

}

// 变量定义:

var vInt = "";

var vDec = ""; // 字符串:金额的整数部分、小数部分

var resAIW; // 字符串:要输出的结果

var parts; // 数组(整数部分.小数部分),length=1时则仅为整数。

var digits, radices, bigRadices, decimals; // 数组:数字(0~9——零~玖);基(十进制记数系统中每个数字位的基是10——拾,佰,仟);大基(万,亿,兆,京,垓,杼,穰,沟,涧,正);辅币(元以下,角/分/厘/毫/丝)。

var zeroCount; // 零计数

var i, p, d; // 循环因子;前一位数字;当前位数字。

var quotient, modulus; // 整数部分计算用:商数、模数。

// 金额数值转换为字符,分割整数部分和小数部分:整数、小数分开来搞(小数部分有可能四舍五入后对整数部分有进位)。

var NoneDecLen = (typeof (maxDec) == "undefined" || maxDec == null || Number(maxDec) < 0 || Number(maxDec) > 5); // 是否未指定有效小数位(true/false)

parts = dValue.split(‘.’); // 数组赋值:(整数部分.小数部分),Array的length=1则仅为整数。

if (parts.length > 1) {

vInt = parts[0];

vDec = parts[1]; // 变量赋值:金额的整数部分、小数部分

if (NoneDecLen) {

maxDec = vDec.length > 5 ? 5 : vDec.length;

} // 未指定有效小数位参数值时,自动取实际小数位长但不超5。

var rDec = Number("0." + vDec);

rDec *= Math.pow(10, maxDec);

rDec = Math.round(Math.abs(rDec));

rDec /= Math.pow(10, maxDec); // 小数四舍五入

var aIntDec = rDec.toString().split(‘.’);

if (Number(aIntDec[0]) == 1) {

vInt = (Number(vInt) + 1).toString();

} // 小数部分四舍五入后有可能向整数部分的个位进位(值1)

if (aIntDec.length > 1) {

vDec = aIntDec[1];

} else {

vDec = "";

}

} else {

vInt = dValue;

vDec = "";

if (NoneDecLen) {

maxDec = 0;

}

}

if (vInt.length > 44) {

return "错误:金额值太大了!整数位长【" + vInt.length.toString() + "】超过了上限——44位/千正/10^43(注:1正=1万涧=1亿亿亿亿亿,10^40)!";

}

// 准备各字符数组 Prepare the characters corresponding to the digits:

digits = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"); // 零~玖

radices = new Array("", "拾", "佰", "仟"); // 拾,佰,仟

bigRadices = new Array("", "万", "亿", "兆", "京", "垓", "杼", "穰", "沟", "涧", "正"); // 万,亿,兆,京,垓,杼,穰,沟,涧,正

decimals = new Array("角", "分", "厘", "毫", "丝"); // 角/分/厘/毫/丝

resAIW = ""; // 开始处理

// 处理整数部分(如果有)

if (Number(vInt) > 0) {

zeroCount = 0;

for (i = 0; i < vInt.length; i++) {

p = vInt.length – i – 1;

d = vInt.substr(i, 1);

quotient = p / 4;

modulus = p % 4;

if (d == "0") {

zeroCount++;

} else {

if (zeroCount > 0) {

resAIW += digits[0];

}

zeroCount = 0;

resAIW += digits[Number(d)] + radices[modulus];

}

if (modulus == 0 && zeroCount < 4) {

resAIW += bigRadices[quotient];

}

}

resAIW += "元";

}

// 处理小数部分(如果有)

for (i = 0; i < vDec.length; i++) {

d = vDec.substr(i, 1);

if (d != "0") {

resAIW += digits[Number(d)] + decimals[i];

}

}

// 处理结果

if (resAIW == "") {

resAIW = "零" + "元";

} // 零元

if (vDec == "") {

resAIW += "整";

} // …元整

resAIW = CN_SYMBOL + minus + resAIW; // 人民币/负……元角分/整

return resAIW;

}

1.在\Portal\WFRes\_Scripts\MVCRuntime\Sheet.Computation.js文件中长初级中之chineseNumber方法,在算函数CompuationFun扩张SUMCAPITAL定义。

 

{

        Name: "SUMCAPITAL",

        Accept: function (express) {

            return express.toLocaleLowerCase().indexOf("sumcapital(") == 0;

        },

        Compuator: function (obj, ctl, express, round) {

            var field = this.Field(express);

            express = this.Express(express);

            var val = 0;

            $("input[data-datafield=’" + field + "’],span[data-datafield=’" + field + "’]").each(function (obj, express, round) {

                var thisValue = 0;

                if (express) {

                    thisValue = obj.executeCompute(this.id, round, express);

                }

                else {

                    if (this.tagName.toLocaleLowerCase() == "input" || this.tagName.toLocaleLowerCase() == "select")

                        thisValue = this.value;

                    else

                        thisValue = this.innerText;

                }

                if ($(this).attr("data-formatrule")) thisValue = thisValue.replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "");

                if (thisValue && !isNaN(thisValue)) {

                    val += parseFloat(thisValue);

                }

            }, [obj, express, round]);

            return chineseNumber(val);

        },

        Field: function (express) {

            var field = express.substring(express.indexOf("{") + 1);

            field = field.substring(0, field.indexOf("}"));

            return field;

        },

        Express: function (express) {

            if (express.indexOf(",") == -1) return "";

            var str = express.substring(express.indexOf(",") + 1);

            return str.substring(0, str.length – 1);

        },

        IsFunc: true

    },

2.在表单“小写金额”控件扩大onchange事件

2.
履行总计主方法判断普通话统计,修改后如若下

$.MvcSheetUI.MvcRuntime.setDataFieldControlValue($(this),’jinedaxie’,chineseNumber($("input[data-datafield=’jinexiaoxie’]").val()));

computator: function (id, round, express) {

        var v = this.executeCompute(id, round, express);

        try {

            eval(v); //判断是否中文数字

            // 结果四舍五入取小数位

            if (isFinite(v)) {

                v = Math.round(v * Math.pow(10, round)) / Math.pow(10, round);

                var target = $("#" + id);

                if (target.is("input,textarea")) {

                    var oldV = target.val().replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "");

                    if (oldV != v) {

                        target.val(v);

                        target.trigger("change"); // target.trigger("change.MobileMaskText");

                        target.blur();

                    }

                }

                else if (target.is("div,span")) {

                    var oldV = target.html().replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "");

                    if (oldV != v) {

                        target.html(v);

                        target.trigger("change"); //target.trigger("change.MobileMaskText");

                        target.blur();

                    }

                }

            } // end if(isFinite(v))

        }

        catch (e) {

            var target = $("#" + id);

            if (target.is("input,textarea")) {

                var oldV = target.val().replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "");

                if (oldV != v) {

                    target.val(v);

                    target.trigger("change"); // target.trigger("change.MobileMaskText");

                    target.blur();

                }

            }

            else if (target.is("div,span")) {

                var oldV = target.html().replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "");

                if (oldV != v) {

                    target.html(v);

                    target.trigger("change"); //target.trigger("change.MobileMaskText");

                    target.blur();

                }

            }

        }

    }

    金额(小写)数据项编码:jinexiaoxie

3.\Portal\WFRes\_Scripts\MVCRuntime\Sheet.js
文件总计结果值getResultValue定义修改如下

金额(大写)数据项编码:jinedaxie

getResultValue: function (express) {

        if (express.indexOf("return") == -1) {

            try {

                return eval(express);}

            catch (e) {

            return express;}

        }

        else {

            return new Function(express).call(this);

        }

    },

 

 

高档用法

4.
\Portal\Admin\MvcDesigner\MvcDesigner.aspx表单中扩大金额大写的按钮

表单文本控件“ComputationRule”属性加大写总计函数。

<div style="margin-top: 10px;">

                <input type="button" id="btnSum" value="SUM"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

                <input type="button" id="btnSumCapital" value="SUMCAPITAL"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

                <input type="button" id="btnAvg" value="AVG"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

                <input type="button" id="btnMax" value="MAX"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

                <input type="button" id="btnMin" value="MIN"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

                <input type="button" id="btnCount" value="COUNT"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

            </div>

1.在\Portal\WFRes\_Scripts\MVCRuntime\Sheet.Computation.js文件中长初级中的chineseNumber方法,在算函数CompuationFun扩展SUMCAPITAL定义。

5.
\Portal\Admin\MvcDesigner\MvcDesigner.aspx表单中增金额大写的按钮事件

{

        Name: "SUMCAPITAL",

        Accept: function (express) {

            return express.toLocaleLowerCase().indexOf("sumcapital(") == 0;

        },

        Compuator: function (obj, ctl, express, round) {

            var field = this.Field(express);

            express = this.Express(express);

            var val = 0;

            $("input[data-datafield=’" + field + "’],span[data-datafield=’" + field + "’]").each(function (obj, express, round) {

                var thisValue = 0;

                if (express) {

                    thisValue = obj.executeCompute(this.id, round, express);

                }

                else {

                    if (this.tagName.toLocaleLowerCase() == "input" || this.tagName.toLocaleLowerCase() == "select")

                        thisValue = this.value;

                    else

                        thisValue = this.innerText;

                }

                if ($(this).attr("data-formatrule")) thisValue = thisValue.replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "");

                if (thisValue && !isNaN(thisValue)) {

                    val += parseFloat(thisValue);

                }

            }, [obj, express, round]);

            return chineseNumber(val);

        },

        Field: function (express) {

            var field = express.substring(express.indexOf("{") + 1);

            field = field.substring(0, field.indexOf("}"));

            return field;

        },

        Express: function (express) {

            if (express.indexOf(",") == -1) return "";

            var str = express.substring(express.indexOf(",") + 1);

            return str.substring(0, str.length – 1);

        },

        IsFunc: true

    },

$("#btnSum,#btnSumCapital,#btnAvg,#btnCount,#btnMax,#btnMin").click(function () {

                var input = $("#txtComputationRule")[0];

                var text = $(this).val() + "()";

                var pos = getCaretPos(input);

                insertAtCaret(input, text);

                setCaretToPos(input, pos + text.length – 1);

2.执行总括主方法判断闽南语总结,修改后如下

 

computator: function (id, round, express) {

        var v = this.executeCompute(id, round, express);

        try {

            eval(v); //判断是否中文数字

            // 结果四舍五入取小数位

            if (isFinite(v)) {

                v = Math.round(v * Math.pow(10, round)) / Math.pow(10, round);

                var target = $("#" + id);

                if (target.is("input,textarea")) {

                    var oldV = target.val().replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "");

                    if (oldV != v) {

                        target.val(v);

                        target.trigger("change"); // target.trigger("change.MobileMaskText");

                        target.blur();

                    }

                }

                else if (target.is("div,span")) {

                    var oldV = target.html().replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "");

                    if (oldV != v) {

                        target.html(v);

                        target.trigger("change"); //target.trigger("change.MobileMaskText");

                        target.blur();

                    }

                }

            } // end if(isFinite(v))

        }

        catch (e) {

            var target = $("#" + id);

            if (target.is("input,textarea")) {

                var oldV = target.val().replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "");

                if (oldV != v) {

                    target.val(v);

                    target.trigger("change"); // target.trigger("change.MobileMaskText");

                    target.blur();

                }

            }

            else if (target.is("div,span")) {

                var oldV = target.html().replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "");

                if (oldV != v) {

                    target.html(v);

                    target.trigger("change"); //target.trigger("change.MobileMaskText");

                    target.blur();

                }

            }

        }

    }

   
接下去控件的ComputationRule属性就得选用大写总结公式了,是无是殊丰裕,赶紧试一跃跃欲试吧。

3.\Portal\WFRes\_Scripts\MVCRuntime\Sheet.js
文件总计结果值getResultValue定义修改如下

 

getResultValue: function (express) {

        if (express.indexOf("return") == -1) {

            try {

                return eval(express);}

            catch (e) {

            return express;}

        }

        else {

            return new Function(express).call(this);

        }

    },

 

4.\Portal\Admin\MvcDesigner\MvcDesigner.aspx表单中扩展金额大写的按钮

<div style="margin-top: 10px;">

                <input type="button" id="btnSum" value="SUM"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

                <input type="button" id="btnSumCapital" value="SUMCAPITAL"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

                <input type="button" id="btnAvg" value="AVG"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

                <input type="button" id="btnMax" value="MAX"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

                <input type="button" id="btnMin" value="MIN"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

                <input type="button" id="btnCount" value="COUNT"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

            </div>

5.\Portal\Admin\MvcDesigner\MvcDesigner.aspx表单中长金额大写的按钮事件

$("#btnSum,#btnSumCapital,#btnAvg,#btnCount,#btnMax,#btnMin").click(function () {

                var input = $("#txtComputationRule")[0];

                var text = $(this).val() + "()";

                var pos = getCaretPos(input);

                insertAtCaret(input, text);

                setCaretToPos(input, pos + text.length – 1);

 

    接下去控件的ComputationRule属性就可拔取大写总计公式了,是免是万分要命,赶紧试一试行吧。

 

 

 

Ø  金额规则大写

每当干金额之流程中时会遇上需要好写金额数及稍写金额匹配,怎么着贯彻输入数字后自动转换为?

初级用法

1.于默认表单基本特性javascript 中追加如下金额转换方法

/** 数字金额大写转换(可以处理整数,小数,负数) */

function chineseNumber(dValue) {

var maxDec = 2;

// 验证输入金额数值或数值字符串:

dValue = dValue.toString().replace(/,/g, "");

dValue = dValue.replace(/^0+/, ""); // 金额数值转字符、移除逗号、移除前导零

if (dValue == "") {

return "零元整";

} // (错误:金额为空!)

else if (isNaN(dValue)) {

return "错误:金额不是合法的数值!";

}

var minus = ""; // 负数的符号“-”的大写:“负”字。可自定义字符,如“(负)”。

var CN_SYMBOL = ""; // 币种名称(如“人民币”,默认空)

if (dValue.length > 1) {

if (dValue.indexOf(‘-‘) == 0) {

dValue = dValue.replace("-", "");

minus = "负";

} // 处理负数符号“-”

if (dValue.indexOf(‘+’) == 0) {

dValue = dValue.replace("+", "");

} // 处理前导正数符号“+”(无实际意义)

}

// 变量定义:

var vInt = "";

var vDec = ""; // 字符串:金额的整数部分、小数部分

var resAIW; // 字符串:要输出的结果

var parts; // 数组(整数部分.小数部分),length=1时则仅为整数。

var digits, radices, bigRadices, decimals; // 数组:数字(0~9——零~玖);基(十进制记数系统中每个数字位的基是10——拾,佰,仟);大基(万,亿,兆,京,垓,杼,穰,沟,涧,正);辅币(元以下,角/分/厘/毫/丝)。

var zeroCount; // 零计数

var i, p, d; // 循环因子;前一位数字;当前位数字。

var quotient, modulus; // 整数部分计算用:商数、模数。

// 金额数值转换为字符,分割整数部分和小数部分:整数、小数分开来搞(小数部分有可能四舍五入后对整数部分有进位)。

var NoneDecLen = (typeof (maxDec) == "undefined" || maxDec == null || Number(maxDec) < 0 || Number(maxDec) > 5); // 是否未指定有效小数位(true/false)

parts = dValue.split(‘.’); // 数组赋值:(整数部分.小数部分),Array的length=1则仅为整数。

if (parts.length > 1) {

vInt = parts[0];

vDec = parts[1]; // 变量赋值:金额的整数部分、小数部分

if (NoneDecLen) {

maxDec = vDec.length > 5 ? 5 : vDec.length;

} // 未指定有效小数位参数值时,自动取实际小数位长但不超5。

var rDec = Number("0." + vDec);

rDec *= Math.pow(10, maxDec);

rDec = Math.round(Math.abs(rDec));

rDec /= Math.pow(10, maxDec); // 小数四舍五入

var aIntDec = rDec.toString().split(‘.’);

if (Number(aIntDec[0]) == 1) {

vInt = (Number(vInt) + 1).toString();

} // 小数部分四舍五入后有可能向整数部分的个位进位(值1)

if (aIntDec.length > 1) {

vDec = aIntDec[1];

} else {

vDec = "";

}

} else {

vInt = dValue;

vDec = "";

if (NoneDecLen) {

maxDec = 0;

}

}

if (vInt.length > 44) {

return "错误:金额值太大了!整数位长【" + vInt.length.toString() + "】超过了上限——44位/千正/10^43(注:1正=1万涧=1亿亿亿亿亿,10^40)!";

}

// 准备各字符数组 Prepare the characters corresponding to the digits:

digits = new Array("零", "壹", "贰", "叁", "肆", "伍", "陆", "柒", "捌", "玖"); // 零~玖

radices = new Array("", "拾", "佰", "仟"); // 拾,佰,仟

bigRadices = new Array("", "万", "亿", "兆", "京", "垓", "杼", "穰", "沟", "涧", "正"); // 万,亿,兆,京,垓,杼,穰,沟,涧,正

decimals = new Array("角", "分", "厘", "毫", "丝"); // 角/分/厘/毫/丝

resAIW = ""; // 开始处理

// 处理整数部分(如果有)

if (Number(vInt) > 0) {

zeroCount = 0;

for (i = 0; i < vInt.length; i++) {

p = vInt.length – i – 1;

d = vInt.substr(i, 1);

quotient = p / 4;

modulus = p % 4;

if (d == "0") {

zeroCount++;

} else {

if (zeroCount > 0) {

resAIW += digits[0];

}

zeroCount = 0;

resAIW += digits[Number(d)] + radices[modulus];

}

if (modulus == 0 && zeroCount < 4) {

resAIW += bigRadices[quotient];

}

}

resAIW += "元";

}

// 处理小数部分(如果有)

for (i = 0; i < vDec.length; i++) {

d = vDec.substr(i, 1);

if (d != "0") {

resAIW += digits[Number(d)] + decimals[i];

}

}

// 处理结果

if (resAIW == "") {

resAIW = "零" + "元";

} // 零元

if (vDec == "") {

resAIW += "整";

} // …元整

resAIW = CN_SYMBOL + minus + resAIW; // 人民币/负……元角分/整

return resAIW;

}

 

2.每当表单“小写金额”控件扩充onchange事件

$.MvcSheetUI.MvcRuntime.setDataFieldControlValue($(this),’jinedaxie’,chineseNumber($("input[data-datafield=’jinexiaoxie’]").val()));

    金额(小写)数据项编码:jinexiaoxie

金额(大写)数据项编码:jinedaxie

 

尖端用法

表单文本控件“ComputationRule”属性加大写统计函数。

1.在\Portal\WFRes\_Scripts\MVCRuntime\Sheet.Computation.js文件被添加初级中的chineseNumber方法,在盘算函数CompuationFun增添SUMCAPITAL定义。

{

        Name: "SUMCAPITAL",

        Accept: function (express) {

            return express.toLocaleLowerCase().indexOf("sumcapital(") == 0;

        },

        Compuator: function (obj, ctl, express, round) {

            var field = this.Field(express);

            express = this.Express(express);

            var val = 0;

            $("input[data-datafield=’" + field + "’],span[data-datafield=’" + field + "’]").each(function (obj, express, round) {

                var thisValue = 0;

                if (express) {

                    thisValue = obj.executeCompute(this.id, round, express);

                }

                else {

                    if (this.tagName.toLocaleLowerCase() == "input" || this.tagName.toLocaleLowerCase() == "select")

                        thisValue = this.value;

                    else

                        thisValue = this.innerText;

                }

                if ($(this).attr("data-formatrule")) thisValue = thisValue.replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "");

                if (thisValue && !isNaN(thisValue)) {

                    val += parseFloat(thisValue);

                }

            }, [obj, express, round]);

            return chineseNumber(val);

        },

        Field: function (express) {

            var field = express.substring(express.indexOf("{") + 1);

            field = field.substring(0, field.indexOf("}"));

            return field;

        },

        Express: function (express) {

            if (express.indexOf(",") == -1) return "";

            var str = express.substring(express.indexOf(",") + 1);

            return str.substring(0, str.length – 1);

        },

        IsFunc: true

    },

2.执总计主方法判断粤语总括,修改后若下

computator: function (id, round, express) {

        var v = this.executeCompute(id, round, express);

        try {

            eval(v); //判断是否中文数字

            // 结果四舍五入取小数位

            if (isFinite(v)) {

                v = Math.round(v * Math.pow(10, round)) / Math.pow(10, round);

                var target = $("#" + id);

                if (target.is("input,textarea")) {

                    var oldV = target.val().replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "");

                    if (oldV != v) {

                        target.val(v);

                        target.trigger("change"); // target.trigger("change.MobileMaskText");

                        target.blur();

                    }

                }

                else if (target.is("div,span")) {

                    var oldV = target.html().replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "");

                    if (oldV != v) {

                        target.html(v);

                        target.trigger("change"); //target.trigger("change.MobileMaskText");

                        target.blur();

                    }

                }

            } // end if(isFinite(v))

        }

        catch (e) {

            var target = $("#" + id);

            if (target.is("input,textarea")) {

                var oldV = target.val().replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "");

                if (oldV != v) {

                    target.val(v);

                    target.trigger("change"); // target.trigger("change.MobileMaskText");

                    target.blur();

                }

            }

            else if (target.is("div,span")) {

                var oldV = target.html().replace(/,/g, "").replace(/$/g, "").replace(/¥/g, "");

                if (oldV != v) {

                    target.html(v);

                    target.trigger("change"); //target.trigger("change.MobileMaskText");

                    target.blur();

                }

            }

        }

    }

3.\Portal\WFRes\_Scripts\MVCRuntime\Sheet.js
文件总计结果值getResultValue定义修改如下

getResultValue: function (express) {

        if (express.indexOf("return") == -1) {

            try {

                return eval(express);}

            catch (e) {

            return express;}

        }

        else {

            return new Function(express).call(this);

        }

    },

 

4.\Portal\Admin\MvcDesigner\MvcDesigner.aspx表单中多金额大写的按钮

<div style="margin-top: 10px;">

                <input type="button" id="btnSum" value="SUM"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

                <input type="button" id="btnSumCapital" value="SUMCAPITAL"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

                <input type="button" id="btnAvg" value="AVG"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

                <input type="button" id="btnMax" value="MAX"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

                <input type="button" id="btnMin" value="MIN"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

                <input type="button" id="btnCount" value="COUNT"

                    style="height: 28px; padding-left: 8px; padding-right: 8px;" />

            </div>

5.\Portal\Admin\MvcDesigner\MvcDesigner.aspx表单中加进金额大写的按钮事件

$("#btnSum,#btnSumCapital,#btnAvg,#btnCount,#btnMax,#btnMin").click(function () {

                var input = $("#txtComputationRule")[0];

                var text = $(this).val() + "()";

                var pos = getCaretPos(input);

                insertAtCaret(input, text);

                setCaretToPos(input, pos + text.length – 1)});

 

    接下控件的ComputationRule属性就得行使大写统计公式了,是未是生怪,赶紧试一试试吧。

亚洲必赢手机 1

 

 

 

 

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图