duhe
2023-12-20 ac2ea5a96b01aa962c8b379aa196ee0683e47e9b
WebTM/views/ÏúÊÛ¹ÜÀí/ÏúÊÛ¶©µ¥±ä¸üµ¥/Xs_SeOrderChangeBill.html
@@ -45,6 +45,7 @@
                    <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="Exit">退出</button>
                        </div>
                    </div>
@@ -69,8 +70,8 @@
                                        </div>
                                        <div class="layui-inline">
                                            <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 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">
@@ -397,9 +398,33 @@
            //#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]["状态"] != "已审核") {
                            layer.alert("保存失败!源单单据状态未为'已审核'状态!", { icon: 5 });
                            return;
                        }
                    } else {
                        return;
                    }
                //#endregion
                }
                //if (AllowLoadData(data)) {
                    set_SaveBill(data);
                //}
            });
            //#endregion
            //#region å®¡æ ¸æŒ‰é’®
            form.on('submit(set_CheckBill)', function (data) {
                set_CheckBill(0);
            });
            //#endregion
@@ -489,6 +514,10 @@
            //#region ç›‘听单元格编辑  å•元格编辑后 å˜æ›´
            table.on('edit(mainTable)', function (obj) {
                //数值格式校验工具
                var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
                var temp = "";
                // å•元格编辑之前的值
                var oldText = $(this).prev().text();
                var value = obj.value //得到修改后的值
@@ -497,25 +526,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:
                }
@@ -599,20 +660,21 @@
                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: '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;" }
@@ -738,10 +800,10 @@
                                        "规格型号": 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),
                                        "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]["表体备注"],
@@ -826,10 +888,10 @@
                                        "规格型号": 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),
                                        "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": "",
@@ -1640,6 +1702,57 @@
            }
            //#endregion
            //#region åå®¡æ ¸/审核数据
            function set_CheckBill(num) {
                var InterID = $("#HInterID").val();
                //逻辑审核方法
                $.ajax({
                    type: "GET",
                    url: GetWEBURL() + "/Xs_SeOrderChangeBill/AuditXs_SeOrderChangeBill", //方法所在页面和方法名
                    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 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
@@ -1669,6 +1782,54 @@
            $("#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 å¤„理小数显示位数(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>