1
duhe
2024-08-15 40cd70d9a9d13001c1b6c2269334e8a363c562c3
WebTM/views/²É¹º¹ÜÀí/Ó¦¸¶µ¥/Cg_PayableBill.html
@@ -81,9 +81,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">
@@ -100,56 +100,46 @@
                                        </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="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;">
                                                    <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="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="HMangerName" id="HMangerName" class="layui-input" value="" style="background-color:#efefef4d;" 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;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>-->
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                        <div class="layui-inline" style="width:625px">
                                            <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;" readonly>
                                                <input type="hidden" name="HSupID" id="HSupID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <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;">
                                                <!--<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>-->
                                            </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="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:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HDeptList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>-->
                                                </button>
                                            </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="HEmpName" id="HEmpName" class="layui-input" value="" style="background-color: #efefef4d; float: left; width: 150px;" 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>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">币别</label>
                                            <label class="layui-form-label">币别<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HCurName" id="HCurName" class="layui-input" value="" style="background-color:#efefef4d;" readonly>
                                                <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>-->
                                                <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">
@@ -159,27 +149,37 @@
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">采购方式</label>
                                            <label class="layui-form-label">采购方式<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HPSStyleName" id="HPSStyleName" class="layui-input" value="" style="background-color:#efefef4d;" readonly>
                                                <input type="text" name="HPSStyleName" id="HPSStyleName" class="layui-input" value="" style="background-color: #efefef4d; float: left; width: 150px;" readonly>
                                                <input type="hidden" name="HPSStyleID" id="HPSStyleID" 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>-->
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HPSStyleList" 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 type="text" name="HSSName" id="HSSName" class="layui-input" value="" style="background-color:#efefef4d;" readonly>
                                                <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>-->
                                                <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>
                                            <div class="layui-input-inline">
                                                <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;">
                                                    <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">
@@ -305,20 +305,38 @@
                        </div>
                    </div>
                    <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
                    <script type="text/html" id="toolbarDemo">
                        <div class="layui-btn-container">
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-AddLine"><i class="layui-icon layui-icon-form"></i>增加一行</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-InsertLine"><i class="layui-icon layui-icon-form"></i>插入一行</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine"><i class="layui-icon layui-icon-form"></i>复制一行</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Up"><i class="layui-icon layui-icon-form"></i>上移</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Under"><i class="layui-icon layui-icon-form"></i>下移</button>
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>列设置</button>
                    <div class="layui-tab" lay-filter="tab-POStockInBill">
                        <ul class="layui-tab-title" lay-filter="tab-all">
                            <li style="padding:1px;" class="layui-this">汇总表格</li>
                            <li style="padding:1px;">明细表格</li>
                        </ul>
                        <div class="layui-tab-content">
                            <div class="layui-tab-item layui-show">
                                <table class="layui-hide" id="mainTable" lay-filter="mainTable"></table>
                                <script type="text/html" id="toolbarDemo">
                                    <div class="layui-btn-container">
                                        {{# if(haveSource == false){ }}
                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-AddLine"><i class="layui-icon layui-icon-form"></i>增加一行</button>
                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-InsertLine"><i class="layui-icon layui-icon-form"></i>插入一行</button>
                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine"><i class="layui-icon layui-icon-form"></i>复制一行</button>
                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Up"><i class="layui-icon layui-icon-form"></i>上移</button>
                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Under"><i class="layui-icon layui-icon-form"></i>下移</button>
                                        {{# } }}
                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="get_Inventory" id="get_Inventory"><i class="layui-icon layui-icon-form"></i>库存查询</button>
                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="get_InOutSum" id="get_InOutSum"><i class="layui-icon layui-icon-form"></i>出入库记录查询</button>
                                        <button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>列设置</button>
                                    </div>
                                </script>
                                <script type="text/html" id="xuhao">
                                    {{d.LAY_TABLE_INDEX+1}}
                                </script>
                            </div>
                            <div class="layui-tab-item">
                                <table class="layui-hide" id="mainTableEntry" lay-filter="mainTableEntry"></table>
                            </div>
                        </div>
                    </script>
                    <script type="text/html" id="xuhao">
                        {{d.LAY_TABLE_INDEX+1}}
                    </script>
                    </div>
                </form>
            </div>
        </div>
@@ -330,6 +348,8 @@
    <script>
        //#region æŠ˜å æ³¨é‡Š
        //#endregion
        //是否有源单
        var haveSource = false;
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
@@ -350,10 +370,11 @@
            //记录组织的值
            var HOrgIDBar = 0;
            //子表渲染参数
            var option = {};
            var optionEntry = {};
            //#endregion
            //#region è¿›å…¥é¡µé¢å³åŠ è½½
@@ -498,9 +519,9 @@
                }
                //#endregion
                //if (AllowLoadData(data)) {
                if (AllowLoadData(data)) {
                    set_SaveBill(data);
                //}
                }
            });
            //#endregion
            //#endregion
@@ -618,6 +639,12 @@
                    //下移
                    case 'btn-Under': btn_under();
                        break;
                    //库存查询
                    case 'get_Inventory': get_Inventory();
                        break;
                    //出入库记录查询
                    case 'get_InOutSum': get_InOutSum();
                        break;
                    //列设置
                    case 'set_HideColumn':
                        get_HideColumn();
@@ -633,19 +660,6 @@
            });
            //#endregion
            //#region ç›‘听单元格编辑  å•元格编辑后 å˜æ›´
            table.on('edit(mainTable)', function (obj) {
                //数值格式校验工具
                var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                var temp = "";
                // å•元格编辑之前的值
                var oldText = $(this).prev().text();
                var value = obj.value //得到修改后的值
                    , data = obj.data //得到所在行所有键值
                    , field = obj.field; //得到字段
            });
            //#endregion
            //#endregion
            //#endregion
@@ -759,7 +773,7 @@
                    }
                });
            }
            ////#endregion
            //#endregion
            //#region å¼¹çª—选择方法
            //#region é€‰æ‹©é‡‡è´­éƒ¨é—¨
@@ -770,7 +784,19 @@
                    , area: ['90%', '90%']//大小
                    , title: '采购部门列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_DepartmentList.html', 'yes']
                    , 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
@@ -783,7 +809,19 @@
                    , area: ['90%', '90%']//大小
                    , title: '采购主管列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_EmployeeList.html?Type=HManager', 'yes']
                    , 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
@@ -796,7 +834,19 @@
                    , area: ['90%', '90%']//大小
                    , title: '业务员列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_EmployeeList.html?Type=HEmp', 'yes']
                    , content: ['../../基础资料/公用基础资料/Gy_EmployeeList.html?Type=HEmp', '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('请选择数据');
                        }
                        $("#HEmpName").val(checkStatus.data[0].职员名称);
                        $("#HEmpID").val(checkStatus.data[0].HItemID);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
                })
            }
            //#endregion
@@ -822,7 +872,20 @@
                    , area: ['90%', '90%']//大小
                    , title: '采购方式列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_PoStockStyle.html', 'yes']
                    , content: ['../../基础资料/公用基础资料/Gy_PoStockStyle.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('请选择数据');
                        }
                        $("#HPSStyleName").val(checkStatus.data[0].采购方式名称);
                        $("#HPSStyleID").val(checkStatus.data[0].HItemID);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
                })
            }
            //#endregion
@@ -835,7 +898,7 @@
                    , area: ['90%', '90%']//大小
                    , title: '结算方式列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_SettleStyle.html', 'yes']
                    , content: ['../../基础资料/基础资料/Gy_SettleStyle.html', 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
@@ -843,7 +906,7 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HSSName").val(checkStatus.data[0].HName);
                        $("#HSSName").val(checkStatus.data[0].结算方式名称);
                        $("#HSSID").val(checkStatus.data[0].HItemID);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
@@ -974,7 +1037,7 @@
                        , { 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: 'HRelTaxPrice', title: '实际含税单价', width: 100, style: 'background-color:#efefef4d;' }
                        , { 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;' }
@@ -1000,7 +1063,51 @@
                        , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 70 }
                    ]]
                }
                optionEntry = {
                    elem: '#mainTableEntry'
                    , 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, style: 'background-color:#efefef4d;'}
                        , { field: '物料名称', title: '物料名称', width: 150, style: 'background-color:#efefef4d;' }
                        , { field: '规格型号', title: '规格型号', width: 100, style: 'background-color:#efefef4d;' }
                        , { field: 'HUnitID', title: 'HUnitID', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: '计量单位', title: '计量单位', width: 100, style: 'background-color:#efefef4d;'}
                        , { field: 'HQty', title: '数量', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HPrice', title: '单价', width: 100, style: 'background-color:#efefef4d;' }
                        , { field: 'HMoney', title: '金额', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HTaxPrice', title: '含税单价', width: 100, style: 'background-color:#efefef4d;' }
                        , { field: 'HDiscountRate', title: '折扣率', width: 100, style: 'background-color:#efefef4d;' }
                        , { field: 'HRelTaxPrice', title: '实际含税单价', width: 100, style: 'background-color:#efefef4d;' }
                        , { field: 'HTaxRate', title: '税率', width: 100, style: 'background-color:#efefef4d;' }
                        , { 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, style: 'background-color:#efefef4d;' }
                        , { 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;' }
                    ]]
                }
                var rowdata = [{
                    "HMaterID": "0"
                    , "物料代码": ""
@@ -1039,7 +1146,58 @@
                }];
                option.data = rowdata;
                table.render(option);
                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 }
                    ]]
                }
            }
            //#endregion
@@ -1049,7 +1207,10 @@
                //数值格式校验工具
                var ref = /^\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"];  //金额精度
                // å•元格编辑之前的值
                var oldText = $(this).prev().text();
                var value = obj.value //得到修改后的值
@@ -1078,11 +1239,17 @@
                        var HPrice = obj.data.HPrice * 1;               //单价
                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                        var HTaxRate = obj.data.HTaxRate * 0.01;           //税率 
                        var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //税额=金额*税率
                        var HTaxMoney = Number((HMoney * HTaxRate));         //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        var HExRate = $("#HExRate").val();                      //汇率
                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate).toFixed(4));      //本位币价税合计=(税额+金额)*汇率
                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));      //本位币价税合计=(税额+金额)*汇率
                        HQty = Number(HQty.toFixed(HQtyDec));
                        HPrice = Number(HPrice.toFixed(HPriceDec));
                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                        HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                        HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
@@ -1092,6 +1259,7 @@
                            , HlineTotal: HlineTotal
                            , HlineTotalBB: HlineTotalBB
                        });
                        table.render(option);
                        break;
                    case "HPrice":                                         //单价
                        //数据格式校验
@@ -1119,6 +1287,15 @@
                        var HExRate = $("#HExRate").val();                      //汇率
                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate).toFixed(4));     //本位币价税合计=(税额+金额)*汇率
                        //数字精度
                        HQty = Number(HQty.toFixed(HQtyDec));
                        HPrice = Number(HPrice.toFixed(HPriceDec));
                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                        HTaxPrice = Number(HPrice.toFixed(HPriceDec));
                        HRelTaxPrice = Number(HPrice.toFixed(HPriceDec));
                        HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
                        HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
@@ -1130,6 +1307,7 @@
                            , HRelTaxPrice: HRelTaxPrice
                            , HlineTotalBB: HlineTotalBB
                        });
                        table.render(option);
                        break;
                    case "HTaxRate":                                                       //数量
                        //数据格式校验
@@ -1158,7 +1336,15 @@
                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate).toFixed(4));   //实际含税单价=含税单价*折扣率
                        var HExRate = $("#HExRate").val();                       //汇率
                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate).toFixed(4));       //本位币价税合计=(税额+金额)*汇率
                        //数字精度
                        HQty = Number(HQty.toFixed(HQtyDec));
                        HPrice = Number(HPrice.toFixed(HPriceDec));
                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                        HTaxPrice = Number(HPrice.toFixed(HPriceDec));
                        HRelTaxPrice = Number(HPrice.toFixed(HPriceDec));
                        HlineTotalBB = Number(HlineTotalBB.toFixed(HMoneyDec));
                        HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HTaxRate: HTaxRate * 100
@@ -1172,6 +1358,7 @@
                            , HRelTaxPrice: HRelTaxPrice
                            , HlineTotalBB: HlineTotalBB
                        });
                        table.render(option);
                        break;
                    case "HDiscountRate":                                                       //数量
                        //数据格式校验
@@ -1192,12 +1379,18 @@
                        var HQty = obj.data.HQty * 1;                   //数量
                        var HPrice = obj.data.HPrice * 1;
                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                        var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //税额=金额*税率
                        var HTaxPrice = Number((HPrice * (1 + HTaxRate)).toFixed(4));        //含税单价=单价*(1+税率)
                        var HTaxMoney = Number((HMoney * HTaxRate));         //税额=金额*税率
                        var HTaxPrice = Number((HPrice * (1 + HTaxRate)));        //含税单价=单价*(1+税率)
                        var HDiscountRate = obj.data.HDiscountRate * 1;     //折扣率
                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate).toFixed(4));   //实际含税单价=含税单价*折扣率
                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate));   //实际含税单价=含税单价*折扣率
                        //数字精度
                        HQty = Number(HQty.toFixed(HQtyDec));
                        HPrice = Number(HPrice.toFixed(HPriceDec));
                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                        HTaxPrice = Number(HPrice.toFixed(HPriceDec));
                        HRelTaxPrice = Number(HPrice.toFixed(HPriceDec));
                        HTaxMoney = Number(HTaxMoney.toFixed(HMoneyDec));
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HTaxRate: HTaxRate * 100
@@ -1209,8 +1402,57 @@
                            , HDiscountRate: HDiscountRate
                            , HRelTaxPrice: HRelTaxPrice
                        });
                        break;
                        table.render(option);
                        break;
                    case "HTaxPrice":                                         //单价
                        //数据格式校验
                        temp = value + "";     //修改后的值 è½¬ä¸ºå­—符串 èµ‹å€¼ç»™  å˜é‡temp
                        // ref很可能是一个正则表达式对象,用于匹配特定的字符串模式。ref.test(temp)会检查变量temp(即转换后的单价字符串)是否符合ref定义的模式。如果test方法返回false
                        if (!ref.test(temp)) { //检查单价字符串是否符合预期的格式
                            //恢复数据到编辑前
                            obj.update({            //更新表格某一行数据
                                HTaxPrice: oldText     //将hprice字段恢复到保存前的值
                            });
                            table.render(option);
                            layer.msg("含税单价请输入数字!");   //请输入单价的数值
                            return;
                        }
                        //数据校验合格,重算记录
                        var HQty = obj.data.HQty * 1;                   //数量
                        var HTaxPrice = value * 1;                    //含税单价
                        var HTaxRate = obj.data.HTaxRate * 0.01;           //税率
                        var HPrice = Number((HTaxPrice / (1 + HTaxRate)).toFixed(4));                         //单价 = å«ç¨Žå•ä»·/(1+税率)
                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                        var HTaxMoney = Number((HMoney * HTaxRate).toFixed(4));         //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        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));     //本位币价税合计=(税额+金额)*汇率
                        //数字精度
                        HQty = Number(HQty.toFixed(HQtyDec));
                        HPrice = Number(HPrice.toFixed(HPriceDec));
                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                        HTaxMoney = Number(HTaxMoney.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
                        });
                        table.render(option);
                        break;
                    default:
                }
            });
@@ -1275,6 +1517,10 @@
                                , "HDeleteDate": data.作废日期 == null ? "" : Format(new Date(data.作废日期), "yyyy-MM-dd HH:mm:ss")
                            });
                            if (data.HMainSourceBillType != "") {
                                haveSource = true;
                            }
                            HOrgIDBar = 0;
                            //子表  èµ‹å€¼
@@ -1321,6 +1567,13 @@
                            }
                            option.data = rowdata;
                            table.render(option);
                            //子表  èµ‹å€¼
                            var rowdata = result.list[0];
                            optionEntry.data = rowdata;
                            table.render(optionEntry);
                            layer.close(ajaxLoad);
                        } else {
                            layer.close(ajaxLoad);
@@ -1404,7 +1657,7 @@
                                , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                                , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                                , 'HDiscountRate': dataArray[i].折扣率                                                       //
                                , 'HRelTaxPrice': dataArray[i].实际含税单价
                                , 'HRelTaxPrice': dataArray[i].实际含税单价
                                , "HTaxRate": dataArray[i].税率
                                , 'HTaxMoney': dataArray[i].税额                                                             //
                                , "HMoney": dealDoubleToFixed(dataArray[i].金额, 2)
@@ -1481,7 +1734,7 @@
                                , "计量单位": dataArray[i].计量单位
                                , "HQty": dealDoubleToFixed(dataArray[i].实收数量, 1)
                                , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                                , "HTaxPrice": dataArray[i].含税单价
                                , "HTaxPrice": dataArray[i].含税单价
                                , 'HDiscountRate': dataArray[i].折扣率                                               //
                                , 'HRelTaxPrice': "0"
                                , "HTaxRate": dataArray[i].税率
@@ -1540,7 +1793,20 @@
                    }
                }
                var sSubStr = JSON.stringify(num);
                var sSubStr2;
                if (haveSource == true) {
                    //获取子表2数据
                    var num = [];
                    for (var i = 0; i < table.cache["mainTableEntry"].length; i++) {
                        if (table.cache["mainTableEntry"][i] != "") {
                            table.cache["mainTableEntry"][i].LAY_TABLE_INDEX = i;
                            num.push(table.cache["mainTableEntry"][i])
                        }
                    }
                    sSubStr2 = JSON.stringify(num);
                } else {
                    sSubStr2 = JSON.stringify([]);
                }
                //获取操作方式
                var refSav = "";
                if (OperationType == 1 || OperationType == 2 || OperationType == 4) {
@@ -1550,7 +1816,7 @@
                    refSav = "Update";
                }
                var sMainSub = sMainStr + ';' + sSubStr + ';' + refSav + ';' + sessionStorage["HUserName"];
                var sMainSub = sMainStr + ';' + sSubStr + ';' + sSubStr2 + ';'+ refSav + ';' + sessionStorage["HUserName"];
                $.ajax({
                    type: "POST",
@@ -1594,14 +1860,33 @@
                    layer.msg("日期不能为空!");
                    return false;
                }
                if ($("#HSupID").val() == "0") {
                    layer.msg("供应商未选择!");
                    return false;
                if ($("#HCurID").val() == 0) {
                    layer.msg("请选择币别!");
                    return;
                }
                if ($("#HCurID").val() == "0") {
                    layer.msg("币别未选择!");
                    return false;
                if ($("#HExRate").val() == 0) {
                    layer.msg("请输入汇率!");
                    return;
                }
                if ($("#HEmpID").val() == 0) {
                    layer.msg("请选择业务员员!");
                    return;
                }
                if ($("#HDeptID").val() == 0) {
                    layer.msg("请选择采购部门!");
                    return;
                }
                if ($("#HSupID").val() == 0) {
                    layer.msg("请选择供应商!");
                    return;
                }
                if ($("#HPSStyleID").val() == 0) {
                    layer.msg("请选择采购方式!");
                    return;
                }
                if ($("#HSSID").val() == 0) {
                    layer.msg("请选择结算方式!");
                    return;
                }
                temp = $("#HExRate").val() + "";
@@ -1616,6 +1901,9 @@
                //#region å­è¡¨ æ•°æ®æ£€éªŒ
                for (var i = 0; i < option.data.length; i++) {
                    if (typeof option.data[i] !== 'object' || option.data[i] === null || Array.isArray(option.data[i])) {
                        continue; // è·³è¿‡éžå¯¹è±¡é¡¹ï¼ˆå¦‚空数组)
                    }
                    if (option.data[i]["HMaterID"] == "0") {
                        layer.msg("第" + (i+1) + "行:物料未选择!");
                        return false;
@@ -1675,17 +1963,12 @@
                    //价税合计格式校验
                    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") {
                        layer.msg("第" + (i + 1) + "行:发货仓库未选择!");
                    //if (temp == "0") {
                    //    layer.msg("第" + (i + 1) + "行:价税合计不能为0!");
                    //    return false;
                    //} else
                    if (!ref.test(temp)) {
                        layer.msg("第" + (i + 1) + "行:税额请输入大于0的数字!");
                        return false;
                    }
                }
@@ -1700,7 +1983,7 @@
                    if (event.key == "F7") {
                        //物料
                        if (obj.event == "HMaterID") {
                                var HOrgID = $("#HOrgID").val();
                            var HOrgID = $("#HOrgID").val();  //获取id="HOrgID"的元素中获取其值,并将该值存储在变量HOrgID中
                            layer.open({
                                type: 2
                                , skin: "layui-layer-rim" //加上边框
@@ -1720,27 +2003,76 @@
                                        return layer.msg("请选择一条数据");
                                    }
                                    OptionData = checkStatus.data[0];
                                    //更新表格缓存的数据
                                    obj.update({
                                        "HMaterID": checkStatus.data[0].HItemID
                                        , "物料代码": checkStatus.data[0].HNumber
                                        , "物料名称": checkStatus.data[0].HName
                                        , "规格型号": checkStatus.data[0].HModel
                                        , "HUnitID": checkStatus.data[0].HUnitID
                                        , "计量单位": checkStatus.data[0].HUnitName
                                    })
                                    layer.close(index);//关闭弹窗
                                }
                               , end: function () {
                                obj.update({
                                   "HMaterID" :OptionData.HMaterID
                                        ,"物料代码" : OptionData.物料代码
                                       , "物料名称" :OptionData.物料名称
                                        ,"规格型号" : OptionData.规格型号
                                        ,"HUnitID" :OptionData.HUnitID
                                        ,"计量单位" : OptionData.计量单位名称
                                })
                            }
                                , end: function () {
                                    //通过供应商id获取税率
                                    var HSupID = $("#HSupID").val();
                                    if (HSupID != 0 && typeof (OptionData.HItemID) != "undefined") {
                                        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_Supplier/xg",
                                            //url: "http://localhost:12761/Gy_Supplier/xg",
                                            type: "GET",
                                            data: {
                                                "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 HDiscountRate = obj.data.HDiscountRate * 1;   //折扣率
                                                var HRelTaxPrice = Number((HTaxPrice * HDiscountRate));   //实际含税单价=含税单价*折扣率
                                                var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));     //本位币价税合计=(税额+金额)*汇率
                                                //数字精度
                                                HQty = Number(HQty.toFixed(HQtyDec));
                                                HPrice = Number(HPrice.toFixed(HPriceDec));
                                                HMoney = Number(HMoney.toFixed(HMoneyDec));
                                                HTaxMoney = Number(HTaxMoney.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
                                                })
                                            }
                                        });
                                    } else if (typeof (OptionData.HItemID) != "undefined") {
                                        obj.update({ //更新表格数据
                                            "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                            , "物料代码": OptionData.物料代码
                                            , "物料名称": OptionData.物料名称
                                            , "规格型号": OptionData.规格型号
                                            , "HUnitID": OptionData.HUnitID
                                            , "计量单位": OptionData.计量单位名称
                                        })
                                    }
                                }
                            })
                        }
                        //计量单位
@@ -1783,7 +2115,102 @@
                    return false;
                }
            })
                })
                //双击
                $('.layui-table-box tbody td[data-field="物料代码"]').off('dblclick').on('dblclick', function () {
                    var HOrgID = $("#HOrgID").val();  //获取id="HOrgID"的元素中获取其值,并将该值存储在变量HOrgID中
                    layer.open({
                        type: 2
                        , skin: "layui-layer-rim" //加上边框
                        , title: "物料列表"  //标题
                        , closeBtn: 1  //窗体右上角关闭 çš„ æ ·å¼
                        , shift: 2 //弹出动画
                        , area: ["90%", "90%"] //窗体大小
                        , maxmin: true //设置最大最小按钮是否显示
                        , content: ['../../基础资料/公用基础资料/Gy_Material.html?openType=2&HOrgID=' + HOrgID, 'yes']
                        , btn: ["确定", "取消"]
                        , btn1: function (index, laero) {
                            //按钮一  çš„回调
                            var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
                            var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
                            if (checkStatus.data.length != 1) {
                                return layer.msg("请选择一条数据");
                            }
                            OptionData = checkStatus.data[0];
                            layer.close(index);//关闭弹窗
                        }
                        , end: function () {
                            //通过供应商id获取税率
                            var HSupID = $("#HSupID").val();
                            if (HSupID != 0 && typeof (OptionData.HItemID) != "undefined") {
                                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_Supplier/xg",
                                    //url: "http://localhost:12761/Gy_Supplier/xg",
                                    type: "GET",
                                    data: {
                                        "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 HDiscountRate = obj.data.HDiscountRate * 1;   //折扣率
                                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate));   //实际含税单价=含税单价*折扣率
                                        var HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate));     //本位币价税合计=(税额+金额)*汇率
                                        //数字精度
                                        HQty = Number(HQty.toFixed(HQtyDec));
                                        HPrice = Number(HPrice.toFixed(HPriceDec));
                                        HMoney = Number(HMoney.toFixed(HMoneyDec));
                                        HTaxMoney = Number(HTaxMoney.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
                                        })
                                    }
                                });
                            } else if (typeof (OptionData.HItemID) != "undefined"){
                                obj.update({ //更新表格数据
                                    "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                    , "物料代码": OptionData.物料代码
                                    , "物料名称": OptionData.物料名称
                                    , "规格型号": OptionData.规格型号
                                    , "HUnitID": OptionData.HUnitID
                                    , "计量单位": OptionData.计量单位名称
                                })
                            }
                        }
                    })
                });
        }
            //#endregion
@@ -1796,7 +2223,10 @@
                        console.log("索引为:" + rowIndex);
                        if (rowIndex === '0') {
                            layer.msg('首行无法删除!!!');
                        } else {
                        } else if (haveSource == true) {
                            layer.msg('有源单无法删除!!!');
                        }
                        else {
                            obj.del();
                            option.data = table.cache["mainTable"];//将数据绑定到data上
                            table.reload(option);
@@ -1814,6 +2244,56 @@
                table.render(option);
                //rows++;
                layer.msg('增加一行按钮!')
            }
            //#endregion
            //#region åº“存查询
            function get_Inventory() {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                if (checkStatus.data.length === 1 && data[0].HMaterID != 0) {
                    var HMaterID = data[0].HMaterID.toString();
                    //弹窗方法
                    layer.open({
                        type: 2//弹窗类型
                        , skin: 'layui-layer-rim' //加上边框
                        , area: ['90%', '90%']//大小
                        , title: '库存查询列表'//标题
                        , shift: 2//弹出动画
                        , content: ['../../仓存管理/条码报表/Kf_ICinventoryQueryReport.html?Type=1&HMaterID=' + HMaterID, 'yes']
                        , btn: ['取消']
                        , btn1: function (index, layero) {
                            layer.close(index);
                        }
                    })
                }
                else {
                    layer.msg('请选择一行有物料数据查询!');
                }
            }
            //#endregion
            //#region å‡ºå…¥åº“记录查询
            function get_InOutSum() {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                if (checkStatus.data.length === 1 && data[0].HMaterID != 0) {
                    var HMaterID = data[0].HMaterID.toString();
                    layer.open({
                        type: 2//弹窗类型
                        , skin: 'layui-layer-rim' //加上边框
                        , area: ['90%', '90%']//大小
                        , title: '出入库记录列表'//标题
                        , shift: 2//弹出动画
                        , content: ['../../仓存管理/条码报表/Kf_StockInOutSumQueryReport.html?Type=1&HMaterID=' + HMaterID, 'yes']
                        , btn: ['取消']
                        , btn1: function (index, layero) {
                            layer.close(index);
                        }
                    })
                }
                else {
                    layer.msg('请选择一行有物料数据查询!');
                }
            }
            //#endregion
@@ -2087,24 +2567,24 @@
                    , "HPSStyleName": dataArray[0].采购方式
                });
                //子表  èµ‹å€¼
                var rowdata = [];
                //子表Entry  èµ‹å€¼
                var rowdataEntry = [];
                for (var i = 0; i < dataArray.length; i++) {
                    rowdata.push(
                    rowdataEntry.push(
                        {
                             "HMaterID": dataArray[i].HMaterID
                            "HMaterID": dataArray[i].HMaterID
                            , "物料代码": dataArray[i].物料代码
                            , "物料名称": dataArray[i].物料名称
                            , "规格型号": dataArray[i].规格型号
                            , "HUnitID": dataArray[i].HUnitID
                            , "计量单位": dataArray[i].计量单位
                            , "HQty": dealDoubleToFixed(dataArray[i].数量-dataArray[i].关联数量, 1)
                            , "HQty": dealDoubleToFixed(dataArray[i].数量 - dataArray[i].关联数量, 1)
                            , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                            , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                            , 'HDiscountRate':"0"                                                     //
                            , 'HDiscountRate': "0"                                                     //
                            , 'HRelTaxPrice': "0"
                            , "HTaxRate": dataArray[i].税率
                            , 'HTaxMoney':"0"                                                         //
                            , 'HTaxMoney': "0"                                                         //
                            , "HMoney": dealDoubleToFixed(dataArray[i].金额, 2)
                            , 'HMoneyBB': dealDoubleToFixed(dataArray[i].金额 * dataArray[0].汇率, 2)
                            , 'HlineTotal': dealDoubleToFixed(dataArray[i].价税合计, 2)
@@ -2129,7 +2609,28 @@
                        }
                    );
                }
                option.data = rowdata;
                optionEntry.data = 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.splice(j, 1);
                            j = j - 1;
                        }
                    }
                }
                set_InitGridHaveSource();
                option.data = rowdataEntry;
                haveSource = true;
                table.render(option);
            }
            //#endregion
@@ -2180,10 +2681,10 @@
                    , "HPSStyleName": dataArray[0].采购方式
                });
                //子表  èµ‹å€¼
                var rowdata = [];
                //子表Entry  èµ‹å€¼
                var rowdataEntry = [];
                for (var i = 0; i < dataArray.length; i++) {
                    rowdata.push(
                    rowdataEntry.push(
                        {
                            "HMaterID": dataArray[i].HMaterID
                            , "物料代码": dataArray[i].物料代码
@@ -2191,13 +2692,14 @@
                            , "规格型号": dataArray[i].规格型号
                            , "HUnitID": dataArray[i].HUnitID
                            , "计量单位": dataArray[i].计量单位
                            , "HQty": dealDoubleToFixed(dataArray[i].实收数量-dataArray[i].关联数量, 1)
                            , "HQty": dealDoubleToFixed(dataArray[i].实收数量 - dataArray[i].关联数量, 1)
                            , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                            , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                            , 'HDiscountRate': "0"                                                     //
                            , 'HRelTaxPrice': "0"
                            , "HTaxRate": dataArray[i].税率
                            , 'HTaxMoney': "0"                                                         //
                            , "HMoney":dataArray[i].金额
                            , "HMoney": dataArray[i].金额
                            , "HRemark": ""
                            , "HSourceInterID": dataArray[i].hmainid
@@ -2211,15 +2713,36 @@
                            , 'HPOOrderEntryID': "0"
                            , 'HPOOrderBillNo': ""
                           // , 'HSeOrderTaxPrice': dealDoubleToFixed(dataArray[i].含税单价, 3)
                            , "HSeOrderInterID": dataArray[i].HSourceBillType == "1401" ? dataArray[i].HSourceInterID: "0"
                            // , '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].源单单号 : ""
                        }
                    );
                }
                option.data = rowdata;
                optionEntry.data = 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.splice(j, 1);
                            j = j - 1;
                        }
                    }
                }
                set_InitGridHaveSource();
                option.data = rowdataEntry;
                haveSource = true;
                table.render(option);
            }
            //#endregion
@@ -2277,6 +2800,32 @@
            }
            //#endregion
            //#region æ ¹æ®ç‰©æ–™ID获取精度
            function getDecByMaterID(HMaterID) {
                var resultData = {};
                $.ajax({  // å¼‚步请求
                    url: GetWEBURL() + "Gy_Material/getDecByID",  //请求地址
                    async: false,   //是否开启异步
                    type: "GET",   //请求类型
                    data: {   //定义发送到服务器的数据
                        "HMaterID": HMaterID     //  å°†hmaterid作为请求参数发送
                    },
                    success: function (result) {   // å½“请求成功时,执行这个函数
                        if (result.code == 1) { // å¦‚果服务器返回的数据中的`code字段等于1,这可能表示审核操作成功执行
                            var data = result.data; //声明data变量,并将其赋值为result对象中的data属性
                            resultData = data[0];   //将data数组(或类数组对象)的第一个元素赋值给变量resultData
                        }
                        //else {
                        //    layer.alert(result.Message, { icon: 5, btn: ['退出'], time: 100000, offset: 't' }); //result.msg对象,提示弹窗 ç±»åž‹ä¸º5, æŒ‰é’®ï¼Œå’ŒæŒ‰é’®çš„名称为退出  æ—¶é—´ ä¸º100秒,以及偏移量(`offset: 't'
                        //}
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });  //提示弹窗 å‘生错误 ï¼Œè­¦ç¤ºæ ‡å¿—为5的
                    }
                });
                return resultData;
            }
            //#endregion
            //#region æ ¹æ®ä¸»å†…码与子内码获取源单采购入库单数据
            function getPushSource_POStockInBillInit(HSourceInterID, HSourceEntryID) {
                var res = "none";
@@ -2303,6 +2852,9 @@
                return res;
            }
            //#endregion
            //#endregion
@@ -2311,7 +2863,7 @@
        // åŸºç¡€èµ„料返回数据
        function GetHEmpValue(obj)  //返回业务员
        {
            $("#HEmpName").val(obj[0].HName);
            $("#HEmpName").val(obj[0].职员名称);
            $("#HEmpID").val(obj[0].HItemID);
        }
@@ -2323,25 +2875,25 @@
        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 GetHPSStyleValue(obj)  //返回采购方式
        function GetHPSStyleNameValue(obj)  //返回采购方式
        {
            $("#HSellSName").val(obj[0].HName);
            $("#HSellSID").val(obj[0].HItemID);
            $("#HPSStyleName").val(obj[0].采购方式名称);
            $("#HPSStyleID").val(obj[0].HItemID);
        }
        function GetSettleStyleValue(obj)           //返回结算方式
        {
            $("#HSSName").val(obj[0].HName);
            $("#HSSName").val(obj[0].结算方式名称);
            $("#HSSID").val(obj[0].HItemID);
        }