zrg
2024-08-13 ba1fb184917b1651221a6decf1144911ff489f86
WebTM/views/²É¹º¹ÜÀí/Ó¦¸¶µ¥/Cg_PayableBill.html
@@ -77,10 +77,13 @@
                                        <div class="layui-inline">
                                            <label class="layui-form-label">源单类型</label>
                                            <div class="layui-input-inline">
                                                <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 name="BillType" id="BillType" lay-verify="BillType">
                                                    <!--动态渲染源单类型-->
                                                </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>-->
                                            </div>
                                        </div>
                                        <div class="layui-inline">
@@ -97,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">
@@ -156,31 +149,41 @@
                                            </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">
                                                <input type="date" class="layui-input" lay-verify="HPayDate" name="HPayDate" id="HPayDate" style="width:190px;">
                                                <input type="date" class="layui-input" lay-verify="HReceiveDate" name="HReceiveDate" id="HReceiveDate" style="width:190px;">
                                            </div>
                                        </div>
                                    </div>
@@ -302,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>
@@ -327,6 +348,8 @@
    <script>
        //#region æŠ˜å æ³¨é‡Š
        //#endregion
        //是否有源单
        var haveSource = false;
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
@@ -347,10 +370,11 @@
            //记录组织的值
            var HOrgIDBar = 0;
            //子表渲染参数
            var option = {};
            var optionEntry = {};
            //#endregion
            //#region è¿›å…¥é¡µé¢å³åŠ è½½
@@ -378,6 +402,12 @@
            //初始化子表
            set_InitGrid();
            //初始化组织
            Organ();
            //初始化 èŽ·å–æºå•ç±»åž‹
            HSourceBillType();
            //#region åˆ¤æ–­æ“ä½œç±»åž‹å¹¶åˆå§‹åŒ–界面
            if (OperationType == 1) {                                                   //无源单新增
@@ -411,8 +441,9 @@
            DisPlay_HideColumn();
            //初始化组织
            Organ();
            //#endregion
@@ -488,9 +519,9 @@
                }
                //#endregion
                //if (AllowLoadData(data)) {
                if (AllowLoadData(data)) {
                    set_SaveBill(data);
                //}
                }
            });
            //#endregion
            //#endregion
@@ -508,7 +539,7 @@
            });
            //#endregion
            //#region é€‰æ‹©é‡‡è´­å‘˜æŒ‰é’®
            //#region é€‰æ‹©ä¸šåŠ¡å‘˜æŒ‰é’®
            form.on('submit(HEmpList)', function () {
                get_checkEmp();
            });
@@ -608,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();
@@ -623,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
@@ -711,10 +735,7 @@
                                Organization += '<option  style="color:blue;" value="' + data[i].ID + '">' + data[i].Name + '</option>';
                            }
                            $("#HOrgID").append(Organization);
                            if (OperationType == 1 || OperationType == 4) {
                                HOrgIDBar = sessionStorage["OrganizationID"];
                            }
                            $("#HOrgID").val(HOrgIDBar);
                            $("#HOrgID").val(sessionStorage["OrganizationID"])
                            form.render('select');
                        }
                        layer.closeAll("loading");
@@ -752,7 +773,7 @@
                    }
                });
            }
            ////#endregion
            //#endregion
            //#region å¼¹çª—选择方法
            //#region é€‰æ‹©é‡‡è´­éƒ¨é—¨
@@ -763,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
@@ -776,20 +809,44 @@
                    , 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
            //#region é€‰æ‹©é‡‡è´­å‘˜
            //#region é€‰æ‹©ä¸šåŠ¡å‘˜
            function get_checkEmp() {
                layer.open({
                    type: 2//弹窗类型
                    , skin: 'layui-layer-rim' //加上边框
                    , area: ['90%', '90%']//大小
                    , title: '采购员列表'//标题
                    , 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
@@ -815,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
@@ -828,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]  //获取弹框页面
@@ -836,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内部动态递增计算的
                    }
@@ -867,6 +937,30 @@
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
                })
            }
            //#endregion
            //#region èŽ·å–æºå•ç±»åž‹
            function HSourceBillType() {
                var HName = '应付单';
                //获取登录页组织列
                $.ajax({
                    type: "get",
                    async: false,
                    data: { "HName": HName, "Num": 2 },       //0蓝单 1红单 2不分红蓝单
                    url: GetWEBURL() + "/Web/GetHSourceBillType",
                    success: function (result) {
                        var HSourceBillTypes = "";
                        if (result.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            var data = result.data;
                            for (var i = 0; i < data.length; i++) {
                                HSourceBillTypes += '<option  style="color:blue;" value="' + data[i].HSourceBillType + '">' + data[i].HSourceBillTypeName + '</option>';
                            }
                            $("#BillType").append(HSourceBillTypes);
                            form.render('select');
                        }
                    }
                })
            }
            //#endregion
@@ -943,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;' }
@@ -969,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"
                    , "物料代码": ""
@@ -1008,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
@@ -1018,13 +1207,16 @@
                //数值格式校验工具
                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 //得到修改后的值
                    , data = obj.data //得到所在行所有键值
                    , field = obj.field; //得到字段
                //#endregion
                switch (field) {
                    case "HQty":                                         //数量
@@ -1052,6 +1244,10 @@
                        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));
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
@@ -1061,6 +1257,7 @@
                            , HlineTotal: HlineTotal
                            , HlineTotalBB: HlineTotalBB
                        });
                        table.render(option);
                        break;
                    case "HPrice":                                         //单价
                        //数据格式校验
@@ -1088,6 +1285,13 @@
                        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));
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
@@ -1099,6 +1303,7 @@
                            , HRelTaxPrice: HRelTaxPrice
                            , HlineTotalBB: HlineTotalBB
                        });
                        table.render(option);
                        break;
                    case "HTaxRate":                                                       //数量
                        //数据格式校验
@@ -1127,7 +1332,13 @@
                        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));
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HTaxRate: HTaxRate * 100
@@ -1141,6 +1352,7 @@
                            , HRelTaxPrice: HRelTaxPrice
                            , HlineTotalBB: HlineTotalBB
                        });
                        table.render(option);
                        break;
                    case "HDiscountRate":                                                       //数量
                        //数据格式校验
@@ -1166,7 +1378,13 @@
                        var HDiscountRate = obj.data.HDiscountRate * 1;     //折扣率
                        var HRelTaxPrice = Number((HTaxPrice * HDiscountRate).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));
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HTaxRate: HTaxRate * 100
@@ -1178,12 +1396,59 @@
                            , 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));
                        HlineTotal = Number(HlineTotal.toFixed(HMoneyDec));
                        HTaxPrice = Number(HPrice.toFixed(HPriceDec));
                        HRelTaxPrice = Number(HPrice.toFixed(HPriceDec));
                        //同步更新表格和缓存对应的值
                        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:
                }
            });
            //#endregion
          //#endregion
            //#endregion
            //#endregion
@@ -1227,7 +1492,7 @@
                                , "HSSName": data.结算方式
                                , "HPSStyleID": data.HPSStyleID
                                , "HPSStyleName": data.采购方式
                                , "HPayDate": formatDate(data.付款日期)
                                , "HReceiveDate": formatDate(data.付款日期)
                                , "HRemark": data.表头备注
                                , "HExplanation": data.摘要
                                , "HInnerBillNo": data.内部单据号
@@ -1243,6 +1508,10 @@
                                , "HDeleteMan": data.作废人
                                , "HDeleteDate": data.作废日期 == null ? "" : Format(new Date(data.作废日期), "yyyy-MM-dd HH:mm:ss")
                            });
                            if (data.HMainSourceBillType != "") {
                                haveSource = true;
                            }
                            HOrgIDBar = 0;
@@ -1290,6 +1559,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);
@@ -1346,7 +1622,7 @@
                        , "HMangerID": dataArray[0].HManagerID
                        , "HMangerName": dataArray[0].主管
                        , "HEmpID": dataArray[0].HEmpID
                        , "HEmpName": dataArray[0].采购员
                        , "HEmpName": dataArray[0].业务员
                        , "HSupID": dataArray[0].HSupID
                        , "HSupName": dataArray[0].供应商
                        , "HCurID": dataArray[0].HCurID
@@ -1373,7 +1649,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)
@@ -1427,7 +1703,7 @@
                        , "HManagerID": dataArray[0].hmanagerid
                        , "HMangerName": dataArray[0].主管
                        , "HEmpID": dataArray[0].HEmpID
                        , "HEmpName": dataArray[0].采购员
                        , "HEmpName": dataArray[0].业务员
                        , "HSupID": dataArray[0].HSupID
                        , "HSupName": dataArray[0].供应商
                        , "HCurID": dataArray[0].HCurID
@@ -1442,7 +1718,7 @@
                    for (var i = 0; i < dataArray.length; i++) {
                        rowdata.push(
                            {
                                "HMaterID": dataArray[i].hmaterid
                                "HMaterID": dataArray[i].HMaterID
                                , "物料代码": dataArray[i].物料代码
                                , "物料名称": dataArray[i].物料名称
                                , "规格型号": dataArray[i].规格型号
@@ -1450,7 +1726,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].税率
@@ -1509,7 +1785,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) {
@@ -1519,7 +1808,7 @@
                    refSav = "Update";
                }
                var sMainSub = sMainStr + ';' + sSubStr + ';' + refSav + ';' + sessionStorage["HUserName"];
                var sMainSub = sMainStr + ';' + sSubStr + ';' + sSubStr2 + ';'+ refSav + ';' + sessionStorage["HUserName"];
                $.ajax({
                    type: "POST",
@@ -1563,14 +1852,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() + "";
@@ -1585,6 +1893,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;
@@ -1644,17 +1955,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;
                    }
                }
@@ -1688,18 +1994,63 @@
                                    if (checkStatus.data.length != 1) {
                                        return layer.msg("请选择一条数据");
                                    }
                                    //更新表格缓存的数据
                                    obj.update({
                                        "HMaterID": checkStatus.data[0].HItemID
                                        , "物料代码": checkStatus.data[0].HNumber
                                        , "物料名称": checkStatus.data[0].HName
                                        , "规格型号": checkStatus.data[0].HModel
                                        , "HUnitID": checkStatus.data[0].HUnitID
                                        , "计量单位": checkStatus.data[0].HUnitName
                                    })
                                    OptionData = checkStatus.data[0];
                                    layer.close(index);//关闭弹窗
                                }
                               , end: function () {
                                   //通过供应商id获取税率
                                   var HSupID = $("#HSupID").val();
                                   if (HSupID != 0) {
                                       $.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).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 HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate).toFixed(4));     //本位币价税合计=(税额+金额)*汇率
                                               obj.update({ //更新表格数据
                                                   "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                                   , "物料代码": OptionData.物料代码
                                                   , "物料名称": OptionData.物料名称
                                                   , "规格型号": OptionData.规格型号
                                                   , "HUnitID": OptionData.HUnitID
                                                   , "计量单位": OptionData.计量单位名称
                                                   , "HTaxRate": HTaxRate * 100
                                                   , HQty: HQty                               //更新HQty字段,HQty
                                                   , HPrice: HPrice                         //更新HPrice字段,HPrice
                                                   , HMoney: HMoney                      //更新HMoney字段,HMoney
                                                   , HTaxMoney: HTaxMoney                  //更新HTaxMoney字段,HTaxMoney
                                                   , HlineTotal: HlineTotal             //更新HlineTotal字段,HlineTotal
                                                   , HTaxPrice, HTaxPrice                   //更新HTaxPrice字段,HTaxPrice
                                                   , HRelTaxPrice: HRelTaxPrice            //更新HRelTaxPrice字段,其值来自变量HRelTaxPrice
                                                   , HlineTotalBB: HlineTotalBB              //更新HlineTotalBB字段,其值来自变量HlineTotalBB
                                               })
                                           }
                                       });
                                   } else {
                                       obj.update({ //更新表格数据
                                           "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                           , "物料代码": OptionData.物料代码
                                           , "物料名称": OptionData.物料名称
                                           , "规格型号": OptionData.规格型号
                                           , "HUnitID": OptionData.HUnitID
                                           , "计量单位": OptionData.计量单位名称
                                       })
                                   }
                            }
                            })
                        }
                        //计量单位
@@ -1715,27 +2066,116 @@
                                , content: ['../../基础资料/公用基础资料/Gy_Unit.html', 'yes']
                                , btn: ["确定", "取消"]
                                , btn1: function (index, laero) {
                                    //按钮一  çš„回调
                                    var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
                                    var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
                                //按钮一  çš„回调
                                var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
                                var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
                                    if (checkStatus.data.length != 1) {
                                        return layer.msg("请选择一条数据");
                                    }
                                    //更新表格缓存的数据
                                    obj.update({
                                        "计量单位": checkStatus.data[0].计量单位名称
                                        , "HUnitID": checkStatus.data[0].HItemID
                                    })
                                    layer.close(index);//关闭弹窗
                                if (checkStatus.data.length != 1) {
                                    return layer.msg("请选择一条数据");
                                }
                            })
                        }
                        obj.event = "";
                        return false;
                                OptionData = checkStatus.data[0];
                                //更新表格缓存的数据
                                obj.update({
                                    "HUnitID": checkStatus.data[0].HItemID
                                    , "计量单位": checkStatus.data[0].计量单位名称
                                })
                                layer.close(index);//关闭弹窗
                            }
                            , end: function () {
                                obj.update({
                                    "HUnitID": OptionData.HItemID
                                    , "计量单位": OptionData.计量单位名称
                                })
                            }
                        })
                    }
                    obj.event = "";
                    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) {
                                $.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).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 HlineTotalBB = Number(((HMoney + HTaxMoney) * HExRate).toFixed(4));     //本位币价税合计=(税额+金额)*汇率
                                        obj.update({ //更新表格数据
                                            "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                            , "物料代码": OptionData.物料代码
                                            , "物料名称": OptionData.物料名称
                                            , "规格型号": OptionData.规格型号
                                            , "HUnitID": OptionData.HUnitID
                                            , "计量单位": OptionData.计量单位名称
                                            , "HTaxRate": HTaxRate * 100
                                            , HQty: HQty                               //更新HQty字段,HQty
                                            , HPrice: HPrice                         //更新HPrice字段,HPrice
                                            , HMoney: HMoney                      //更新HMoney字段,HMoney
                                            , HTaxMoney: HTaxMoney                  //更新HTaxMoney字段,HTaxMoney
                                            , HlineTotal: HlineTotal             //更新HlineTotal字段,HlineTotal
                                            , HTaxPrice, HTaxPrice                   //更新HTaxPrice字段,HTaxPrice
                                            , HRelTaxPrice: HRelTaxPrice            //更新HRelTaxPrice字段,其值来自变量HRelTaxPrice
                                            , HlineTotalBB: HlineTotalBB              //更新HlineTotalBB字段,其值来自变量HlineTotalBB
                                        })
                                    }
                                });
                            } else {
                                obj.update({ //更新表格数据
                                    "HMaterID": OptionData.HItemID             //设置HItemID的值为“HBillNo”字段的值HItemID`的值
                                    , "物料代码": OptionData.物料代码
                                    , "物料名称": OptionData.物料名称
                                    , "规格型号": OptionData.规格型号
                                    , "HUnitID": OptionData.HUnitID
                                    , "计量单位": OptionData.计量单位名称
                                })
                            }
                        }
                    })
                });
        }
            //#endregion
            //#region è¡Œå†…删除
@@ -1747,7 +2187,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);
@@ -1765,6 +2208,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
@@ -2038,24 +2531,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)
@@ -2080,7 +2573,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
@@ -2116,7 +2630,7 @@
                    , "HDeptID": dataArray[0].HDeptID
                    , "HDeptName": dataArray[0].部门
                    , "HMangerID": dataArray[0].hmanagerid
                    , "HMangerID": dataArray[0].hmanagerid == null ? "0" : dataArray[0].hmanagerid
                    , "HMangerName": dataArray[0].主管
                    , "HEmpID": dataArray[0].HEmpID
                    , "HEmpName": dataArray[0].业务员
@@ -2131,24 +2645,25 @@
                    , "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
                            , "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
@@ -2162,15 +2677,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
@@ -2228,6 +2764,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";
@@ -2254,6 +2816,9 @@
                return res;
            }
            //#endregion
            //#endregion
@@ -2262,7 +2827,7 @@
        // åŸºç¡€èµ„料返回数据
        function GetHEmpValue(obj)  //返回业务员
        {
            $("#HEmpName").val(obj[0].HName);
            $("#HEmpName").val(obj[0].职员名称);
            $("#HEmpID").val(obj[0].HItemID);
        }
@@ -2274,25 +2839,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);
        }
@@ -2331,6 +2896,18 @@
            }
        }
            //#endregion
        //双击返回计量单位
         function GetGyUnit(data) {
             OptionData = data
         }
            //双击返回物料
         function GetGyMaterial(data) {
             OptionData = data
         }
    </script>
</body>
</html>