duhe
2024-03-14 b8f41703ae78e3890320f8eae215af6b8b63a454
WebTM/views/ÁìÁÏ·¢»õ/ÏúÊÛ³ö¿â/Kf_SellOutBill.html
@@ -15,6 +15,7 @@
    <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 {
            margin-right: 0;
@@ -45,7 +46,8 @@
                    <div class="layui-card-header">
                        <div class="layui-btn-group">
                            <button type="button" id="set_SaveBill" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Saver">保存</button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="set_CheckBill">审核</button>
                            <button type="button" id="set_CheckBill" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="set_CheckBill">审核</button>
                            <button type="button" id="btn-print" 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>
@@ -96,21 +98,21 @@
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-inline">
                                            <label class="layui-form-label">销售部门</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HDeptName" id="HDeptName" class="layui-input" value="" style="background-color:#efefef4d;" readonly>
                                                <input type="hidden" name="HDeptID" id="HDeptID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <!--<button type="button" lay-submit="" class="layui-btn" lay-filter="HDeptList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>-->
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">销售员</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HEmpName" id="HEmpName" " class="layui-input" value="" style="background-color:#efefef4d;" readonly>
                                                <input type="hidden" name="HEmpID" id="HEmpID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <!--<button type="button" lay-submit="" class="layui-btn" lay-filter="HEmpList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>-->
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label">销售部门</label>
                                            <div class="layui-input-inline">
                                                <input type="text" name="HDeptName" id="HDeptName" class="layui-input" value="" style="background-color:#efefef4d;" readonly>
                                                <input type="hidden" name="HDeptID" id="HDeptID" class="layui-input" value="0" style="float:left;width:150px;">
                                                <!--<button type="button" lay-submit="" class="layui-btn" lay-filter="HDeptList" style="width:40px;">
                                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                </button>-->
                                            </div>
@@ -452,6 +454,13 @@
            get_LoginIs();
            //#endregion
            //#region ã€åŠ¨æ€èŽ·å–æ¨¡å—åç§°ã€‘
            //var HModuleType = "1205";
            ////通过单据类型,从数据库动态获取单据模块命名,引用js文件 PageTitle.js
            //var HPageTitle = get_PageTitle(HModuleType) == "" ? $("h1").html() : get_PageTitle(HModuleType);
            //$("h1").html('<b>' + HPageTitle + '</b>');
         //#endregion
            //#region èŽ·å–é¡µé¢è·³è½¬å‚æ•°
            var params = get_UrlVars();
            if (typeof (params[params[0]]) == "undefined") {
@@ -460,6 +469,7 @@
                var OperationType = params[params[0]];//操作类型
                var linterid = params[params[1]];//源单id
                var HSouceBillType = params[params[2]];//源单类型
                var closeType = params[params[3]];//客户应收账款明细 åŒå‡»å¼¹çª—弹出只能查看不能编辑  ç¦ç”¨æŒ‰é’®
            }
            //#endregion
@@ -480,11 +490,19 @@
                $("#HMakeDate").val(Format(new Date(), "yyyy-MM-dd"));
            }
            else if (OperationType == 3) {                                              //编辑
                if (closeType == 10) {
                    $('#set_SaveBill').addClass("layui-btn-disabled").attr("disabled", true);
                    $('#set_CheckBill').addClass("layui-btn-disabled").attr("disabled", true);
                    $('#btn-print').addClass("layui-btn-disabled").attr("disabled", true);
                }
                //修改时主表ID
                $("#HInterID").val(linterid);
                //编辑状态时,根据内码,获取信息并写入界面
                RoadBillMain(linterid);
                //判断单据是否由扫码生成,是则保存按钮禁用
                getBarCodeNoteBySellOutBill();
            }
            else if (OperationType == 4) {                     //下推
                setInit_PushBill();
@@ -524,6 +542,12 @@
            });
            //#endregion
            //#region æ‰“印按钮
            form.on('submit(btn-print)', function (data) {
                get_PrintReport();
            });
            //#endregion
            //#region ä¿å­˜æŒ‰é’®
            form.on('submit(Saver)', function (data) {
                if (OperationType == 1 || OperationType == 4) {
@@ -536,7 +560,11 @@
                                layer.alert("保存失败!第" + (i+1) + "行:未查询到源单单据!", { icon: 5 });
                                return;
                            } else if (HSourceBillData.状态 != "已审核") {
                                layer.alert("保存失败!第" + (i+1) + "行:源单单据状态未为'已审核'状态!", { icon: 5 });
                                var err = "保存失败!原因:第" + (i + 1) + "行-源单单据状态为“" + HSourceBillData.状态 + "”,不允许保存!";
                                layer.alert(err, { icon: 5 });
                                return;
                            } else if (HSourceBillData.行状态 == "已关闭") {
                                layer.alert("保存失败!第" + (i + 1) + "行:该行记录行状态为'已关闭'状态!", { icon: 5 });
                                return;
                            }
                        } else {
@@ -652,6 +680,7 @@
                    , "计量单位": ""
                    , "HQtyMust": "0"
                    , "HQty": "0"
                    , "HPieceQty": "0"
                    , "HPrice": "0"
                    , "HTaxPrice": "0"
                    , "HTaxRate": "0"
@@ -816,7 +845,7 @@
                            , HMoney: HMoney
                            , HTaxMoney: HTaxMoney
                        });
                        //table.render(option);
                        table.render(option);
                        break;
                    case "HPrice":                                                       //单价
                        //数据格式校验
@@ -861,7 +890,7 @@
                            , HMoney: HMoney
                            , HTaxMoney: HTaxMoney
                        });
                        //table.render(option);
                        table.render(option);
                        break;
                    case "HTaxRate":                                                       //数量
                        //数据格式校验
@@ -906,7 +935,7 @@
                            , HMoney: HMoney
                            , HTaxMoney: HTaxMoney
                        });
                        //table.render(option);
                        table.render(option);
                        break;
                    case "HTaxPrice":                                                       //数量
                        //数据格式校验
@@ -951,7 +980,7 @@
                            , HMoney: HMoney
                            , HTaxMoney: HTaxMoney
                        });
                        //table.render(option);
                        table.render(option);
                        break;
                    default:
                }
@@ -1357,6 +1386,7 @@
                        , { field: '计量单位', title: '计量单位', width: 100, edit: 'text', event: "HUnitID"}//f7
                        , { field: 'HQtyMust', title: '应发数量', width: 100, totalRow: true, style: 'background-color:#efefef4d;'}
                        , { field: 'HQty', title: '实发数量', width: 100, totalRow: true, edit: 'text', event: "HQty" }
                        , { field: 'HPieceQty', title: '件数', width: 100, totalRow: true, edit: 'text'}
                        , { field: 'HPrice', title: '单价', width: 100, edit: 'text', event: "HPrice" }
                        , { field: 'HTaxPrice', title: '含税单价', width: 100, edit: 'text', event: "HTaxPrice" }
                        , { field: 'HTaxRate', title: '税率', width: 100, edit: 'text' }
@@ -1421,6 +1451,7 @@
                    , "计量单位": ""
                    , "HQtyMust": "0"
                    , "HQty": "0"
                    , "HPieceQty": "0"
                    , "HPrice": "0"
                    , "HTaxPrice": "0"
                    , "HTaxRate": "0"
@@ -1558,7 +1589,7 @@
                                , "HDeleteDate": data.作废日期 == null ? "" : Format(new Date(data.作废日期), "yyyy-MM-dd")
                            });
                            HOrgIDBar = data.HOrgID == null ? 0 : data.HOrgID;
                            HOrgIDBar = data.HSTOCKORGID == null ? 0 : data.HSTOCKORGID;
                            //子表  èµ‹å€¼
                            var rowdata = [];
@@ -1573,6 +1604,7 @@
                                        , "计量单位": result.data[i].计量单位
                                        , "HQtyMust": dealDoubleToFixed(result.data[i].应发数量, 1)
                                        , "HQty": dealDoubleToFixed(result.data[i].数量, 1)
                                        , "HPieceQty": dealDoubleToFixed(result.data[i].件数, 1)
                                        , "HPrice": dealDoubleToFixed(result.data[i].单价, 3)
                                        , "HTaxPrice": dealDoubleToFixed(result.data[i].含税单价, 3)
                                        , "HTaxRate": result.data[i].税率
@@ -1704,6 +1736,7 @@
                            , "计量单位": dataArray[i].计量单位
                            , "HQtyMust": dealDoubleToFixed(dataArray[i].数量, 1)
                            , "HQty": dealDoubleToFixed(dataArray[i].数量, 1)
                            , "HPieceQty": "0"
                            , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                            , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                            , "HTaxRate": dataArray[i].税率
@@ -2263,6 +2296,9 @@
                            dataCol = data1.data[0].HGridString.split(',');
                            for (var i = 0; i < option.cols[0].length - 2; i++) {
                                if (i > dataCol.length - 1) {
                                    return;
                                }
                                var dataCols = dataCol[i].split('|');
                                //隐藏列
                                if (dataCols[1] == 1) {
@@ -2346,6 +2382,12 @@
                            layer.msg("下推失败!单据号【" + temp.单据号 + "】单据状态不为已审核状态!");
                            return;
                        }
                        if (temp.行状态 == "已关闭") {
                            layer.msg("下推失败!单据号【" + temp.单据号 + "】下选中的记录中存在已关闭状态的记录!");
                            return;
                        }
                        if (temp.客户 != HCusName) {
                            layer.msg("下推失败!已经选中的记录中存在不同客户!");
                            return;
@@ -2394,6 +2436,7 @@
                            , "计量单位": dataArray[i].计量单位
                            , "HQtyMust": dealDoubleToFixed(dataArray[i].数量, 1)
                            , "HQty": dealDoubleToFixed(dataArray[i].数量, 1)
                            , "HPieceQty": "0"
                            , "HPrice": dealDoubleToFixed(dataArray[i].单价, 3)
                            , "HTaxPrice": dealDoubleToFixed(dataArray[i].含税单价, 3)
                            , "HTaxRate": dataArray[i].税率
@@ -2479,6 +2522,53 @@
            }
            //#endregion
            //#region æ‰“印
            function get_PrintReport() {
                //#region åˆ¤æ–­æºå•状态
                var HSourceBillData = "";
                var HSourceBillData = getSourceBillStatus_SellOutBill();            //获取源单数据
                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() + "/Kf_SellOutBill/CheckSellOutBill_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=Kf_SellOutBillList', 'yes']
                                , resize: false
                            })
                        } else {
                            layer.alert(result.code + result.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //#endregion
            //#region æ ¹æ®ä¸»å†…码与子内码获取源单销售订单数据
            function getPushSourceBillInit(HSourceInterID, HSourceEntryID) {
                var res = "none";
@@ -2505,6 +2595,50 @@
                return res;
            }
            //#endregion
            //#region èŽ·å–é”€å”®å‡ºåº“å•å•æ®çŠ¶æ€
            function getSourceBillStatus_SellOutBill() {
                var HSourceBillData = "none";
                var sWhere = " and hmainid = " + $("#HInterID").val();
                $.ajax({
                    url: GetWEBURL() + '/Kf_SellOutBill/GetSellOutBillList',
                    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 èŽ·å–é”€å”®å‡ºåº“å•å¯¹åº”çš„æ¡ç æ˜Žç»†
            function getBarCodeNoteBySellOutBill() {
                $.ajax({
                    url: GetWEBURL() + '/Kf_SellOutBill/BarCodeNote',
                    async: false,
                    type: "GET",
                    data: { "HInterID": linterid },
                    success: function (data1) {
                        if (data1.count == 1) {
                            if (data1.data[2].length > 0) {
                                layer.alert("当前单据由扫码生成,不可以编辑!", { icon: 5 });
                                $('#set_SaveBill').addClass("layui-btn-disabled").attr("disabled", true);
                            }
                        } else {}
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //#endregion
            //#endregion