wtt
2025-11-05 2bf4ff2ba42a6b68de0b298f9b701e6d6338dfdb
WebTM/views/²É¹º¹ÜÀí/Ó¦¸¶µ¥/Cg_PayableBill.html
@@ -45,8 +45,10 @@
                <form class="layui-form" lay-filter="component-form-group" action="">
                    <div class="layui-card-header">
                        <div class="layui-btn-group">
                            <button type="button" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="set_AddNew" id="set_AddNew">新增</button>
                            <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 +56,9 @@
                        <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">
                            <!--基本信息-->
@@ -81,9 +85,9 @@
                                                    <!--动态渲染源单类型-->
                                                </select>
                                                <!--<select name="BillType" id="BillType" lay-filter="BillType" style="width: 180px; ">
                                    <option style="color:blue;" selected="selected" value="1102">采购订单</option>
                                    <option style="color:blue;" value="1201">采购入库单</option>
                                </select>-->
                            <option style="color:blue;" selected="selected" value="1102">采购订单</option>
                            <option style="color:blue;" value="1201">采购入库单</option>
                        </select>-->
                                            </div>
                                        </div>
                                        <div class="layui-inline">
@@ -92,7 +96,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; ">
                                                <input type="text" name="HMainSourceBillNo" id="HMainSourceBillNo" class="layui-input" value="" style="float: left; width: 150px; " readonly>
                                                <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>
@@ -100,14 +104,14 @@
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline" style="width:625px">
                                        <div class="layui-inline" >
                                            <label class="layui-form-label">供应商<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HSupName" id="HSupName" class="layui-input" value="" style="background-color: #efefef4d; width: 505px" readonly>
                                                <input type="hidden" name="HSupID" id="HSupID" class="layui-input" value="0" style="float: left; width: 505px;">
                                                <input type="text" name="HSupName" id="HSupName" class="layui-input" value="" style="background-color: #efefef4d; width: 150px" readonly>
                                                <input type="hidden" name="HSupID" id="HSupID" class="layui-input" value="0" style="float: left; width: 150px;">
                                                <!--<button type="button" lay-submit="" class="layui-btn" lay-filter="HSupList" style="width:40px;">
                                        <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                    </button>-->
                <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
            </button>-->
                                            </div>
                                        </div>
                                        <div class="layui-inline">
@@ -130,24 +134,6 @@
                                                </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-inline">
                                                <input type="text" name="HCurName" id="HCurName" class="layui-input" value="" style="background-color: #efefef4d; float: left; width: 150px;" 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">
@@ -158,17 +144,8 @@
                                                </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; float: left; width: 150px;" 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>
@@ -180,10 +157,24 @@
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-inline" style="">
                                            <label class="layui-form-label">发票编号</label>
                                            <div class="layui-input-inline" style="background-color: #efefef4d; float: left; width: 150px;">
                                                <input class="layui-input" name="HInvoiceBillNo" id="HInvoiceBillNo" autocomplete="off">
                                            </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;">
                                            <label class="layui-form-label">项目名称</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HProjectName" id="HProjectName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                                <input type="hidden" name="HProjectID" id="HProjectID" class="layui-input" value="0" style="float: left; width: 150px; background-color: #efefef4d;">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">项目编码</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HProjectNumber" id="HProjectNumber" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                            </div>
                                        </div>
                                    </div>
@@ -192,16 +183,6 @@
                                            <label class="layui-form-label">备注</label>
                                            <div class="layui-input-block">
                                                <input class="layui-input" name="HRemark" id="HRemark" autocomplete="off" style="width: 1135px;">
                                            </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>
@@ -227,6 +208,59 @@
                                            </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="HSSName" id="HSSName" class="layui-input" value="" style="background-color: #efefef4d; float: left; width: 150px;" 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 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 style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HCurName" id="HCurName" class="layui-input" value="" style="background-color: #efefef4d; float: left; width: 150px;" 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>
                                    <div class="layui-row">
                                        <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>
                                    <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>
                            </div>
                            <!--制单信息-->
@@ -366,7 +400,7 @@
            var allVal;
            var HModName = "Cg_PayableBill";
            var topScroll = 0;//记录滚动条的位置
            //记录组织的值
            var HOrgIDBar = 0;
@@ -385,7 +419,7 @@
            //#region ã€åŠ¨æ€èŽ·å–æ¨¡å—åç§°ã€‘
            var HModuleType = "1114";
            //通过单据类型,从数据库动态获取单据模块命名,引用js文件 PageTitle.js
            var HPageTitle = get_PageTitle(HModuleType) == "" ? $("h1").html() : get_PageTitle(HModuleType);
            var HPageTitle = get_PageTitle(HModuleType) || $("h1").html();
            $("h1").html('<b>' + HPageTitle + '</b>');
            //#endregion
@@ -460,9 +494,22 @@
            })
            //#endregion
            //#region æ–°å¢ž
            form.on('submit(set_AddNew)', function (data) {
                const url = new URL(location.href);
                location.href = url.origin + url.pathname;
            });
            //#endregion
            //#region å®¡æ ¸æŒ‰é’®
            form.on('submit(set_CheckBill)', function (data) {
                set_CheckBill(0);
            });
            //#endregion
            //#region é€‰æ•´å•
            form.on('submit(set_SelectMainBill)', function (data) {
                set_SelectMainBill();
            });
            //#endregion
@@ -583,6 +630,7 @@
                    var url;
                    //判断文本框是否有数据    new
                    if (HSourceBillNo == "") {
                        layer.close(ajaxLoad);
                        return;
                    }
                    if ($("#BillType").val() == "1102") {
@@ -621,6 +669,9 @@
                                        , "HSSName": dataArray[0].结算方式
                                        , "HPSStyleID": dataArray[0].HPSStyleID
                                        , "HPSStyleName": dataArray[0].采购方式
                                        , "HProjectID": dataArray[0].HProjectID
                                        , "HProjectName": dataArray[0].项目名称
                                        , "HProjectNumber": dataArray[0].项目代码
                                    });
                                    //子表Entry  èµ‹å€¼
@@ -646,8 +697,8 @@
                                                , "HQty": dealDoubleToFixed(HQty, 1)
                                                , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                                                , 'HDiscountRate': "0"                                                     //
                                                , 'HRelTaxPrice': "0"
                                                , 'HDiscountRate': "1"                                                     //
                                                , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                                                , "HTaxRate": dataArray[i].税率
                                                , 'HTaxMoney': HTaxMoney                                                         //
                                                , "HMoney": dealDoubleToFixed(HMoney, 2)
@@ -674,7 +725,7 @@
                                            }
                                        );
                                    }
                                    optionEntry.data = rowdataEntry;
                                    optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
                                    table.render(optionEntry);
                                    //子表汇总
                                    for (var i = 0; i < rowdataEntry.length; i++) {
@@ -683,7 +734,9 @@
                                        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].HMoney += rowdataEntry[j].HMoney;//金额
                                                rowdataEntry[i].HPrice = rowdataEntry[i].HMoney / rowdataEntry[i].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();
@@ -719,6 +772,10 @@
                                        , "HSSName": ""
                                        , "HPSStyleID": dataArray[0].HPSStyleID
                                        , "HPSStyleName": dataArray[0].采购方式
                                        , "HProjectID": dataArray[0].HProjectID
                                        , "HProjectName": dataArray[0].项目名称
                                        , "HProjectNumber": dataArray[0].项目代码
                                        , "HInvoiceBillNo": dataArray[0].发票编号
                                    });
                                    //子表Entry  èµ‹å€¼
                                    var rowdataEntry = [];
@@ -743,8 +800,8 @@
                                                , "HQty": dealDoubleToFixed(HQty, 1)
                                                , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                                                , 'HDiscountRate': "0"                                                     //
                                                , 'HRelTaxPrice': "0"
                                                , 'HDiscountRate': "1"                                                     //
                                                , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                                                , "HTaxRate": dataArray[i].税率
                                                , 'HTaxMoney': HTaxMoney                                                         //
                                                , "HMoney": dealDoubleToFixed(HMoney, 2)
@@ -771,7 +828,7 @@
                                            }
                                        );
                                    }
                                    optionEntry.data = rowdataEntry;
                                    optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
                                    table.render(optionEntry);
                                    //子表汇总
                                    for (var i = 0; i < rowdataEntry.length; i++) {
@@ -779,7 +836,8 @@
                                        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].HMoney += rowdataEntry[j].HMoney;//金额
                                                rowdataEntry[i].HPrice = rowdataEntry[i].HMoney / rowdataEntry[i].HQty;//单价
                                                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();
@@ -833,7 +891,7 @@
                    , "HQty": "0"
                    , "HPrice": "0"
                    , "HTaxPrice": "0"
                    , 'HDiscountRate': "0"
                    , 'HDiscountRate': "1"
                    , 'HRelTaxPrice': "0"
                    , "HTaxRate": "0"
                    , 'HTaxMoney': "0"
@@ -1264,6 +1322,318 @@
                })
            }
            //#endregion
            //#region é€‰æ•´å•
            function set_SelectMainBill() {
                var url;
                if ($("#BillType").val() == "1102") {
                    url = "../../采购管理/采购订单/Cg_POOrderBillQuery.html?openType=2&HOrgID=" + HOrgID;
                } else if ($("#BillType").val() == "1201") {
                    url = "../../验收入库/外购入库/Kf_POStockInBillListQuery.html?openType=2&HOrgID=" + HOrgID;
                } 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 HSupID = $("#HSupID").val();//判断供应商
                        if (HSupID == 0 || HSupID == '') {
                            HSupID = checkStatus.data[0]["HSupID"];
                        }
                        //获取供应商代码,设置条件
                        var sMainWhere = " and hmainid in(";
                        for (var i = 0; i < checkStatus.data.length; i++) {
                            if (checkStatus.data[i]["HSupID"] != HSupID) {
                                layer.msg("下推失败!已经选中的记录中存在不同供应商!");
                                layer.close(index);//关闭弹窗
                                return;
                            }
                            sMainWhere += checkStatus.data[i]["hmainid"]
                            if (i != checkStatus.data.length - 1) {
                                sMainWhere += ",";
                            } else {
                                sMainWhere += ") ";
                            }
                        }
                        getSeletMainInfo(sMainWhere);
                        layer.close(index);//关闭弹窗
                    }
                });
            }
            //#endregion
            //#region æ•´å•信息获取方法
            function getSeletMainInfo(sMainWhere) {
                var ajaxLoad = layer.load();
                if ($("#BillType").val() == "1102") {
                    $.ajax({
                        url: GetWEBURL() + '/Cg_POOrderBill/list',
                        async: false,
                        type: "GET",
                        data: { "sWhere": sMainWhere, "user": sessionStorage["HUserName"] },
                        success: function (data1) {
                            if (data1.count == 1) {
                                var dataArray = data1.data;
                                option.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].业务员
                                    , "HSupID": dataArray[0].HSupID
                                    , "HSupName": dataArray[0].供应商
                                    , "HCurID": dataArray[0].HCurID
                                    , "HCurName": dataArray[0].币别
                                    , "HExRate": dataArray[0].汇率
                                    , "HSSID": dataArray[0].HSSID
                                    , "HSSName": dataArray[0].结算方式
                                    , "HPSStyleID": dataArray[0].HPSStyleID
                                    , "HPSStyleName": dataArray[0].采购方式
                                    , "HProjectID": dataArray[0].HProjectID
                                    , "HProjectName": dataArray[0].项目名称
                                    , "HProjectNumber": 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].含税单价, 3)
                                            , 'HDiscountRate': "1"                                                     //
                                            , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                                            , "HTaxRate": dataArray[i].税率
                                            , 'HTaxMoney': HTaxMoney                                                         //
                                            , "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].单据类型
                                            , "HRelationQty": "0"
                                            , "HRelationMoney": "0"
                                            , 'HPOOrderInterID': "0"
                                            , 'HPOOrderEntryID': "0"
                                            , 'HPOOrderBillNo': ""
                                            , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 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[j].HMoney;//金额
                                            rowdataEntry[i].HPrice = rowdataEntry[i].HMoney / rowdataEntry[i].HQty;//单价
                                            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() == "1201") {
                    $.ajax({
                        url: GetWEBURL() + '/Kf_POStockInBill/list',
                        type: "GET",
                        data: { "sWhere": sMainWhere, "user": sessionStorage["HUserName"] },
                        success: function (data1) {
                            if (data1.count == 1) {
                                dataArray = data1.data;
                                form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                                    "HMainSourceInterID": "0"
                                    , "HMainSourceEntryID": "0"
                                    /*, "HMainSourceBillNo": ""*/
                                    , "HMainSourceBillType": $("#BillType").val()
                                    , "HDeptID": dataArray[0].HDeptID
                                    , "HDeptName": dataArray[0].部门
                                    , "HMangerID": dataArray[0].hmanagerid == null ? "0" : dataArray[0].hmanagerid
                                    , "HMangerName": dataArray[0].主管
                                    , "HEmpID": dataArray[0].HEmpID
                                    , "HEmpName": dataArray[0].业务员
                                    , "HSupID": dataArray[0].HSupID
                                    , "HSupName": dataArray[0].供应商
                                    , "HCurID": dataArray[0].HCurID
                                    , "HCurName": dataArray[0].币别
                                    , "HExRate": dataArray[0].汇率
                                    , "HSSID": "0"
                                    , "HSSName": ""
                                    , "HPSStyleID": dataArray[0].HPSStyleID
                                    , "HPSStyleName": dataArray[0].采购方式
                                    , "HProjectID": dataArray[0].HProjectID
                                    , "HProjectName": dataArray[0].项目名称
                                    , "HProjectNumber": dataArray[0].项目代码
                                    , "HInvoiceBillNo": 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].含税单价, 3)
                                            , 'HDiscountRate': "1"                                                     //
                                            , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                                            , "HTaxRate": dataArray[i].税率
                                            , 'HTaxMoney': HTaxMoney                                                         //
                                            , "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].单据类型
                                            , "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[j].HMoney;//金额
                                            rowdataEntry[i].HPrice = rowdataEntry[i].HMoney / rowdataEntry[i].HQty;//单价
                                            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 å­è¡¨åˆå§‹åŒ–
@@ -1285,8 +1655,8 @@
                        , { 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'}
                        , { field: 'HPrice', title: '单价', width: 100, edit: 'text', event: "HPrice" }
                        , { field: 'HMoney', title: '金额', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HPrice', title: '单价', width: 100, event: "HPrice", style: 'background-color:#efefef4d;' }
                        , { field: 'HMoney', title: '金额', width: 100, totalRow: true, edit: 'text' }
                        , { field: 'HTaxPrice', title: '含税单价', width: 100, edit: 'text', event: "HTaxPrice" }
                        , { field: 'HDiscountRate', title: '折扣率', width: 100, edit: 'text' }
                        , { field: 'HRelTaxPrice', title: '实际含税单价', width: 100, style: 'background-color:#efefef4d;' }
@@ -1314,6 +1684,10 @@
                        , { 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);
                    }
                }
                optionEntry = {
                    elem: '#mainTableEntry'
@@ -1370,7 +1744,7 @@
                    , "HQty": "0"
                    , "HPrice": "0"
                    , "HTaxPrice": "0"
                    , 'HDiscountRate': "0"
                    , 'HDiscountRate': "1"
                    , 'HRelTaxPrice': "0"
                    , "HTaxRate": "0"
                    , 'HTaxMoney': "0"
@@ -1403,52 +1777,15 @@
                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;
                    }
                    //if (option.cols[0][i]["field"] == "HMoney") {
                    //    option.cols[0][i]["edit"] = false;
                    //}
                }
            }
            //#endregion
@@ -1458,11 +1795,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 //得到修改后的值
@@ -1474,14 +1813,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;
                        }
@@ -1715,6 +2063,64 @@
                        });
                        table.render(option);
                        break;
                    case "HMoney":                                         //金额
                        //数据格式校验
                        temp = value + "";
                        if (!ref1.test(temp)) {
                            //恢复数据到编辑前
                            obj.update({
                                HMoney: oldText
                            });
                            table.render(option);
                            layer.msg("金额或数量请输入大于0的数字!");
                            return;
                        } else if (temp * 1 == 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).toFixed(4));         //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        var HTaxPrice = Number((HPrice * (1 + HTaxRate)).toFixed(4));        //含税单价=单价*(1+税率)
                        var HDiscountRate = obj.data.HDiscountRate * 1;   //折扣率
                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate).toFixed(4));   //实际含税单价=含税单价*折扣率
                        var HExRate = $("#HExRate").val();                      //汇率
                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate).toFixed(4));     //本位币价税合计=(税额+金额)*汇率
                        var HMoneyBB = HMoney * HExRate;
                        //数字精度
                        HQty = Number(HQty.toFixed(HQtyDec));
                        HPrice = Number(HPrice.toFixed(HPriceDec));
                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                        HTaxPrice = Number(HTaxPrice.toFixed(HPriceDec));
                        HRelTaxPrice = Number(HRelTaxPrice.toFixed(HPriceDec));
                        HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
                        HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
                        HMoneyBB = Number(HMoneyBB.toFixed(HMoneyDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
                            , HPrice: HPrice
                            , HMoney: HMoney
                            , HTaxMoney: HTaxMoney
                            , HlineTotal: HlineTotal
                            , HTaxPrice, HTaxPrice
                            , HRelTaxPrice: HRelTaxPrice
                            , HlineTotalBB: HlineTotalBB
                            , HMoneyBB: HMoneyBB
                        });
                        table.render(option);
                        break;
                    default:
                }
            });
@@ -1767,16 +2173,21 @@
                                , "HExplanation": data.摘要
                                , "HInnerBillNo": data.内部单据号
                                , "HProjectID": data.HProjectID == null ? 0 : data.HProjectID
                                , "HProjectName": data.项目名称
                                , "HProjectNumber": data.项目代码
                                , "HInvoiceBillNo": data.发票编号
                                , "HMaker": data.制单人
                                , "HMakeDate": data.制单日期 == null ? "" : Format(new Date(data.制单日期), "yyyy-MM-dd HH:mm:ss")
                                , "HMakeDate": data.制单日期 == null ? "" : Format(new Date(data.制单日期), "yyyy-MM-dd hh:mm:ss")
                                , "HUpDater": data.修改人
                                , "HUpDateDate": data.修改日期 == null ? "" : Format(new Date(data.修改日期), "yyyy-MM-dd HH:mm:ss")
                                , "HUpDateDate": data.修改日期 == null ? "" : Format(new Date(data.修改日期), "yyyy-MM-dd hh:mm:ss")
                                , "HChecker": data.审核人
                                , "HCheckDate": data.审核日期 == null ? "" : Format(new Date(data.审核日期), "yyyy-MM-dd HH:mm:ss")
                                , "HCheckDate": data.审核日期 == null ? "" : Format(new Date(data.审核日期), "yyyy-MM-dd hh:mm:ss")
                                , "HCloseMan": data.关闭人
                                , "HCloseDate": data.关闭日期 == null ? "" : Format(new Date(data.关闭日期), "yyyy-MM-dd HH:mm:ss")
                                , "HCloseDate": data.关闭日期 == null ? "" : Format(new Date(data.关闭日期), "yyyy-MM-dd hh:mm:ss")
                                , "HDeleteMan": data.作废人
                                , "HDeleteDate": data.作废日期 == null ? "" : Format(new Date(data.作废日期), "yyyy-MM-dd HH:mm:ss")
                                , "HDeleteDate": data.作废日期 == null ? "" : Format(new Date(data.作废日期), "yyyy-MM-dd hh:mm:ss")
                            });
                            if (data.HMainSourceBillType != "") {
@@ -1902,6 +2313,9 @@
                        , "HSSName": dataArray[0].结算方式
                        , "HPSStyleID": dataArray[0].HPSStyleID
                        , "HPSStyleName": dataArray[0].采购方式
                        , "HProjectID": dataArray[0].HProjectID
                        , "HProjectName": dataArray[0].项目名称
                        , "HProjectNumber": dataArray[0].项目代码
                    });
                    //子表  èµ‹å€¼
@@ -1981,6 +2395,10 @@
                        , "HExRate": dataArray[0].汇率
                        , "HPSStyleID": dataArray[0].HPSStyleID
                        , "HPSStyleSName": dataArray[0].采购方式
                        , "HProjectID": dataArray[0].HProjectID
                        , "HProjectName": dataArray[0].项目名称
                        , "HProjectNumber": dataArray[0].项目代码
                        , "HInvoiceBillNo": dataArray[0].发票编号
                    });
                    //子表  èµ‹å€¼
@@ -2045,7 +2463,6 @@
                    $("#HUpDateDate").val(Format(new Date(), "yyyy-MM-dd hh:mm:ss"));
                }
                var sMainStr = JSON.stringify(data.field);
                //获取子表数据
                var num = [];
                for (var i = 0; i < table.cache["mainTable"].length; i++) {
@@ -2115,6 +2532,7 @@
            function AllowLoadData(data) {
                //数值格式校验工具
                var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                var ref1 = /^-?\d+(\.\d+)?$/;          //判断字符串是否为数字(包含整数、浮点数),正则表达式
                var temp = "";
                //#region è¡¨å¤´æ•°æ®æ£€éªŒ
@@ -2127,22 +2545,22 @@
                    layer.msg("日期不能为空!");
                    return false;
                }
                if ($("#HCurID").val() == 0) {
                    layer.msg("请选择币别!");
                    return;
                }
                if ($("#HExRate").val() == 0) {
                    layer.msg("请输入汇率!");
                    return;
                }
                //if ($("#HCurID").val() == 0) {
                //    layer.msg("请选择币别!");
                //    return;
                //}
                //if ($("#HExRate").val() == 0) {
                //    layer.msg("请输入汇率!");
                //    return;
                //}
                //if ($("#HEmpID").val() == 0) {
                //    layer.msg("请选择业务员员!");
                //    return;
                //}
                if ($("#HDeptID").val() == 0) {
                    layer.msg("请选择采购部门!");
                    return;
                }
                //if ($("#HDeptID").val() == 0) {
                //    layer.msg("请选择采购部门!");
                //    return;
                //}
                if ($("#HSupID").val() == 0) {
                    layer.msg("请选择供应商!");
                    return;
@@ -2156,14 +2574,14 @@
                //    return;
                //}
                temp = $("#HExRate").val() + "";
                if (temp == 0) {
                    layer.msg("汇率不能为0!");
                    return false;
                } else if (!ref.test(temp)) {
                    layer.msg("汇率请输入大于0的数字!");
                    return false;
                }
                //temp = $("#HExRate").val() + "";
                //if (temp == 0) {
                //    layer.msg("汇率不能为0!");
                //    return false;
                //} else if (!ref.test(temp)) {
                //    layer.msg("汇率请输入大于0的数字!");
                //    return false;
                //}
                //#endregion
                //#region å­è¡¨ æ•°æ®æ£€éªŒ
@@ -2181,13 +2599,13 @@
                        return false;
                    }
                    //实发数量格式校验
                    //数量格式校验
                    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;
                    }
@@ -2218,26 +2636,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]["HTaxMoney"] + "";
                    ////金额格式校验
                    //temp = option.data[i]["HMoney"] + "";
                    //if (temp == "0") {
                    //    layer.msg("第" + (i + 1) + "行:价税合计不能为0!");
                    //    layer.msg("第" + (i + 1) + "行:金额不能为0!");
                    //    return false;
                    //} else
                    if (!ref.test(temp)) {
                        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;
                    //}
                }
                //#endregion
                return true;
@@ -2489,15 +2907,16 @@
                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);
                        }
                    });
@@ -2841,6 +3260,9 @@
                    , "HSSName": dataArray[0].结算方式
                    , "HPSStyleID": dataArray[0].HPSStyleID
                    , "HPSStyleName": dataArray[0].采购方式
                    , "HProjectID": dataArray[0].HProjectID
                    , "HProjectName": dataArray[0].项目名称
                    , "HProjectNumber": dataArray[0].项目代码
                });
                //子表Entry  èµ‹å€¼
@@ -2866,8 +3288,8 @@
                            , "HQty": dealDoubleToFixed(HQty, 1)
                            , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                            , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                            , 'HDiscountRate': "0"                                                     //
                            , 'HRelTaxPrice': "0"
                            , 'HDiscountRate': "1"                                                     //
                            , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                            , "HTaxRate": dataArray[i].税率
                            , 'HTaxMoney': HTaxMoney                                                         //
                            , "HMoney": dealDoubleToFixed(HMoney, 2)
@@ -2894,7 +3316,7 @@
                        }
                    );
                }
                optionEntry.data = rowdataEntry;
                optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
                table.render(optionEntry);
                //子表汇总
                for (var i = 0; i < rowdataEntry.length; i++) {
@@ -2903,7 +3325,8 @@
                    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].HMoney += rowdataEntry[j].HMoney;//金额
                            rowdataEntry[i].HPrice = rowdataEntry[i].HMoney / rowdataEntry[i].HQty;//单价
                            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();
@@ -2943,6 +3366,12 @@
                        return;
                    }
                }
                if (dataArray[0].源单类型 == "1102") {
                    getPushSource_POOrderBillCur(dataArray[0].源单主内码, dataArray[0].源单子内码);
                } else {
                    getPushSource_POInStockBillCur(dataArray[0].源单主内码, dataArray[0].源单子内码);
                }
                form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                    "HMainSourceInterID": "0"
@@ -2965,6 +3394,10 @@
                    , "HSSName": ""
                    , "HPSStyleID": dataArray[0].HPSStyleID
                    , "HPSStyleName": dataArray[0].采购方式
                    , "HProjectID": dataArray[0].HProjectID
                    , "HProjectName": dataArray[0].项目名称
                    , "HProjectNumber": dataArray[0].项目代码
                    , "HInvoiceBillNo": dataArray[0].发票编号
                });
                //子表Entry  èµ‹å€¼
@@ -2990,8 +3423,8 @@
                            , "HQty": dealDoubleToFixed(HQty, 1)
                            , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                            , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                            , 'HDiscountRate': "0"                                                     //
                            , 'HRelTaxPrice': "0"
                            , 'HDiscountRate': "1"                                                     //
                            , 'HRelTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                            , "HTaxRate": dataArray[i].税率
                            , 'HTaxMoney': HTaxMoney                                                         //
                            , "HMoney": dealDoubleToFixed(HMoney, 2)
@@ -3018,7 +3451,7 @@
                        }
                    );
                }
                optionEntry.data = rowdataEntry;
                optionEntry.data = JSON.parse(JSON.stringify(rowdataEntry));
                table.render(optionEntry);
                //子表汇总
                for (var i = 0; i < rowdataEntry.length; i++) {
@@ -3026,7 +3459,8 @@
                    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].HMoney += rowdataEntry[j].HMoney;//金额
                            rowdataEntry[i].HPrice = rowdataEntry[i].HMoney / rowdataEntry[i].HQty;//单价
                            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();
@@ -3152,7 +3586,69 @@
            }
            //#endregion
            //#region æ ¹æ®ä¸»å†…码与子内码获取源单采购订单币别汇率
            function getPushSource_POOrderBillCur(HSourceInterID, HSourceEntryID) {
                var res = "none";
                $.ajax({
                    url: GetWEBURL() + "/Cg_POOrderBill/loadCg_POOrderBill_Push",
                    async: false,
                    type: "GET",
                    data: {
                        "HInterID": HSourceInterID
                        , "HSubID": HSourceEntryID
                    },
                    success: function (result) {
                        if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            res = result.data[0];
                            form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                                "HCurID": res.HCurID
                                , "HCurName": res.币别
                                , "HExRate": res.汇率
                            });
                        } else {
                            res = result.data;
                            //layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        res = "none";
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
                return res;
            }
            //#endregion
            //#region æ ¹æ®ä¸»å†…码与子内码获取源单收料通知单币别汇率
            function getPushSource_POInStockBillCur(HSourceInterID, HSourceEntryID) {
                var res = "none";
                $.ajax({
                    url: GetWEBURL() + "/Cg_POInStockBill/loadCg_POInStockBill_Push",
                    async: false,
                    type: "GET",
                    data: {
                        "HInterID": HSourceInterID
                        , "HSubID": HSourceEntryID
                    },
                    success: function (result) {
                        if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            res = result.data[0];
                            form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                                "HCurID": res.HCurID
                                , "HCurName": res.币别
                                , "HExRate": res.汇率
                            });
                        } else {
                            res = result.data;
                            //layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        res = "none";
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
                return res;
            }
            //#endregion
            //#endregion