金额法规大写

 

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();

                }

            }

        }

    }

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

$("#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);

 

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

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

 

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();

                }

            }

        }

    }

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

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定义。

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

$("#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);

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

5.
\Portal\Admin\MvcDesigner\MvcDesigner.aspx表单中追加金额大写的开关事件

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

高等用法

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

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.在私下认可表单基本属性javascript
中加进如下金额转变方法

 

中低端用法

2.实施总结主方法判别普通话总括,修改后如下

 

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

<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.在暗中认可表单Kit天性javascript 中追加如下金额转变方法

   
接下去控件的ComputationRule属性就足以选取大写总计公式了,是或不是很酷,赶紧试一试吧。

 

表单文本控件“ComputationRule”属性扩张大写计算函数。

 

2.
施行总结主方法判断中文计算,修改后如下

在关系金额的流程中时常会碰着必要大写金额多少与小写金额相称,怎么样落到实处输入数字后活动转变呢?

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

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;

}

{

        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

    },

 

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

 

getResultValue: function (express) {

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

            try {

                return eval(express);}

            catch (e) {

            return express;}

        }

        else {

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

        }

    },

 

 

在事关金额的流水生产线中平时会碰着须求大写金额多少与小写金额相配,如何贯彻输入数字后自动转变呢?

  给小写金额加多onchange事件怎么增添笔者不会了。于是就改了原先的格局:

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

 

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

  注意:在运用高端方法的时候,修改了js文件,所以要祛除一下缓存,不然浏览器有缓存,会看不到效果。

 金额法规大写

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

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表单中追加金额大写的开关

Ø  金额法规大写

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

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

    },

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();

                }

            }

        }

    }

4.\Portal\Admin\MvcDesigner\MvcDesigner.aspx表单中增加金额大写的按键

高档用法

1.在私下认可表单基本属性javascript 中加进如下金额调换方法

 

    接下去控件的ComputationRule属性就可以采取大写总计公式了,是或不是很酷,赶紧试一试吧。

{

        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

    },

 

  然后把chineseNumber()中的return去掉改为
$.MvcSheetUI.SetControlValue(“daxiejine”, resAIW);

在论及金额的流程中平日会遭逢需求大写金额多少与小写金额匹配,怎样贯彻输入数字后活动转变呢?

 

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

 

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

起码用法

    接下去控件的ComputationRule属性就能够应用大写总计公式了,是或不是很酷,赶紧试一试吧。

 

 

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>

 

$("#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)});

 

 

  在看这些的时候,笔者想起码小白会和自己同样呢,老鸟勿喷,笔者是菜鸟。下边说自家遇上的状态:

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

2.在表单“小写金额”控件增添onchange事件

Ø  金额法则大写

初级用法

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

 

 

getResultValue: function (express) {

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

            try {

                return eval(express);}

            catch (e) {

            return express;}

        }

        else {

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

        }

    },

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

高级用法

<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>

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

图片 1

表单文本控件“ComputationRule”属性扩张大写总括函数。

官方网址的方法:

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

2.推行总计主方法判别粤语总结,修改后如下