WebTM/views/ÏúÊÛ¹ÜÀí/ÏúÊÛ¶©µ¥/Add_Edit_Xs_SeOrderBillList.html
@@ -16,7 +16,7 @@
    <script src="../../../layuiadmin/PubCustom.js"></script>
    <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <style type="text/css">
        .layui-form-item .layui-inline {
        /*.layui-form-item .layui-inline {
            margin-right: 0;
        }
@@ -33,7 +33,7 @@
            margin-top: -10px;
            margin-left: -15px;
            margin-right: -15px;
        }
        }*/
    </style>
</head>
<body>
@@ -60,7 +60,7 @@
                                <div class="layui-form-item" style="padding-top: 10px;">
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">单据编号</label>
                                            <label class="layui-form-label">单据编号<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" class="layui-input" name="HBillNo" id="HBillNo" style="background-color:#efefef4d;" readonly>
                                                <input type="hidden" name="HInterID" id="HInterID" value="0">
@@ -68,7 +68,7 @@
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">日期</label>
                                            <label class="layui-form-label">日期<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="date" class="layui-input" lay-verify="HDate" name="HDate" id="HDate" style="padding-left: 80px;">
                                            </div>
@@ -76,7 +76,7 @@
                                        <div class="layui-inline">
                                            <label class="layui-form-label">销售部门</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HDeptName" id="HDeptName" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="text" name="HDeptName" id="HDeptName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                                <input type="hidden" name="HDeptID" id="HDeptID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HDeptList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -86,7 +86,7 @@
                                        <div class="layui-inline">
                                            <label class="layui-form-label">销售员</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HEmpName" id="HEmpName" " class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="text" name="HEmpName" id="HEmpName" " class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                                <input type="hidden" name="HEmpID" id="HEmpID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HEmpList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -96,9 +96,9 @@
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">销售币别</label>
                                            <label class="layui-form-label">销售币别<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HCurName" id="HCurName" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="text" name="HCurName" id="HCurName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;">
                                                <input type="hidden" name="HCurID" id="HCurID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HCurList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -106,15 +106,15 @@
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">汇率</label>
                                            <label class="layui-form-label">汇率<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HExRate" id="HExRate" autocomplete="off" value="0" readonly>
                                                <input class="layui-input" name="HExRate" id="HExRate" autocomplete="off" value="0" style="background-color: #efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline" style="width:900px;">
                                            <label class="layui-form-label">客户</label>
                                            <label class="layui-form-label">客户<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline" style="width:700px;">
                                                <input type="text" name="HCusName" id="HCusName" class="layui-input" value="" style="float:left;width:465px;">
                                                <input type="text" name="HCusName" id="HCusName" class="layui-input" value="" style="float: left; width: 465px; background-color: #efefef4d;" readonly>
                                                <input type="hidden" name="HCusID" id="HCusID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HCusList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -124,9 +124,9 @@
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">结算方式</label>
                                            <label class="layui-form-label">结算方式<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HSSName" id="HSSName" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="text" name="HSSName" id="HSSName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                                <input type="hidden" name="HSSID" id="HSSID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HSSList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -136,7 +136,7 @@
                                        <div class="layui-inline">
                                            <label class="layui-form-label">销售方式</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HSellSName" id="HSellSName" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="text" name="HSellSName" id="HSellSName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                                <input type="hidden" name="HSellSID" id="HSellSID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HSellSList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -154,7 +154,7 @@
                                        <div class="layui-inline">
                                            <label class="layui-form-label">销售主管</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HManagerName" id="HManagerName" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="text" name="HManagerName" id="HManagerName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                                <input type="hidden" name="HManagerID" id="HManagerID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HManagerList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -176,7 +176,7 @@
                                        <div class="layui-inline">
                                            <label class="layui-form-label">内部订单号</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HInnerBillNo" id="HInnerBillNo" autocomplete="off" readonly>
                                                <input class="layui-input" name="HInnerBillNo" id="HInnerBillNo" style="background-color: #efefef4d;" autocomplete="off" readonly>
                                            </div>
                                        </div>
                                    </div>
@@ -468,15 +468,19 @@
            //#region è¡¨å¤´æŒ‰é’®è§¦å‘事件
            //#region ä¿å­˜æŒ‰é’®
            form.on('submit(set_SaveBill)', function (data) {
                //if (AllowLoadData(data)) {
                if (AllowLoadData(data)) {
                    set_SaveBill(data);
                //}
                }
            });
            //#endregion
            //#region é€€å‡ºæŒ‰é’®
            form.on('submit(Exit)', function () {
                Pub_Close(1);
                if (params[1] != null) {
                    Pub_Close(1);
                } else if (params[1] == null) {
                    Pub_Close(2);
                }
            })
            //#endregion
            //#endregion
@@ -505,7 +509,7 @@
                    "HTaxMoney": "0",
                    "HlineTotal": "0",
                    "HlineTotalBB": "0",
                    "HDate": "",
                    "HDate": Format(new Date(), 'yyyy-MM-dd'),
                    "HOutStockQty": "0",
                    "HInvoiceQty": "0",
                    "HRemark": ""
@@ -558,6 +562,10 @@
            //#region ç›‘听单元格编辑  å•元格编辑后 å˜æ›´
            table.on('edit(mainTable)', function (obj) {
                //数值格式校验工具
                var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                var temp = "";
                // å•元格编辑之前的值
                var oldText = $(this).prev().text();
                var value = obj.value //得到修改后的值
@@ -566,41 +574,125 @@
                //layer.msg('[ID: ' + data.id + '] ' + field + ' å­—段更改为:' + value);
                switch (field) {
                    case "HRate":     //用量
                        value = (value * 1).toFixed(6);
                    case "HQty":                                                       //数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp) || temp == 0) {
                            //恢复数据到编辑前
                            obj.update({
                                HQty: oldText
                            });
                            table.render(option);
                        var HWeight = $("#HWeight").val();
                        var HWaterQty = $("#HWaterQty").val();
                        var HRate = value;
                        var HQty = 0;
                        var HMaterRuleType = obj.data.HMaterRuleType;
                        if (HMaterRuleType == "染料") {
                            HQty = HRate * HWeight;
                        } else if (HMaterRuleType == "助剂") {
                            HQty = HRate * HWaterQty;
                            layer.msg("数量请输入大于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HQty = value * 1;                           //数量
                        var HPrice = obj.data.HPrice * 1;               //单价
                        var HTaxRate = obj.data.HTaxRate * 0.01;           //税率
                        /*var HDiscountRate = obj.data.HDiscountRate * 1; //折扣率*/
                        var HTaxPrice = HPrice * (1 + HTaxRate);        //含税单价=单价*(1+税率)
                        /*var HRelTaxPrice = HTaxPrice * HDiscountRate;   //实际含税单价=含税单价*折扣率*/
                                                                        //折扣额 = å«ç¨Žå•ä»· * (1 - æŠ˜æ‰£çއ) * æ•°é‡
                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                        var HTaxMoney = HMoney * HTaxRate;              //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HRate: value,
                            HQty: HQty
                            , HPrice: HPrice
                            , HTaxRate: HTaxRate * 100
                            , HTaxPrice: HTaxPrice
                            , HMoney: HMoney
                            , HlineTotal: HlineTotal
                        });
                        table.render(option);
                        break;
                    case "HMaterRuleType":
                        var HWeight = $("#HWeight").val();
                        var HWaterQty = $("#HWaterQty").val();
                        var HRate = obj.data.HRate;
                        var HQty = 0;
                        var HMaterRuleType = value;
                        if (HMaterRuleType == "染料") {
                            HQty = HRate * HWeight;
                        } else if (HMaterRuleType == "助剂") {
                            HQty = HRate * HWaterQty;
                    case "HPrice":                                                       //单价
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp) || temp == 0) {
                            //恢复数据到编辑前
                            obj.update({
                                HPrice: oldText
                            });
                            table.render(option);
                            layer.msg("单价请输入大于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HQty = obj.data.HQty * 1;                   //数量
                        var HPrice = value * 1;                         //单价
                        var HTaxRate = obj.data.HTaxRate * 0.01;           //税率
                        /*var HDiscountRate = obj.data.HDiscountRate * 1; //折扣率*/
                        var HTaxPrice = HPrice * (1 + HTaxRate);        //含税单价=单价*(1+税率)
                        /*var HRelTaxPrice = HTaxPrice * HDiscountRate;   //实际含税单价=含税单价*折扣率*/
                        //折扣额 = å«ç¨Žå•ä»· * (1 - æŠ˜æ‰£çއ) * æ•°é‡
                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                        var HTaxMoney = HMoney * HTaxRate;              //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
                            , HPrice: HPrice
                            , HTaxRate: HTaxRate * 100
                            , HTaxPrice: HTaxPrice
                            , HMoney: HMoney
                            , HlineTotal: HlineTotal
                        });
                        table.render(option);
                        break;
                    case "HTaxRate":                                                       //数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp) || temp == 0) {
                            //恢复数据到编辑前
                            obj.update({
                                HTaxRate: oldText
                            });
                            table.render(option);
                            layer.msg("税率请输入大于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HQty = obj.data.HQty * 1;                   //数量
                        var HPrice = obj.data.HPrice * 1;               //单价
                        var HTaxRate = value * 0.01;                       //税率
                        /*var HDiscountRate = obj.data.HDiscountRate * 1; //折扣率*/
                        var HTaxPrice = HPrice * (1 + HTaxRate);        //含税单价=单价*(1+税率)
                        /*var HRelTaxPrice = HTaxPrice * HDiscountRate;   //实际含税单价=含税单价*折扣率*/
                        //折扣额 = å«ç¨Žå•ä»· * (1 - æŠ˜æ‰£çއ) * æ•°é‡
                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                        var HTaxMoney = HMoney * HTaxRate;              //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
                            , HPrice: HPrice
                            , HTaxRate: HTaxRate * 100
                            , HTaxPrice: HTaxPrice
                            , HMoney: HMoney
                            , HlineTotal: HlineTotal
                        });
                        table.render(option);
                        break;
                    default:
                }
@@ -665,6 +757,37 @@
            }
            //#endregion
            //#region æ ¹æ®è´¦å·èŽ·å–éƒ¨é—¨ã€èŒå‘˜ã€ä¸»ç®¡
            function getCzyglByUser() {
                $.ajax({
                    url: GetWEBURL() + "/Xs_SeOrderBill/getCzyglByUser",
                    async: false,
                    type: "GET",
                    data: {
                        "CurUserName": sessionStorage["HUserName"]
                    },
                    success: function (result) {
                        if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            var data = result.data[0];
                            $("#HEmpID").val(data.HEmpID);
                            $("#HEmpName").val(data.HEmpName);
                            $("#HDeptID").val(data.HDeptID);
                            $("#HDeptName").val(data.HDeptName);
                            $("#HManagerID").val(data.HManagerID);
                            $("#HManagerName").val(data.HManagerName);
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
            }
            //#endregion
            //#region ç”Ÿæˆå•据号
            function createBillNo() {
                $.ajax({
@@ -688,20 +811,20 @@
                    , height: 500
                    , loading: false
                    , cols: [[ //子表
                        { type: 'checkbox', totalRowText: '合计行' }
                        , { type: 'numbers', title: '序号', width: 100, totalRow: true }
                        , { field: 'HMaterID', title: 'HMaterID', width: 100, hide: true }
                        { type: 'checkbox', totalRowText: '合计行', style: 'background-color:#efefef4d;' }
                        , { type: 'numbers', title: '序号', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HMaterID', title: 'HMaterID', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: '物料代码', title: '物料代码', width: 150, edit: 'text', event: "HMaterID" }//f7
                        , { field: '物料名称', title: '物料名称', width: 150, }
                        , { field: '规格型号', title: '规格型号', width: 100, }
                        , { field: 'HUnitID', title: 'HUnitID', width: 100, hide: true }
                        , { field: '计量单位', title: '计量单位', width: 100 }//f7
                        , { field: '物料名称', title: '物料名称', width: 150, style: 'background-color:#efefef4d;' }
                        , { field: '规格型号', title: '规格型号', width: 100, style: 'background-color:#efefef4d;' }
                        , { field: 'HUnitID', title: 'HUnitID', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: '计量单位', title: '计量单位', width: 100, style: 'background-color:#efefef4d;' }//f7
                        , { field: 'HQty', title: '数量', width: 100, edit: 'text' }
                        , { field: 'HPrice', title: '单价', width: 100, edit: 'text' }
                        , { field: 'HTaxRate', title: '税率', width: 100, edit: 'text' }
                        , { field: 'HTaxPrice', title: '含税单价', width: 100, edit: 'text' }
                        , { field: 'HMoney', title: '金额', width: 100, edit: 'text' }
                        , { field: 'HlineTotal', title: '价税合计', width: 100, }
                        , { field: 'HTaxPrice', title: '含税单价', width: 100, style: 'background-color:#efefef4d;' }
                        , { field: 'HMoney', title: '金额', width: 100, style: 'background-color:#efefef4d;' }
                        , { field: 'HlineTotal', title: '价税合计', width: 100, style: 'background-color:#efefef4d;' }
                        , { field: 'HDate', title: '交货日期', event: "HDate", width: 120 }
                        , { field: 'HRemark', title: '备注', width: 100, edit: 'text' }
@@ -733,7 +856,7 @@
                    "HTaxMoney": "0",
                    "HlineTotal": "0",
                    "HlineTotalBB": "0",
                    "HDate": "",
                    "HDate": Format(new Date(),'yyyy-MM-dd'),
                    "HOutStockQty": "0",
                    "HInvoiceQty": "0",
                    "HRemark": ""
@@ -757,6 +880,9 @@
                $("#HSSDate").val(Format(new Date(), "yyyy-MM-dd"));
                $("#HMaker").val(sessionStorage["HUserName"]);
                $("#HMakeDate").val(Format(new Date(), "yyyy-MM-dd"));
                //销售员、销售部门、销售主管初始化
                getCzyglByUser();
                //初始化并列设置:子表1
                set_InitGrid();
@@ -912,8 +1038,7 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HCusName").val(checkStatus.data[0].HName);
                        $("#HCusID").val(checkStatus.data[0].HItemID);
                        getCustomerByCusID(checkStatus.data[0].HItemID);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
@@ -1141,8 +1266,27 @@
                    return false;
                }
                if ($("#HDeptID").val() == "0") {
                    layer.msg("销售部门未选择!");
                //if ($("#HDeptID").val() == "0") {
                //    layer.msg("销售部门未选择!");
                //    return false;
                //}
                //if ($("#HEmpID").val() == "0") {
                //    layer.msg("销售员未选择!");
                //    return false;
                //}
                if ($("#HCurID").val() == "0") {
                    layer.msg("销售币别未选择!");
                    return false;
                }
                temp = $("#HExRate").val() + "";
                if (temp == 0 || temp == "") {
                    layer.msg("汇率不能为0或空!");
                    return false;
                } else if (!ref.test(temp)) {
                    layer.msg("汇率请输入大于0的数字!");
                    return false;
                }
@@ -1151,25 +1295,22 @@
                    return false;
                }
                if ($("#HEmpID").val() == "0") {
                    layer.msg("销售员未选择!");
                    return false;
                }
                if ($("#HCurID").val() == "0") {
                    layer.msg("销售币别未选择!");
                    return false;
                }
                if ($("#HMangerID").val() == "0") {
                    layer.msg("销售主管未选择!");
                    return false;
                }
                if ($("#HSSID").val() == "0") {
                    layer.msg("结算方式未选择!");
                    return false;
                }
                //if ($("#HSellSID").val() == "0") {
                //    layer.msg("销售方式未选择!");
                //    return false;
                //}
                //if ($("#HMangerID").val() == "0") {
                //    layer.msg("销售主管未选择!");
                //    return false;
                //}
                //if ($("#HPayCusID").val() == "0") {
                //    layer.msg("结算方未选择!");
@@ -1181,14 +1322,7 @@
                //    return false;
                //}
                temp = $("HExRate").val() + "";
                if (temp == 0 || temp == "") {
                    layer.msg("汇率不能为0或空!");
                    return false;
                } else if (!ref.test(temp)){
                    layer.msg("汇率请输入大于0的数字!");
                    return false;
                }
                //#endregion
                //#region å­è¡¨ æ•°æ®æ£€éªŒ
@@ -1200,11 +1334,6 @@
                    if (option.data[i]["HUnitID"] == "0") {
                        layer.msg("第" + i + "行:计量单位未选择!");
                        return false;
                    }
                    if (option.data[i]["HDate"] == "") {
                        layer.msg("第" + i + "行:交货日期不能为空!");
                        return false;
                    }
@@ -1228,6 +1357,13 @@
                        return false;
                    }
                    //税率格式校验
                    temp = option.data[i]["HTaxRate"] + "";
                    if (!ref.test(temp)) {
                        layer.msg("第" + i + "行:税率请输入不小于0的数字!");
                        return false;
                    }
                    //含税单价格式校验
                    temp = option.data[i]["HTaxPrice"] + "";
                    if (temp == "0") {
@@ -1247,6 +1383,27 @@
                        layer.msg("第" + i + "行:金额请输入大于0的数字!");
                        return false;
                    }
                    //价税合计格式校验
                    temp = option.data[i]["HlineTotal"] + "";
                    if (temp == "0") {
                        layer.msg("第" + i + "行:价税合计不能为0!");
                        return false;
                    } else if (!ref.test(temp)) {
                        layer.msg("第" + i + "行:价税合计请输入大于0的数字!");
                        return false;
                    }
                    if (option.data[i]["HDate"] == "") {
                        layer.msg("第" + i + "行:交货日期不能为空!");
                        return false;
                    }
                    ////折扣率格式校验
                    //temp = option.data[i]["HDiscountRate"] + "";
@@ -1268,35 +1425,19 @@
                    //    return false;
                    //}
                    //税率格式校验
                    temp = option.data[i]["HTaxRate"] + "";
                    if (temp == "0") {
                        layer.msg("第" + i + "行:税率不能为0!");
                        return false;
                    } else if (!ref.test(temp)) {
                        layer.msg("第" + i + "行:税率请输入大于0的数字!");
                        return false;
                    }
                    //税额格式校验
                    temp = option.data[i]["HTaxMoney"] + "";
                    if (temp == "0") {
                        layer.msg("第" + i + "行:税额不能为0!");
                        return false;
                    } else if (!ref.test(temp)) {
                        layer.msg("第" + i + "行:税额请输入大于0的数字!");
                        return false;
                    }
                    //temp = option.data[i]["HTaxMoney"] + "";
                    //if (temp == "0") {
                    //    layer.msg("第" + i + "行:税额不能为0!");
                    //    return false;
                    //} else if (!ref.test(temp)) {
                    //    layer.msg("第" + i + "行:税额请输入大于0的数字!");
                    //    return false;
                    //}
                    //价税合计格式校验
                    temp = option.data[i]["HlineTotal"] + "";
                    if (temp == "0") {
                        layer.msg("第" + i + "行:价税合计不能为0!");
                        return false;
                    } else if (!ref.test(temp)) {
                        layer.msg("第" + i + "行:价税合计请输入大于0的数字!");
                        return false;
                    }
                    ////本位币价税合计格式校验
                    //temp = option.data[i]["HlineTotalBB"] + "";
@@ -1501,15 +1642,64 @@
                                        return layer.msg("请选择一条数据");
                                    }
                                    //更新表格缓存的数据
                                    obj.update({
                                        "HMaterID": checkStatus.data[0].HItemID
                                        , "物料代码": checkStatus.data[0].HNumber
                                        , "物料名称": checkStatus.data[0].HName
                                        , "规格型号": checkStatus.data[0].HModel
                                        , "HUnitID": checkStatus.data[0].HUnitID
                                        , "计量单位": checkStatus.data[0].HUnitName
                                    })
                                    //数值格式校验工具
                                    var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                                    var temp = "";
                                    //获取选择物料前后的税率
                                    var value = subHTaxRate;                    //选择物料后根据客户得到的税率
                                    var oldText = obj.data.HTaxRate;            //该记录中原有的税率
                                    //税率数据格式校验
                                    temp = value + "";
                                    if (!ref.test(temp)) {
                                        //税率恢复到编辑前,设置物料等信息
                                        obj.update({
                                            HTaxRate: oldText
                                            , "HMaterID": checkStatus.data[0].HItemID
                                            , "物料代码": checkStatus.data[0].HNumber
                                            , "物料名称": checkStatus.data[0].HName
                                            , "规格型号": checkStatus.data[0].HModel
                                            , "HUnitID": checkStatus.data[0].HUnitID
                                            , "计量单位": checkStatus.data[0].HUnitName
                                        });
                                        table.render(option);
                                        layer.msg("获取到的税率不合法,已自动变更为原有税率!");
                                    } else {
                                        //数据校验合格,重算记录
                                        var HQty = obj.data.HQty * 1;                   //数量
                                        var HPrice = obj.data.HPrice * 1;               //单价
                                        var HTaxRate = value * 0.01;                       //税率
                                        /*var HDiscountRate = obj.data.HDiscountRate * 1; //折扣率*/
                                        var HTaxPrice = HPrice * (1 + HTaxRate);        //含税单价=单价*(1+税率)
                                        /*var HRelTaxPrice = HTaxPrice * HDiscountRate;   //实际含税单价=含税单价*折扣率*/
                                        //折扣额 = å«ç¨Žå•ä»· * (1 - æŠ˜æ‰£çއ) * æ•°é‡
                                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                                        var HTaxMoney = HMoney * HTaxRate;              //税额=金额*税率
                                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                                        //同步更新表格和缓存对应的值
                                        obj.update({
                                            HQty: HQty
                                            , HPrice: HPrice
                                            , HTaxRate: HTaxRate * 100
                                            , HTaxPrice: HTaxPrice
                                            , HMoney: HMoney
                                            , HlineTotal: HlineTotal
                                            , "HMaterID": checkStatus.data[0].HItemID
                                            , "物料代码": checkStatus.data[0].HNumber
                                            , "物料名称": checkStatus.data[0].HName
                                            , "规格型号": checkStatus.data[0].HModel
                                            , "HUnitID": checkStatus.data[0].HUnitID
                                            , "计量单位": checkStatus.data[0].HUnitName
                                        });
                                        table.render(option);
                                    }
                                    layer.close(index);//关闭弹窗
                                }
                            })
@@ -1678,11 +1868,18 @@
            }
            //#endregion
            //#endregion
            //以上是layui模块
        });
        //子表税率,根据客户带出
        var subHTaxRate = 0;
        // åŸºç¡€èµ„料返回数据
        function GetHEmpValue(obj)  //返回业务员
        {
@@ -1692,8 +1889,9 @@
        function GetHSupValue(obj)  //返回客户
        {
            $("#HCusName").val(obj[0].HName);
            $("#HCusID").val(obj[0].HItemID);
            //$("#HCusName").val(obj[0].HName);
            //$("#HCusID").val(obj[0].HItemID);
            getCustomerByCusID(obj[0].HItemID);
        }
        function GetHManagerValue(obj)  //返回主管
@@ -1707,6 +1905,39 @@
            $("#HDeptName").val(obj[0].HName);
            $("#HDeptID").val(obj[0].HItemID);
        }
        //#region æ ¹æ®å®¢æˆ·èŽ·å–å¸åˆ«ã€æ±‡çŽ‡ã€ç»“ç®—æ–¹å¼
        function getCustomerByCusID(HCusID) {
            $.ajax({
                url: GetWEBURL() + "/Xs_SeOrderBill/getCustomerByCusID",
                async: false,
                type: "GET",
                data: {
                    "HCusID": HCusID
                },
                success: function (result) {
                    if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                        var data = result.data[0];
                        $("#HCusID").val(data.HCusID);
                        $("#HCusName").val(data.HCusName);
                        $("#HCurID").val(data.HCurID);
                        $("#HCurName").val(data.HCurName);
                        $("#HExRate").val(data.HExRate);
                        $("#HSSID").val(data.HSSID);
                        $("#HSSName").val(data.HSSName);
                        subHTaxRate = data.HTaxRate;
                    } else {
                        layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                    }
                }, error: function () {
                    layer.alert("发生错误!", { icon: 5 });
                }
            });
        }
        //#endregion
    </script>
</body>
</html>