王 垚
2022-03-10 0a5f8549460f47342b670fe7137e2eb1469bc706
WebTM/views/²Ö´æ¹ÜÀí/ÌõÂëÉú³É/Gy_BarCodeBill.html
@@ -2,7 +2,7 @@
<html>
<head>
    <meta charset="utf-8" />
    <title>新增/编辑器具采购入库单</title>
    <title>条码生成</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
@@ -13,6 +13,7 @@
    <script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
    <script src="../../../layuiadmin/Scripts/webConfig.js"></script>
    <script src="../../../layuiadmin/PubCustom.js"></script>
    <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <style type="text/css">
        /*begin æ­¤æ ·å¼ç”¨äºŽæ¶ˆé™¤è¡Œå…ƒç´ ä¸­å¸ƒå±€å®½åº¦ä¸å¤Ÿçš„问题*/
@@ -22,7 +23,13 @@
            margin-right: 0px;
        }
        /*end*/
        .layui-table-cell .layui-form-checkbox[lay-skin="primary"] {
            margin-left: 35%;
        }
        .layui-input-block {
            margin-left: 0px;
        }
    </style>
</head>
<body>
@@ -32,17 +39,15 @@
                <div class="layui-card">
                    <form id="form0" class="layui-form" lay-filter="component-form-group" action="">
                        <div class="layui-card-header">
                            <div class="layui-btn-group">
                                <button type="button" id="copy-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Copy">复制</button>
                                <button type="button" id="addnew-btn" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="Add">新增</button>
                                <button type="button" id="add-btn" 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="Exit">退出</button>
                                <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="planview">预览</button>
                                <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit="" lay-filter="print">打印</button>
                            <div class="layui-input-block">
                                <button type="button" class="layui-btn" id="ToolPrint" lay-submit="" lay-filter="ToolPrint">预览打印</button>
                                <button type="button" class="layui-btn" id="ToolCreate" lay-submit="" lay-filter="ToolCreate">生成</button>
                                <button type="button" class="layui-btn" id="ToolReset" lay-submit="" lay-filter="ToolReset">重置</button>
                                <button type="button" class="layui-btn" id="ToolStock" lay-submit="" lay-filter="ToolStock">库存</button>
                                <button type="button" class="layui-btn" id="ToolSynch" lay-submit="" lay-filter="ToolSynch">同步资料</button>
                                <button type="button" class="layui-btn" id="ToolBatch" lay-submit="" lay-filter="ToolBatch">批次</button>
                                <button type="button" class="layui-btn" id="ToolExit" lay-submit="" lay-filter="ToolExit">退出</button>
                            </div>
                        </div>
                        <div class="layui-card-body">
@@ -55,9 +60,6 @@
                                                <label class="layui-form-label">组织</label>
                                                <div class="layui-input-inline">
                                                    <select name="HOrgID" id="HOrgID" lay-filter="HOrgID" class="layui-input" value="" style="float:left;width:150px">
                                                        <option value="1">供应商</option>
                                                        <option value="2">客户</option>
                                                        <option value="3">车间部门</option>
                                                    </select>
                                                </div>
                                            </div>
@@ -65,9 +67,6 @@
                                                <label class="layui-form-label">工厂代码</label>
                                                <div class="layui-input-inline">
                                                    <select name="HWorksNumber" id="HWorksNumber" lay-filter="HWorksNumber" class="layui-input" value="" style="float:left;width:150px">
                                                        <option value="1">供应商</option>
                                                        <option value="2">客户</option>
                                                        <option value="3">车间部门</option>
                                                    </select>
                                                </div>
                                            </div>
@@ -83,9 +82,17 @@
                                                <label class="layui-form-label">源单类型</label>
                                                <div class="layui-input-inline">
                                                    <select name="HSourceBillType" id="HSourceBillType" lay-filter="HSourceBillType" class="layui-input" value="" style="float:left;width:150px">
                                                        <option value="1">供应商</option>
                                                        <option value="2">客户</option>
                                                        <option value="3">车间部门</option>
                                                        <option value="1">生产订单</option>
                                                        <option value="2">生产汇报单</option>
                                                        <option value="3">采购订单</option>
                                                        <option value="4">收料通知单</option>
                                                        <option value="5">委外订单</option>
                                                        <option value="6">退货通知单</option>
                                                        <option value="7">其他入库单</option>
                                                        <option value="8">直接调拨单</option>
                                                        <option value="9">采购退料单</option>
                                                        <option value="10">生产退料单</option>
                                                        <option value="11">组装拆卸单</option>
                                                    </select>
                                                </div>
                                            </div>
@@ -93,8 +100,7 @@
                                                <label class="layui-form-label">选单号<label style="color:red"> * </label></label>
                                                <div class="layui-input-inline">
                                                    <input type="text" name="HSourceBillNo" id="HSourceBillNo" readonly class="layui-input" value="" style="float:left;width:150px;">
                                                    <input type="hidden" name="HKeeperID" id="HKeeperID" class="layui-input" value="" style="float:left;width:150px;">
                                                    <button type="button" lay-submit="" class="layui-btn" lay-filter="HKeeperList" style="width:40px;">
                                                    <button type="button" lay-submit="" class="layui-btn" lay-filter="HSourceBillNoList" style="width:40px;">
                                                        <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                    </button>
                                                </div>
@@ -103,9 +109,6 @@
                                                <label class="layui-form-label">条码类型</label>
                                                <div class="layui-input-inline">
                                                    <select name="HBarCodeType" id="HBarCodeType" lay-filter="HBarCodeType" class="layui-input" value="" style="float:left;width:150px">
                                                        <option value="1">供应商</option>
                                                        <option value="2">客户</option>
                                                        <option value="3">车间部门</option>
                                                    </select>
                                                </div>
                                            </div>
@@ -116,10 +119,11 @@
                            </div>
                        </div>
                        <div class="layui-tab layui-tab-card" lay-filter="TabTest">
                        <div class="layui-tab layui-tab-card" lay-filter="tab-TabTest">
                            <ul class="layui-tab-title">
                                <li class="layui-this">物料信息</li>
                                <li>条码信息</li>
                                <li lay-id="1" class="layui-this">物料信息</li>
                                <li lay-id="2">条码信息</li>
                                <li lay-id="3">档案列表</li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
@@ -127,6 +131,9 @@
                                </div>
                                <div class="layui-tab-item">
                                    <table class="layui-hide" id="mainTable1" lay-filter="mainTable1"></table>
                                </div>
                                <div class="layui-tab-item">
                                    <table class="layui-hide" id="mainTable2" lay-filter="mainTable2"></table>
                                </div>
                            </div>
                        </div>
@@ -141,6 +148,14 @@
                        </script>
                        <script type="text/html" id="xuhao">
                            {{d.LAY_TABLE_INDEX+1}}
                        </script>
                        <script type="text/html" id="switchTpl">
                            <!-- è¿™é‡Œçš„ checked çš„状态只是演示 -->
                            <input type="checkbox" name="checkbox" value="{{d.HGiveAwayFlag}}" lay-skin="primary" lay-filter="HGiveAwayFlag" {{ d.HGiveAwayFlag == 1 ? 'checked' : '' }}>
                        </script>
                        <script type="text/html" id="switchTp2">
                            <!-- è¿™é‡Œçš„ checked çš„状态只是演示 -->
                            <input type="checkbox" name="checkbox" lay-skin="primary" lay-filter="HGiveAwayFlag1">
                        </script>
                    </form>
                </div>
@@ -182,21 +197,31 @@
            //查询条件
            var option = [];
            var option1 = [];
            var option2 = [];
            var sWhere = "";
            var sBillType = "3801";
            //#endregion
            //#region è¿›å…¥é¡µé¢æ—¢åŠ è½½
            //初始化表单插件
            set_InitFrom();
            //加载组织数据
            set_HOrg();
            //加载工厂代码数据
            set_HWorksNumber();
            //加载条码类型数据
            set_HBarCodeType();
            //初始化表格
            set_InitGrid();
            set_CountGrid();
            set_InitGrid2();
            //判断操作类型
            if (OperationType == 1) {//无源新增
                //初始基本信息赋值
                $("#HDate").val(Format(new Date(), "yyyy-MM-dd hh:mm:ss"));      //单据日期
                set_AddFNew();
                set_AddFNew1();
                set_AddFNew2();
            }
            else if (OperationType == 3) {//编辑
                set_EditFromGrid(linterid);
@@ -212,7 +237,7 @@
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;;
                var AddRow = table.cache['mainTable'];
                var NewRow = { "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HBatchNo": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "", "HDesignLife": 0, "HLeaveLife": 0, "HUseLife": 0, "HQtyMust": 0, "HQty": 0, "HPrice": 0, "HMoney": 0, "HWHID": 0, "HWHCode": "", "HWHName": "", "HSPID": 0, "HSPCode": "", "HSPName": "", "HStockOrgID": sessionStorage["OrganizationID"], "HRemark": "" };
                var NewRow = { "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HBatchNo": "", "HUnitID": 0, "HUnitNumber": "", "HUnitName": "", "HDesignLife": 0, "HLeaveLife": 0, "HUseLife": 0, "HQtyMust": 0, "HQty": 0, "HPrice": 0, "HMoney": 0, "HWHID": 0, "HWHCode": "", "HWHName": "", "HSPID": 0, "HSPCode": "", "HSPName": "", "HStockOrgID": sessionStorage["OrganizationID"], "HRemark": "" };
                console.log(NewRow);
                switch (obj.event) {
                    //新增一行
@@ -228,57 +253,156 @@
                set_GridDelete(obj);   //行内删除
                set_GridCellCheck(obj); //行内快捷键筛选
            });
            //监听单元格编辑  å•元格编辑后 å˜æ›´
            table.on('edit(mainTable)', function (obj) {
                // å•元格编辑之前的值
                var oldText = $(this).prev().text();
                var value = obj.value //得到修改后的值
                    , data = obj.data //得到所在行所有键值
                    , field = obj.field; //得到字段
                //layer.msg('[ID: ' + data.id + '] ' + field + ' å­—段更改为:' + value);
                switch (field) {
                    case "HQty":  //数量
                        value = isNaN(value) ? 0 : value;
                        var HMinQty = isNaN(data.HMinQty) ? 0 : data.HMinQty;
                        if (HMinQty == 0) {
                            //同步更新表格和缓存对应的值
                            obj.update({
                                HQty: value,                                   //数量
                                HBQty: 0,                                      //箱数=数量/最小包装数量
                            });
                        }
                        else
                        {
                            //同步更新表格和缓存对应的值
                            obj.update({
                                HQty: value,                                   //数量
                                HBQty: Math.ceil(value / HMinQty),             //箱数=数量/最小包装数量
                            });
                        }
                        break;
                    case "HMinQty":  //最小包装数量
                        value = isNaN(value) ? 0 : value;
                        var HQty = isNaN(data.HQty) ? 0 : data.HQty;
                        if (HQty == 0) //除数为0
                        {
                            //同步更新表格和缓存对应的值
                            obj.update({
                                HMinQty: value,                                //最小包装数量
                                HBQty: 0,                                      //箱数=数量/最小包装数量
                            });
                        }
                        else {
                            //同步更新表格和缓存对应的值
                            obj.update({
                                HMinQty: value,                                //最小包装数量
                                HBQty: Math.ceil(HQty / value),                //箱数=数量/最小包装数量
                            });
                        }
                        break;
                    default:
                }
            });
            //下拉框事件选择触发
            form.on('select(HSupTypeID)', function (data) {
                $("#HSupID").val("");
                $("#HSupName").val("");
            form.on('select(HSourceBillType)', function (data) {
                $("#HSourceBillNo").val("");
            });
            function getSupType() {
                var type = $("#HSupTypeID").val();
                console.log(type)
                var type = $("#HSourceBillType").val();
                switch (type) {
                    case '1':
                        return "SupplierInformation";
                        return "生产订单";
                        break;
                    case '2':
                        return "CustomerInformation";
                        return "生产汇报单";
                        break;
                    case '3':
                        return "DeptInformation";
                        return "采购订单";
                        break;
                    case '4':
                        return "收料通知单";
                        break;
                    case '5':
                        return "委外订单";
                        break;
                }
            }
            //表头信息往来单位弹窗
            form.on('submit(HSupList)', function () {
                debugger;
                if ($("#HSupTypeID").val() == 0 || $("#HSupTypeID").val() == null) {
                    return layer.msg('请选择往来类型');
            //表头信息源单信息弹窗
            form.on('submit(HSourceBillNoList)', function () {
                if ($("#HSourceBillType").val() == 0 || $("#HSourceBillType").val() == null) {
                    return layer.msg('请选择单据类型');
                }
                //获取组织ID
                var SetHOrgID = $("#HOrgID").find("option:selected").val();
                //页面层-自定义
                var url = '../../PublicPage/' + getSupType() + '.html';
                var url = '../../PublicPage/HSourceReportHtml.html?OperationType=3&linterid=' + SetHOrgID + '&HSouceBillType=' + getSupType() + '';
                url = encodeURI(url);
                //alert(url);
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '往来单位列表',
                    title: '' + getSupType() + '列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    area: ['95%', '80%'],
                    maxmin: true,
                    content: [url, 'yes'],
                    btn: ['确定', '取消']
                    , btn1: function (index, layero) {
                        //按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                        var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                        var checkStatus = iframeWindow.layui.table.checkStatus('layTable');//获取table的elem:"#test"
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                            return layer.msg('请选择单据数据');
                        }
                        $("#HSupName").val(checkStatus.data[0].HName);
                        $("#HSupID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                        var list = [];
                        var BillSelect = [];
                        for (var i = 0; i < checkStatus.data.length; i++) {
                            if (checkStatus.data[i].部门 != "" && checkStatus.data[i].部门 != null) {
                                list.push(checkStatus.data[i].部门)
                            }
                            BillSelect.push({ BillType: checkStatus.data[i].HBillType, BillTitle: getSupType(), BillNo: checkStatus.data[i].单据号, "BillMainID": checkStatus.data[i].HMainID, "BillSubID": checkStatus.data[i].HSubID, "SPID": 0, "BatchNo": "", "HAuxPropID": 0 });
                        }
                        if (isAllEqual(list))  //不允许选择不同部门
                        {
                            //获取选中数据
                            var GrdSelectData = JSON.stringify(BillSelect);
                            //获取选择的源单类型
                            var HSourceBillType = $("#HSourceBillType").find("option:selected").html();
                            //获取选择的条码类型
                            var HBarCodeType = $("#HBarCodeType").find("option:selected").html();
                            //获取当前登录人员
                            var UserName = sessionStorage["HUserName"];
                            var Str = GrdSelectData + ";" + HSourceBillType + ";" + HBarCodeType + ";" + UserName;
                            //通过选择的源单主子内码查找详细信息
                            $.ajax({
                                type: "post",
                                url: GetWEBURL() + "/Sc_BarCode/SelectReportFromBillList",
                                //contentType: 'application/json',
                                async: true,
                                dataType: "json",
                                data: { "msg": Str },
                                //traditional: true,
                                success: function (result) {
                                    if (result.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                                        table.reload('mainTable', {
                                            data: result.list // è°ƒç”¨table.reload é‡æ–°æ¸²æŸ“显示加载追加了数据的表格
                                        });
                                        //关闭当前frame
                                        layer.close(index);
                                    }
                                }
                            })
                        }
                        else {
                            layer.msg("不允许选择不同的部门数据!", { time: 1 * 2000, icon: 5 });
                        }
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
@@ -292,7 +416,61 @@
                    }
                });
            });
            function isAllEqual(array) {
                if (array.length > 0) {
                    return !array.some(function (value, index) {
                        return value !== array[0];
                    });
                } else {
                    return true;
                }
            }
            //打印
            form.on('submit(ToolPrint)', function (data) {
                get_PrintReport();
            })
            //条码生成
            form.on('submit(ToolCreate)', function (data) {
                var sSubStr = JSON.stringify(table.cache['mainTable']);
                //物料明细信息不为空判断
                if (!AllowLoadData(sSubStr))//数据验证
                {
                    return false;
                }
                //获取选择的组织
                var HOrgType = $("#HOrgID").find("option:selected").html();
                //获取选择的工厂代码
                var CampanyName = $("#HWorksNumber").find("option:selected").html();
                if (CampanyName == "" || CampanyName == null)
                {
                    CampanyName = "xxx";
                }
                //获取选择的源单类型
                var HSourceBillType = $("#HSourceBillType").find("option:selected").html();
                //获取选择的条码类型
                var HSelectBarCodeType = $("#HBarCodeType").find("option:selected").html();
                //获取当前登录人员
                //var UserName = sessionStorage["HUserName"];
                var UserName = "Admin";
                var sMainSub = sSubStr + ';' + HOrgType + ';' + HSourceBillType + ';' + HSelectBarCodeType + ';' + CampanyName + ';' + UserName;
                SaveBarCodeCreate(sMainSub);
            })
            //退出
            form.on('submit(ToolExit)', function (data) {
                if (linterid == undefined) {
                    //关闭页签
                    Pub_Close(2);
                }
                else {
                    //关闭页签
                    Pub_Close(1);
                }
            });
            //#endregion
            //#region æ­¤é¡µé¢æ‰€æœ‰æ–¹æ³•
@@ -302,34 +480,104 @@
                    elem: '#HDate'
                });
            }
            //初始化明细表格
            //获取组织
            function set_HOrg() {
                //获取登录页组织列
                var Organization = '';
                $.ajax({
                    type: "get",
                    url: GetWEBURL() + "/Web/GetOrganizations",
                    success: function (result) {
                        if (result.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            var data = result.data;
                            for (var i = 0; i < data.length; i++) {
                                Organization += '<option  style="color:blue;" value="' + data[i].ID + '">' + data[i].Name + '</option>';
                            }
                            $("#HOrgID").append(Organization);
                            form.render('select');
                        }
                        $('#HOrgID').find("option[value=" + result.data[0].ID + "]").attr("selected", true);
                        form.render('select') //再次渲染
                        layer.closeAll("loading");
                    }
                })
            }
            //获取工厂代码
            function set_HWorksNumber() {
                //获取工厂代码
                var Organization = '';
                $.ajax({
                    type: "get",
                    url: GetWEBURL() + "/Sc_BarCode/GetHWorksNumberBill",
                    success: function (result) {
                        if (result.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            var data = result.list;
                            for (var i = 0; i < data.length; i++) {
                                Organization += '<option  style="color:blue;" value="' + i + '">' + data[i] + '</option>';
                            }
                            $("#HWorksNumber").append(Organization);
                            form.render('select');
                            if (result.list[0] != "" && result.list[0] != null) {
                                $('#HWorksNumber').find("option[value=" + result.list[0] + "]").attr("selected", true);
                                form.render('select') //再次渲染
                            }
                        }
                        layer.closeAll("loading");
                    }
                })
            }
            //获取条码类型
            function set_HBarCodeType() {
                //获取条码类型代码
                var Organization = '';
                $.ajax({
                    type: "get",
                    url: GetWEBURL() + "/Sc_BarCode/GetHBarCodeTypeBill",
                    success: function (result) {
                        if (result.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            var data = result.list;
                            for (var i = 0; i < data.length; i++) {
                                Organization += '<option  style="color:blue;" value="' + i + '">' + data[i] + '</option>';
                            }
                            $("#HBarCodeType").append(Organization);
                            form.render('select');
                        }
                        $('#HBarCodeType').find("option[value=" + result.list[0] + "]").attr("selected", true);
                        form.render('select') //再次渲染
                        layer.closeAll("loading");
                    }
                })
            }
            //初始化物料信息表格
            function set_InitGrid() {
                columns = [
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao', title: '序号', sort: true, fixed: 'left', event: "qwe", width: 100 }
                    , { field: 'HSourceInterID', title: '源单主内码', edit: 'text', width: 100, hide: true }
                    , { field: 'HSourceEntryID', title: '源单子内码', edit: 'text', width: 100, hide: true }
                    , { field: 'HSourceBillNo', title: '源单单号', edit: 'text', event: 'HMaterCode', width: 100 }
                    , { field: 'HMaterID', title: '物料ID', edit: 'text', width: 100, hide: true }
                    , { field: 'HMaterNumber', title: '物料代码', edit: 'text', width: 100 }
                    , { field: 'HMaterName', title: '物料名称', edit: 'text', width: 100 }
                    , { field: 'HMaterModel', title: '规格型号', edit: 'text', width: 100 }
                    , { field: 'HAuxPropID', title: '辅助属性ID', edit: 'text', width: 100, hide: true }
                    , { field: 'HAuxPropNumber', title: '辅助属性代码', edit: 'text', event: 'HUnitCode', width: 100 }
                    , { field: 'HAuxPropName', title: '辅助属性名称', edit: 'text', width: 100 }
                    , { field: 'HUnitID', title: '计量单位ID', edit: 'text', width: 100, hide: true }
                    , { field: 'HUnitCode', title: '计量单位代码', edit: 'text', event: 'HUnitCode', width: 100 }
                    , { field: 'HUnitName', title: '计量单位', edit: 'text', width: 100 }
                    , { field: 'HMainID', title: '源单主内码',  width: 100, hide: true }
                    , { field: 'HSubID', title: '源单子内码',  width: 100, hide: true }
                    , { field: 'HBillNo', title: '源单单号', width: 200 }
                    , { field: 'HMaterID', title: '物料ID',  width: 100, hide: true }
                    , { field: 'HMaterNumber', title: '物料代码', edit: 'text', event: 'HMaterNumber', width: 200 }
                    , { field: 'HMaterName', title: '物料名称',  width: 200 }
                    , { field: 'HMaterModel', title: '规格型号', width: 200 }
                    , { field: 'HAuxPropID', title: '辅助属性ID',  width: 100, hide: true }
                    , { field: 'HAuxPropNumber', title: '辅助属性代码', edit: 'text', event: 'HAuxPropNumber', width: 100 }
                    , { field: 'HAuxPropName', title: '辅助属性名称',  width: 100 }
                    , { field: 'HUnitID', title: '计量单位ID', width: 100, hide: true }
                    , { field: 'HUnitNumber', title: '计量单位代码', edit: 'text', event: 'HUnitNumber', width: 100 }
                    , { field: 'HUnitName', title: '计量单位',width: 100 }
                    , { field: 'HBatchNo', title: '批号', edit: 'text', width: 100 }
                    , { field: 'HGiveAwayFlag', title: '是否赠品', edit: 'text', width: 100 }
                    , { field: 'HGiveAwayFlag', title: '是否赠品', width: 100, templet: '#switchTpl', unresize: false }
                    , { field: 'HQty', title: '数量', edit: 'text', width: 100 }
                    , { field: 'HMinQty', title: '最小包装数', edit: 'text', width: 100 }
                    , { field: 'HBQty', title: '箱数', edit: 'text', width: 100 }
                    , { field: 'HBQty', title: '箱数', width: 100 }
                    , { field: 'HPackQty', title: '外箱数', edit: 'text', width: 100 }
                    , { field: 'HDate', title: '进料日期', edit: 'text', width: 100 }
                    , { field: 'HCusID', title: '客户ID', edit: 'text', width: 100, hide: true }
                    , { field: 'HCusNumber', title: '客户代码', edit: 'text', event: 'HWHCode', width: 120 }
                    , { field: 'HCusName', title: '客户名称', edit: 'text', width: 120 }
                    , { field: 'HDate', title: '进料日期',  width: 100 }
                    , { field: 'HCusID', title: '客户ID',  width: 100, hide: true }
                    , { field: 'HCusNumber', title: '客户代码', edit: 'text', event: 'HCusNumber', width: 120 }
                    , { field: 'HCusName', title: '客户名称', width: 120 }
                    , { field: 'HSeOrderBillNo', title: '销售订单号', width: 200 }
                    , { field: 'HRemark', title: '备注', edit: 'text', width: 100 }
                    , { fixed: 'right', title: '操作', toolbar: '#barDemo' }
@@ -347,28 +595,38 @@
                    }
                };
            }
            //初始汇总信息
            //初始条码信息表格
            function set_CountGrid() {
                //表头
                columns = [
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao', title: '序号', sort: true, fixed: 'left', event: "qwe", width: 100 }
                    , { field: '物料代码', title: '物料代码', edit: 'text', event: 'HMaterCode', width: 100 }
                    , { field: '物料名称', title: '物料名称', edit: 'text', width: 100 }
                    , { field: '规格型号', title: '规格型号', edit: 'text', width: 100 }
                    , { field: '单据号', title: '单据号', edit: 'text', width: 100 }
                    , { field: '批次', title: '批次', edit: 'text', width: 100 }
                    , { field: '实收数量', title: '实收数量', edit: 'text', width: 100 }
                    , { field: 'hwhid1', title: 'HWHID', edit: 'text', width: 100, hide: true }
                    , { field: '收料仓库代码', title: '收料仓库代码', edit: 'text', event: 'HWHCode', width: 120 }
                    , { field: '收料仓库', title: '收料仓库名称', edit: 'text', width: 120 }
                    , { field: '表体备注', title: '备注', edit: 'text', width: 100 }
                    , { field: 'HBarCode2', title: '条码编号', width: 100 }
                    , { field: 'HMaterNumber2', title: '物料代码', width: 100 }
                    , { field: 'HMaterName2', title: '物料名称', width: 100 }
                    , { field: 'HMaterModel2', title: '规格型号', width: 100 }
                    , { field: 'HAuxPropNumber2', title: '辅助属性代码', width: 100 }
                    , { field: 'HAuxPropName2', title: '辅助属性', event: 'HWHCode', width: 120 }
                    , { field: 'HGiveAwayFlag2', title: '是否赠品', width: 120, templet: '#switchTpl', unresize: false }
                    , { field: 'HUnitCode2', title: '计量单位代码', width: 120 }
                    , { field: 'HUnitName2', title: '计量单位', width: 120 }
                    , { field: 'HQty2', title: '数量', width: 120 }
                    , { field: 'HDate2', title: '进料日期', width: 120 }
                    , { field: 'HCusNumber2', title: '客户代码', width: 120 }
                    , { field: 'HCusName2', title: '客户', width: 120 }
                    , { field: 'HSourceBillNo2', title: '源单单号', width: 120 }
                    , { field: 'HSeOrderBillNo2', title: '销售订单号', width: 120 }
                    , { field: 'HRemark2', title: '备注', width: 120 }
                    , { field: 'HMTONo2', title: '计划跟踪号', width: 120 }
                    , { field: 'HShowDate2', title: '日期', width: 100 }
                    , { field: 'HInnerBillNo2', title: '内部采购订单号', width: 100 }
                    , { field: 'HMaker2', title: '制单人', width: 100 }
                ];
                option1 = {
                    id: 'mainTable1'
                    , elem: '#mainTable1'
                    , height: 500
                    , page: true
                    , page: false
                    , limit: 500
                    , cellMinWidth: 120
                    , height: 650
@@ -377,16 +635,99 @@
                    }
                };
            }
            //初始化档案列表信息表格
            function set_InitGrid2() {
                //表头
                columns = [
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao', title: '序号', sort: true, fixed: 'left', event: "qwe", width: 100 }
                    , { field: 'HItemID', title: 'HItemID', width: 100, hide: true }
                    , { field: 'hmainid', title: 'hmainid', width: 100, hide: true }
                    , { field: 'hsubid', title: 'hsubid', width: 100, hide: true }
                    , { field: 'HinterID', title: 'HinterID', width: 100, hide: true }
                    , { field: '条码类型', title: '条码类型', width: 100 }
                    , { field: '条码编号', title: '条码编号', width: 120 }
                    , { field: 'HMaterID', title: '物料ID', width: 100, hide: true }
                    , { field: '物料代码', title: '物料代码', width: 120 }
                    , { field: '物料名称', title: '物料名称', width: 120 }
                    , { field: '规格型号', title: '规格型号', width: 120 }
                    , { field: 'HUnitID', title: '计量单位ID', width: 100, hide: true }
                    , { field: '计量单位代码', title: '计量单位代码', width: 120 }
                    , { field: '计量单位', title: '计量单位', width: 120 }
                    , { field: 'HAuxPropID', title: '辅助属性ID', width: 100, hide: true }
                    , { field: '辅助属性代码', title: '辅助属性代码', width: 120 }
                    , { field: '辅助属性', title: '辅助属性', width: 120 }
                    , { field: '批号', title: '批号', width: 120 }
                    , { field: '数量', title: '数量', width: 100 }
                    , { field: '源单单号', title: '源单单号', width: 120 }
                    , { field: '计划跟踪号', title: '计划跟踪号', width: 120 }
                    , { field: '是否赠品', title: '是否赠品', width: 100 }
                    , { field: 'DeptID', title: '车间ID', width: 100, hide: true }
                    , { field: '车间', title: '车间', width: 120 }
                    , { field: 'HSupID', title: '供应商ID', width: 100, hide: true }
                    , { field: '供应商代码', title: '供应商代码', width: 120 }
                    , { field: '供应商', title: '供应商', width: 120 }
                    , { field: '客户条码编号', title: '客户条码编号', width: 120 }
                    , { field: '客户型号', title: '客户型号', width: 120 }
                    , { field: '往来单位', title: '往来单位', width: 120 }
                    , { field: '销售订单号', title: '销售订单号', width: 120 }
                    , { field: '销售订单行号', title: '销售订单行号', width: 120 }
                    , { field: '托号', title: '托号', width: 120 }
                    , { field: '总托数', title: '总托数', width: 100 }
                    , { field: '条码日期', title: '条码日期', width: 120 }
                    , { field: '生产入库日期', title: '生产入库日期', width: 120 }
                    , { field: '生产入库单号', title: '生产入库单号', width: 120 }
                    , { field: '生产入库次数', title: '生产入库次数', width: 100 }
                    , { field: '销售出库日期', title: '销售出库日期', width: 120 }
                    , { field: '销售出库单号', title: '销售出库单号', width: 120 }
                    , { field: '销售出库次数', title: '销售出库次数', width: 100 }
                    , { field: '作废标记', title: '作废标记', width: 100 }
                    , { field: '作废人', title: '作废人', width: 100 }
                    , { field: '备注', title: '备注', width: 120 }
                    , { field: '制作人', title: '制作人', width: 100 }
                    , { field: '日期', title: '日期', width: 120 }
                    , { field: '计划完工日期', title: '计划完工日期', width: 120 }
                    , { field: '打印次数', title: '打印次数', width: 100 }
                    , { field: 'HSTOCKORGID', title: 'HSTOCKORGID', width: 100, hide: true }
                    , { field: '生成组织', title: '生成组织', width: 120 }
                ];
                option2 = {
                    id: 'mainTable2'
                    , elem: '#mainTable2'
                    , height: 500
                    , page: false
                    , limit: 500
                    , cellMinWidth: 120
                    , height: 650
                    , cols: [columns]
                    , done: function (res, curr, count) {
                    }
                };
            }
            //无源单新增
            function set_AddFNew() {
                option.data = [{ "HSourceInterID": 0, "HSourceEntryID": 0,"HSourceBillNo":"", "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HBatchNo": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "", "HDesignLife": 0, "HLeaveLife": 0, "HUseLife": 0, "HQtyMust": 0, "HQty": 0, "HPrice": 0, "HMoney": 0, "HWHID": 0, "HWHCode": "", "HWHName": "", "HSPID": 0, "HSPCode": "", "HSPName": "", "HStockOrgID": sessionStorage["OrganizationID"], "HRemark": "" }];
                option.data = [{
                    "HMainID": 0, "HSubID": 0, "HBillNo": "", "HMaterID": 0, "HMaterNumber": "", "HMaterName": "", "HMaterModel": ""
                    , "HAuxPropID": 0, "HAuxPropNumber": "", "HAuxPropName": "", "HUnitID": 0, "HUnitNumber": "", "HUnitName": "", "HBatchNo": "", "HGiveAwayFlag": 0
                    , "HQty": 0, "HMinQty": 0, "HBQty": 0, "HPackQty": 0, "HDate": "", "HCusID": 0, "HCusNumber": "", "HCusName": "", "HSeOrderBillNo": "", "HRemark": ""
                }];
                table.render(option);
            }
            function set_AddFNew1() {
                option1.data = [{ "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HBatchNo": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "", "HDesignLife": 0, "HLeaveLife": 0, "HUseLife": 0, "HQtyMust": 0, "HQty": 0, "HPrice": 0, "HMoney": 0, "HWHID": 0, "HWHCode": "", "HWHName": "", "HSPID": 0, "HSPCode": "", "HSPName": "", "HStockOrgID": sessionStorage["OrganizationID"], "HRemark": "" }];
                option1.data = [{
                    "HBarCode": "", "HMaterNumber": "", "HMaterName": "", "HMaterModel": "", "HAuxPropNumber": "", "HAuxPropName": ""
                    , "HGiveAwayFlag": "", "HUnitCode": "", "HUnitName": "", "HQty": 0, "HDate": "", "HCusNumber": "", "HCusName": ""
                    , "HSourceBillNo": "", "HSeOrderBillNo": "", "HRemark": "", "HMTONo": "", "HShowDate": "", "HInnerBillNo": "", "HMaker": ""
                }];
                table.render(option1);
            }
            function set_AddFNew2() {
                option2.data = [];
                table.render(option2);
            }
            //日期格式化
            function formatDate(date) {
                var d = new Date(date),
@@ -459,18 +800,18 @@
                $(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {
                    if (event.key == "F7") {
                        //模具信息  å¦‚果在模具代码列 æŒ‰F7
                        if (obj.event === 'HMaterCode')  //模具信息  å¦‚果在模具代码列 æŒ‰F7
                        if (obj.event === 'HMaterNumber')  //模具信息  å¦‚果在模具代码列 æŒ‰F7
                        {
                            //页面层-自定义  //F7选择模具
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '器具列表',
                                title: '物料列表',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../../PublicPage/MouldInformation.html', 'yes'],
                                content: ['../../PublicPage/PartInformation.html', 'yes'],
                                btn: ['确定', '取消']
                                , btn1: function (index, layero) {
@@ -484,14 +825,9 @@
                                    //同步更新表格和缓存对应的值
                                    obj.update({
                                        HMaterID: checkStatus.data[0].HItemID,
                                        HMaterCode: checkStatus.data[0].HNumber,
                                        HMaterNumber: checkStatus.data[0].HNumber,
                                        HMaterName: checkStatus.data[0].HName,
                                        HMaterSpec: checkStatus.data[0].HModel,
                                        HDesignLife: 0,  //设计寿命
                                        HLeaveLife: 0,   //剩余寿命
                                        HQty: 1,         //实收数量
                                        HMoney: 0,       //金额
                                        HMaterModel: checkStatus.data[0].HModel
                                    });
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
@@ -506,7 +842,7 @@
                            });
                        }
                        //辅助属性信息
                        if (obj.event === 'HPropertyCode')  //辅助属性信息
                        if (obj.event === 'HAuxPropNumber')  //辅助属性信息
                        {
                            //页面层-自定义
                            layer.open({
@@ -530,9 +866,9 @@
                                    //同步更新表格和缓存对应的值
                                    obj.update({
                                        HPropertyID: checkStatus.data[0].HItemID,
                                        HPropertyCode: checkStatus.data[0].HNumber,
                                        HPropertyName: checkStatus.data[0].HName,
                                        HAuxPropID: checkStatus.data[0].HItemID,
                                        HAuxPropNumber: checkStatus.data[0].HNumber,
                                        HAuxPropName: checkStatus.data[0].HName,
                                    });
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
@@ -548,7 +884,7 @@
                        }
                        //计量单位代码
                        if (obj.event === 'HUnitCode')  //计量单位代码
                        if (obj.event === 'HUnitNumber')  //计量单位代码
                        {
                            //页面层-自定义
                            layer.open({
@@ -573,7 +909,7 @@
                                    //同步更新表格和缓存对应的值
                                    obj.update({
                                        HUnitID: checkStatus.data[0].HItemID,
                                        HUnitCode: checkStatus.data[0].HNumber,
                                        HUnitNumber: checkStatus.data[0].HNumber,
                                        HUnitName: checkStatus.data[0].HName,
                                    });
@@ -588,19 +924,19 @@
                                }
                            });
                        }
                        //仓库代码
                        if (obj.event === 'HWHCode')  //仓库代码
                        //客户代码
                        if (obj.event === 'HCusNumber')  //客户代码
                        {
                            //页面层-自定义
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '仓库列表',
                                title: '客户列表',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../../PublicPage/WareHouseInformation.html', 'yes'],
                                content: ['../../PublicPage/CustomerInformation.html', 'yes'],
                                btn: ['确定', '取消']
                                , btn1: function (index, layero) {
@@ -613,60 +949,10 @@
                                    //同步更新表格和缓存对应的值
                                    obj.update({
                                        HWHID: checkStatus.data[0].HItemID,
                                        HWHCode: checkStatus.data[0].HNumber,
                                        HWHName: checkStatus.data[0].HName,
                                        HSPID: "",
                                        HSPCode: "",
                                        HSPName: "",
                                        HCusID: checkStatus.data[0].HItemID,
                                        HCusNumber: checkStatus.data[0].HNumber,
                                        HCusName: checkStatus.data[0].HName
                                    });
                                    ////表头仓库为空时 ç»‘定明细行仓库信息
                                    //if ($("#HWHID").val() == '' || $("#HWHID").val() == null) {
                                    //    $("#HWHName").val(checkStatus.data[0].HName);
                                    //    $("#HWHID").val(checkStatus.data[0].HItemID);
                                    //}
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                                },
                                end: function () {
                                }
                            });
                        }
                        //仓位代码
                        if (obj.event === 'HSPCode')  //仓位代码
                        {
                            //页面层-自定义
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '仓位列表',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../../PublicPage/WareLocationInformation.html', 'yes'],
                                btn: ['确定', '取消']
                                , btn1: function (index, layero) {
                                    //按钮【按钮一】的回调
                                    var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                                    var checkStatus = iframeWindow.layui.table.checkStatus('mainTable');//获取table的elem:"#test"
                                    if (checkStatus.data.length === 0) {
                                        return layer.msg('请选择数据');
                                    }
                                    //同步更新表格和缓存对应的值
                                    obj.update({
                                        HSPID: checkStatus.data[0].HItemID,
                                        HSPCode: checkStatus.data[0].HNumber,
                                        HSPName: checkStatus.data[0].HName,
                                    });
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
                                , btn2: function (index, layero) {
@@ -688,26 +974,68 @@
                layer.alert(sMsg, { icon: 5 });
            }
            //条码生成
            function SaveBarCodeCreate(sMainSub, CampanyName) {
                $.ajax(
                    {
                        type: "POST",
                        url: GetWEBURL() + "/Sc_BarCode/Sub_SaveBill", //方法所在页面和方法名
                        async: true,
                        data: { "msg": sMainSub, "CampanyName": CampanyName },
                        dataType: "json",
                        success: function (result) {
                            if (result.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                                table.reload('mainTable1', {
                                    data: result.list // è°ƒç”¨table.reload é‡æ–°æ¸²æŸ“显示加载追加了数据的表格
                                });
                                //生成成功跳转到条码信息标签页
                                element.tabChange('tab-TabTest', '2');
                                //加载档案列表
                                table.reload('mainTable2', {
                                    data: result.data // è°ƒç”¨table.reload é‡æ–°æ¸²æŸ“显示加载追加了数据的表格
                                });
                            }
                            else {
                                layer.alert(result.Message, { icon: 5 });
                            }
                            layer.closeAll("loading");
                        },
                        error: function (err) {
                            layer.alert(err.Message, { icon: 5 });
                        }
                    });
            }
            //条码打印
            function get_PrintReport() {
                var checkStatus = table.checkStatus('mainTable2')
                    , data = checkStatus.data;
                if (checkStatus.data.length>0) {
                    var rows = '';
                    for (var i = 0; i < data.length; i++) {
                        rows += data[i].HItemID.toString() + ',';
                    }
                    rows = rows.substring(rows.length - 1, 0);
                    layer.open({
                        type: 2
                        , area: ['50%', '50%']
                        , title: '打印模版选择'
                        , shade: 0.6 //遮罩透明度
                        , maxmin: false //允许全屏最小化
                        , anim: 0 //0-6的动画形式,-1不开启
                        , content: ['../../BaseSet/SRM_OpenTmpList.html?linterid=' + rows + '&MyMsg=' + rows + '&Type=HGy_BarCodeBill', 'yes']
                        , resize: false
                    })
                }
                else {
                    layer.msg('请选择要打印的条码数据!');
                }
            }
            //非空验证
            function AllowLoadData(sSubStr) {
                var Result = true;
                if ($("#HWHID").val() == '' || $("#HWHID").val() == null) {
                    layer.msg("仓库不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
                if ($("#HSecManagerID").val() == '' || $("#HSecManagerID").val() == null) {
                    layer.msg("验收员不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
                if ($("#HKeeperID").val() == '' || $("#HKeeperID").val() == null) {
                    layer.msg("保管员不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
                if ($("#HDeptID").val() == '' || $("#HDeptID").val() == null) {
                    layer.msg("部门不能为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
                }
                if (typeof (sSubStr) == "undefined" || sSubStr == "") {
                    layer.msg("没有物料明细记录", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return Result = false;
@@ -715,16 +1043,16 @@
                if (typeof (sSubStr) != "undefined" && typeof (sSubStr) != "") {
                    sSubStr = JSON.parse(sSubStr);
                    for (var i = 0; i < sSubStr.length; i++) {
                        if (sSubStr[i].HMainID == "") {
                            layer.msg("明细记录第" + (i + 1) + "行,源单信息为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                            return Result = false;
                        }
                        if (sSubStr[i].HMaterID == "") {
                            layer.msg("明细记录第" + (i + 1) + "行,器具信息为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                            layer.msg("明细记录第" + (i + 1) + "行,物料信息为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                            return Result = false;
                        }
                        if (sSubStr[i].HUnitID == "") {
                            layer.msg("明细记录第" + (i + 1) + "行,计量单位为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                            return Result = false;
                        }
                        if (sSubStr[i].HWHID == "") {
                            layer.msg("明细记录第" + (i + 1) + "行,收料仓库为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                        if (sSubStr[i].HQty == "") {
                            layer.msg("明细记录第" + (i + 1) + "行,数量为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                            return Result = false;
                        }
                    }