duhe
2023-11-09 a8effe0ef3122ea93521cd2c65fdac2aa73bb0a1
WebTM/views/ÏúÊÛ¹ÜÀí/ÏúÊÛ¶©µ¥/Add_Edit_Xs_SeOrderBillList.html
@@ -16,7 +16,7 @@
    <script src="../../../layuiadmin/PubCustom.js"></script>
    <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <style type="text/css">
        .layui-form-item .layui-inline {
        /*.layui-form-item .layui-inline {
            margin-right: 0;
        }
@@ -33,7 +33,7 @@
            margin-top: -10px;
            margin-left: -15px;
            margin-right: -15px;
        }
        }*/
    </style>
</head>
<body>
@@ -60,7 +60,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,7 +68,7 @@
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">日期</label>
                                            <label class="layui-form-label">日期<label style="color:red"> * </label></label>
                                            <div class="layui-input-inline">
                                                <input type="date" class="layui-input" lay-verify="HDate" name="HDate" id="HDate" style="padding-left: 80px;">
                                            </div>
@@ -76,7 +76,7 @@
                                        <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 +86,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 +96,9 @@
                                    </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="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,15 +106,15 @@
                                            </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>
                                            <label class="layui-form-label">客户<label style="color:red"> * </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="text" name="HCusName" id="HCusName" class="layui-input" value="" style="float: left; width: 465px; background-color: #efefef4d;" readonly>
                                                <input type="hidden" name="HCusID" id="HCusID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HCusList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
@@ -124,9 +124,9 @@
                                    </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 +136,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>
@@ -154,7 +154,7 @@
                                        <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="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>
@@ -176,7 +176,7 @@
                                        <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>
                                                <input class="layui-input" name="HInnerBillNo" id="HInnerBillNo" style="background-color: #efefef4d;" autocomplete="off" readonly>
                                            </div>
                                        </div>
                                    </div>
@@ -657,14 +657,14 @@
                    case "HTaxRate":                                                       //数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp) || temp == 0) {
                        if (!ref.test(temp)) {
                            //恢复数据到编辑前
                            obj.update({
                                HTaxRate: oldText
                            });
                            table.render(option);
                            layer.msg("税率请输入大于0的数字!");
                            layer.msg("税率请输入不小于0的数字!");
                            return;
                        }
@@ -757,6 +757,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({
@@ -780,20 +811,20 @@
                    , 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, totalRow: true, 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: '物料名称', 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: 'HQty', title: '数量', width: 100, edit: 'text' }
                        , { field: 'HPrice', title: '单价', width: 100, edit: 'text' }
                        , { field: 'HTaxRate', title: '税率', width: 100, edit: 'text' }
                        , { field: 'HTaxPrice', title: '含税单价', width: 100 }
                        , { field: 'HMoney', title: '金额', width: 100 }
                        , { field: 'HlineTotal', title: '价税合计', width: 100, }
                        , { field: 'HTaxPrice', title: '含税单价', width: 100, style: 'background-color:#efefef4d;' }
                        , { field: 'HMoney', title: '金额', width: 100, style: 'background-color:#efefef4d;' }
                        , { field: 'HlineTotal', title: '价税合计', width: 100, style: 'background-color:#efefef4d;' }
                        , { field: 'HDate', title: '交货日期', event: "HDate", width: 120 }
                        , { field: 'HRemark', title: '备注', width: 100, edit: 'text' }
@@ -849,6 +880,9 @@
                $("#HSSDate").val(Format(new Date(), "yyyy-MM-dd"));
                $("#HMaker").val(sessionStorage["HUserName"]);
                $("#HMakeDate").val(Format(new Date(), "yyyy-MM-dd"));
                //销售员、销售部门、销售主管初始化
                getCzyglByUser();
                //初始化并列设置:子表1
                set_InitGrid();
@@ -1232,15 +1266,15 @@
                    return false;
                }
                if ($("#HDeptID").val() == "0") {
                    layer.msg("销售部门未选择!");
                    return false;
                }
                //if ($("#HDeptID").val() == "0") {
                //    layer.msg("销售部门未选择!");
                //    return false;
                //}
                if ($("#HEmpID").val() == "0") {
                    layer.msg("销售员未选择!");
                    return false;
                }
                //if ($("#HEmpID").val() == "0") {
                //    layer.msg("销售员未选择!");
                //    return false;
                //}
                if ($("#HCurID").val() == "0") {
                    layer.msg("销售币别未选择!");
@@ -1266,15 +1300,15 @@
                    return false;
                }
                if ($("#HSellSID").val() == "0") {
                    layer.msg("销售方式未选择!");
                    return false;
                }
                //if ($("#HSellSID").val() == "0") {
                //    layer.msg("销售方式未选择!");
                //    return false;
                //}
                if ($("#HMangerID").val() == "0") {
                    layer.msg("销售主管未选择!");
                    return false;
                }
                //if ($("#HMangerID").val() == "0") {
                //    layer.msg("销售主管未选择!");
                //    return false;
                //}
                
@@ -1325,11 +1359,8 @@
                    //税率格式校验
                    temp = option.data[i]["HTaxRate"] + "";
                    if (temp == "0") {
                        layer.msg("第" + i + "行:税率不能为0!");
                        return false;
                    } else if (!ref.test(temp)) {
                        layer.msg("第" + i + "行:税率请输入大于0的数字!");
                    if (!ref.test(temp)) {
                        layer.msg("第" + i + "行:税率请输入不小于0的数字!");
                        return false;
                    }
@@ -1600,26 +1631,76 @@
                                , shift: 2 //弹出动画
                                , area: ["90%", "90%"] //窗体大小
                                , maxmin: true //设置最大最小按钮是否显示
                                , content: ['../../Baseset/基础资料/Gy_MaterialList.html', 'yes']
                                , content: ['../../基础资料/公用基础资料/Gy_Material.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("请选择一条数据");
                                    }
                                    //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": ""
                                            }
                                            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.HMaterID;
                                        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);
                                    layer.close(index);//关闭弹窗
                                }
                            })
@@ -1797,6 +1878,9 @@
            //以上是layui模块
        });
        //子表税率,根据客户带出
        var subHTaxRate = 0;
        // åŸºç¡€èµ„料返回数据
        function GetHEmpValue(obj)  //返回业务员
        {
@@ -1844,6 +1928,7 @@
                        $("#HSSID").val(data.HSSID);
                        $("#HSSName").val(data.HSSName);
                        subHTaxRate = data.HTaxRate;
                    } else {
                        layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });