duhe
2024-03-07 bbc7eaa15e381ae6e734526548dd285ab1432927
WebTM/views/ÏúÊÛ¹ÜÀí/ÏúÊÛ¶©µ¥/Add_Edit_Xs_SeOrderBillList.html
@@ -15,25 +15,37 @@
    <script src="../../../layuiadmin/Scripts/webConfig.js"></script>
    <script src="../../../layuiadmin/PubCustom.js"></script>
    <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <style type="text/css">
        .layui-form-item .layui-inline {
            margin-right: 0;
        }
    <script src="../../../layuiadmin/PageTitle.js"></script>
    <style>
        /*.main-btn {*/ /*头部主按钮*/
        /*padding: 0 2px;*/ /*调整按钮左右空隙大小*/
        /*height: 30px;
            line-height: 30px;
        }*/
        html {
            background-color: white;
            color: white;
        .btn-title {
            font-size: 16px;
        }
        /* é˜²æ­¢ä¸‹æ‹‰æ¡†çš„下拉列表被隐藏---必须设置--- */
        .layui-table-cell {
            overflow: visible !important;
        }
        /* ä½¿å¾—下拉框与单元格刚好合适 */
        td .layui-form-select {
            margin-top: -10px;
            margin-left: -15px;
            margin-right: -15px;
        }
        /* .layui-form-item .layui-inline {
            margin-top: 0px;
            margin-bottom: 5px;
            margin-right: 0px;
        }
        .layui-form-label {
            width: 25%;
        }*/
    </style>
</head>
<body>
@@ -45,6 +57,9 @@
                    <div class="layui-card-header">
                        <div class="layui-btn-group">
                            <button type="button" id="add-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="set_SaveBill">保存</button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="set_CheckBill">审核</button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="set_AbandonCheck">反审核</button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="btn-print">打印</button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Exit">退出</button>
                        </div>
                    </div>
@@ -60,7 +75,7 @@
                                <div class="layui-form-item" style="padding-top: 10px;">
                                    <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" class="layui-input" name="HBillNo" id="HBillNo" style="background-color:#efefef4d;" readonly>
                                                <input type="hidden" name="HInterID" id="HInterID" value="0">
@@ -68,15 +83,15 @@
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">日期</label>
                                            <div class="layui-input-inline">
                                                <input type="date" class="layui-input" lay-verify="HDate" name="HDate" id="HDate" style="padding-left: 80px;">
                                            <label class="layui-form-label">日期<label style="color:red"> * </label></label>
                                            <div class="layui-input-block">
                                                <input type="date" class="layui-input" lay-verify="HDate" name="HDate" id="HDate" style="width:190px;">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">销售部门</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HDeptName" id="HDeptName" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="text" name="HDeptName" id="HDeptName" class="layui-input" value="" style="float: left; width: 150px; 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>
@@ -86,7 +101,7 @@
                                        <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="float:left;width:150px;">
                                                <input type="text" name="HEmpName" id="HEmpName" " class="layui-input" value="" style="float: left; width: 150px; 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>
@@ -96,9 +111,19 @@
                                    </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="float:left;width:150px;">
                                                <input type="text" name="HCusName" id="HCusName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;">
                                                <input type="hidden" name="HCusID" id="HCusID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HCusList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">销售币别<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HCurName" id="HCurName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;">
                                                <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>
@@ -106,27 +131,26 @@
                                            </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 class="layui-input" name="HExRate" id="HExRate" autocomplete="off" value="0" readonly>
                                                <input class="layui-input" name="HExRate" id="HExRate" autocomplete="off" value="0" style="background-color: #efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline" style="width:900px;">
                                            <label class="layui-form-label">客户</label>
                                            <div class="layui-input-inline" style="width:700px;">
                                                <input type="text" name="HCusName" id="HCusName" class="layui-input" value="" style="float:left;width:465px;">
                                                <input type="hidden" name="HCusID" id="HCusID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HCusList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">定金比例%</label>
                                            <div class="layui-input-inline">
                                                <select name="HEarnestRate" id="HEarnestRate" lay-filter="HEarnestRate" style="width: 180px; ">
                                                    <option style="color:blue;" selected="selected" value="50">50%</option>
                                                    <option style="color:blue;" value="100">100%</option>
                                                </select>
                                            </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="HSSName" id="HSSName" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="text" name="HSSName" id="HSSName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                                <input type="hidden" name="HSSID" id="HSSID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HSSList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -136,7 +160,7 @@
                                        <div class="layui-inline">
                                            <label class="layui-form-label">销售方式</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HSellSName" id="HSellSName" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="text" name="HSellSName" id="HSellSName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                                <input type="hidden" name="HSellSID" id="HSellSID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HSellSList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -144,27 +168,9 @@
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">摘要</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HExplanation" id="HExplanation" autocomplete="off" style="width: 501px;">
                                            </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="HManagerName" id="HManagerName" class="layui-input" value="" style="float:left;width:150px;">
                                                <input type="hidden" name="HManagerID" id="HManagerID" 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>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HLinkMan" id="HLinkMan" autocomplete="off" value="" >
                                                <input class="layui-input" name="HLinkMan" id="HLinkMan" autocomplete="off" value="">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
@@ -173,18 +179,39 @@
                                                <input class="layui-input" name="HLinkPhone" id="HLinkPhone" autocomplete="off" value="">
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">内部订单号</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HInnerBillNo" id="HInnerBillNo" autocomplete="off" readonly>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">备注</label>
                                            <div class="layui-input-block">
                                                <input class="layui-input" name="HRemark" id="HRemark" autocomplete="off" style="width: 1135px;">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">客户余额<i class="layui-icon layui-icon-tips" id="tips-HCusBalance"></i></label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HCusBalance" id="HCusBalance" autocomplete="off" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">信用额度</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HCreditRating_Now" id="HCreditRating_Now" autocomplete="off" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">可用额度<i class="layui-icon layui-icon-tips" id="tips-HAvailableBalance"></i></label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HAvailableBalance" id="HAvailableBalance" autocomplete="off" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">需求金额<i class="layui-icon layui-icon-tips" id="tips-HBillMoney"></i></label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HBillMoney" id="HBillMoney" autocomplete="off" readonly>
                                            </div>
                                        </div>
                                    </div>
@@ -197,21 +224,33 @@
                                                </select>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">客户余额</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="" id="" autocomplete="off" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">客户信用额度</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="" id="" autocomplete="off" readonly>
                                            </div>
                                        </div>
                                    </div>
                                    <!--隐藏字段:暂时没有用处-->
                                    <div class="layui-row" style="display:none;">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">销售主管</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HManagerName" id="HManagerName" class="layui-input" value="" style="float: left; width: 150px; background-color: #efefef4d;" readonly>
                                                <input type="hidden" name="HManagerID" id="HManagerID" 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>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HInnerBillNo" id="HInnerBillNo" style="background-color: #efefef4d;" autocomplete="off" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">摘要</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HExplanation" id="HExplanation" autocomplete="off" style="width: 501px;">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row" style="display:none;">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">结算日期</label>
@@ -349,7 +388,13 @@
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <!--行下拉选择(是否取库存)-->
    <script type="text/html" id="HisStockGoods">
        <select name="HisStockGoods" lay-filter="HisStockGoods" id="HisStockGoods{{d.LAY_TABLE_INDEX+1}}">
            <option value="false">否</option>
            <option value="true">是</option>
        </select>
    </script>
    <script>
        //#region æŠ˜å æ³¨é‡Š
        //#endregion
@@ -377,6 +422,7 @@
            //模块名
            var HModName = "Xs_SeOrderBill";
            var HBillType = "1401";
            var HEarnestRateTemp = "50";
            //获取页面跳转参数
            var params = get_UrlVars();
@@ -389,14 +435,37 @@
            //#region åˆ¤æ–­æ˜¯å¦ç™»å½• æœªç™»å½•则跳到登录页
            get_LoginIs();
            //#endregion
            //#region ã€åŠ¨æ€èŽ·å–æ¨¡å—åç§°ã€‘
            //var HModuleType = "1401";
            ////通过单据类型,从数据库动态获取单据模块命名,引用js文件 PageTitle.js
            //var HPageTitle = get_PageTitle(HModuleType) == "" ? $("h1").html() : get_PageTitle(HModuleType);
            //$("h1").html('<b>' + HPageTitle + '</b>');
            //#endregion
            //#endregion
            //#region åˆ¤æ–­å¹¶è®¾ç½®æ“ä½œç±»åž‹ã€é¡µé¢åˆå§‹åŒ–
            if (OperationType == null || OperationType == 1) {                            //新增
            if (OperationType == null || OperationType == 1) {                          //新增
                //新增页面初始化
                Init_setAdd();
            }
            else if (OperationType == 3) {                                                 //编辑
            else if (OperationType == 2) {                                              //复制
                //子表初始化
                set_InitGrid();
                //加载表体和表体数据
                RoadBillMain(linterid);
                //生成并设置主表的内码和单据号
                createBillNo();
                //相关文本框信息初始化
                $("#HDate").val(Format(new Date(), "yyyy-MM-dd"));
                $("#HSSDate").val(Format(new Date(), "yyyy-MM-dd"));
                $("#HMaker").val(sessionStorage["HUserName"]);
                $("#HMakeDate").val(Format(new Date(), "yyyy-MM-dd"));
            }
            else if (OperationType == 3) {                                              //编辑
                $("#HInterID").val(linterid);
                //子表初始化
                set_InitGrid();
@@ -409,11 +478,15 @@
            Organ();
            //#endregion
            //#region é¡µé¢åˆå§‹åŒ–后,根据客户获取客户余额
            getCustomerBalance( $("#HCusID").val() );
            //#endregion
            //#region åˆ—设置:子表1
            //DisPlay_HideColumn();
            //#endregion
            //#endregion
            //#region è§¦å‘事件:包括form.on(){}格式的所有点击事件、选择事件等
            //#region å¼¹çª—选择触发事件
            //#region é€‰æ‹©é”€å”®å‘˜æŒ‰é’®
@@ -432,7 +505,7 @@
            form.on('submit(HSellSList)', function () {
                get_checkSellS();
            });
            //#endregion
            //#endregion
            //#region é€‰æ‹©ç»“算方式按钮
            form.on('submit(HSSList)', function () {
@@ -444,7 +517,7 @@
            form.on('submit(HCurList)', function () {
                get_checkCur();
            });
            //#endregion
            //#endregion
            //#region é€‰æ‹©é”€å”®éƒ¨é—¨æŒ‰é’®
            form.on('submit(HDeptList)', function () {
@@ -468,15 +541,37 @@
            //#region è¡¨å¤´æŒ‰é’®è§¦å‘事件
            //#region ä¿å­˜æŒ‰é’®
            form.on('submit(set_SaveBill)', function (data) {
                //if (AllowLoadData(data)) {
                if (AllowLoadData(data)) {
                    set_SaveBill(data);
                //}
                }
            });
            //#endregion
            //#region å®¡æ ¸æŒ‰é’®
            form.on('submit(set_CheckBill)', function (data) {
                set_CheckBill(0);
            });
            //#endregion
            //#region åå®¡æ ¸æŒ‰é’®
            form.on('submit(set_AbandonCheck)', function (data) {
                set_CheckBill(1);
            });
            //#endregion
            //#region æ‰“印按钮
            form.on('submit(btn-print)', function (data) {
                get_PrintReport();
            });
            //#endregion
            //#region é€€å‡ºæŒ‰é’®
            form.on('submit(Exit)', function () {
                Pub_Close(1);
                if (params[1] != null) {
                    Pub_Close(1);
                } else if (params[1] == null) {
                    Pub_Close(2);
                }
            })
            //#endregion
            //#endregion
@@ -492,6 +587,9 @@
                    "HMaterID": "0",
                    "物料代码": "",
                    "物料名称": "",
                    "HOrderLevID": "0",
                    "订单等级代码": "",
                    "订单等级名称": "",
                    "规格型号": "",
                    "HUnitID": "0",
                    "计量单位": "",
@@ -505,10 +603,20 @@
                    "HTaxMoney": "0",
                    "HlineTotal": "0",
                    "HlineTotalBB": "0",
                    "HDate": "",
                    "HDate": Format(new Date(), 'yyyy-MM-dd'),
                    "HisStockGoods": "false",
                    "HOutStockQty": "0",
                    "HInvoiceQty": "0",
                    "HRemark": ""
                    "HRemark": "",
                    "HCusMaterNumber": "",
                    "HCusModel": "",
                    "HCusMaterName": "",
                    "HRelationQty": "0",
                    "HRelationQty_SellOutCheck": "0",
                    "HRelationMoney_SellOutCheck": "0",
                    "HRelationQty_ICMO": "0",
                    "HRelationQty_SellBack": "0",
                    "HRelationQty_SellBackCheck": "0"
                };
                switch (obj.event) {
                    //新增一行
@@ -544,7 +652,7 @@
                    var field = $(this).data('field');
                    laydate.render({
                        elem: this.firstChild
                        , show: true //直接显示
                        , show: true //直接显示
                        , closeStop: this
                        , done: function (nowDate) {
                            //时间选择完成,行数据更新
@@ -558,6 +666,10 @@
            //#region ç›‘听单元格编辑  å•元格编辑后 å˜æ›´
            table.on('edit(mainTable)', function (obj) {
                //数值格式校验工具
                var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                var temp = "";
                // å•元格编辑之前的值
                var oldText = $(this).prev().text();
                var value = obj.value //得到修改后的值
@@ -566,46 +678,267 @@
                //layer.msg('[ID: ' + data.id + '] ' + field + ' å­—段更改为:' + value);
                switch (field) {
                    case "HRate":     //用量
                        value = (value * 1).toFixed(6);
                    case "HQty":                                                       //数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp) || temp == 0) {
                            //恢复数据到编辑前
                            obj.update({
                                HQty: oldText
                            });
                            table.render(option);
                        var HWeight = $("#HWeight").val();
                        var HWaterQty = $("#HWaterQty").val();
                        var HRate = value;
                        var HQty = 0;
                        var HMaterRuleType = obj.data.HMaterRuleType;
                        if (HMaterRuleType == "染料") {
                            HQty = HRate * HWeight;
                        } else if (HMaterRuleType == "助剂") {
                            HQty = HRate * HWaterQty;
                            //刷新表格同时根据option中HisStockGoods值设置下拉列表
                            setSelectHisStockGoodsByTableRender();
                            layer.msg("数量请输入大于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HQty = value * 1;                           //数量
                        var HPrice = obj.data.HPrice * 1;               //单价
                        var HTaxRate = obj.data.HTaxRate * 0.01;           //税率
                        /*var HDiscountRate = obj.data.HDiscountRate * 1; //折扣率*/
                        var HTaxPrice = HPrice * (1 + HTaxRate);        //含税单价=单价*(1+税率)
                        /*var HRelTaxPrice = HTaxPrice * HDiscountRate;   //实际含税单价=含税单价*折扣率*/
                        //折扣额 = å«ç¨Žå•ä»· * (1 - æŠ˜æ‰£çއ) * æ•°é‡
                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                        var HTaxMoney = HMoney * HTaxRate;              //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        //设置数据小数位数
                        HQty = dealDoubleToFixed(HQty, 1);
                        HPrice = dealDoubleToFixed(HPrice, 3);
                        HTaxRate = HTaxRate;
                        HTaxPrice = dealDoubleToFixed(HTaxPrice, 3);
                        HMoney = dealDoubleToFixed(HMoney, 2);
                        HlineTotal = dealDoubleToFixed(HlineTotal, 2);
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HRate: value,
                            HQty: HQty
                            , HPrice: HPrice
                            , HTaxRate: HTaxRate * 100
                            , HTaxPrice: HTaxPrice
                            , HMoney: HMoney
                            , HlineTotal: HlineTotal
                        });
                        table.render(option);
                        //刷新表格同时根据option中HisStockGoods值设置下拉列表
                        setSelectHisStockGoodsByTableRender();
                        //设置表头所需金额
                        set_HBillMoney($("#HEarnestRate").val()*1);
                        break;
                    case "HMaterRuleType":
                        var HWeight = $("#HWeight").val();
                        var HWaterQty = $("#HWaterQty").val();
                        var HRate = obj.data.HRate;
                        var HQty = 0;
                        var HMaterRuleType = value;
                        if (HMaterRuleType == "染料") {
                            HQty = HRate * HWeight;
                        } else if (HMaterRuleType == "助剂") {
                            HQty = HRate * HWaterQty;
                    case "HPrice":                                                       //单价
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp) || temp == 0) {
                            //恢复数据到编辑前
                            obj.update({
                                HPrice: oldText
                            });
                            table.render(option);
                            //刷新表格同时根据option中HisStockGoods值设置下拉列表
                            setSelectHisStockGoodsByTableRender();
                            layer.msg("单价请输入大于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HQty = obj.data.HQty * 1;                   //数量
                        var HPrice = value * 1;                         //单价
                        var HTaxRate = obj.data.HTaxRate * 0.01;           //税率
                        /*var HDiscountRate = obj.data.HDiscountRate * 1; //折扣率*/
                        var HTaxPrice = HPrice * (1 + HTaxRate);        //含税单价=单价*(1+税率)
                        /*var HRelTaxPrice = HTaxPrice * HDiscountRate;   //实际含税单价=含税单价*折扣率*/
                        //折扣额 = å«ç¨Žå•ä»· * (1 - æŠ˜æ‰£çއ) * æ•°é‡
                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                        var HTaxMoney = HMoney * HTaxRate;              //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        //设置数据小数位数
                        HQty = dealDoubleToFixed(HQty, 1);
                        HPrice = dealDoubleToFixed(HPrice, 3);
                        HTaxRate = HTaxRate;
                        HTaxPrice = dealDoubleToFixed(HTaxPrice, 3);
                        HMoney = dealDoubleToFixed(HMoney, 2);
                        HlineTotal = dealDoubleToFixed(HlineTotal, 2);
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
                            , HPrice: HPrice
                            , HTaxRate: HTaxRate * 100
                            , HTaxPrice: HTaxPrice
                            , HMoney: HMoney
                            , HlineTotal: HlineTotal
                        });
                        table.render(option);
                        //刷新表格同时根据option中HisStockGoods值设置下拉列表
                        setSelectHisStockGoodsByTableRender();
                        //设置表头所需金额
                        set_HBillMoney($("#HEarnestRate").val() * 1);
                        break;
                    case "HTaxRate":                                                       //数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp)) {
                            //恢复数据到编辑前
                            obj.update({
                                HTaxRate: oldText
                            });
                            table.render(option);
                            //刷新表格同时根据option中HisStockGoods值设置下拉列表
                            setSelectHisStockGoodsByTableRender();
                            layer.msg("税率请输入不小于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HQty = obj.data.HQty * 1;                   //数量
                        var HPrice = obj.data.HPrice * 1;               //单价
                        var HTaxRate = value * 0.01;                       //税率
                        /*var HDiscountRate = obj.data.HDiscountRate * 1; //折扣率*/
                        var HTaxPrice = HPrice * (1 + HTaxRate);        //含税单价=单价*(1+税率)
                        /*var HRelTaxPrice = HTaxPrice * HDiscountRate;   //实际含税单价=含税单价*折扣率*/
                        //折扣额 = å«ç¨Žå•ä»· * (1 - æŠ˜æ‰£çއ) * æ•°é‡
                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                        var HTaxMoney = HMoney * HTaxRate;              //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        //设置数据小数位数
                        HQty = dealDoubleToFixed(HQty, 1);
                        HPrice = dealDoubleToFixed(HPrice, 3);
                        HTaxRate = HTaxRate;
                        HTaxPrice = dealDoubleToFixed(HTaxPrice, 3);
                        HMoney = dealDoubleToFixed(HMoney, 2);
                        HlineTotal = dealDoubleToFixed(HlineTotal, 2);
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
                            , HPrice: HPrice
                            , HTaxRate: HTaxRate * 100
                            , HTaxPrice: HTaxPrice
                            , HMoney: HMoney
                            , HlineTotal: HlineTotal
                        });
                        table.render(option);
                        //刷新表格同时根据option中HisStockGoods值设置下拉列表
                        setSelectHisStockGoodsByTableRender();
                        //设置表头所需金额
                        set_HBillMoney($("#HEarnestRate").val() * 1);
                        break;
                    case "HTaxPrice":                                                       //数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp)) {
                            //恢复数据到编辑前
                            obj.update({
                                HTaxPrice: oldText
                            });
                            table.render(option);
                            //刷新表格同时根据option中HisStockGoods值设置下拉列表
                            setSelectHisStockGoodsByTableRender();
                            layer.msg("含税单据请输入不小于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HQty = obj.data.HQty * 1;                   //数量
                        var HTaxRate = obj.data.HTaxRate * 0.01;        //税率
                        var HTaxPrice = value * 1;                          //含税单价=单价*(1+税率)
                        var HPrice = HTaxPrice / (1 + HTaxRate);        //单价=含税单据/(1+税率)
                        /*var HDiscountRate = obj.data.HDiscountRate * 1; //折扣率*/
                        /*var HRelTaxPrice = HTaxPrice * HDiscountRate;   //实际含税单价=含税单价*折扣率*/
                        //折扣额 = å«ç¨Žå•ä»· * (1 - æŠ˜æ‰£çއ) * æ•°é‡
                        var HMoney = HQty * HPrice;                     //金额=数量*单价
                        var HTaxMoney = HMoney * HTaxRate;              //税额=金额*税率
                        var HlineTotal = HMoney + HTaxMoney;            //价税合计=金额+税额
                        //设置数据小数位数
                        HQty = dealDoubleToFixed(HQty, 1);
                        HPrice = dealDoubleToFixed(HPrice, 3);
                        HTaxRate = HTaxRate;
                        HTaxPrice = dealDoubleToFixed(HTaxPrice, 3);
                        HMoney = dealDoubleToFixed(HMoney, 2);
                        HlineTotal = dealDoubleToFixed(HlineTotal, 2);
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty: HQty
                            , HPrice: HPrice
                            , HTaxRate: HTaxRate * 100
                            , HTaxPrice: HTaxPrice
                            , HMoney: HMoney
                            , HlineTotal: HlineTotal
                        });
                        table.render(option);
                        //刷新表格同时根据option中HisStockGoods值设置下拉列表
                        setSelectHisStockGoodsByTableRender();
                        //设置表头所需金额
                        set_HBillMoney($("#HEarnestRate").val() * 1);
                        break;
                    default:
                }
            });
            //#endregion
            //#endregion
            //#region æ–‡æœ¬æ¡†ç›‘听
            $(document).ready(function () {
                //#region å®¢æˆ·ä½™é¢æç¤ºä¿¡æ¯
                $("#tips-HCusBalance").on('click', function (data) {
                    var tips_Message = "客户余额 = æœŸåˆ+本期收款(已审核)-本期退款(已审核)-本期出库(已审核)+本期退货(已审核)";
                    layer.alert(tips_Message, { icon: 0, btn: ['退出'], time: 100000, offset: 't' });
                });
                //#endregion
                //#region å¯ç”¨ä½™é¢æç¤ºä¿¡æ¯
                $("#tips-HAvailableBalance").on('click', function (data) {
                    var tips_Message = "可用额度 = å®¢æˆ·ä½™é¢ + ä¿¡ç”¨é¢åº¦ - ï¼ˆæœ¬æœŸé”€å”®è®¢å•总金额 * å®šé‡‘比例%)";
                    layer.alert(tips_Message, { icon: 0, btn: ['退出'], time: 100000, offset: 't' });
                });
                //#endregion
                //#region éœ€æ±‚金额
                $("#tips-HBillMoney").on('click', function (data) {
                    var tips_Message = "需求金额 = ä»·ç¨Žåˆè®¡ * å®šé‡‘比例%";
                    layer.alert(tips_Message, { icon: 0, btn: ['退出'], time: 100000, offset: 't' });
                });
                //#endregion
            });
            //#endregion
            //#region èµ é€æ¯”例下拉列表监听
            form.on('select(HEarnestRate)', function (data) {
                //输入的金额合法,重算折扣后金额
                var HEarnestRate = $("#HEarnestRate").val() * 1;    //定金比例%
                set_HBillMoney(HEarnestRate);
                if (HEarnestRate != 0) {
                    HEarnestRateTemp = HEarnestRate;
                }
            });
            //#endregion
            //#endregion
@@ -665,6 +998,37 @@
            }
            //#endregion
            //#region æ ¹æ®è´¦å·èŽ·å–éƒ¨é—¨ã€èŒå‘˜ã€ä¸»ç®¡
            function getCzyglByUser() {
                $.ajax({
                    url: GetWEBURL() + "/Xs_SeOrderBill/getCzyglByUser",
                    async: false,
                    type: "GET",
                    data: {
                        "CurUserName": sessionStorage["HUserName"]
                    },
                    success: function (result) {
                        if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            var data = result.data[0];
                            $("#HEmpID").val(data.HEmpID);
                            $("#HEmpName").val(data.HEmpName);
                            $("#HDeptID").val(data.HDeptID);
                            $("#HDeptName").val(data.HDeptName);
                            $("#HManagerID").val(data.HManagerID);
                            $("#HManagerName").val(data.HManagerName);
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
            }
            //#endregion
            //#region ç”Ÿæˆå•据号
            function createBillNo() {
                $.ajax({
@@ -684,42 +1048,72 @@
                option = {
                    elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , totalRow: true
                    , limit: 500
                    , height: 500
                    , loading: false
                    , cols: [[ //子表
                        { type: 'checkbox', totalRowText: '合计行' }
                        , { type: 'numbers', title: '序号', width: 100, totalRow: true }
                        , { field: 'HMaterID', title: 'HMaterID', width: 100, hide: true }
                        { type: 'checkbox', totalRowText: '合计行', style: 'background-color:#efefef4d;' }
                        , { type: 'numbers', title: '序号', width: 100, style: 'background-color:#efefef4d;' }
                        , { field: 'HOrderLevID', title: 'HOrderLevID', width: 100, hide: true, style: 'background-color:#efefef4d;' }
                        , { field: '订单等级代码', title: '订单等级代码', width: 150, hide: true, edit: 'text', event: "HOrderLevID" }//f7
                        , { field: '订单等级名称', title: '订单等级名称', width: 150, style: 'background-color:#efefef4d;' }
                        , { 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, }
                        , { field: '规格型号', title: '规格型号', width: 100, }
                        , { field: 'HUnitID', title: 'HUnitID', width: 100, hide: true }
                        , { field: '计量单位', title: '计量单位', width: 100 }//f7
                        , { field: 'HQty', title: '数量', width: 100, edit: 'text' }
                        , { 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;' }//f7
                        , { field: 'HisStockGoods', title: '是否取库存', width: 120, templet: '#HisStockGoods' }
                        , { field: 'HQty', title: '数量', width: 100, totalRow: true, edit: 'text' }
                        , { field: 'HPrice', title: '单价', width: 100, edit: 'text' }
                        , { field: 'HTaxRate', title: '税率', width: 100, edit: 'text' }
                        , { field: 'HTaxRate', title: '税率%', width: 100, edit: 'text' }
                        , { field: 'HTaxPrice', title: '含税单价', width: 100, edit: 'text' }
                        , { field: 'HMoney', title: '金额', width: 100, edit: 'text' }
                        , { field: 'HlineTotal', title: '价税合计', width: 100, }
                        , { field: 'HMoney', title: '金额', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HlineTotal', title: '价税合计', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HCusMaterName', title: '客户物料名称', width: 100, edit: 'text' }
                        , { field: 'HCusMaterNumber', title: '客户物料编码', width: 100, edit: 'text' }
                        , { field: 'HCusModel', title: '客户规格型号', width: 100, edit: 'text' }
                        , { field: 'HDate', title: '交货日期', event: "HDate", width: 120 }
                        , { field: 'HRemark', title: '备注', width: 100, edit: 'text' }
                        , { field: 'HDiscountRate', title: '折扣率', width: 100, edit: 'text', hide: true }
                        , { field: 'HRelTaxPrice', title: '实际含税单价', width: 110, hide: true }
                        , { field: 'HTaxMoney', title: '税额', width: 100, hide: true }
                        , { field: 'HlineTotalBB', title: '本位币价税合计', width: 120, hide: true }
                        , { field: 'HOutStockQty', title: '出库数量', width: 100, edit: 'text', hide: true }
                        , { field: 'HInvoiceQty', title: '开票数量', width: 100, edit: 'text', hide: true }
                        , { field: 'HRelationQty', title: '销售出库数量', width: 100, totalRow: true, style: 'background-color:#efefef4d;'}
                        , { field: 'HRelationQty_SellOutCheck', title: '销售出库审核数量', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HRelationMoney_SellOutCheck', title: '销售出库审核金额', width: 100, totalRow: true, style: 'background-color:#efefef4d;' }
                        , { field: 'HRelationQty_ICMO', title: '生产数量', width: 100, totalRow: true, style: 'background-color:#efefef4d;'}
                        , { field: 'HRelationQty_SellBack', title: '销售退库数量', width: 100, totalRow: true, style: 'background-color:#efefef4d;'}
                        , { field: 'HRelationQty_SellBackCheck', title: '销售退库审核数量', width: 100, totalRow: true, style: 'background-color:#efefef4d;'}
                        , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 70 }
                    ]]
                    , done: function (res, curr, count) {
                        option.data = res.data;
                        //去掉下拉框失焦事件否则在下拉框里输入值
                        $('.layui-form-select').find('input').unbind("blur");
                        //表格重载回显下拉框里的数据
                        $('tr').each(function (e) {
                            var $cr = $(this);
                            var dataIndex = $cr.attr("data-index");
                            $.each(option.data, function (index, value) {
                                if (value.LAY_TNDEX == dataIndex) {
                                    $cr.find('input').val(value.HisStockGoods);
                                }
                            });
                        });
                    }
                }
                var rowdata = [{
                    "HMaterID": "0",
                    "物料代码": "",
                    "物料名称": "",
                    "HOrderLevID": "0",
                    "订单等级代码": "",
                    "订单等级名称": "",
                    "规格型号": "",
                    "HUnitID": "0",
                    "计量单位": "",
@@ -733,14 +1127,30 @@
                    "HTaxMoney": "0",
                    "HlineTotal": "0",
                    "HlineTotalBB": "0",
                    "HDate": "",
                    "HDate": Format(new Date(),'yyyy-MM-dd'),
                    "HisStockGoods": "false",
                    "HOutStockQty": "0",
                    "HInvoiceQty": "0",
                    "HRemark": ""
                    "HRemark": "",
                    "HCusMaterNumber": "",
                    "HCusModel": "",
                    "HCusMaterName": "",
                    "HRelationQty": "0",
                    "HRelationQty_SellOutCheck": "0",
                    "HRelationMoney_SellOutCheck": "0",
                    "HRelationQty_ICMO": "0",
                    "HRelationQty_SellBack": "0",
                    "HRelationQty_SellBackCheck": "0"
                }];
                option.data = rowdata;
                table.render(option);
                //刷新表格同时根据option中HisStockGoods值设置下拉列表
                setSelectHisStockGoodsByTableRender();
                //设置表头所需金额
                set_HBillMoney($("#HEarnestRate").val() * 1);
            }
            //#endregion
@@ -758,11 +1168,17 @@
                $("#HMaker").val(sessionStorage["HUserName"]);
                $("#HMakeDate").val(Format(new Date(), "yyyy-MM-dd"));
                //销售员、销售部门、销售主管初始化
                getCzyglByUser();
                //初始化并列设置:子表1
                set_InitGrid();
                DisPlay_HideColumn();
                //根据是否取库存获取定金比例
                setHEarnestRateByHisStockGoods();
            }
            //#endregion
            //#endregion
            //#region ç¼–辑页面初始化
            function RoadBillMain(linterid) {
@@ -793,6 +1209,7 @@
                                , "HCurID": data.HCurID
                                , "HCurName": data.币别
                                , "HExRate": data.汇率
                                , "HEarnestRate": data.定金比例
                                , "HManagerID": data.HManagerID
                                , "HManagerName": data.主管
                                , "HSellSID": data.HSellSID
@@ -805,6 +1222,7 @@
                                , "HLinkMan": data.联系人
                                , "HExplanation": data.摘要
                                , "HLinkPhone": data.联系电话
                                , "HCreditRating_Now": data.HCreditRating_Now
                                , "HRemark": data.表头备注
                                , "HMaker": data.制单人
                                , "HMakeDate": data.制单人 == "" ? "" :formatDate(data.制单日期)
@@ -822,6 +1240,8 @@
                            //组织的值HOrgID变化,重新渲染
                            HOrgIDBar = data.HOrgID;
                            //获取税率(用于子表税率的默认值)
                            getHTaxRateByCusID(data.HCusID);
                            //子表  èµ‹å€¼
                            var rowdata = [];
@@ -831,33 +1251,58 @@
                                        "HMaterID": result.data[i]["HMaterID"],
                                        "物料代码": result.data[i]["物料代码"],
                                        "物料名称": result.data[i]["物料名称"],
                                        "HOrderLevID": result.data[i]["HOrderLevID"],
                                        "订单等级代码": result.data[i]["订单等级代码"],
                                        "订单等级名称": result.data[i]["订单等级名称"],
                                        "规格型号": result.data[i]["规格型号"],
                                        "HUnitID": result.data[i]["HUnitID"],
                                        "计量单位": result.data[i]["计量单位"],
                                        "HQty": result.data[i]["数量"],
                                        "HPrice": result.data[i]["单价"],
                                        "HTaxPrice": result.data[i]["含税单价"],
                                        "HMoney": result.data[i]["金额"],
                                        "HQty": dealDoubleToFixed(result.data[i]["数量"], 1),
                                        "HPrice": dealDoubleToFixed(result.data[i]["单价"], 3),
                                        "HTaxPrice": dealDoubleToFixed(result.data[i]["含税单价"], 3),
                                        "HMoney": dealDoubleToFixed(result.data[i]["金额"],2),
                                        "HDiscountRate": result.data[i]["折扣率"],
                                        "HRelTaxPrice": result.data[i]["实际含税单价"],
                                        "HTaxRate": result.data[i]["税率"],
                                        "HTaxMoney": result.data[i]["税额"],
                                        "HlineTotal": result.data[i]["价税合计"],
                                        "HlineTotal": dealDoubleToFixed(result.data[i]["价税合计"], 2),
                                        "HlineTotalBB": result.data[i]["本位币价税合计"],
                                        "HisStockGoods": result.data[i]["是否取库存"]=="Y"?"true":"false",
                                        "HDate": formatDate(result.data[i]["交货日期"]),
                                        "HOutStockQty": result.data[i]["出库数量"],
                                        "HInvoiceQty": result.data[i]["开票数量"],
                                        "HRemark": result.data[i]["表体备注"]
                                        "HRemark": result.data[i]["表体备注"],
                                        "HCusMaterNumber": result.data[i]["客户物料编码"],
                                        "HCusModel": result.data[i]["客户规格型号"],
                                        "HCusMaterName": result.data[i]["客户物料名称"],
                                        "HRelationQty": OperationType == 2 ? "0" : result.data[i]["关联数量"],
                                        "HRelationQty_SellOutCheck": OperationType == 2 ? "0" : result.data[i]["销售出库审核数量"],
                                        "HRelationMoney_SellOutCheck": OperationType == 2 ? "0" : result.data[i]["销售出库审核金额"],
                                        "HRelationQty_ICMO": OperationType == 2 ? "0" : result.data[i]["生产关联数量"],
                                        "HRelationQty_SellBack": OperationType == 2 ? "0" : result.data[i]["销售退库数量"],
                                        "HRelationQty_SellBackCheck": OperationType == 2 ? "0" : result.data[i]["销售退库审核数量"],
                                    }
                                );
                            }
                            option.data = rowdata;
                            //出库数量、开票数量不可编辑
                            option.cols[0][19].edit = null;
                            option.cols[0][20].edit = null;
                            option.cols[0][22].edit = null;
                            option.cols[0][23].edit = null;
                            table.render(option);
                            //获取临时定金比例
                            HEarnestRateTemp = data.定金比例 + "" == "0" ? "50" : data.定金比例 + "";
                            //刷新表格同时根据option中HisStockGoods值设置下拉列表
                            setSelectHisStockGoodsByTableRender();
                            //根据是否取库存获取定金比例
                            setHEarnestRateByHisStockGoods();
                            //设置表头所需金额
                            set_HBillMoney($("#HEarnestRate").val() * 1);
                            layer.close(ajaxLoad);
                        } else {
                            layer.close(ajaxLoad);
@@ -871,6 +1316,7 @@
            }
            //#endregion
            //#region è¡¨å¤´é€‰æ‹©æ–¹æ³•
            //#region é”€å”®å‘˜é€‰æ‹©é¡µé¢
            function get_checkEmp() {
                layer.open({
@@ -912,8 +1358,10 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HCusName").val(checkStatus.data[0].HName);
                        $("#HCusID").val(checkStatus.data[0].HItemID);
                        getCustomerByCusID(checkStatus.data[0].HItemID);
                        //根据客户获取客户余额
                        getCustomerBalance(checkStatus.data[0].HItemID);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
@@ -1071,6 +1519,7 @@
                })
            }
            //#endregion
            //#endregion
            //#region ä¿å­˜æ–¹æ³•
            function set_SaveBill(data) {
@@ -1079,10 +1528,12 @@
                if (OperationType == 1 || OperationType == 2) {
                    refSav = "Add";
                    data.field.HChangeDate = new Date();
                    data.field.HSTOCKORGID = data.field.HOrgID;
                }
                if (OperationType == 3) {
                    refSav = "Update";
                    data.field.HChangeDate = new Date();
                    data.field.HSTOCKORGID = data.field.HOrgID;
                }
                //若为编辑-保存,则更新修改人和修改时间
@@ -1141,8 +1592,27 @@
                    return false;
                }
                if ($("#HDeptID").val() == "0") {
                    layer.msg("销售部门未选择!");
                //if ($("#HDeptID").val() == "0") {
                //    layer.msg("销售部门未选择!");
                //    return false;
                //}
                //if ($("#HEmpID").val() == "0") {
                //    layer.msg("销售员未选择!");
                //    return false;
                //}
                if ($("#HCurID").val() == "0") {
                    layer.msg("销售币别未选择!");
                    return false;
                }
                temp = $("#HExRate").val() + "";
                if (temp == 0 || temp == "") {
                    layer.msg("汇率不能为0或空!");
                    return false;
                } else if (!ref.test(temp)) {
                    layer.msg("汇率请输入大于0的数字!");
                    return false;
                }
@@ -1151,25 +1621,22 @@
                    return false;
                }
                if ($("#HEmpID").val() == "0") {
                    layer.msg("销售员未选择!");
                    return false;
                }
                if ($("#HCurID").val() == "0") {
                    layer.msg("销售币别未选择!");
                    return false;
                }
                if ($("#HMangerID").val() == "0") {
                    layer.msg("销售主管未选择!");
                    return false;
                }
                if ($("#HSSID").val() == "0") {
                    layer.msg("结算方式未选择!");
                    return false;
                }
                //if ($("#HSellSID").val() == "0") {
                //    layer.msg("销售方式未选择!");
                //    return false;
                //}
                //if ($("#HMangerID").val() == "0") {
                //    layer.msg("销售主管未选择!");
                //    return false;
                //}
                //if ($("#HPayCusID").val() == "0") {
                //    layer.msg("结算方未选择!");
@@ -1181,14 +1648,7 @@
                //    return false;
                //}
                temp = $("HExRate").val() + "";
                if (temp == 0 || temp == "") {
                    layer.msg("汇率不能为0或空!");
                    return false;
                } else if (!ref.test(temp)){
                    layer.msg("汇率请输入大于0的数字!");
                    return false;
                }
                //#endregion
                //#region å­è¡¨ æ•°æ®æ£€éªŒ
@@ -1200,11 +1660,6 @@
                    if (option.data[i]["HUnitID"] == "0") {
                        layer.msg("第" + i + "行:计量单位未选择!");
                        return false;
                    }
                    if (option.data[i]["HDate"] == "") {
                        layer.msg("第" + i + "行:交货日期不能为空!");
                        return false;
                    }
@@ -1228,6 +1683,13 @@
                        return false;
                    }
                    //税率格式校验
                    temp = option.data[i]["HTaxRate"] + "";
                    if (!ref.test(temp)) {
                        layer.msg("第" + i + "行:税率请输入不小于0的数字!");
                        return false;
                    }
                    //含税单价格式校验
                    temp = option.data[i]["HTaxPrice"] + "";
                    if (temp == "0") {
@@ -1247,6 +1709,27 @@
                        layer.msg("第" + i + "行:金额请输入大于0的数字!");
                        return false;
                    }
                    //价税合计格式校验
                    temp = option.data[i]["HlineTotal"] + "";
                    if (temp == "0") {
                        layer.msg("第" + i + "行:价税合计不能为0!");
                        return false;
                    } else if (!ref.test(temp)) {
                        layer.msg("第" + i + "行:价税合计请输入大于0的数字!");
                        return false;
                    }
                    if (option.data[i]["HDate"] == "") {
                        layer.msg("第" + i + "行:交货日期不能为空!");
                        return false;
                    }
                    ////折扣率格式校验
                    //temp = option.data[i]["HDiscountRate"] + "";
@@ -1268,35 +1751,19 @@
                    //    return false;
                    //}
                    //税率格式校验
                    temp = option.data[i]["HTaxRate"] + "";
                    if (temp == "0") {
                        layer.msg("第" + i + "行:税率不能为0!");
                        return false;
                    } else if (!ref.test(temp)) {
                        layer.msg("第" + i + "行:税率请输入大于0的数字!");
                        return false;
                    }
                    //税额格式校验
                    temp = option.data[i]["HTaxMoney"] + "";
                    if (temp == "0") {
                        layer.msg("第" + i + "行:税额不能为0!");
                        return false;
                    } else if (!ref.test(temp)) {
                        layer.msg("第" + i + "行:税额请输入大于0的数字!");
                        return false;
                    }
                    //temp = option.data[i]["HTaxMoney"] + "";
                    //if (temp == "0") {
                    //    layer.msg("第" + i + "行:税额不能为0!");
                    //    return false;
                    //} else if (!ref.test(temp)) {
                    //    layer.msg("第" + i + "行:税额请输入大于0的数字!");
                    //    return false;
                    //}
                    //价税合计格式校验
                    temp = option.data[i]["HlineTotal"] + "";
                    if (temp == "0") {
                        layer.msg("第" + i + "行:价税合计不能为0!");
                        return false;
                    } else if (!ref.test(temp)) {
                        layer.msg("第" + i + "行:价税合计请输入大于0的数字!");
                        return false;
                    }
                    ////本位币价税合计格式校验
                    //temp = option.data[i]["HlineTotalBB"] + "";
@@ -1341,9 +1808,25 @@
            //#region åœ¨æœ«å°¾å¢žåŠ ä¸€è¡Œ
            function btnAddLine(NewRow) {
                if (option.data.length > 0) {
                    NewRow.HisStockGoods = option.data[0]["HisStockGoods"];
                } else {
                    NewRow.HisStockGoods = "false";
                }
                table.cache["mainTable"].push(NewRow);
                option.data = table.cache["mainTable"];
                table.render(option);
                //刷新表格同时根据option中HisStockGoods值设置下拉列表
                setSelectHisStockGoodsByTableRender();
                //根据是否取库存获取定金比例
                //setHEarnestRateByHisStockGoods();
                //设置表头所需金额
                set_HBillMoney($("#HEarnestRate").val() * 1);
                //rows++;
                layer.msg('增加一行按钮!')
            }
@@ -1351,6 +1834,12 @@
            //#region åœ¨æŒ‡å®šè¡Œä¸‹æ’入一行
            function btnInsertLine(NewRow) {
                if (option.data.length > 0) {
                    NewRow.HisStockGoods = option.data[0]["HisStockGoods"];
                } else {
                    NewRow.HisStockGoods = "false";
                }
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                if (checkStatus.data.length === 1) {
@@ -1365,6 +1854,15 @@
                    }
                    option.data = tables;
                    table.render(option);
                    //刷新表格同时根据option中HisStockGoods值设置下拉列表
                    setSelectHisStockGoodsByTableRender();
                    //根据是否取库存获取定金比例
                    //setHEarnestRateByHisStockGoods();
                    //设置表头所需金额
                    set_HBillMoney($("#HEarnestRate").val() * 1);
                } else {
                    layer.msg('请选择一行数据编辑!');
                }
@@ -1389,6 +1887,15 @@
                    option.data[option.data.length - 1].HWeight = "0";
                    table.render(option);//将数据渲染到表格上
                    //刷新表格同时根据option中HisStockGoods值设置下拉列表
                    setSelectHisStockGoodsByTableRender();
                    //根据是否取库存获取定金比例
                    //setHEarnestRateByHisStockGoods();
                    //设置表头所需金额
                    set_HBillMoney($("#HEarnestRate").val() * 1);
                }
            }
            //#endregion
@@ -1413,6 +1920,15 @@
                            option.data[i - 1] = data[0];
                            option.data[i] = tables[0];
                            table.render(option);
                            //刷新表格同时根据option中HisStockGoods值设置下拉列表
                            setSelectHisStockGoodsByTableRender();
                            //根据是否取库存获取定金比例
                            //setHEarnestRateByHisStockGoods();
                            //设置表头所需金额
                            set_HBillMoney($("#HEarnestRate").val() * 1);
                            break;
                        }
                    }
@@ -1444,6 +1960,15 @@
                            option.data[i + 1] = data[0];
                            option.data[i] = tables[0];
                            table.render(option);
                            //刷新表格同时根据option中HisStockGoods值设置下拉列表
                            setSelectHisStockGoodsByTableRender();
                            //根据是否取库存获取定金比例
                            //setHEarnestRateByHisStockGoods();
                            //设置表头所需金额
                            set_HBillMoney($("#HEarnestRate").val() * 1);
                            break;
                        }
                    }
@@ -1469,11 +1994,39 @@
                            oldData.splice(obj.tr.data('index'), 1);
                            option.data = oldData;
                            table.render(option);
                            //刷新表格同时根据option中HisStockGoods值设置下拉列表
                            setSelectHisStockGoodsByTableRender();
                            //根据是否取库存获取定金比例
                            setHEarnestRateByHisStockGoods();
                            //设置表头所需金额
                            set_HBillMoney($("#HEarnestRate").val() * 1);
                            layer.close(index);
                        }
                    });
                }
            }
            //#endregion
            //#region è¡¨æ ¼è¡Œé€‰æ‹©å¤„理(是否取库存)
            form.on('select(HisStockGoods)', function (data) {
                //获取下拉框选中的值
                var elem = data.othis.parents('tr');
                var dataindex = elem.attr("data-index");
                $.each(option.data, function (index, value) {
                    value.HisStockGoods = data.value;//把选中下拉框id值赋值给表格缓存
                    //刷新表格同时根据option中HisStockGoods值设置下拉列表
                    setSelectHisStockGoodsByTableRender();
                    //根据是否取库存获取定金比例
                    setHEarnestRateByHisStockGoods();
                    //设置表头所需金额
                    set_HBillMoney($("#HEarnestRate").val() * 1);
                });
            });
            //#endregion
            //#region è¡Œå†…快捷键筛选
@@ -1482,6 +2035,8 @@
                    if (event.key == "F7") {
                        //物料
                        if (obj.event == "HMaterID") {
                            var HOrgID = $("#HOrgID").val();
                            layer.open({
                                type: 2
                                , skin: "layui-layer-rim" //加上边框
@@ -1490,26 +2045,83 @@
                                , shift: 2 //弹出动画
                                , area: ["90%", "90%"] //窗体大小
                                , maxmin: true //设置最大最小按钮是否显示
                                , content: ['../../Baseset/基础资料/Gy_MaterialList.html', 'yes']
                                , 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("请选择一条数据");
                                    }
                                    //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
                                    })
                                    var rowIndex = $(obj.tr).attr("data-index") * 1;
                                    for (var i = 0; i < checkStatus.data.length; i++) {
                                        if (rowIndex + i >= option.data.length) {
                                            var NewRow = {
                                                "HMaterID": "0", "物料代码": "", "物料名称": "", "规格型号": "", "HUnitID": "0", "计量单位": "", "HQty": "0", "HPrice": "0", "HTaxPrice": "0"
                                                , "HMoney": "0", "HDiscountRate": "0", "HRelTaxPrice": "0", "HTaxRate": "0", "HTaxMoney": "0", "HlineTotal": "0", "HlineTotalBB": "0"
                                                , "HDate": Format(new Date(), 'yyyy-MM-dd'), "HOutStockQty": "0", "HInvoiceQty": "0", "HRemark": "", "HCusMaterNumber": "",
                                                "HCusModel": "","HCusMaterName": ""
                                            }
                                            btnAddLine(NewRow);
                                        }
                                        //获取选中的物料信息
                                        var resultData = checkStatus.data[i];
                                        //数值格式校验工具
                                        var ref = /^\d+(\.\d+)?$/;                                  //非负数正则表达式
                                        var temp = "";
                                        //获取选择物料前后的税率
                                        var value = subHTaxRate;                                    //选择物料后根据客户得到的税率
                                        var oldText = option.data[rowIndex + i].HTaxRate;           //该记录中原有的税率
                                        //税率数据格式校验,若根据客户获取的税率不合法,则使用记录中原有的税率,并提示
                                        temp = value + "";
                                        if (!ref.test(temp)) {
                                            value = oldText;
                                            layer.msg("获取到的税率不合法,已自动变更为原有税率!");
                                        }
                                        //数据校验合格,重算记录
                                        var HQty = option.data[rowIndex + i].HQty;                  //数量
                                        var HPrice = option.data[rowIndex + i].HPrice;              //单价
                                        var HTaxRate = value * 0.01;                                //税率
                                        /*var HDiscountRate = obj.data.HDiscountRate * 1;           //折扣率*/
                                        var HTaxPrice = HPrice * (1 + HTaxRate);                    //含税单价=单价*(1+税率)
                                        /*var HRelTaxPrice = HTaxPrice * HDiscountRate;             //实际含税单价=含税单价*折扣率*/
                                        //折扣额 = å«ç¨Žå•ä»· * (1 - æŠ˜æ‰£çއ) * æ•°é‡
                                        var HMoney = HQty * HPrice;                                 //金额=数量*单价
                                        var HTaxMoney = HMoney * HTaxRate;                          //税额=金额*税率
                                        var HlineTotal = HMoney + HTaxMoney;                        //价税合计=金额+税额
                                        option.data[rowIndex + i].HMaterID = resultData.HItemID;
                                        option.data[rowIndex + i].物料代码 = resultData.物料代码;
                                        option.data[rowIndex + i].物料名称 = resultData.物料名称;
                                        option.data[rowIndex + i].规格型号 = resultData.规格型号;
                                        option.data[rowIndex + i].HUnitID = resultData.HUnitID;
                                        option.data[rowIndex + i].计量单位 = resultData.计量单位名称;
                                        option.data[rowIndex + i].HQty = HQty;
                                        option.data[rowIndex + i].HPrice = HPrice;
                                        option.data[rowIndex + i].HTaxRate = HTaxRate * 100;
                                        option.data[rowIndex + i].HTaxPrice = HTaxPrice;
                                        option.data[rowIndex + i].HMoney = HMoney;
                                        option.data[rowIndex + i].HlineTotal = HlineTotal;
                                    }
                                    table.render(option);
                                    //刷新表格同时根据option中HisStockGoods值设置下拉列表
                                    setSelectHisStockGoodsByTableRender();
                                    //设置表头所需金额
                                    set_HBillMoney($("#HEarnestRate").val() * 1);
                                    layer.close(index);//关闭弹窗
                                }
                            })
@@ -1543,6 +2155,37 @@
                                }
                            })
                        }
                        //订单等级
                        if (obj.event == "HOrderLevID") {
                            layer.open({
                                type: 2
                                , skin: "layui-layer-rim" //加上边框
                                , title: "订单等级列表"  //标题
                                , closeBtn: 1  //窗体右上角关闭 çš„ æ ·å¼
                                , shift: 2 //弹出动画
                                , area: ["90%", "90%"] //窗体大小
                                , maxmin: true //设置最大最小按钮是否显示
                                , content: ['../../基础资料/公用基础资料/Gy_OrderLev.html', '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("请选择一条数据");
                                    }
                                    //更新表格缓存的数据
                                    obj.update({
                                        "订单等级名称": checkStatus.data[0].订单等级
                                        , "订单等级代码": checkStatus.data[0].订单等级代码
                                        , "HOrderLevID": checkStatus.data[0].HItemID
                                    })
                                    layer.close(index);//关闭弹窗
                                }
                            })
                        }
                        obj.event = "";
                        return false;
                    }
@@ -1595,7 +2238,7 @@
                    success: function (data1) {
                        if (data1.data.length != 0) {
                            var dataCol = [];//数据库查询出的列数据
                            var titleData = ["HMaterID", "HUnitID", "折扣率", "实际含税单价", "税额","本位币价税合计","出库数量","开票数量"];//不需要显示的字段 å¯æ‰©å±•
                            var titleData = ["HMaterID", "HUnitID", "折扣率", "实际含税单价", "税额", "本位币价税合计", "出库数量", "开票数量", "HOrderLevID","订单等级代码","销售出库数量","销售出库审核数量","销售出库审核金额","生产数量","销售退库数量","销售退库审核数量"];//不需要显示的字段 å¯æ‰©å±•
                            //titleData = [];
                            dataCol = data1.data[0].HGridString.split(',');
@@ -1659,8 +2302,15 @@
                                }
                            }
                            table.render(option);
                            //刷新表格同时根据option中HisStockGoods值设置下拉列表
                            setSelectHisStockGoodsByTableRender();
                        } else {
                            table.render(option);
                            //刷新表格同时根据option中HisStockGoods值设置下拉列表
                            setSelectHisStockGoodsByTableRender();
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
@@ -1678,11 +2328,164 @@
            }
            //#endregion
            //#region åå®¡æ ¸/审核数据
            function set_CheckBill(num) {
                var InterID = $("#HInterID").val();
                //逻辑审核方法
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/Xs_SeOrderBill/AuditXs_SeOrderBill", //方法所在页面和方法名
                    data: { "HInterID": InterID, "IsAudit": num, "CurUserName": sessionStorage["HUserName"] },
                    success: function (result) {
                        if (result.count == 1) {
                            layer.msg(result.Message, { time: 1 * 1000, icon: 1 }, function () {
                                // å¾—到frame索引
                                var index = layer.getFrameIndex(window.name);
                                //关闭当前frame
                                layer.close(index);
                            });
                        } else {
                            layer.alert(result.code + result.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //#endregion
            //#region æ‰“印
            function get_PrintReport() {
                //#region åˆ¤æ–­æºå•状态
                var HSourceBillData = "";
                var HSourceBillData = getSourceBillStatus_SeOrderBill();            //获取源单数据
                if (HSourceBillData != "none") {
                    if (HSourceBillData.length == 0) {
                        layer.alert("打印失败!未查询到单据信息!", { icon: 5 });
                        return;
                    } else if (HSourceBillData[0]["状态"] != "已审核") {
                        layer.alert("打印失败!单据状态未为'已审核'状态!", { icon: 5 });
                        return;
                    }
                } else {
                    return;
                }
                //#endregion
                var InterID = $("#HInterID").val();
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/Xs_SeOrderBill/CheckSeOrderBill_IsExist", //方法所在页面和方法名
                    data: { "HInterID": InterID},
                    success: function (result) {
                        if (result.count == 1) {
                            layer.open({
                                type: 2
                                , area: ['50%', '50%']
                                , title: '打印模版选择'
                                , shade: 0.6 //遮罩透明度
                                , maxmin: false //允许全屏最小化
                                , anim: 0 //0-6的动画形式,-1不开启
                                , content: ['../../BaseSet/SRM_OpenTmpList.html?linterid=' + InterID + '&MyMsg=' + InterID + '&Type=Xs_SeOrderBill', 'yes']
                                , resize: false
                            })
                        } else {
                            layer.alert(result.code + result.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //#endregion
            //#region è®¾ç½®è¡¨å¤´æ‰€éœ€é‡‘额
            function set_HBillMoney(HEarnestRate) {
                var HBillMoney = 0;
                for (var i = 0; i < option.data.length; i++) {
                    if (option.data[i]["HisStockGoods"] == "false") {
                        HBillMoney += option.data[i]["HlineTotal"] * 1;
                    }
                }
                HEarnestRate = HEarnestRate * 0.01;
                $("#HBillMoney").val(dealDoubleToFixed(HBillMoney * HEarnestRate, 2));
            }
            //#endregion
            //#region æ ¹æ®æ˜¯å¦å–库存获取定金比例
            function setHEarnestRateByHisStockGoods() {
                if (option.data.length > 0 && option.data[0]["HisStockGoods"] == "true") {
                    var HEarnestRateList = '<option  value="0" selected="selected" >0%</option>';
                    $("#HEarnestRate").empty();
                    $("#HEarnestRate").append(HEarnestRateList);
                    form.render('select');
                } else if (option.data.length > 0 && option.data[0]["HisStockGoods"] == "false") {
                    var HEarnestRateList = '<option  value="50" selected="selected" >50%</option>';
                    HEarnestRateList += '<option  value="100" >100%</option>';
                    $("#HEarnestRate").empty();
                    $("#HEarnestRate").append(HEarnestRateList);
                    /*form.render('select');*/
                    $("#HEarnestRate").val(HEarnestRateTemp);
                    form.render('select');
                } else {
                    var HEarnestRateList = '<option  value="50" selected="selected" >50%</option>';
                    HEarnestRateList += '<option  value="100" >100%</option>';
                    $("#HEarnestRate").empty();
                    $("#HEarnestRate").append(HEarnestRateList);
                    //form.render('select');
                    $("#HEarnestRate").val(HEarnestRateTemp);
                    form.render('select');
                }
            }
            //#endregion
            //#region èŽ·å–æºå•-销售订单单据状态
            function getSourceBillStatus_SeOrderBill() {
                var HSourceBillData = "none";
                var sWhere = " and hmainid = " + $("#HInterID").val();
                $.ajax({
                    url: GetWEBURL() + '/Xs_SeOrderBill/list',
                    async: false,
                    type: "GET",
                    data: { "sWhere": sWhere, "user": sessionStorage["HUserName"] },
                    success: function (data1) {
                        if (data1.count == 1) {
                            HSourceBillData = data1.data;
                        } else {
                            layer.alert(data1.code + "单据状态判断失败!", { icon: 5 });
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
                return HSourceBillData;
            }
            //#endregion
            //#region åˆ·æ–°è¡¨æ ¼åŒæ—¶æ ¹æ®option中HisStockGoods值设置下拉列表
            function setSelectHisStockGoodsByTableRender() {
                for (var i = 1; i <= option.data.length; i++) {
                    $('#HisStockGoods' + i + '').val(option.data[i - 1].HisStockGoods);
                }
                form.render('select');
            }
            //#endregion
            //#endregion
            //以上是layui模块
        });
        //子表税率,根据客户带出
        var subHTaxRate = 0;
        // åŸºç¡€èµ„料返回数据
        function GetHEmpValue(obj)  //返回业务员
        {
@@ -1692,8 +2495,12 @@
        function GetHSupValue(obj)  //返回客户
        {
            $("#HCusName").val(obj[0].HName);
            $("#HCusID").val(obj[0].HItemID);
            //$("#HCusName").val(obj[0].HName);
            //$("#HCusID").val(obj[0].HItemID);
            //根据客户获取相关信息
            getCustomerByCusID(obj[0].HItemID);
            //根据客户获取客户余额
            getCustomerBalance(obj[0].HItemID);
        }
        function GetHManagerValue(obj)  //返回主管
@@ -1707,6 +2514,140 @@
            $("#HDeptName").val(obj[0].HName);
            $("#HDeptID").val(obj[0].HItemID);
        }
        function GetSettleStyleValue(obj)           //返回结算方式
        {
            $("#HSSName").val(obj[0].HName);
            $("#HSSID").val(obj[0].HItemID);
        }
        function GetSellStyleValue(obj)           //返回销售方式
        {
            $("#HSellSName").val(obj[0].HName);
            $("#HSellSID").val(obj[0].HItemID);
        }
        //#region æ ¹æ®å®¢æˆ·èŽ·å–å¸åˆ«ã€æ±‡çŽ‡ã€ç»“ç®—æ–¹å¼ã€å®¢æˆ·ä¿¡ç”¨é¢åº¦ã€è”ç³»äººã€è”ç³»ç”µè¯
        function getCustomerByCusID(HCusID) {
            $.ajax({
                url: GetWEBURL() + "/Xs_SeOrderBill/getCustomerByCusID",
                async: false,
                type: "GET",
                data: {
                    "HCusID": HCusID
                },
                success: function (result) {
                    if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                        var data = result.data[0];
                        $("#HCusID").val(data.HCusID);
                        $("#HCusName").val(data.HCusName);
                        $("#HCurID").val(data.HCurID);
                        $("#HCurName").val(data.HCurName);
                        $("#HExRate").val(data.HExRate);
                        $("#HSSID").val(data.HSSID);
                        $("#HSSName").val(data.HSSName);
                        $("#HCreditRating_Now").val(data.HCreditRating_Now);
                        $("#HLinkMan").val(data.HLinkMan);
                        $("#HLinkPhone").val(data.HLinkPhone);
                        subHTaxRate = data.HTaxRate;
                    } else {
                        layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                    }
                }, error: function () {
                    layer.alert("发生错误!", { icon: 5 });
                }
            });
        }
        //#endregion
        //#region æ ¹æ®å®¢æˆ·èŽ·å–å®¢æˆ·å¯¹åº”ç¨ŽçŽ‡
        function getHTaxRateByCusID(HCusID) {
            $.ajax({
                url: GetWEBURL() + "/Xs_SeOrderBill/getCustomerByCusID",
                async: false,
                type: "GET",
                data: {
                    "HCusID": HCusID
                },
                success: function (result) {
                    if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                        var data = result.data[0];
                        subHTaxRate = data.HTaxRate;
                    } else {
                        layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                    }
                }, error: function () {
                    layer.alert("发生错误!", { icon: 5 });
                }
            });
        }
        //#endregion
        //#region æ ¹æ®å®¢æˆ·èŽ·å–å®¢æˆ·ä½™é¢
        function getCustomerBalance(HCusID) {
            $.ajax({
                url: GetWEBURL() + "/Xs_CusRatingChangeBill/getCustomerBalance",
                async: false,
                type: "GET",
                data: {
                    "HCusID": HCusID
                },
                success: function (result) {
                    if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                        var data = result.data[0];
                        $("#HCusBalance").val(data.HCusBalance == null ? 0 : data.HCusBalance);
                        $("#HCreditRating_Now").val(data.HCreditRating_Now == null ? 0 : data.HCreditRating_Now);
                        $("#HAvailableBalance").val(data.HAvailableBalance == null ? 0 : data.HAvailableBalance);
                    } else {
                        layer.alert(result.Message, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                    }
                }, error: function () {
                    layer.alert("发生错误!", { icon: 5 });
                }
            });
        }
        //#endregion
        //#region å¤„理小数显示位数(data:需要处理的数据;num:数据的类型(如1:数量;2:金额;3:单价))
        function dealDoubleToFixed(data, num) {
            //用于设置小数位数
            var dotLength = 0;
            if (num == 1) {                                    //当数据为数量时,最多保留6位小数
                //设置最多保留6位小数
                dotLength = 6;
            } else if (num == 2) {                             //当数据为金额时,最多保留2位小数
                //设置最多保留2位小数
                dotLength = 2;
            } else if (num == 3) {                             //当数据为单价时,最多保留4位小数
                //设置最多保留4位小数
                dotLength = 4;
            }
            //判断是否存在小数点及其索引位置
            data = data + "";
            var index = data.indexOf(".");
            //处理数据并返回
            if (index < 0) {
                return data * 1;
            } else {
                //获取小数位数
                var length = data.length - index - 1;
                if (length <= dotLength) {
                    return data * 1;
                } else {
                    data = data * 1;
                    return data.toFixed(dotLength);
                }
            }
        }
                //#endregion
    </script>
</body>
</html>