yusijie
2024-04-25 8e2b58a4bbe75ed3d29f14d004d9dc69e73f2a1d
WebTM/views/ÏúÊÛ¹ÜÀí/ÏúÊÛ¶©µ¥±ä¸üµ¥/Xs_SeOrderChangeBill.html
@@ -15,8 +15,9 @@
    <script src="../../../layuiadmin/Scripts/webConfig.js"></script>
    <script src="../../../layuiadmin/PubCustom.js"></script>
    <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <script src="../../../layuiadmin/PageTitle.js"></script>
    <style type="text/css">
       /* .layui-form-item .layui-inline {
        /* .layui-form-item .layui-inline {
            margin-right: 0;
        }
@@ -75,21 +76,21 @@
                                            </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; background-color: #efefef4d;" readonly>
                                                <input type="hidden" name="HDeptID" id="HDeptID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HDeptList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">销售员</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HEmpName" id="HEmpName" " class="layui-input" value="" style="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>
                                                </button>
                                            </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; background-color: #efefef4d;" readonly>
                                                <input type="hidden" name="HDeptID" id="HDeptID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <button type="button" lay-submit="" class="layui-btn" lay-filter="HDeptList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>
                                            </div>
@@ -307,6 +308,13 @@
            //记录组织的值
            var HOrgIDBar = 0;
        //#region ã€åŠ¨æ€èŽ·å–æ¨¡å—åç§°ã€‘
            var HModuleType = "1425";
            //通过单据类型,从数据库动态获取单据模块命名,引用js文件 PageTitle.js
            var HPageTitle = get_PageTitle(HModuleType) == "" ? $("h1").html() : get_PageTitle(HModuleType);
            $("h1").html('<b>' + HPageTitle + '</b>');
            //#endregion
            //模块名
            var HModName = "Xs_SeOrderChangeBill";
            var HBillType = "1425";
@@ -398,6 +406,25 @@
            //#region è¡¨å¤´æŒ‰é’®è§¦å‘事件
            //#region ä¿å­˜æŒ‰é’®
            form.on('submit(set_SaveBill)', function (data) {
                if (OperationType == 4) {
                    //#region åˆ¤æ–­æºå•状态
                    var HSourceBillData = "";
                    var HSourceBillData = getSourceBillStatus_SeOrderBill();            //获取源单数据
                    if (HSourceBillData != "none") {
                        if (HSourceBillData.length == 0) {
                            layer.alert("保存失败!未查询到源单单据!", { icon: 5 });
                            return;
                        } else if (HSourceBillData[0]["状态"] != "已审核") {
                            var err = "保存失败!原因:源单单据状态为“" + HSourceBillData[0]["状态"] + "”,不允许保存!";
                            layer.alert(err, { icon: 5 });
                            return;
                        }
                    } else {
                        return;
                    }
                //#endregion
                }
                //if (AllowLoadData(data)) {
                    set_SaveBill(data);
                //}
@@ -437,6 +464,8 @@
                    "计量单位": "",
                    "HQty_Old": "0",
                    "HQty_New": "0",
                    "HTaxRate_Old": "0",
                    "HTaxRate_New": "0",
                    "HTaxPrice_Old": "0",
                    "HTaxPrice_New": "0",
                    "HDate_Old": "",
@@ -496,6 +525,10 @@
            //#region ç›‘听单元格编辑  å•元格编辑后 å˜æ›´
            table.on('edit(mainTable)', function (obj) {
                //数值格式校验工具
                var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                var temp = "";
                // å•元格编辑之前的值
                var oldText = $(this).prev().text();
                var value = obj.value //得到修改后的值
@@ -504,25 +537,57 @@
                //layer.msg('[ID: ' + data.id + '] ' + field + ' å­—段更改为:' + value);
                switch (field) {
                    case "HRate":     //用量
                        //value = (value * 1).toFixed(6);
                    case "HQty_New":                                                       //数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp) || temp == 0) {
                            //恢复数据到编辑前
                            obj.update({
                                HQty_New: 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;
                        //}
                        ////同步更新表格和缓存对应的值
                        //obj.update({
                        //    HRate: value,
                        //    HQty: HQty
                        //});
                        //table.render(option);
                            layer.msg("新数量请输入大于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HQty_New = value * 1;                           //新数量
                        //设置数据小数位数
                        HQty_New = dealDoubleToFixed(HQty_New, 1);
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HQty_New: HQty_New
                        });
                        table.render(option);
                        break;
                    case "HTaxPrice_New":                                                       //数量
                        //数据格式校验
                        temp = value + "";
                        if (!ref.test(temp)) {
                            //恢复数据到编辑前
                            obj.update({
                                HTaxPrice_New: oldText
                            });
                            table.render(option);
                            layer.msg("新含税单价请输入不小于0的数字!");
                            return;
                        }
                        //数据校验合格,重算记录
                        var HTaxPrice_New = value * 1;                  //新含税单价=单价*(1+税率)
                        //设置数据小数位数
                        HTaxPrice_New = dealDoubleToFixed(HTaxPrice_New, 3);
                        //同步更新表格和缓存对应的值
                        obj.update({
                            HTaxPrice_New: HTaxPrice_New
                        });
                        table.render(option);
                        break;
                    default:
                }
@@ -606,20 +671,23 @@
                option = {
                    elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , totalRow: true
                    , limit: 500
                    , height: 500
                    , loading: false
                    , cols: [[ //子表
                        { type: 'checkbox', totalRowText: '合计行' }
                        , { type: 'numbers', title: '序号', width: 100, style: "background-color:#efefef4d;", totalRow: true }
                        , { type: 'numbers', title: '序号', width: 100, style: "background-color:#efefef4d;" }
                        , { field: 'HMaterID', title: 'HMaterID', width: 100, style: "background-color:#efefef4d;", hide: true }
                        , { field: '物料代码', title: '物料代码', width: 150, event: "HMaterID", style: "background-color:#efefef4d;" }//f7
                        , { field: '物料名称', title: '物料名称', width: 150, style: "background-color:#efefef4d;" }
                        , { field: '规格型号', title: '规格型号', width: 100, style: "background-color:#efefef4d;" }
                        , { field: 'HUnitID', title: 'HUnitID', width: 100, style: "background-color:#efefef4d;", hide: true }
                        , { field: '计量单位', title: '计量单位', width: 100, style: "background-color:#efefef4d;" }//f7
                        , { field: 'HQty_Old', title: '原数量', width: 100, style: "background-color:#efefef4d;"}
                        , { field: 'HQty_New', title: '新数量', width: 100, edit: 'text' }
                        , { field: 'HQty_Old', title: '原数量', width: 100, totalRow: true, style: "background-color:#efefef4d;"}
                        , { field: 'HQty_New', title: '新数量', width: 100, totalRow: true, edit: 'text' }
                        , { field: 'HTaxRate_Old', title: '原税率%', width: 100, style: "background-color:#efefef4d;" }
                        , { field: 'HTaxRate_New', title: '新税率%', width: 100, edit: 'text' }
                        , { field: 'HTaxPrice_Old', title: '原含税单价', width: 100, style: "background-color:#efefef4d;" }
                        , { field: 'HTaxPrice_New', title: '新含税单价', width: 100, edit: 'text' }
                        , { field: 'HDate_Old', title: '原交货日期', width: 120, style: "background-color:#efefef4d;" }
@@ -631,7 +699,7 @@
                        , { field: 'HSourceBillNo', title: '源单单号', hide: true, style: 'background-color: #f9f9f9;' }     //f7
                        , { field: 'HSourceBillType', title: '源单类型', hide: true, style: 'background-color: #f9f9f9;' }     //f7
                       /* , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 70 }*/
                        , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 70 }
                    ]]
                }
@@ -644,6 +712,8 @@
                    "计量单位": "",
                    "HQty_Old": "0",
                    "HQty_New": "0",
                    "HTaxRate_Old": "0",
                    "HTaxRate_New": "0",
                    "HTaxPrice_Old": "0",
                    "HTaxPrice_New": "0",
                    "HDate_Old": "",
@@ -745,10 +815,12 @@
                                        "规格型号": result.data[i]["规格型号"],
                                        "HUnitID": result.data[i]["HUnitID"],
                                        "计量单位": result.data[i]["计量单位"],
                                        "HQty_Old": result.data[i]["原数量"],
                                        "HQty_New": result.data[i]["新数量"],
                                        "HTaxPrice_Old": result.data[i]["原含税单价"],
                                        "HTaxPrice_New": result.data[i]["新含税单价"],
                                        "HQty_Old": dealDoubleToFixed(result.data[i]["原数量"], 1),
                                        "HQty_New": dealDoubleToFixed(result.data[i]["新数量"], 1),
                                        "HTaxRate_Old": result.data[i]["原税率"],
                                        "HTaxRate_New": result.data[i]["新税率"],
                                        "HTaxPrice_Old": dealDoubleToFixed(result.data[i]["原含税单价"], 3),
                                        "HTaxPrice_New": dealDoubleToFixed(result.data[i]["新含税单价"], 3),
                                        "HDate_Old": formatDate(result.data[i]["原交货日期"]),
                                        "HDate_New": formatDate(result.data[i]["新交货日期"]),
                                        "HRemark": result.data[i]["表体备注"],
@@ -833,12 +905,14 @@
                                        "规格型号": result.data[i]["规格型号"],
                                        "HUnitID": result.data[i]["HUnitID"],
                                        "计量单位": result.data[i]["计量单位"],
                                        "HQty_Old": result.data[i]["数量"],
                                        "HQty_New": result.data[i]["数量"],
                                        "HTaxPrice_Old": result.data[i]["含税单价"],
                                        "HTaxPrice_New": result.data[i]["含税单价"],
                                        "HQty_Old": dealDoubleToFixed(result.data[i]["数量"], 1),
                                        "HQty_New": dealDoubleToFixed(result.data[i]["数量"], 1),
                                        "HTaxRate_Old": result.data[i]["税率"],
                                        "HTaxRate_New": result.data[i]["税率"],
                                        "HTaxPrice_Old": dealDoubleToFixed(result.data[i]["含税单价"], 3),
                                        "HTaxPrice_New": dealDoubleToFixed(result.data[i]["含税单价"] ,3),
                                        "HDate_Old": formatDate(result.data[i]["交货日期"]),
                                        "HDate_New": formatDate(result.data[i]["交货日期"]),
                                        "HDate_New": new Date(result.data[i]["交货日期"]).getTime() < new Date().getTime() ? Format(new Date(),"yyyy-MM-dd"):formatDate(result.data[i]["交货日期"]),
                                        "HRemark": "",
                                        "HSourceInterID": result.data[i]["hmainid"],
                                        "HSourceEntryID": result.data[i]["hsubid"],
@@ -872,7 +946,7 @@
                    , area: ['90%', '90%']//大小
                    , title: '销售部门列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_DepartmentList.html', 'yes']
                    , content: ['../../基础资料/公用基础资料/Gy_DepartmentList.html', 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
@@ -880,7 +954,7 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HDeptName").val(checkStatus.data[0].HName);
                        $("#HDeptName").val(checkStatus.data[0].部门名称);
                        $("#HDeptID").val(checkStatus.data[0].HItemID);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
@@ -897,7 +971,7 @@
                    , area: ['90%', '90%']//大小
                    , title: '销售员列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_EmployeeList.html?Type=HEmp', 'yes']
                    , content: ['../../基础资料/公用基础资料/Gy_EmployeeList.html?Type=HEmp', 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
@@ -905,8 +979,10 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HEmpName").val(checkStatus.data[0].HName);
                        $("#HEmpName").val(checkStatus.data[0].职员名称);
                        $("#HEmpID").val(checkStatus.data[0].HItemID);
                        getEmpInfoByHEmpID(checkStatus.data[0].HItemID);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
@@ -942,13 +1018,14 @@
            //#region å®¢æˆ·é€‰æ‹©é¡µé¢
            function get_checkCus() {
                var HEmpID = $("#HEmpID").val();
                layer.open({
                    type: 2//弹窗类型
                    , skin: 'layui-layer-rim' //加上边框
                    , area: ['90%', '90%']//大小
                    , title: '客户列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_CustomerList.html', 'yes']
                    , content: ['../../Baseset/基础资料/Gy_CustomerList.html?Type=1&openType=3&HEmp=' + HEmpID, 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
@@ -973,7 +1050,7 @@
                    , area: ['90%', '90%']//大小
                    , title: '结算方式列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_SettleStyle.html', 'yes']
                    , content: ['../../基础资料/基础资料/Gy_SettleStyle.html', 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
@@ -981,7 +1058,7 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HSSName").val(checkStatus.data[0].HName);
                        $("#HSSName").val(checkStatus.data[0].结算方式名称);
                        $("#HSSID").val(checkStatus.data[0].HItemID);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
@@ -998,7 +1075,7 @@
                    , area: ['90%', '90%']//大小
                    , title: '销售方式列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../Baseset/基础资料/Gy_SellStyle.html', 'yes']
                    , content: ['../../基础资料/公用基础资料/Gy_SellStyle.html', 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
@@ -1006,7 +1083,7 @@
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        $("#HSellSName").val(checkStatus.data[0].HName);
                        $("#HSellSName").val(checkStatus.data[0].销售方式名称);
                        $("#HSellSID").val(checkStatus.data[0].HItemID);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
@@ -1048,10 +1125,12 @@
                if (OperationType == 1 || OperationType == 2 || OperationType==4) {
                    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;
                }
                //若为编辑-保存,则更新修改人和修改时间
@@ -1429,9 +1508,9 @@
                if (obj.event === 'del') {
                    layer.confirm('真的删除行么', function (index) {
                        console.log("索引为:" + rowIndex);
                        if (rowIndex === '0') {
                            layer.msg('首行无法删除!!!');
                        } else {
                        //if (rowIndex === '0') {
                        //    layer.msg('首行无法删除!!!');
                        //} else {
                            //obj.del();
                            //layer.close(index);
                            var oldData = table.cache["mainTable"];
@@ -1439,7 +1518,7 @@
                            option.data = oldData;
                            table.render(option);
                            layer.close(index);
                        }
                        /*}*/
                    });
                }
            }
@@ -1674,16 +1753,42 @@
                });
            }
            //#endregion
            //#region èŽ·å–æºå•-销售订单单据状态
            function getSourceBillStatus_SeOrderBill() {
                var HSourceBillData = "none";
                var sWhere = " and hmainid = " + $("#HMainSourceInterID").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
            //#endregion
            //以上是layui模块
        });
        // åŸºç¡€èµ„料返回数据
        function GetHEmpValue(obj)  //返回销售员
        function GetHEmpValue(obj)  //返回业务员
        {
            $("#HEmpName").val(obj[0].HName);
            $("#HEmpName").val(obj[0].职员名称);
            $("#HEmpID").val(obj[0].HItemID);
            getEmpInfoByHEmpID(obj[0].HItemID)
        }
        function GetHSupValue(obj)  //返回客户
@@ -1698,11 +1803,84 @@
            $("#HManagerID").val(obj[0].HItemID);
        }
        function GetHDeptNameValue(obj)  //返回销售部门
        function GetHDeptNameValue(obj)  //返回部门
        {
            $("#HDeptName").val(obj[0].HName);
            $("#HDeptName").val(obj[0].部门名称);
            $("#HDeptID").val(obj[0].HItemID);
        }
        function GetSettleStyleValue(obj)           //返回结算方式
        {
            $("#HSSName").val(obj[0].结算方式名称);
            $("#HSSID").val(obj[0].HItemID);
        }
        function GetSellStyleValue(obj)           //返回销售方式
        {
            $("#HSellSName").val(obj[0].销售方式名称);
            $("#HSellSID").val(obj[0].HItemID);
        }
        //#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
        //#region æ ¹æ®èŒå‘˜èŽ·å–éƒ¨é—¨
        function getEmpInfoByHEmpID(HEmpID) {
            $.ajax({
                url: GetWEBURL() + "/Xs_SeOrderBill/getEmpInfoByHEmpID",
                async: false,
                type: "GET",
                data: {
                    "HEmpID": HEmpID
                },
                success: function (result) {
                    if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                        var data = result.data[0];
                        $("#HDeptID").val(data.HDeptID);
                        $("#HDeptName").val(data.HDeptName);
                    } else {
                        layer.alert(result.Message, { icon: 5 });
                    }
                }, error: function () {
                    layer.alert("发生错误!", { icon: 5 });
                }
            });
        }
        //#endregion
    </script>
</body>
</html>