1
duhe
2025-06-16 df3e719955cc93b4e762ac75fbb61737fbf3b7a8
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>
@@ -54,7 +55,8 @@
                        <h1 style="text-align: center; padding: 10px 0;"><b>应收单</b></h1>
                        <ul class="layui-tab-title" lay-filter="tab-all">
                            <li lay-id="1" style="padding:1px;" class="layui-this">基本信息</li>
                            <li lay-id="2" style="padding:1px;">制单信息</li>
                            <li lay-id="2" style="padding:1px;">其他信息</li>
                            <li lay-id="3" style="padding:1px;">制单信息</li>
                        </ul>
                        <div class="layui-tab-content">
                            <!--基本信息-->
@@ -64,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>
@@ -81,9 +83,9 @@
                                                    <!--动态渲染源单类型-->
                                                </select>
                                                <!--<select name="BillType" id="BillType" lay-filter="BillType" style="width: 180px; ">
                                                    <option style="color:blue;" selected="selected" value="1401">销售订单</option>
                                                    <option style="color:blue;" value="1205">销售出库单</option>
                                                </select>-->
                    <option style="color:blue;" selected="selected" value="1401">销售订单</option>
                    <option style="color:blue;" value="1205">销售出库单</option>
                </select>-->
                                            </div>
                                        </div>
                                        <div class="layui-inline">
@@ -92,7 +94,7 @@
                                                <input type="hidden" name="HMainSourceInterID" id="HMainSourceInterID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <input type="hidden" name="HMainSourceEntryID" id="HMainSourceEntryID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <input type="hidden" name="HMainSourceBillType" id="HMainSourceBillType" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="text" name="HMainSourceBillNo" id="HMainSourceBillNo" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                                <input type="text" name="HMainSourceBillNo" id="HMainSourceBillNo" class="layui-input" value="" style="float: left; width: 150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HMainSource" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
@@ -101,33 +103,23 @@
                                    </div>
                                    <div class="layui-row">
                                        <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="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>
                                                </button>-->
                                            </div>
                                        </div>
                                        <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="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;">
                                                <input type="text" name="HDeptName" id="HDeptName" class="layui-input" value="" style="background-color: #efefef4d; float: left; width: 150px;" readonly>
                                                <input type="hidden" name="HDeptID" id="HDeptID" class="layui-input" value="0" style="float: left; width: 110px;">
                                                <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>
                                                </button>-->
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">主管</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HMangerName" id="HMangerName" class="layui-input" value="" style="background-color:#efefef4d;" readonly>
                                                <input type="text" name="HMangerName" id="HMangerName" class="layui-input" value="" style="background-color: #efefef4d; float: left; width: 150px;" readonly>
                                                <input type="hidden" name="HMangerID" id="HMangerID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <!--<button type="button" lay-submit="" class="layui-btn" lay-filter="HManagerList" style="width:40px;">
                                                <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>
                                                </button>-->
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
@@ -136,63 +128,27 @@
                                                <input type="text" name="HCusName" id="HCusName" class="layui-input" value="" style="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>
                                                </button>-->
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">币别</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HCurName" id="HCurName" class="layui-input" value="" style="background-color:#efefef4d;" readonly>
                                                <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>
                </button>-->
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <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" style="background-color: #efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <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="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>
                </button>-->
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">结算方式</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HSSName" id="HSSName" class="layui-input" value="" style="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>
                </button>-->
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">收款日期<label style="color:red"> * </label></label>
                                            <div class="layui-input-block">
                                                <input type="date" class="layui-input" lay-verify="HReceiveDate" name="HReceiveDate" id="HReceiveDate" style="width:190px;">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <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="结算价">结算价</option>
                                                    <option value="去税价">去税价</option>
                                                    <option value="结算价" selected="selected">结算价</option>
                                                    <option value="含税价">含税价</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">项目名称</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HProjectName" id="HProjectName" class="layui-input" lay-filter="HProjectName" value="" style="background-color:#efefef4d;" readonly>
                                                <input type="hidden" name="HProjectID" id="HProjectID" class="layui-input" value="0" style="float:left;width:150px;">
                                            </div>
                                        </div>
                                    </div>
@@ -204,16 +160,7 @@
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row" style="margin-top:10px;">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">组织<label style="color:red"> * </label></label>
                                            <div class="layui-input-block" style="margin-left: 120px; width: 501px;">
                                                <select name="HOrgID" id="HOrgID" lay-verify="HOrgID">
                                                    <!--动态渲染组织-->
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <!--隐藏字段-->
                                    <div class="layui-row" style="display:none;">
@@ -233,6 +180,81 @@
                                            <label class="layui-form-label">内部单据号</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HInnerBillNo" id="HInnerBillNo" value="" autocomplete="off">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <!--其它信息-->
                            <div class="layui-tab-item">
                                <div class="layui-form-item" style="padding-top: 10px;">
                                    <div class="layui-row">
                                        <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="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>
            </button>-->
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">币别</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HCurName" id="HCurName" class="layui-input" value="" style="background-color:#efefef4d;" readonly>
                                                <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>
            </button>-->
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <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" style="background-color: #efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">收款日期<label style="color:red"> * </label></label>
                                            <div class="layui-input-block">
                                                <input type="date" class="layui-input" lay-verify="HReceiveDate" name="HReceiveDate" id="HReceiveDate" style="width:190px;">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <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="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>
            </button>-->
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">结算方式</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HSSName" id="HSSName" class="layui-input" value="" style="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>
            </button>-->
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row" style="margin-top:10px;">
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">组织<label style="color:red"> * </label></label>
                                            <div class="layui-input-block" style="margin-left: 120px; width: 501px;">
                                                <select name="HOrgID" id="HOrgID" lay-verify="HOrgID">
                                                    <!--动态渲染组织-->
                                                </select>
                                            </div>
                                        </div>
                                    </div>
@@ -377,7 +399,7 @@
            window.OptionData = [];
            //记录组织的值
            var HOrgIDBar = 0;
            var topScroll = 0;//记录滚动条的位置
        //#region ã€åŠ¨æ€èŽ·å–æ¨¡å—åç§°ã€‘
            var HModuleType = "1426";
@@ -471,6 +493,12 @@
            });
            //#endregion
            //#region é€‰æ•´å•
            form.on('submit(set_SelectMainBill)', function (data) {
                set_SelectMainBill();
            });
            //#endregion
            //#region ä¿å­˜æŒ‰é’®
            form.on('submit(Saver)', function (data) {
                //#region åˆ¤æ–­æºå•状态
@@ -524,9 +552,9 @@
                }
                //#endregion
                //if (AllowLoadData(data)) {
                if (AllowLoadData(data)) {
                    set_SaveBill(data);
                //}
                }
            });
            //#endregion
            //#endregion
@@ -580,6 +608,243 @@
            });
            //#endregion
            //#region å›žè½¦é€‰æ‹©æºå•
            $('#HMainSourceBillNo').on('keydown', function (event) {
                var HSourceBillNo = $('#HMainSourceBillNo').val();//(源单单据号)
                if (event.keyCode == 13) {
                    var ajaxLoad = layer.load();
                    var url;
                    //判断文本框是否有数据    new
                    if (HSourceBillNo == "") {
                        layer.close(ajaxLoad);
                        return;
                    }
                    if ($("#BillType").val() == "1401") {
                        //源单类型是销售订单
                        url = "/Xs_SeOrderBill/PushList";
                    } else if ($("#BillType").val() == "1205") {
                        //源单类型是销售出库单
                        url = "/Kf_SellOutBill/PushList";
                    }
                    $.ajax({
                        url: GetWEBURL() + url,
                        type: "GET",
                        data: { "HBillNo": HSourceBillNo, "user": sessionStorage["HUserName"] },
                        success: function (result) {
                            if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                                var dataArray = result.data;
                                if ($("#BillType").val() == "1401") {
                                    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].销售方式
                                        , "HProjectID": (dataArray[0].HProjectID == null ? 0 : dataArray[0].HProjectID)
                                        , "HProjectName": (dataArray[0].项目名称)
                                    });
                                        //子表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;
                                } else if ($("#BillType").val() == "1205") {
                                    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].HCurID
                                        , "HCurName": dataArray[0].币别
                                        , "HExRate": dataArray[0].汇率
                                        , "HSSID": "0"
                                        , "HSSName": ""
                                        , "HSellSID": dataArray[0].HSellSID
                                        , "HSellSName": dataArray[0].销售方式
                                        , "HProjectName": dataArray[0].项目名称
                                        , "HProjectID": (dataArray[0].HProjectID == null ? 0 : dataArray[0].HProjectID)
                                    });
                                    //子表  èµ‹å€¼
                                    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);
                                changeHPrice();
                                layer.close(ajaxLoad);
                                layer.msg("查询成功", { time: 1 * 1000, icon: 1 });
                            } else {
                                layer.alert(result.Message, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                                layer.close(ajaxLoad);
                            }
                        }, error: function () {
                            layer.alert(result.Message + "发生错误!", { icon: 5 });
                            layer.close(ajaxLoad);
                        }
                    });
                }
            });
            //#endregion
            //#endregion
            //#region å¤é€‰æ¡†çŠ¶æ€å˜æ›´
@@ -601,7 +866,7 @@
                    , "HQty": "0"
                    , "HPrice": "0"
                    , "HTaxPrice": "0"
                    , 'HDiscountRate': "0"
                    , 'HDiscountRate': "1"
                    , 'HRelTaxPrice': "0"
                    , "HTaxRate": "0"
                    , 'HTaxMoney': "0"
@@ -669,11 +934,13 @@
            table.on('edit(mainTable)', function (obj) {
                //数值格式校验工具
                var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                var ref1 = /^-?\d+(\.\d+)?$/;          //判断字符串是否为数字(包含整数、浮点数),正则表达式
                var temp = "";
                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"];  //金额精度
                topScroll = $('#mainTable').next('.layui-table-view').find('.layui-table-body').scrollTop();//获取滚动条位置
                // å•元格编辑之前的值
                var oldText = $(this).prev().text();
                var value = obj.value //得到修改后的值
@@ -685,14 +952,23 @@
                    case "HQty":                                                       //数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp) || temp == 0) {
                        if (!ref1.test(temp)) {
                            //恢复数据到编辑前
                            obj.update({
                                HQty: oldText
                            });
                            table.render(option);
                            layer.msg("数量请输入大于0的数字!");
                            layer.msg("数量请输入不为0的数字!");
                            return;
                        } else if (temp * 1 == 0) {
                            //恢复数据到编辑前
                            obj.update({
                                HQty: oldText
                            });
                            table.render(option);
                            layer.msg("数量请输入不为0的数字!");
                            return;
                        }
@@ -884,6 +1160,7 @@
                            , HDiscountRate: HDiscountRate                  //更新HDiscountRate字段,其值来自变量HDiscountRate
                            , HRelTaxPrice: HRelTaxPrice                  //更新HRelTaxPrice字段,其值来自变量HRelTaxPrice
                        });
                        table.render(option);
                        break;
                    case "HTaxPrice":                                                       //含税单价
                        //数据格式校验
@@ -937,10 +1214,130 @@
                        });
                        table.render(option)
                        break;
                    case "HMoney":                                                       //金额
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp) || temp == 0 || obj.data.HQty == 0) {
                            //恢复数据到编辑前
                            obj.update({
                                HMoney: oldText
                            });
                            table.render(option);
                            layer.msg("数量或金额请输入大于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HQty = obj.data.HQty * 1;                   //数量
                        var HMoney = value * 1;                     //金额=数量*单价
                        var HPrice = HMoney / HQty;                //单价
                        var HTaxRate = obj.data.HTaxRate * 0.01;           //税率
                        var HTaxMoney = Number((HMoney * HTaxRate));         //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        var HTaxPrice = Number((HPrice * (1 + HTaxRate)));        //含税单价=单价*(1+税率)
                        var HDiscountRate = obj.data.HDiscountRate * 1;   //折扣率
                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate));   //实际含税单价=含税单价*折扣率
                        var HExRate = $("#HExRate").val();                      //汇率
                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));     //本位币价税合计=(税额+金额)*汇率
                        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({
                            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
                        });
                        table.render(option);
                        break;
                    default:
                }
            });
            //#endregion
            //#region ä¸‹æ‹‰æ¡†äº‹ä»¶
            // ç›‘听下拉框选择
            form.on('select(HPriceType)', function (data) {
                console.log(data.value); // å¾—到被选中的值
                changeHPrice();
            });
            //根据下拉框的值设置物料单价等信息
            function changeHPrice() {
                //#region å­è¡¨ æ•°æ®æ£€éªŒ
                for (var i = 0; i < option.data.length; i++) {
                    if (option.data[i]["HMaterID"] == "0" || option.data[i]["HMaterID"] == "" || option.data[i]["HMaterID"] == undefined) {
                        layer.msg("第" + (i + 1) + "行:物料未选择!");
                        return false;
                    } else {
                        var HPrice = option.data[i]["HPrice"];
                        var HMaterID = option.data[i]["HMaterID"];
                        var HType = $("#HPriceType").val();
                        //获取物料对应单价类型的单价
                        $.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
@@ -1067,19 +1464,19 @@
                    , area: ['90%', '90%']//大小
                    , title: '销售部门列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_DepartmentList.html', 'yes']
                    //, btn: ['确定', '取消']
                    //, btn1: function (index, layero) {//按钮【按钮一】的回调
                    //    var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                    //    var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                    //    if (checkStatus.data.length === 0) {
                    //        return layer.msg('请选择数据');
                    //    }
                    //    $("#HDeptName").val(checkStatus.data[0].HName);
                    //    $("#HDeptID").val(checkStatus.data[0].HItemID);
                    //    layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    //}
                    //, btn2: function (index, layero) { }
                    , content: ['../../基础资料/公用基础资料/Gy_DepartmentList.html', 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                        var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HDeptName").val(checkStatus.data[0].部门名称);
                        $("#HDeptID").val(checkStatus.data[0].HItemID);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
                })
            }
            //#endregion
@@ -1092,19 +1489,19 @@
                    , area: ['90%', '90%']//大小
                    , title: '销售主管列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_EmployeeList.html?Type=HManager', 'yes']
                    //, btn: ['确定', '取消']
                    //, btn1: function (index, layero) {//按钮【按钮一】的回调
                    //    var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                    //    var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                    //    if (checkStatus.data.length === 0) {
                    //        return layer.msg('请选择数据');
                    //    }
                    //    $("#HManagerName").val(checkStatus.data[0].HName);
                    //    $("#HManagerID").val(checkStatus.data[0].HItemID);
                    //    layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    //}
                    //, btn2: function (index, layero) { }
                    , content: ['../../基础资料/公用基础资料/Gy_EmployeeList.html?Type=HManager', 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                        var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HMangerName").val(checkStatus.data[0].职员名称);
                        $("#HMangerID").val(checkStatus.data[0].HItemID);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
                })
            }
            //#endregion
@@ -1257,7 +1654,17 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        var HCusID = $("#HCusID").val();//判断客户
                        if (HCusID == 0 || HCusID == '') {
                            HCusID = checkStatus.data[0]["HCusID"];
                        }
                        for (var i = 0; i < checkStatus.data.length; i++) {
                            if (checkStatus.data[i]["HCusID"] != HCusID) {
                                layer.msg("下推失败!已经选中的记录中存在不同客户!");
                                layer.close(index);
                                return;
                            }
                        }
                        if ($("#BillType").val() == "1401") {
                            setInitBySeOrderBill(checkStatus);
                        }
@@ -1265,13 +1672,318 @@
                        {
                            setInitBySellOutBill(checkStatus);
                        }
                        changeHPrice();
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
                })
            }
            //#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);
                        changeHPrice();
                        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].销售方式
                                    , "HProjectName": dataArray[0].项目名称
                                    , "HProjectID": (dataArray[0].HProjectID == null ? 0 : dataArray[0].HProjectID)
                                });
                                //子表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",
                        async: false,
                        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].销售方式
                                    , "HProjectID": (dataArray[0].HProjectID == null ? 0 : dataArray[0].HProjectID)
                                    , "HProjectName": dataArray[0].项目名称
                                });
                                    //子表  èµ‹å€¼
                                var rowdataEntry = [];
                                for (var i = 0; i < dataArray.length; i++) {
                                    var HQty = dataArray[i].数量*1 - 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 å­è¡¨åˆå§‹åŒ–
@@ -1293,13 +2005,13 @@
                        , { field: 'HUnitID', title: 'HUnitID', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: '计量单位', title: '计量单位', width: 100, edit: 'text', event: "HUnitID"}//f7
                        , { field: 'HQty', title: '数量', width: 100, totalRow: true, edit: 'text', event: "HQty" }
                        , { field: 'HPrice', title: '单价', width: 100, edit: 'text', event: "HPrice" }
                        , { field: 'HPrice', title: '单价', width: 100, event: "HPrice", style: 'background-color:#efefef4d;' }
                        , { field: 'HTaxPrice', title: '含税单价', width: 100, edit: 'text', event: "HTaxPrice" }
                        , { field: 'HDiscountRate', title: '折扣率', width: 100, edit: 'text' }
                        , { field: 'HRelTaxPrice', title: '实际含税单价', width: 100, edit: 'text' }
                        , { field: 'HTaxRate', title: '税率', width: 100, edit: 'text' }
                        , { field: 'HTaxMoney', title: '税额', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HMoney', title: '金额', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HMoney', title: '金额', width: 100, totalRow: true, edit: 'text' }
                        , { field: 'HMoneyBB', title: '本位币金额', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HlineTotal', title: '价税合计', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HlineTotalBB', title: '本位币价税合计', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
@@ -1322,6 +2034,9 @@
                        , { field: 'HSeOrderBillNo', title: '销售订单号', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 70 }
                    ]]
                    , done: function (res, curr, count) {
                        $(".layui-table-main").scrollTop(topScroll);
                    }
                }
                var rowdata = [{
@@ -1334,7 +2049,7 @@
                    , "HQty": "0"
                    , "HPrice": "0"
                    , "HTaxPrice": "0"
                    , 'HDiscountRate': "0"
                    , 'HDiscountRate': "1"
                    , 'HRelTaxPrice': "0"
                    , "HTaxRate": "0"
                    , 'HTaxMoney': "0"
@@ -1410,52 +2125,11 @@
                table.render(optionEntry);
            }
            function set_InitGridHaveSource() {
                option = {
                    elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , totalRow: true
                    , limit: 500
                    , height: 500
                    , loading: false
                    , cols: [[ //子表
                        { type: 'checkbox', totalRowText: '合计行' }
                        , { type: 'numbers', title: '序号', width: 100 }
                        , { 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, 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, edit: 'text', event: "HUnitID" }//f7
                        , { field: 'HQty', title: '数量', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HPrice', title: '单价', width: 100, edit: 'text', event: "HPrice" }
                        , { field: 'HMoney', title: '金额', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HTaxPrice', title: '含税单价', width: 100, edit: 'text', event: "HTaxPrice" }
                        , { field: 'HDiscountRate', title: '折扣率', width: 100, edit: 'text' }
                        , { field: 'HRelTaxPrice', title: '实际含税单价', width: 100, edit: 'text' }
                        , { field: 'HTaxRate', title: '税率', width: 100, edit: 'text' }
                        , { field: 'HTaxMoney', title: '税额', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HMoneyBB', title: '本位币金额', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HlineTotal', title: '价税合计', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HlineTotalBB', title: '本位币价税合计', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HRemark', title: '备注', width: 100, edit: 'text' }
                        , { field: 'HSourceInterID', title: '源单内码', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HSourceEntryID', title: '源单子内码', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HSourceBillNo', title: '源单号', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HSourceBillType', title: '源单类型', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HRelationQty', title: '关联数量', width: 100, totalRow: true, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HRelationMoney', title: '关联金额', width: 100, totalRow: true, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HPOOrderInterID', title: '采购订单内码', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HPOOrderEntryID', title: '采购订单子内码', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HPOOrderBillNo', title: '采购订单号', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HSeOrderTaxPrice', title: '订单含税单价', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HSeOrderInterID', title: '销售订单内码', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HSeOrderEntryID', title: '销售订单子内码', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HSeOrderBillNo', title: '销售订单号', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 70 }
                    ]]
                //选中源单后数量不可编辑
                for (var i = 0; i < option.cols[0].length; i++) {
                    if (option.cols[0][i]["field"] == "HQty") {
                        option.cols[0][i]["edit"] = false;
                    }
                }
            }
            //#endregion
@@ -1503,6 +2177,8 @@
                                , "HRemark": data.表头备注
                                , "HExplanation": data.摘要
                                , "HInnerBillNo": data.内部单据号
                                , "HProjectID": (data.HProjectID == null ? 0 : data.HProjectID)
                                , "HProjectName": data.项目名称
                                , "HMaker": data.制单人
                                , "HMakeDate": data.制单日期 == null ? "" : Format(new Date(data.制单日期), "yyyy-MM-dd")
@@ -1653,8 +2329,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)
@@ -1705,7 +2381,7 @@
                        , "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].业务员
@@ -1725,17 +2401,17 @@
                    for (var i = 0; i < dataArray.length; i++) {
                        rowdata.push(
                            {
                                "HMaterID": dataArray[i].hmaterid
                                "HMaterID": dataArray[i].HMaterID
                                , "物料代码": dataArray[i].物料代码
                                , "物料名称": dataArray[i].物料名称
                                , "规格型号": dataArray[i].规格型号
                                , "HUnitID": dataArray[i].hunitid
                                , "HUnitID": dataArray[i].HUnitID
                                , "计量单位": dataArray[i].计量单位
                                , "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)
@@ -1828,6 +2504,11 @@
                        if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            layer.msg(data.Message, { icon: 1 });
                            $('#set_SaveBill').addClass("layui-btn-disabled").attr("disabled", true);
                            if (data.Verify == "Y") //自动审核
                            {
                                $("#HInterID").val(data.HInterID);//获取提交成功返回的单据主ID
                                set_CheckBill(0); //审核
                            }
                            //保存后浏览
                            //ReRoadBillMain();
                        }
@@ -1848,6 +2529,7 @@
            function AllowLoadData(data) {
                //数值格式校验工具
                var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                var ref1 = /^-?\d+(\.\d+)?$/;          //判断字符串是否为数字(包含整数、浮点数),正则表达式
                var temp = "";
                //#region è¡¨å¤´æ•°æ®æ£€éªŒ
@@ -1910,11 +2592,11 @@
                    //实发数量格式校验
                    temp = option.data[i]["HQty"] + "";
                    if (temp == "0") {
                        layer.msg("第" + (i + 1) + "行:实发数量不能为0!");
                    if (!ref1.test(temp)) {
                        layer.msg("第" + (i + 1) + "行:实发数量请输入不为0的数字!");
                        return false;
                    } else if (!ref.test(temp)) {
                        layer.msg("第" + (i + 1) + "行:实发数量请输入大于0的数字!");
                    } else if (temp * 1 == 0) {
                        layer.msg("第" + (i + 1) + "行:实发数量请输入不为0的数字!");
                        return false;
                    }
@@ -1945,25 +2627,26 @@
                        return false;
                    }
                    //金额格式校验
                    temp = option.data[i]["HMoney"] + "";
                    if (temp == "0") {
                        layer.msg("第" + (i + 1) + "行:金额不能为0!");
                        return false;
                    } else if (!ref.test(temp)) {
                        layer.msg("第" + (i + 1) + "行:金额请输入大于0的数字!");
                        return false;
                    }
                    ////金额格式校验
                    //temp = option.data[i]["HMoney"] + "";
                    //if (temp == "0") {
                    //    layer.msg("第" + (i + 1) + "行:金额不能为0!");
                    //    return false;
                    //} else if (!ref.test(temp)) {
                    //    layer.msg("第" + (i + 1) + "行:金额请输入大于0的数字!");
                    //    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的数字!");
                        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的数字!");
                    //    return false;
                    //}
                    //发货仓库非空验证
                    if (option.data[i]["HWHID"] == "0") {
@@ -2007,11 +2690,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",
@@ -2020,63 +2705,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 = [];
                                    }
                                }
                            })
@@ -2149,9 +2822,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",
@@ -2161,46 +2839,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 = [];
                            }
                        }
                    })
@@ -2215,14 +2899,15 @@
                if (obj.event === 'del') {
                    layer.confirm('真的删除行吗?', function (index) {
                        console.log("索引为:" + rowIndex);
                        if (rowIndex === '0') {
                        if (rowIndex === '0' && table.cache["mainTable"].length == 1) {
                            layer.msg('首行无法删除!!!');
                        } else if (haveSource == true) {
                            layer.msg('有源单无法删除!!!');
                        }else {
                            obj.del();
                            obj.del();//假删除
                            table.cache["mainTable"].splice(rowIndex, 1);  //②彻底移除元素,从缓存里移除这一行
                            option.data = table.cache["mainTable"];//将数据绑定到data上
                            table.reload(option);
                            table.render(option);
                            layer.close(index);
                        }
                    });
@@ -2431,6 +3116,7 @@
            function DisPlay_HideColumn() {
                $.ajax({
                    url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList',
                    async:false,
                    type: "GET",
                    data: { "HModName": HModName, "user": sessionStorage["HUserName"] },
                    async: false,
@@ -2479,6 +3165,10 @@
                                    case "R":
                                        option.cols[0][i + 1]["align"] = "right";
                                        break;
                                }
                                //设置表格title属性显示别名
                                if (dataCols[4] != null && dataCols[4] != "") {
                                    option.cols[0][i + 1]["title"] = dataCols[4];
                                }
                            }
@@ -2591,97 +3281,55 @@
                    , "HSSName": dataArray[0].结算方式
                    , "HSellSID": dataArray[0].HSellSID
                    , "HSellSName": dataArray[0].销售方式
                    , "HProjectID": (dataArray[0].HProjectID == null ? 0 : dataArray[0].HProjectID)
                    , "HProjectName": dataArray[0].项目名称
                });
                if ($("#HPriceType").val() == "成本价") {
                    //子表成本价Entry  èµ‹å€¼
                    var rowdataEntry = [];
                    for (var i = 0; i < dataArray.length; i++) {
                //子表Entry  èµ‹å€¼
                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].HTaxPrice, 3)
                            , 'HDiscountRate': "1"                                                     //
                            , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].HTaxPrice, 3)
                            , "HTaxRate": dataArray[i].税率
                            , 'HTaxMoney': "0"                                                         //
                            , "HMoney": dealDoubleToFixed(dataArray[i].金额, 2)
                            , 'HMoneyBB': dealDoubleToFixed(dataArray[i].金额 * dataArray[0].汇率, 2)
                            , 'HlineTotal': dealDoubleToFixed(dataArray[i].价税合计, 2)
                            , 'HlineTotalBB': dealDoubleToFixed(dataArray[i].价税合计 * dataArray[0].汇率, 2)
                            , "HRemark": ""
                        rowdataEntry.push(
                            {
                                "HMaterID": dataArray[i].HMaterID
                                , "物料代码": dataArray[i].物料代码
                                , "物料名称": dataArray[i].物料名称
                                , "规格型号": dataArray[i].规格型号
                                , "HUnitID": dataArray[i].HUnitID
                                , "计量单位": dataArray[i].计量单位
                                , "HQty": dealDoubleToFixed(dataArray[i].数量, 1)
                                , "HPrice": dealDoubleToFixed(dataArray[i].HNoTaxCost, 3)
                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].HTaxCost, 3)
                                , 'HDiscountRate': "0"                                                     //
                                , 'HRelTaxPrice': "0"
                                , "HTaxRate": dataArray[i].税率
                                , 'HTaxMoney': "0"                                                         //
                                , "HMoney": dealDoubleToFixed(dataArray[i].数量 * dataArray[i].HNoTaxCost, 2)
                                , 'HMoneyBB': dealDoubleToFixed(dataArray[i].数量 * dataArray[i].HNoTaxCost, 2)
                                , 'HlineTotal': dealDoubleToFixed(dataArray[i].价税合计, 2)
                                , 'HlineTotalBB': dealDoubleToFixed(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"
                                , "HSourceInterID": dataArray[i].hmainid
                                , "HSourceEntryID": dataArray[i].hsubid
                                , "HSourceBillNo": dataArray[i].单据号
                                , "HSourceBillType": dataArray[i].HBillType
                                , "HRelationQty": "0"
                                , "HRelationMoney": "0"
                            , 'HPOOrderInterID': "0"
                            , 'HPOOrderEntryID': "0"
                            , 'HPOOrderBillNo': ""
                                , '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++) {
                        rowdataEntry.push(
                            {
                                "HMaterID": dataArray[i].HMaterID
                                , "物料代码": dataArray[i].物料代码
                                , "物料名称": dataArray[i].物料名称
                                , "规格型号": dataArray[i].规格型号
                                , "HUnitID": dataArray[i].HUnitID
                                , "计量单位": dataArray[i].计量单位
                                , "HQty": dealDoubleToFixed(dataArray[i].数量, 1)
                                , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].HTaxPrice, 3)
                                , 'HDiscountRate': "0"                                                     //
                                , 'HRelTaxPrice': "0"
                                , "HTaxRate": dataArray[i].税率
                                , 'HTaxMoney': "0"                                                         //
                                , "HMoney": dealDoubleToFixed(dataArray[i].金额, 2)
                                , 'HMoneyBB': dealDoubleToFixed(dataArray[i].金额 * dataArray[0].汇率, 2)
                                , 'HlineTotal': dealDoubleToFixed(dataArray[i].价税合计, 2)
                                , 'HlineTotalBB': dealDoubleToFixed(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].HTaxPrice, 3)
                                , "HSeOrderInterID": dataArray[i].hmainid
                                , "HSeOrderEntryID": dataArray[i].hsubid
                                , "HSeOrderBillNo": dataArray[i].单据号
                            }
                        );
                    }
                            , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].HTaxPrice, 3)
                            , "HSeOrderInterID": dataArray[i].hmainid
                            , "HSeOrderEntryID": dataArray[i].hsubid
                            , "HSeOrderBillNo": dataArray[i].单据号
                        }
                    );
                }
                optionEntry.data = rowdataEntry;
                optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
                table.render(optionEntry);
                //子表汇总
                for (var i = 0; i < rowdataEntry.length; i++) {
@@ -2739,7 +3387,6 @@
                        return;
                    }
                }
                form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                    "HMainSourceInterID": "0"
                    , "HMainSourceEntryID": "0"
@@ -2748,7 +3395,7 @@
                    , "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].业务员
@@ -2761,74 +3408,35 @@
                    , "HSSName": ""
                    , "HSellSID": dataArray[0].HSellSID
                    , "HSellSName": dataArray[0].销售方式
                    , "HProjectName": dataArray[0].项目名称
                    , "HProjectID": dataArray[0].HProjectID == null ? "0" : dataArray[0].HProjectID
                });
                if ($("#HPriceType").val() == "成本价") {
                    //子表  èµ‹å€¼
                    var rowdataEntry = [];
                //子表  èµ‹å€¼
                var rowdataEntry = [];
                try {
                    for (var i = 0; i < dataArray.length; i++) {
                        var HQty = dataArray[i].数量 * 1 - dataArray[i].关联数量;
                        rowdataEntry.push(
                            {
                                "HMaterID": dataArray[i].hmaterid
                                "HMaterID": dataArray[i].HMaterID
                                , "物料代码": dataArray[i].物料代码
                                , "物料名称": dataArray[i].物料名称
                                , "规格型号": dataArray[i].规格型号
                                , "HUnitID": dataArray[i].hunitid
                                , "HUnitID": dataArray[i].HUnitID
                                , "计量单位": dataArray[i].计量单位
                                , "HQty": dealDoubleToFixed(dataArray[i].数量, 1)
                                , "HPrice": dealDoubleToFixed(dataArray[i].成本单价, 3)
                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                                , 'HDiscountRate': "0"                                                     //
                                , 'HRelTaxPrice': "0"
                                , "HTaxRate": dataArray[i].税率
                                , 'HTaxMoney': "0"                                                         //
                                , "HMoney": dealDoubleToFixed(dataArray[i].数量 * dataArray[i].成本单价, 2)
                                , 'HMoneyBB': dealDoubleToFixed(dataArray[i].数量 * dataArray[i].成本单价 * dataArray[0].汇率, 2)
                                , 'HlineTotal': dealDoubleToFixed(dataArray[i].数量 * dataArray[i].含税单价, 2)
                                , 'HlineTotalBB': dealDoubleToFixed(dataArray[i].数量 * 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++) {
                        rowdataEntry.push(
                            {
                                "HMaterID": dataArray[i].hmaterid
                                , "物料代码": dataArray[i].物料代码
                                , "物料名称": dataArray[i].物料名称
                                , "规格型号": dataArray[i].规格型号
                                , "HUnitID": dataArray[i].hunitid
                                , "计量单位": dataArray[i].计量单位
                                , "HQty": dealDoubleToFixed(dataArray[i].数量, 1)
                                , "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': "0"                                                         //
                                , "HMoney": dealDoubleToFixed(dataArray[i].数量 * dataArray[i].单价, 2)
                                , 'HMoneyBB': dealDoubleToFixed(dataArray[i].数量 * dataArray[i].单价 * dataArray[0].汇率, 2)
                                , 'HlineTotal': dealDoubleToFixed(dataArray[i].数量 * dataArray[i].含税单价, 2)
                                , 'HlineTotalBB': dealDoubleToFixed(dataArray[i].数量 * 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
@@ -2850,8 +3458,11 @@
                        );
                    }
                }
                optionEntry.data = rowdataEntry;
                catch (error) {
                    layer.alert(error.Message, { icon: 5 });
                }
                optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
                table.render(optionEntry);
                //子表汇总
                for (var i = 0; i < rowdataEntry.length; i++) {
@@ -2934,11 +3545,11 @@
            function getDecByMaterID(HMaterID) {
                var resultData = {};
                $.ajax({  // å¼‚步请求
                    url: GetWEBURL() + "Gy_Material/getDecByID",  //请求地址
                    url: GetWEBURL() + "/Gy_Material/getDecByID",  //请求地址
                    async: false,   //是否开启异步
                    type: "GET",   //请求类型
                    data: {   //定义发送到服务器的数据
                        "HMaterID": HMaterID     //  å°†hmaterid作为请求参数发送
                        "HMaterID": HMaterID     //  å°†HMaterID作为请求参数发送
                    },
                    success: function (result) {   // å½“请求成功时,执行这个函数
                        if (result.code == 1) { // å¦‚果服务器返回的数据中的`code字段等于1,这可能表示审核操作成功执行
@@ -3000,18 +3611,18 @@
            $("#HCusID").val(obj[0].HItemID);
        }
        function GetHManagerValue(obj)  //返回主管
        {
            $("#HMangerName").val(obj[0].HName);
            $("#HMangerName").val(obj[0].职员名称);
            $("#HMangerID").val(obj[0].HItemID);
        }
        function GetHDeptNameValue(obj)  //返回部门
        {
            $("#HDeptName").val(obj[0].HName);
            $("#HDeptName").val(obj[0].部门名称);
            $("#HDeptID").val(obj[0].HItemID);
        }
        function GetSellStyleValue(obj)  //返回销售方式
        {
            $("#HSellSName").val(obj[0].HName);