zrg
2024-11-28 727ee25aeb5fcaf84e2cf009b2eacd3a86bcb3ca
WebTM/views/ÏúÊÛ¹ÜÀí/Ó¦ÊÕµ¥/Xs_ReceivableBill.html
@@ -47,6 +47,7 @@
                        <div class="layui-btn-group">
                            <button type="button" id="set_SaveBill" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Saver">保存</button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="set_CheckBill">审核</button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="set_SelectMainBill">选整单</button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Exit">退出</button>
                        </div>
                    </div>
@@ -65,7 +66,7 @@
                                        <div class="layui-inline">
                                            <label class="layui-form-label">单据编号</label>
                                            <div class="layui-input-inline">
                                                <input type="text" class="layui-input" name="HBillNo" id="HBillNo" style="background-color:#efefef4d;" readonly>
                                                <input type="text" class="layui-input" name="HBillNo" id="HBillNo" style="background-color:#efefef4d;" >
                                                <input type="hidden" name="HInterID" id="HInterID" value="0">
                                            </div>
                                        </div>
@@ -136,8 +137,9 @@
                                            <label class="layui-form-label">单价类型</label>
                                            <div class="layui-input-inline">
                                                <select name="HPriceType" id="HPriceType" lay-filter="HPriceType" style="width: 190px; ">
                                                    <option value="成本价" selected="selected">成本价</option>
                                                    <option value="去税价" selected="selected">去税价</option>
                                                    <option value="结算价">结算价</option>
                                                    <option value="含税价">含税价</option>
                                                </select>
                                            </div>
                                        </div>
@@ -483,6 +485,12 @@
            });
            //#endregion
            //#region é€‰æ•´å•
            form.on('submit(set_SelectMainBill)', function (data) {
                set_SelectMainBill();
            });
            //#endregion
            //#region ä¿å­˜æŒ‰é’®
            form.on('submit(Saver)', function (data) {
                //#region åˆ¤æ–­æºå•状态
@@ -536,9 +544,9 @@
                }
                //#endregion
                //if (AllowLoadData(data)) {
                if (AllowLoadData(data)) {
                    set_SaveBill(data);
                //}
                }
            });
            //#endregion
            //#endregion
@@ -600,6 +608,7 @@
                    var url;
                    //判断文本框是否有数据    new
                    if (HSourceBillNo == "") {
                        layer.close(ajaxLoad);
                        return;
                    }
                    if ($("#BillType").val() == "1401") {
@@ -640,7 +649,7 @@
                                        , "HSellSName": dataArray[0].销售方式
                                    });
                                    if ($("#HPriceType").val() == "成本价") {
                                    if ($("#HPriceType").val() == "去税价") {
                                        //子表成本价Entry  èµ‹å€¼
                                        var rowdataEntry = [];
                                        for (var i = 0; i < dataArray.length; i++) {
@@ -664,8 +673,8 @@
                                                    , "HQty": dealDoubleToFixed(HQty, 1)
                                                    , "HPrice": dealDoubleToFixed(dataArray[i].HNoTaxCost, 3)
                                                    , "HTaxPrice": dealDoubleToFixed(dataArray[i].HTaxCost, 3)
                                                    , 'HDiscountRate': "0"                                                     //
                                                    , 'HRelTaxPrice': "0"
                                                    , 'HDiscountRate': "1"                                                     //
                                                    , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].HTaxCost, 3)
                                                    , "HTaxRate": dataArray[i].税率
                                                    , 'HTaxMoney': dealDoubleToFixed(HTaxMoney, 2)                                                         //
                                                    , "HMoney": dealDoubleToFixed(HMoney, 2)
@@ -716,8 +725,8 @@
                                                    , "HQty": dealDoubleToFixed(HQty, 1)
                                                    , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                                                    , "HTaxPrice": dealDoubleToFixed(dataArray[i].HTaxPrice, 3)
                                                    , 'HDiscountRate': "0"                                                     //
                                                    , 'HRelTaxPrice': "0"
                                                    , 'HDiscountRate': "1"                                                     //
                                                    , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].HTaxPrice, 3)
                                                    , "HTaxRate": dataArray[i].税率
                                                    , 'HTaxMoney': dealDoubleToFixed(HTaxMoney, 2)                                                         //
                                                    , "HMoney": dealDoubleToFixed(HMoney, 2)
@@ -745,7 +754,7 @@
                                            );
                                        }
                                    }
                                    optionEntry.data = rowdataEntry;
                                    optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
                                    table.render(optionEntry);
                                    //子表汇总
                                    for (var i = 0; i < rowdataEntry.length; i++) {
@@ -777,25 +786,25 @@
                                        , "HDeptID": dataArray[0].HDeptID
                                        , "HDeptName": dataArray[0].部门
                                        , "HMangerID": dataArray[0].hmanagerid
                                        , "HMangerID": dataArray[0].HManagerID
                                        , "HMangerName": dataArray[0].主管
                                        , "HEmpID": dataArray[0].HEmpID
                                        , "HEmpName": dataArray[0].业务员
                                        , "HCusID": dataArray[0].hsupid
                                        , "HCusID": dataArray[0].HSupID
                                        , "HCusName": dataArray[0].客户
                                        , "HCurID": dataArray[0].HCurID
                                        , "HCurName": dataArray[0].币别
                                        , "HExRate": dataArray[0].汇率
                                        , "HCurID": dataArray[0].主表币别id
                                        , "HCurName": dataArray[0].主表币别
                                        , "HExRate": dataArray[0].主表汇率
                                        , "HSSID": "0"
                                        , "HSSName": ""
                                        , "HSellSID": dataArray[0].HSellSID
                                        , "HSellSName": dataArray[0].销售方式
                                    });
                                    if ($("#HPriceType").val() == "成本价") {
                                    if ($("#HPriceType").val() == "去税价") {
                                        //子表  èµ‹å€¼
                                        var rowdataEntry = [];
                                        for (var i = 0; i < dataArray.length; i++) {
                                            var HQty = dataArray[i].数量 - dataArray[i].关联数量;                           //数量
                                            var HQty = dataArray[i].数量 - dataArray[i].已关联数量;                           //数量
                                            
                                            rowdataEntry.push(
                                                {
@@ -808,8 +817,8 @@
                                                    , "HQty": dealDoubleToFixed(HQty, 1)
                                                    , "HPrice": dealDoubleToFixed(dataArray[i].成本单价, 3)
                                                    , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                                                    , 'HDiscountRate': "0"                                                     //
                                                    , 'HRelTaxPrice': "0"
                                                    , 'HDiscountRate': "1"                                                     //
                                                    , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                                                    , "HTaxRate": dataArray[i].税率
                                                    , 'HTaxMoney': dealDoubleToFixed(HQty * dataArray[i].成本单价 * dataArray[0].税率, 2)                                                         //
                                                    , "HMoney": dealDoubleToFixed(HQty * dataArray[i].成本单价, 2)
@@ -853,8 +862,8 @@
                                                    , "HQty": dealDoubleToFixed(HQty, 1)
                                                    , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                                                    , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                                                    , 'HDiscountRate': "0"                                                     //
                                                    , 'HRelTaxPrice': "0"
                                                    , 'HDiscountRate': "1"                                                     //
                                                    , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                                                    , "HTaxRate": dataArray[i].税率
                                                    , 'HTaxMoney': dealDoubleToFixed(HQty * dataArray[i].单价 * dataArray[0].税率, 2)                                                         //
                                                    , "HMoney": dealDoubleToFixed(HQty * dataArray[i].单价, 2)
@@ -883,7 +892,7 @@
                                        }
                                    }
                                    optionEntry.data = rowdataEntry;
                                    optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
                                    table.render(optionEntry);
                                    //子表汇总
                                    for (var i = 0; i < rowdataEntry.length; i++) {
@@ -946,7 +955,7 @@
                    , "HQty": "0"
                    , "HPrice": "0"
                    , "HTaxPrice": "0"
                    , 'HDiscountRate': "0"
                    , 'HDiscountRate': "1"
                    , 'HRelTaxPrice': "0"
                    , "HTaxRate": "0"
                    , 'HTaxMoney': "0"
@@ -1286,6 +1295,69 @@
                }
            });
            //#endregion
            //#region ä¸‹æ‹‰æ¡†äº‹ä»¶
            // ç›‘听下拉框选择
            form.on('select(HPriceType)', function (data) {
                console.log(data.value); // å¾—到被选中的值
                // æ‰§è¡Œç›¸å…³æ“ä½œ
                //#region å­è¡¨ æ•°æ®æ£€éªŒ
                for (var i = 0; i < option.data.length; i++) {
                    if (option.data[i]["HMaterID"] == "0") {
                        layer.msg("第" + (i + 1) + "行:物料未选择!");
                        return false;
                    } else {
                        var HPrice = option.data[i]["HPrice"];
                        var HMaterID = option.data[i]["HMaterID"];
                        var HType = data.value.toString();
                        //获取物料对应单价类型的单价
                        $.ajax({
                            url: GetWEBURL() + "/Xs_ReceivableBill/getPriceByType",
                            type: "GET",
                            async: false,
                            data: { "HMaterID": HMaterID, HType: HType },
                            success: function (d) {
                                HPrice = Number(d.data);
                            }, error: function () {
                                layer.alert("发生错误!" + d.Message, { icon: 5 });
                            }
                        });
                        var Dec = getDecByMaterID(option.data[i]["HMaterID"]) //获取精度
                        var HQtyDec = (Dec["HQtyDec"] == null || Dec["HQtyDec"] == 0) ? 4 : Dec["HQtyDec"];  //数量精度
                        var HPriceDec = (Dec["HPriceDec"] == null || Dec["HPriceDec"] == 0) ? 4 : Dec["HPriceDec"];  //单价精度
                        var HMoneyDec = (Dec["HMoneyDec"] == null || Dec["HMoneyDec"] == 0) ? 2 : Dec["HMoneyDec"];  //金额精度
                        //数据校验合格,重算记录
                        var HTaxRate = option.data[i]["HTaxRate"] * 0.01;
                        var HExRate = $("#HExRate").val();                      //汇率
                        var HQty = option.data[i]["HQty"] * 1;                           //数量
                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                        var HTaxMoney = Number((HMoney * HTaxRate));         //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        var HTaxPrice = Number((HPrice * (1 + HTaxRate)));        //含税单价=单价*(1+税率)
                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));     //本位币价税合计=(税额+金额)*汇率
                        var HDiscountRate = option.data[i]["HDiscountRate"] * 1;   //折扣率
                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate));   //实际含税单价=含税单价*折扣率
                        var HExRate = $("#HExRate").val();                      //汇率
                        var HMoneyBB = HMoney * HExRate;
                        ///数字精度
                        option.data[i]["HQty"] = Number(HQty.toFixed(HQtyDec));
                        option.data[i]["HPrice"] = Number(HPrice.toFixed(HPriceDec));
                        option.data[i]["HMoney"] = Number(HMoney.toFixed(HMoneyDec));
                        option.data[i]["HTaxMoney"] = Number(HTaxMoney.toFixed(HMoneyDec));
                        option.data[i]["HMoneyBB"] = Number(HMoneyBB.toFixed(HMoneyDec));
                        option.data[i]["HlineTotal"] = Number(HlineTotal.toFixed(HMoneyDec));
                        option.data[i]["HTaxPrice"] = Number(HTaxPrice.toFixed(HPriceDec));
                        option.data[i]["HRelTaxPrice"] = Number(HRelTaxPrice.toFixed(HPriceDec));
                        option.data[i]["HlineTotalBB"] = Number(HlineTotalBB.toFixed(HMoneyDec));
                    }
                }
                table.render(option);
                //#endregion
            });
            //#endregion
            //#endregion
            //#endregion
@@ -1627,6 +1699,406 @@
                })
            }
            //#endregion
            //#region é€‰æ•´å•
            function set_SelectMainBill() {
                var url;
                if ($("#BillType").val() == "1401") {
                    url = "../../销售管理/销售订单/Xs_SeOrderBillQuery.html?openType=2&HOrgID=" + HOrgID;
                    HSourceBillName = "销售订单";
                }
                else if ($("#BillType").val() == "1205") {
                    url = "../../领料发货/销售出库/Kf_SellOutBillQuery.html?openType=2&HOrgID=" + HOrgID;
                    HSourceBillName = "销售出库单";
                }
                else {
                    return layer.msg('当前不支持该源单选择!!');
                }
                //页面层-自定义
                layer.open({
                    type: 2
                    , skin: "layui-layer-rim" //加上边框
                    , title: '' + '源单' + '列表'  //标题
                    , closeBtn: 1  //窗体右上角关闭 çš„ æ ·å¼
                    , shift: 2 //弹出动画
                    , area: ["90%", "90%"] //窗体大小
                    , maxmin: true //设置最大最小按钮是否显示
                    , content: [url, "yes"]
                    , btn: ["确定", "取消"]
                    , btn1: function (index, laero) {
                        //按钮一  çš„回调
                        var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
                        var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
                        if (checkStatus.data.length == 0) {
                            return layer.msg("请至少选择一条数据!");
                        }
                        var HCusID = $("#HCusID").val();//判断客户
                        if (HCusID == 0 || HCusID == '') {
                            HCusID = checkStatus.data[0]["HCusID"];
                        }
                        //获取设置条件
                        var sMainWhere = " and hmainid in(";
                        for (var i = 0; i < checkStatus.data.length; i++) {
                            if (checkStatus.data[i]["HCusID"] != HCusID) {
                                layer.msg("下推失败!已经选中的记录中存在不同客户!");
                                layer.close(index);//关闭弹窗
                                return;
                            }
                            sMainWhere += checkStatus.data[i]["hmainid"]
                            if (i != checkStatus.data.length - 1) {
                                sMainWhere += ",";
                            } else {
                                sMainWhere += ") ";
                            }
                        }
                        getSeletMainInfo(sMainWhere);
                        layer.close(index);//关闭弹窗
                    }
                });
            }
            //#endregion
            //#region æ•´å•信息获取方法
            function getSeletMainInfo(sMainWhere) {
                var ajaxLoad = layer.load();
                if ($("#BillType").val() == "1401") {
                    $.ajax({
                        url: GetWEBURL() + '/Xs_SeOrderBill/list',
                        async: false,
                        type: "GET",
                        data: { "sWhere": sMainWhere, "user": sessionStorage["HUserName"] },
                        success: function (data1) {
                            if (data1.count == 1) {
                                var dataArray = data1.data;
                                form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                                    "HMainSourceInterID": "0"
                                    , "HMainSourceEntryID": "0"
                                    /*, "HMainSourceBillNo": ""*/
                                    , "HMainSourceBillType": $("#BillType").val()
                                    , "HDeptID": dataArray[0].HDeptID
                                    , "HDeptName": dataArray[0].部门
                                    , "HMangerID": dataArray[0].HManagerID
                                    , "HMangerName": dataArray[0].主管
                                    , "HEmpID": dataArray[0].HEmpID
                                    , "HEmpName": dataArray[0].业务员
                                    , "HCusID": dataArray[0].HCusID
                                    , "HCusName": dataArray[0].客户
                                    , "HCurID": dataArray[0].HCurID
                                    , "HCurName": dataArray[0].币别
                                    , "HExRate": dataArray[0].汇率
                                    , "HSSID": dataArray[0].HSSID
                                    , "HSSName": dataArray[0].结算方式
                                    , "HSellSID": dataArray[0].HSellSID
                                    , "HSellSName": dataArray[0].销售方式
                                });
                                if ($("#HPriceType").val() == "去税价") {
                                    //子表成本价Entry  èµ‹å€¼
                                    var rowdataEntry = [];
                                    for (var i = 0; i < dataArray.length; i++) {
                                        var HQty = dataArray[i].数量 - dataArray[i].关联数量;                           //数量
                                        var HPrice = dataArray[i].HNoTaxCost;               //成本价
                                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                                        var HTaxRate = dataArray[i].税率 * 0.01;           //税率
                                        var HTaxMoney = Number((HMoney * HTaxRate));         //税额=金额*税率
                                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                                        var HExRate = $("#HExRate").val();                      //汇率
                                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));      //本位币价税合计=(税额+金额)*汇率
                                        var HMoneyBB = HMoney * HExRate;
                                        rowdataEntry.push(
                                            {
                                                "HMaterID": dataArray[i].HMaterID
                                                , "物料代码": dataArray[i].物料代码
                                                , "物料名称": dataArray[i].物料名称
                                                , "规格型号": dataArray[i].规格型号
                                                , "HUnitID": dataArray[i].HUnitID
                                                , "计量单位": dataArray[i].计量单位
                                                , "HQty": dealDoubleToFixed(HQty, 1)
                                                , "HPrice": dealDoubleToFixed(dataArray[i].HNoTaxCost, 3)
                                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].HTaxCost, 3)
                                                , 'HDiscountRate': "1"                                                     //
                                                , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].HTaxCost, 3)
                                                , "HTaxRate": dataArray[i].税率
                                                , 'HTaxMoney': dealDoubleToFixed(HTaxMoney, 2)                                                         //
                                                , "HMoney": dealDoubleToFixed(HMoney, 2)
                                                , 'HMoneyBB': dealDoubleToFixed(HMoneyBB, 2)
                                                , 'HlineTotal': dealDoubleToFixed(HlineTotal, 2)
                                                , 'HlineTotalBB': dealDoubleToFixed(HlineTotalBB, 2)
                                                , "HRemark": ""
                                                , "HSourceInterID": dataArray[i].hmainid
                                                , "HSourceEntryID": dataArray[i].hsubid
                                                , "HSourceBillNo": dataArray[i].单据号
                                                , "HSourceBillType": dataArray[i].HBillType
                                                , "HRelationQty": "0"
                                                , "HRelationMoney": "0"
                                                , 'HPOOrderInterID': "0"
                                                , 'HPOOrderEntryID': "0"
                                                , 'HPOOrderBillNo': ""
                                                , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].HTaxPrice, 3)
                                                , "HSeOrderInterID": dataArray[i].hmainid
                                                , "HSeOrderEntryID": dataArray[i].hsubid
                                                , "HSeOrderBillNo": dataArray[i].单据号
                                            }
                                        );
                                    }
                                } else {
                                    //子表Entry  èµ‹å€¼
                                    var rowdataEntry = [];
                                    for (var i = 0; i < dataArray.length; i++) {
                                        var HQty = dataArray[i].数量 - dataArray[i].关联数量;                           //数量
                                        var HPrice = dataArray[i].单价;               //单价
                                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                                        var HTaxRate = dataArray[i].税率 * 0.01;           //税率
                                        var HTaxMoney = Number((HMoney * HTaxRate));         //税额=金额*税率
                                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                                        var HExRate = $("#HExRate").val();                      //汇率
                                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));      //本位币价税合计=(税额+金额)*汇率
                                        var HMoneyBB = HMoney * HExRate;
                                        rowdataEntry.push(
                                            {
                                                "HMaterID": dataArray[i].HMaterID
                                                , "物料代码": dataArray[i].物料代码
                                                , "物料名称": dataArray[i].物料名称
                                                , "规格型号": dataArray[i].规格型号
                                                , "HUnitID": dataArray[i].HUnitID
                                                , "计量单位": dataArray[i].计量单位
                                                , "HQty": dealDoubleToFixed(HQty, 1)
                                                , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].HTaxPrice, 3)
                                                , 'HDiscountRate': "1"                                                     //
                                                , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].HTaxPrice, 3)
                                                , "HTaxRate": dataArray[i].税率
                                                , 'HTaxMoney': dealDoubleToFixed(HTaxMoney, 2)                                                         //
                                                , "HMoney": dealDoubleToFixed(HMoney, 2)
                                                , 'HMoneyBB': dealDoubleToFixed(HMoneyBB, 2)
                                                , 'HlineTotal': dealDoubleToFixed(HlineTotal, 2)
                                                , 'HlineTotalBB': dealDoubleToFixed(HlineTotalBB, 2)
                                                , "HRemark": ""
                                                , "HSourceInterID": dataArray[i].hmainid
                                                , "HSourceEntryID": dataArray[i].hsubid
                                                , "HSourceBillNo": dataArray[i].单据号
                                                , "HSourceBillType": dataArray[i].HBillType
                                                , "HRelationQty": "0"
                                                , "HRelationMoney": "0"
                                                , 'HPOOrderInterID': "0"
                                                , 'HPOOrderEntryID': "0"
                                                , 'HPOOrderBillNo': ""
                                                , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].HTaxPrice, 3)
                                                , "HSeOrderInterID": dataArray[i].hmainid
                                                , "HSeOrderEntryID": dataArray[i].hsubid
                                                , "HSeOrderBillNo": dataArray[i].单据号
                                            }
                                        );
                                    }
                                }
                                optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
                                table.render(optionEntry);
                                //子表汇总
                                for (var i = 0; i < rowdataEntry.length; i++) {
                                    var item = rowdataEntry[i];
                                    for (var j = i + 1; j < rowdataEntry.length; j++) {
                                        if (rowdataEntry[j].HMaterID == item.HMaterID) {
                                            rowdataEntry[i].HQty += rowdataEntry[j].HQty;
                                            rowdataEntry[i].HMoney = rowdataEntry[i].HQty * rowdataEntry[i].HPrice//金额=数量*单价
                                            rowdataEntry[i].HTaxMoney = Number((rowdataEntry[i].HMoney * rowdataEntry[i].HTaxRate).toFixed(4))//税额
                                            rowdataEntry[i].HlineTotal = rowdataEntry[i].HMoney + rowdataEntry[i].HTaxMoney //价税合计
                                            var HExRate = $("#HExRate").val();
                                            rowdataEntry[i].HlineTotalBB = Number(((rowdataEntry[i].HMoney + rowdataEntry[i].HTaxMoney) * HExRate).toFixed(4)) //本位币价税合计
                                            rowdataEntry[i].HMoneyBB = Number((rowdataEntry[i].HMoney * HExRate).toFixed(4)) //本位币金额
                                            rowdataEntry.splice(j, 1);
                                            j = j - 1;
                                        }
                                    }
                                }
                                set_InitGridHaveSource();
                                option.data = rowdataEntry;
                                haveSource = true;
                                table.render(option);
                                layer.close(ajaxLoad);
                                //layer.alert("查询成功", { icon: 1 });
                            } else {
                                layer.close(ajaxLoad);
                                layer.alert(data1.code + data1.Message, { icon: 5 });
                                return;
                            }
                        }, error: function () {
                            layer.close(ajaxLoad);
                            layer.alert("接口请求失败!", { icon: 5 });
                            return;
                        }
                    });
                } else if ($("#BillType").val() == "1205") {
                    $.ajax({
                        url: GetWEBURL() + '/Kf_SellOutBill/GetSellOutBillList',
                        type: "GET",
                        data: { "sWhere": sMainWhere, "user": sessionStorage["HUserName"] },
                        success: function (data1) {
                            if (data1.count == 1) {
                                dataArray = data1.data;
                                form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                                    "HMainSourceInterID": "0"
                                    , "HMainSourceEntryID": "0"
                                    /*, "HMainSourceBillNo": ""*/
                                    , "HMainSourceBillType": $("#BillType").val()
                                    , "HDeptID": dataArray[0].HDeptID
                                    , "HDeptName": dataArray[0].部门
                                    , "HMangerID": dataArray[0].HManagerID
                                    , "HMangerName": dataArray[0].主管
                                    , "HEmpID": dataArray[0].HEmpID
                                    , "HEmpName": dataArray[0].业务员
                                    , "HCusID": dataArray[0].HSupID
                                    , "HCusName": dataArray[0].客户
                                    , "HCurID": dataArray[0].主表币别id
                                    , "HCurName": dataArray[0].主表币别
                                    , "HExRate": dataArray[0].主表汇率
                                    , "HSSID": "0"
                                    , "HSSName": ""
                                    , "HSellSID": dataArray[0].HSellSID
                                    , "HSellSName": dataArray[0].销售方式
                                });
                                if ($("#HPriceType").val() == "去税价") {
                                    //子表  èµ‹å€¼
                                    var rowdataEntry = [];
                                    for (var i = 0; i < dataArray.length; i++) {
                                        var HQty = dataArray[i].数量 * 1 - dataArray[i].已关联数量 * 1;                           //数量
                                        rowdataEntry.push(
                                            {
                                                "HMaterID": dataArray[i].HMaterID
                                                , "物料代码": dataArray[i].物料代码
                                                , "物料名称": dataArray[i].物料名称
                                                , "规格型号": dataArray[i].规格型号
                                                , "HUnitID": dataArray[i].hunitid
                                                , "计量单位": dataArray[i].计量单位
                                                , "HQty": dealDoubleToFixed(HQty, 1)
                                                , "HPrice": dealDoubleToFixed(dataArray[i].成本单价, 3)
                                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                                                , 'HDiscountRate': "1"                                                     //
                                                , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                                                , "HTaxRate": dataArray[i].税率
                                                , 'HTaxMoney': dealDoubleToFixed(HQty * dataArray[i].成本单价 * dataArray[0].税率, 2)                                                         //
                                                , "HMoney": dealDoubleToFixed(HQty * dataArray[i].成本单价, 2)
                                                , 'HMoneyBB': dealDoubleToFixed(HQty * dataArray[i].成本单价 * dataArray[0].汇率, 2)
                                                , 'HlineTotal': dealDoubleToFixed(HQty * dataArray[i].含税单价, 2)
                                                , 'HlineTotalBB': dealDoubleToFixed(HQty * dataArray[i].含税单价 * dataArray[0].汇率, 2)
                                                , "HRemark": ""
                                                , "HSourceInterID": dataArray[i].hmainid
                                                , "HSourceEntryID": dataArray[i].hsubid
                                                , "HSourceBillNo": dataArray[i].单据号
                                                , "HSourceBillType": dataArray[i].HBillType
                                                , "HRelationQty": "0"
                                                , "HRelationMoney": "0"
                                                , 'HPOOrderInterID': "0"
                                                , 'HPOOrderEntryID': "0"
                                                , 'HPOOrderBillNo': ""
                                                , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                                                , "HSeOrderInterID": dataArray[i].HSourceBillType == "1401" ? dataArray[i].HSourceInterID : "0"
                                                , "HSeOrderEntryID": dataArray[i].HSourceBillType == "1401" ? dataArray[i].HSourceEntryID : "0"
                                                , "HSeOrderBillNo": dataArray[i].HSourceBillType == "1401" ? dataArray[i].源单单号 : ""
                                            }
                                        );
                                    }
                                }
                                else {
                                    //子表  èµ‹å€¼
                                    var rowdataEntry = [];
                                    for (var i = 0; i < dataArray.length; i++) {
                                        var HQty = dataArray[i].数量 - dataArray[i].关联数量;                           //数量
                                        rowdataEntry.push(
                                            {
                                                "HMaterID": dataArray[i].HMaterID
                                                , "物料代码": dataArray[i].物料代码
                                                , "物料名称": dataArray[i].物料名称
                                                , "规格型号": dataArray[i].规格型号
                                                , "HUnitID": dataArray[i].hunitid
                                                , "计量单位": dataArray[i].计量单位
                                                , "HQty": dealDoubleToFixed(HQty, 1)
                                                , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                                                , 'HDiscountRate': "1"                                                     //
                                                , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                                                , "HTaxRate": dataArray[i].税率
                                                , 'HTaxMoney': dealDoubleToFixed(HQty * dataArray[i].单价 * dataArray[0].税率, 2)                                                         //
                                                , "HMoney": dealDoubleToFixed(HQty * dataArray[i].单价, 2)
                                                , 'HMoneyBB': dealDoubleToFixed(HQty * dataArray[i].单价 * dataArray[0].汇率, 2)
                                                , 'HlineTotal': dealDoubleToFixed(HQty * dataArray[i].含税单价, 2)
                                                , 'HlineTotalBB': dealDoubleToFixed(HQty * dataArray[i].含税单价 * dataArray[0].汇率, 2)
                                                , "HRemark": ""
                                                , "HSourceInterID": dataArray[i].hmainid
                                                , "HSourceEntryID": dataArray[i].hsubid
                                                , "HSourceBillNo": dataArray[i].单据号
                                                , "HSourceBillType": dataArray[i].HBillType
                                                , "HRelationQty": "0"
                                                , "HRelationMoney": "0"
                                                , 'HPOOrderInterID': "0"
                                                , 'HPOOrderEntryID': "0"
                                                , 'HPOOrderBillNo': ""
                                                , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                                                , "HSeOrderInterID": dataArray[i].HSourceBillType == "1401" ? dataArray[i].HSourceInterID : "0"
                                                , "HSeOrderEntryID": dataArray[i].HSourceBillType == "1401" ? dataArray[i].HSourceEntryID : "0"
                                                , "HSeOrderBillNo": dataArray[i].HSourceBillType == "1401" ? dataArray[i].源单单号 : ""
                                            }
                                        );
                                    }
                                }
                                optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
                                table.render(optionEntry);
                                //子表汇总
                                for (var i = 0; i < rowdataEntry.length; i++) {
                                    var item = rowdataEntry[i];
                                    for (var j = i + 1; j < rowdataEntry.length; j++) {
                                        if (rowdataEntry[j].HMaterID == item.HMaterID) {
                                            rowdataEntry[i].HQty += rowdataEntry[j].HQty;
                                            rowdataEntry[i].HMoney = rowdataEntry[i].HQty * rowdataEntry[i].HPrice//金额=数量*单价
                                            rowdataEntry[i].HTaxMoney = Number((rowdataEntry[i].HMoney * rowdataEntry[i].HTaxRate).toFixed(4))//税额
                                            rowdataEntry[i].HlineTotal = rowdataEntry[i].HMoney + rowdataEntry[i].HTaxMoney //价税合计
                                            var HExRate = $("#HExRate").val();
                                            rowdataEntry[i].HlineTotalBB = Number(((rowdataEntry[i].HMoney + rowdataEntry[i].HTaxMoney) * HExRate).toFixed(4)) //本位币价税合计
                                            rowdataEntry[i].HMoneyBB = Number((rowdataEntry[i].HMoney * HExRate).toFixed(4)) //本位币金额
                                            rowdataEntry.splice(j, 1);
                                            j = j - 1;
                                        }
                                    }
                                }
                                set_InitGridHaveSource();
                                option.data = rowdataEntry;
                                haveSource = true;
                                table.render(option);
                                layer.close(ajaxLoad);
                            } else {
                                layer.close(ajaxLoad);
                                layer.alert(data1.code + data1.Message, { icon: 5 });
                                return;
                            }
                        }, error: function () {
                            layer.close(ajaxLoad);
                            layer.alert("接口请求失败!", { icon: 5 });
                            return;
                        }
                    });
                } else {
                    return layer.msg('当前不支持该源单选择!!');
                }
            }
            //#endregion
            //#endregion
            //#region å­è¡¨åˆå§‹åŒ–
@@ -1689,7 +2161,7 @@
                    , "HQty": "0"
                    , "HPrice": "0"
                    , "HTaxPrice": "0"
                    , 'HDiscountRate': "0"
                    , 'HDiscountRate': "1"
                    , 'HRelTaxPrice': "0"
                    , "HTaxRate": "0"
                    , 'HTaxMoney': "0"
@@ -2008,8 +2480,8 @@
                                , "HQty": dealDoubleToFixed(dataArray[i].数量, 1)
                                , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                                , 'HDiscountRate': "0"                                                     //
                                , 'HRelTaxPrice': "0"
                                , 'HDiscountRate': "1"                                                     //
                                , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                                , "HTaxRate": dataArray[i].税率
                                , 'HTaxMoney': "0"                                                         //
                                , "HMoney": dealDoubleToFixed(dataArray[i].金额, 2)
@@ -2089,8 +2561,8 @@
                                , "HQty": dealDoubleToFixed(dataArray[i].数量, 1)
                                , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                                , 'HDiscountRate': "0"                                                     //
                                , 'HRelTaxPrice': "0"
                                , 'HDiscountRate': "1"                                                     //
                                , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                                , "HTaxRate": dataArray[i].税率
                                , 'HTaxMoney': "0"                                                         //
                                , "HMoney": dealDoubleToFixed(dataArray[i].数量 * dataArray[i].单价, 2)
@@ -2315,13 +2787,14 @@
                        return false;
                    }
                    //价税合计格式校验
                    //税额格式校验
                    temp = option.data[i]["HTaxMoney"] + "";
                    if (temp == "0") {
                        layer.msg("第" + (i + 1) + "行:价税合计不能为0!");
                        return false;
                    } else if (!ref.test(temp)) {
                        layer.msg("第" + (i + 1) + "行:价税合计请输入大于0的数字!");
                    //if (temp == "0") {
                    //    layer.msg("第" + (i + 1) + "行:税额不能为0!");
                    //    return false;
                    //} else
                    if (!ref.test(temp)) {
                        layer.msg("第" + (i + 1) + "行:税额请输入不小于0的数字!");
                        return false;
                    }
@@ -2367,11 +2840,13 @@
                                    if (typeof (OptionData.HItemID) != "undefined") {
                                        //通过供应商id获取税率
                                        var HSupID = $("#HCusID").val();
                                        var Dec = getDecByMaterID(obj.data.HMaterID) //获取精度
                                        var HQtyDec = (Dec["HQtyDec"] == null || Dec["HQtyDec"] == 0) ? 4 : Dec["HQtyDec"];  //数量精度
                                        var HPriceDec = (Dec["HPriceDec"] == null || Dec["HPriceDec"] == 0) ? 4 : Dec["HPriceDec"];  //单价精度
                                        var HMoneyDec = (Dec["HMoneyDec"] == null || Dec["HMoneyDec"] == 0) ? 2 : Dec["HMoneyDec"];  //金额精度
                                        var HPrice = obj.data.HPrice * 1;
                                        var HTaxRate = obj.data.HTaxRate*0.01;
                                        if (HSupID != 0) {
                                            var Dec = getDecByMaterID(obj.data.HMaterID) //获取精度
                                            var HQtyDec = (Dec["HQtyDec"] == null || Dec["HQtyDec"] == 0) ? 4 : Dec["HQtyDec"];  //数量精度
                                            var HPriceDec = (Dec["HPriceDec"] == null || Dec["HPriceDec"] == 0) ? 4 : Dec["HPriceDec"];  //单价精度
                                            var HMoneyDec = (Dec["HMoneyDec"] == null || Dec["HMoneyDec"] == 0) ? 2 : Dec["HMoneyDec"];  //金额精度
                                            $.ajax({
                                                url: GetWEBURL() + "/Gy_Customer/xg",
                                                //url: "http://localhost:12761/Gy_Supplier/xg",
@@ -2380,63 +2855,51 @@
                                                    "HInterID": HSupID
                                                },
                                                success: function (d) {
                                                    var HTaxRate = parseInt(d.data[0].增值税率) * 0.01;
                                                    var HExRate = $("#HExRate").val();                      //汇率
                                                    //数据校验合格,重算记录
                                                    var HQty = obj.data.HQty * 1;                           //数量
                                                    var HPrice = obj.data.HPrice * 1;               //单价
                                                    var HMoney = HQty * HPrice;                     //金额=数量*单价
                                                    var HTaxMoney = Number((HMoney * HTaxRate));         //税额=金额*税率
                                                    var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                                                    var HTaxPrice = Number((HPrice * (1 + HTaxRate)));        //含税单价=单价*(1+税率)
                                                    var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));     //本位币价税合计=(税额+金额)*汇率
                                                    var HDiscountRate = obj.data.HDiscountRate * 1;   //折扣率
                                                    var HRelTaxPrice = Number((HTaxPrice * HDiscountRate));   //实际含税单价=含税单价*折扣率
                                                    var HExRate = $("#HExRate").val();                      //汇率
                                                    var HMoneyBB = HMoney * HExRate;
                                                    ///数字精度
                                                    HQty = Number(HQty.toFixed(HQtyDec));
                                                    HPrice = Number(HPrice.toFixed(HPriceDec));
                                                    HMoney = Number(HMoney.toFixed(HMoneyDec));
                                                    HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
                                                    HMoneyBB = Number(HMoneyBB.toFixed(HMoneyDec));
                                                    HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                                                    HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
                                                    HRelTaxPrice = Number(HRelTaxPrice.toFixed(HPriceDec));
                                                    HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
                                                    obj.update({ //更新表格数据
                                                        "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                                        , "物料代码": OptionData.物料代码
                                                        , "物料名称": OptionData.物料名称
                                                        , "规格型号": OptionData.规格型号
                                                        , "HUnitID": OptionData.HUnitID
                                                        , "计量单位": OptionData.计量单位名称
                                                        , "HTaxRate": HTaxRate * 100
                                                        , HQty: HQty                          //更新HQty字段,HQty
                                                        , HPrice: HPrice                     //更新HPrice字段,HPrice
                                                        , HMoney: HMoney                      //更新HMoney字段,HMoney
                                                        , HTaxMoney: HTaxMoney                  //更新HTaxMoney字段,HTaxMoney
                                                        , HlineTotal: HlineTotal             //更新HlineTotal字段,HlineTotal
                                                        , HTaxPrice, HTaxPrice                   //更新HTaxPrice字段,HTaxPrice
                                                        , HRelTaxPrice: HRelTaxPrice            //更新HRelTaxPrice字段,其值来自变量HRelTaxPrice
                                                        , HlineTotalBB: HlineTotalBB              //更新HlineTotalBB字段,其值来自变量HlineTotalBB
                                                        , HMoneyBB: HMoneyBB
                                                    })
                                                    OptionData = [];
                                                   HTaxRate = parseInt(d.data[0].增值税率) * 0.01;
                                                }
                                            });
                                        } else {
                                            obj.update({ //更新表格数据
                                                "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                                , "物料代码": OptionData.物料代码
                                                , "物料名称": OptionData.物料名称
                                                , "规格型号": OptionData.规格型号
                                                , "HUnitID": OptionData.HUnitID
                                                , "计量单位": OptionData.计量单位名称
                                            })
                                            OptionData = [];
                                        }
                                        var HExRate = $("#HExRate").val();                      //汇率
                                        //数据校验合格,重算记录
                                        var HQty = obj.data.HQty * 1;                           //数量
                                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                                        var HTaxMoney = Number((HMoney * HTaxRate));         //税额=金额*税率
                                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                                        var HTaxPrice = Number((HPrice * (1 + HTaxRate)));        //含税单价=单价*(1+税率)
                                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));     //本位币价税合计=(税额+金额)*汇率
                                        var HDiscountRate = obj.data.HDiscountRate * 1;   //折扣率
                                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate));   //实际含税单价=含税单价*折扣率
                                        var HMoneyBB = HMoney * HExRate;
                                        ///数字精度
                                        HQty = Number(HQty.toFixed(HQtyDec));
                                        HPrice = Number(HPrice.toFixed(HPriceDec));
                                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                                        HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
                                        HMoneyBB = Number(HMoneyBB.toFixed(HMoneyDec));
                                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                                        HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
                                        HRelTaxPrice = Number(HRelTaxPrice.toFixed(HPriceDec));
                                        HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
                                        obj.update({ //更新表格数据
                                            "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                            , "物料代码": OptionData.物料代码
                                            , "物料名称": OptionData.物料名称
                                            , "规格型号": OptionData.规格型号
                                            , "HUnitID": OptionData.HUnitID
                                            , "计量单位": OptionData.计量单位名称
                                            , "HTaxRate": HTaxRate * 100
                                            , HQty: HQty                          //更新HQty字段,HQty
                                            , HPrice: HPrice                     //更新HPrice字段,HPrice
                                            , HMoney: HMoney                      //更新HMoney字段,HMoney
                                            , HTaxMoney: HTaxMoney                  //更新HTaxMoney字段,HTaxMoney
                                            , HlineTotal: HlineTotal             //更新HlineTotal字段,HlineTotal
                                            , HTaxPrice, HTaxPrice                   //更新HTaxPrice字段,HTaxPrice
                                            , HRelTaxPrice: HRelTaxPrice            //更新HRelTaxPrice字段,其值来自变量HRelTaxPrice
                                            , HlineTotalBB: HlineTotalBB              //更新HlineTotalBB字段,其值来自变量HlineTotalBB
                                            , HMoneyBB: HMoneyBB
                                        })
                                        OptionData = [];
                                    }
                                }
                            })
@@ -2509,9 +2972,14 @@
                        }
                        , end: function () {
                            if (typeof (OptionData.HItemID) != "undefined") {
                                //通过供应商id获取税率
                                var HSupID = $("#HCusID").val();
                                var Dec = getDecByMaterID(obj.data.HMaterID) //获取精度
                                var HQtyDec = (Dec["HQtyDec"] == null || Dec["HQtyDec"] == 0) ? 4 : Dec["HQtyDec"];  //数量精度
                                var HPriceDec = (Dec["HPriceDec"] == null || Dec["HPriceDec"] == 0) ? 4 : Dec["HPriceDec"];  //单价精度
                                var HMoneyDec = (Dec["HMoneyDec"] == null || Dec["HMoneyDec"] == 0) ? 2 : Dec["HMoneyDec"];  //金额精度
                                var HPrice = obj.data.HPrice * 1;
                                var HTaxRate = obj.data.HTaxRate*0.01;
                                if (HSupID != 0) {
                                    $.ajax({
                                        url: GetWEBURL() + "/Gy_Customer/xg",
@@ -2521,46 +2989,52 @@
                                            "HInterID": HSupID
                                        },
                                        success: function (d) {
                                            var HTaxRate = parseInt(d.data[0].增值税率) * 0.01;
                                            var HExRate = $("#HExRate").val();                      //汇率
                                            //数据校验合格,重算记录
                                            var HQty = obj.data.HQty * 1;                           //数量
                                            var HPrice = obj.data.HPrice * 1;               //单价
                                            var HMoney = HQty * HPrice;                     //金额=数量*单价
                                            var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //税额=金额*税率
                                            var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                                            var HTaxPrice = Number((HPrice * (1 + HTaxRate)).toFixed(4));        //含税单价=单价*(1+税率)
                                            var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate).toFixed(4));     //本位币价税合计=(税额+金额)*汇率
                                            obj.update({ //更新表格数据
                                                "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                                , "物料代码": OptionData.物料代码
                                                , "物料名称": OptionData.物料名称
                                                , "规格型号": OptionData.规格型号
                                                , "HUnitID": OptionData.HUnitID
                                                , "计量单位": OptionData.计量单位名称
                                                , "HTaxRate": HTaxRate * 100
                                                , HQty: HQty                               //更新HQty字段,HQty
                                                , HPrice: HPrice                         //更新HPrice字段,HPrice
                                                , HMoney: HMoney                      //更新HMoney字段,HMoney
                                                , HTaxMoney: HTaxMoney                  //更新HTaxMoney字段,HTaxMoney
                                                , HlineTotal: HlineTotal             //更新HlineTotal字段,HlineTotal
                                                , HTaxPrice, HTaxPrice                   //更新HTaxPrice字段,HTaxPrice
                                                , HlineTotalBB: HlineTotalBB              //更新HlineTotalBB字段,其值来自变量HlineTotalBB
                                            })
                                            OptionData = [];
                                            HTaxRate = parseInt(d.data[0].增值税率) * 0.01;
                                        }
                                    });
                                } else {
                                    obj.update({ //更新表格数据
                                        "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                        , "物料代码": OptionData.物料代码
                                        , "物料名称": OptionData.物料名称
                                        , "规格型号": OptionData.规格型号
                                        , "HUnitID": OptionData.HUnitID
                                        , "计量单位": OptionData.计量单位名称
                                    })
                                    OptionData = [];
                                }
                                var HExRate = $("#HExRate").val();                      //汇率
                                //数据校验合格,重算记录
                                var HQty = obj.data.HQty * 1;                           //数量
                                var HMoney = HQty * HPrice;                     //金额=数量*单价
                                var HTaxMoney = Number((HMoney * HTaxRate));         //税额=金额*税率
                                var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                                var HTaxPrice = Number((HPrice * (1 + HTaxRate)));        //含税单价=单价*(1+税率)
                                var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));     //本位币价税合计=(税额+金额)*汇率
                                var HDiscountRate = obj.data.HDiscountRate * 1;   //折扣率
                                var HRelTaxPrice = Number((HTaxPrice * HDiscountRate));   //实际含税单价=含税单价*折扣率
                                var HExRate = $("#HExRate").val();                      //汇率
                                var HMoneyBB = HMoney * HExRate;
                                ///数字精度
                                HQty = Number(HQty.toFixed(HQtyDec));
                                HPrice = Number(HPrice.toFixed(HPriceDec));
                                HMoney = Number(HMoney.toFixed(HMoneyDec));
                                HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
                                HMoneyBB = Number(HMoneyBB.toFixed(HMoneyDec));
                                HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                                HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
                                HRelTaxPrice = Number(HRelTaxPrice.toFixed(HPriceDec));
                                HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
                                obj.update({ //更新表格数据
                                    "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                    , "物料代码": OptionData.物料代码
                                    , "物料名称": OptionData.物料名称
                                    , "规格型号": OptionData.规格型号
                                    , "HUnitID": OptionData.HUnitID
                                    , "计量单位": OptionData.计量单位名称
                                    , "HTaxRate": HTaxRate * 100
                                    , HQty: HQty                          //更新HQty字段,HQty
                                    , HPrice: HPrice                     //更新HPrice字段,HPrice
                                    , HMoney: HMoney                      //更新HMoney字段,HMoney
                                    , HTaxMoney: HTaxMoney                  //更新HTaxMoney字段,HTaxMoney
                                    , HlineTotal: HlineTotal             //更新HlineTotal字段,HlineTotal
                                    , HTaxPrice, HTaxPrice                   //更新HTaxPrice字段,HTaxPrice
                                    , HRelTaxPrice: HRelTaxPrice            //更新HRelTaxPrice字段,其值来自变量HRelTaxPrice
                                    , HlineTotalBB: HlineTotalBB              //更新HlineTotalBB字段,其值来自变量HlineTotalBB
                                    , HMoneyBB: HMoneyBB
                                })
                                OptionData = [];
                            }
                        }
                    })
@@ -2974,8 +3448,8 @@
                                , "HQty": dealDoubleToFixed(dataArray[i].数量, 1)
                                , "HPrice": dealDoubleToFixed(dataArray[i].HNoTaxCost, 3)
                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].HTaxCost, 3)
                                , 'HDiscountRate': "0"                                                     //
                                , 'HRelTaxPrice': "0"
                                , 'HDiscountRate': "1"                                                     //
                                , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].HTaxCost, 3)
                                , "HTaxRate": dataArray[i].税率
                                , 'HTaxMoney': "0"                                                         //
                                , "HMoney": dealDoubleToFixed(dataArray[i].数量 * dataArray[i].HNoTaxCost, 2)
@@ -3017,8 +3491,8 @@
                                , "HQty": dealDoubleToFixed(dataArray[i].数量, 1)
                                , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].HTaxPrice, 3)
                                , 'HDiscountRate': "0"                                                     //
                                , 'HRelTaxPrice': "0"
                                , 'HDiscountRate': "1"                                                     //
                                , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].HTaxPrice, 3)
                                , "HTaxRate": dataArray[i].税率
                                , 'HTaxMoney': "0"                                                         //
                                , "HMoney": dealDoubleToFixed(dataArray[i].金额, 2)
@@ -3046,7 +3520,7 @@
                        );
                    }
                }
                optionEntry.data = rowdataEntry;
                optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
                table.render(optionEntry);
                //子表汇总
                for (var i = 0; i < rowdataEntry.length; i++) {
@@ -3119,15 +3593,15 @@
                    , "HEmpName": dataArray[0].业务员
                    , "HCusID": dataArray[0].hsupid
                    , "HCusName": dataArray[0].客户
                    , "HCurID": dataArray[0].HCurID
                    , "HCurName": dataArray[0].币别
                    , "HExRate": dataArray[0].汇率
                    , "HCurID": dataArray[0].主表币别id
                    , "HCurName": dataArray[0].主表币别
                    , "HExRate": dataArray[0].主表汇率
                    , "HSSID": "0"
                    , "HSSName": ""
                    , "HSellSID": dataArray[0].HSellSID
                    , "HSellSName": dataArray[0].销售方式
                });
                if ($("#HPriceType").val() == "成本价") {
                if ($("#HPriceType").val() == "去税价") {
                    //子表  èµ‹å€¼
                    var rowdataEntry = [];
                    for (var i = 0; i < dataArray.length; i++) {
@@ -3142,8 +3616,8 @@
                                , "HQty": dealDoubleToFixed(dataArray[i].数量, 1)
                                , "HPrice": dealDoubleToFixed(dataArray[i].成本单价, 3)
                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                                , 'HDiscountRate': "0"                                                     //
                                , 'HRelTaxPrice': "0"
                                , 'HDiscountRate': "1"                                                     //
                                , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                                , "HTaxRate": dataArray[i].税率
                                , 'HTaxMoney': "0"                                                         //
                                , "HMoney": dealDoubleToFixed(dataArray[i].数量 * dataArray[i].成本单价, 2)
@@ -3186,8 +3660,8 @@
                                , "HQty": dealDoubleToFixed(dataArray[i].数量, 1)
                                , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                                , 'HDiscountRate': "0"                                                     //
                                , 'HRelTaxPrice': "0"
                                , 'HDiscountRate': "1"                                                     //
                                , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                                , "HTaxRate": dataArray[i].税率
                                , 'HTaxMoney': "0"                                                         //
                                , "HMoney": dealDoubleToFixed(dataArray[i].数量 * dataArray[i].单价, 2)
@@ -3216,7 +3690,7 @@
                    }
                }
                
                optionEntry.data = rowdataEntry;
                optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
                table.render(optionEntry);
                //子表汇总
                for (var i = 0; i < rowdataEntry.length; i++) {
@@ -3299,7 +3773,7 @@
            function getDecByMaterID(HMaterID) {
                var resultData = {};
                $.ajax({  // å¼‚步请求
                    url: GetWEBURL() + "Gy_Material/getDecByID",  //请求地址
                    url: GetWEBURL() + "/Gy_Material/getDecByID",  //请求地址
                    async: false,   //是否开启异步
                    type: "GET",   //请求类型
                    data: {   //定义发送到服务器的数据