制作通用的单据编辑样例模块(生产汇报单列表/编辑),以方便其他开发人员可以借鉴。
4个文件已修改
884 ■■■■■ 已修改文件
WebTM/layuiadmin/Scripts/webConfig.js 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/生产管理/生产开工单/Sc_Add_MESBeginWorkBillList.html 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/生产管理/生产汇报单/Sc_Add_ICMOReportBillList.html 444 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/生产管理/生产汇报单/Sc_ICMOReportBillList.html 434 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/layuiadmin/Scripts/webConfig.js
@@ -6,10 +6,10 @@
     //var WEBURL = "http://101.37.171.70/API/";   //公司服务器
    //var WEBURL = "http://localhost:8080/API/";   //颜晓军本地配置
    //var WEBURL = "http://localhost:8082/lubao";   //颜晓军本地配置
    //var WEBURL = "http://localhost:8082/LuBaoAPI/";    //杨露本地配置
    var WEBURL = "http://localhost:8082/LuBaoAPI/";    //杨露本地配置
    //var WEBURL = "http://10.1.4.154/API/";   //江丰客户
    //var WEBURL = "http://10.1.4.155/API/";   //江丰客户NEW
    var WEBURL = "http://47.96.97.237/API/";   //智云服务器
    //var WEBURL = "http://47.96.97.237/API/";   //智云服务器
    //var WEBURL = "http://183.129.128.86:9090/API/";   //凯贝奈特客户服务器
    return WEBURL
}
WebTM/views/Éú²ú¹ÜÀí/Éú²ú¿ª¹¤µ¥/Sc_Add_MESBeginWorkBillList.html
@@ -434,10 +434,12 @@
                    $("#HMainSourceBillType").val("");
                    $('#HMainSourceBillNo').attr("disabled", false);
                    $('#XDHList').addClass("layui-btn-disabled").attr("disabled", true);
                    Type = 1;
                }
                else {
                    $('#HMainSourceBillNo').attr("disabled", true);
                    $('#XDHList').removeClass("layui-btn-disabled").attr("disabled", false);
                    Type = 2;
                }
            });
WebTM/views/Éú²ú¹ÜÀí/Éú²ú»ã±¨µ¥/Sc_Add_ICMOReportBillList.html
@@ -90,18 +90,18 @@
                                            <div class="layui-inline">
                                                <label class="layui-form-label">源单类型</label>
                                                <div class="layui-input-inline">
                                                    <select name="HSourceBillType" lay-filter="HSourceBillType" id="HSourceBillType">
                                                        <option value="0" selected="selected">生产任务单</option>
                                                        <option value="1">手工录入</option>
                                                    <select name="HMainSourceBillType" lay-filter="HMainSourceBillType" id="HMainSourceBillType">
                                                        <option value="2">生产任务单</option>
                                                        <option value="1" selected="selected">手工录入</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <label class="layui-form-label">选单号</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" name="HSourceBillNo" id="HSourceBillNo" class="layui-input" value="" style="float:left;width:150px;">
                                                    <input type="hidden" name="HSourceInterID" id="HSourceInterID" class="layui-input" value="" style="float:left;width:150px;">
                                                    <input type="hidden" name="HSourceEntryID" id="HSourceEntryID" class="layui-input" value="" style="float:left;width:150px;">
                                                    <input type="text" name="HMainSourceBillNo" id="HMainSourceBillNo" class="layui-input" value="" style="float:left;width:150px;">
                                                    <input type="hidden" name="HMainSourceInterID" id="HMainSourceInterID" class="layui-input" value="" style="float:left;width:150px;">
                                                    <input type="hidden" name="HMainSourceEntryID" id="HMainSourceEntryID" class="layui-input" value="" style="float:left;width:150px;">
                                                    <button type="button" lay-submit="" class="layui-btn" lay-filter="XDHList" id="XDHList" style="width:40px;">
                                                        <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                    </button>
@@ -162,6 +162,8 @@
        var params = getUrlVars();
        var hID = params[params[0]];//编辑查看
        var Type = params[params[1]] == undefined ? "1" : params[params[1]];//单据编辑状态: 1.无源单新增  Â 2.有源单新增  Â 3.编辑  4.浏览  5.变更
        var Sctag = "0";
        layui.config({
@@ -178,100 +180,64 @@
                , element = layui.element;
           
            //公共变量
            var option = [];
            //常规用法
            laydate.render({
                elem: '#HDate'
            });
            //判断是否登录 æœªç™»å½•则跳到登录页
            //if (sessionStorage.login != "login") {
            //    layer.confirm("登录失效,请重新登录!", {
            //        icon: 4, skin: 'layui-layer-lan', title: "温馨提示", closeBtn: 0, btn: ['重新登录']
            //    }, function () { window.location.href = "../../user/login.html"; });
            //}
            //var tableReload = table.reload;
            var option = {
                id:'mainTable'
                ,elem: '#mainTable'
                , toolbar: '#toolbarDemo'
                , height: 500
                //,url: '/demo/table/user/' //数据接口
                , page: true //开启分页
                , cols: [[ //表头
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao', title: '序号', sort: true, fixed: 'left', event: "qwe", width: 100 }
                    , { field: 'HMaterID', title: 'HMaterID', edit: 'text', width: 100, hide: true }
                    , { field: 'HMaterCode', title: '物料代码', edit: 'text', event: 'HMaterCode', width: 100 }
                    , { field: 'HMaterName', title: '物料名称', edit: 'text', width: 100 }
                    , { field: 'HMaterSpec', title: '规格型号', edit: 'text', width: 100 }
                    , { field: 'HUnitID', title: 'HUnitID', edit: 'text', width: 100, hide: true }
                    , { field: 'HUnitCode', title: '单位代码', edit: 'text', event: 'HUnitCode', width: 100 }
                    , { field: 'HUnitName', title: '单位名称', edit: 'text', width: 100 }
                    , { field: 'HSourceID', title: 'HSourceID', edit: 'text', width: 100, hide: true }
                    , { field: 'HSourceCode', title: '资源代码', edit: 'text', event: 'HSourceCode', width: 100 }
                    , { field: 'HSourceName', title: '资源名称', edit: 'text', width: 100 }
                    , { field: 'HWorkerid', title: 'HWorkerid', edit: 'text', width: 100, hide: true }
                    , { field: 'HWorkerCode', title: '操作员代码', edit: 'text', event: 'HWorkerCode', width: 100 }
                    , { field: 'HWorkerName', title: '操作员名称', edit: 'text', width: 100 }
                    , { field: 'HQty', title: '生产数量', edit: 'text', width: 100 }
                    , { field: 'HRemark', title: '表体备注', edit: 'text', width: 100 }
                    , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150 }
                ]]
                , limit: 500 //每页默认显示的数量
            };
            //判断是否新增
            if (hID == null || hID == 0) {
                //初始加载表格{ "ID": 0, "HWasterReasonName": " ","HBadReasonID":0,"HEmpName": "  ", "HSQProcName": "   ","HProcID":0, "HZRProcName": "  ", "HMRBChecker": "  ", "HRemark": "  ", "HPSProcName": "  ", "HCloseMan": "   " }
                option.data = [TabRow];
                table.render(option);
            }
            else {
                $("#HInterID").val(hID);//修改时主表ID
                //编辑加载数据
                $.ajax({
                    url: GetWEBURL() + 'Sc_ICMOReportBill/Sc_ICMOReportBillListProjectDetai',
                    type: "GET",
                    data: { "sqlWhere": "and hmainid=" + hID },
                    success: function (result) {
                        //console.log(result);
                        //console.log('gouba' + result);
                        if (result.count == 1) {
                            option.data = result.data;
                            table.render(option);
                        } else {
                            layer.alert(result.code + result.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close(index0);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //初始化表单插件
            set_InitFrom();
            //头工具栏事件
            table.on('toolbar(mainTable)', function (obj) {
            var rowid = 0;
            var rows = 0;
            table.on('toolbar(mainTable)', function (obj) {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;;
                var AddRow = table.cache['mainTable'];
                var NewRow = TabRow;
                switch (obj.event) {
                    case 'btn-AddLine':
                        //table.cache["mainTable"].push(AddRow[rows]);
                    case 'btn-AddLine': btnAddLine(NewRow);
                        break;
                    case 'btn-CopyLine': btnCopyLine(data);
                        break;
                }
            });
            //行内事件
            table.on('tool(mainTable)', function (obj) {
                set_GridDelete(obj);   //行内删除
                set_GridCellCheck(obj); //行内快捷键筛选
            });
            //初始化表格
            set_InitGrid();
            //判断是源单新增、无源单新增、编辑
            set_Type(Type);
            //判断是否源单新增、或者编辑
            set_CheckSelect();
            //初始化表单
            function set_InitFrom() {
                laydate.render({
                    elem: '#HDate'
                });
            }
            //表格增加行事件
            function btnAddLine(NewRow) {
                        table.cache["mainTable"].push(NewRow);
                        option.data = table.cache["mainTable"];
                        table.render(option);
                        rows++;
                        layer.msg('增加一行按钮!')
                        break;
                    case 'btn-CopyLine':
            }
            //表格复制行事件
            function btnCopyLine(data) {
                        var copydata = JSON.stringify(data);
                        if (data.length <= 0) {
                            layer.alert("请选择需要复制的一行!");
@@ -285,14 +251,11 @@
                            table.cache["mainTable"].push(JSON.parse(copyrow));//将复制的行强转成json追加到表格上
                            option.data = table.cache["mainTable"];//将数据绑定到data上
                            table.render(option);//将数据渲染到表格上
                            //layer.alert(copyrow);
                        }
                        break;
                }
            });
            //行内事件
            table.on('tool(mainTable)', function (obj) {
            //表格行内事件删除
            function set_GridDelete(obj) {
                var data = obj.data;
                var rowIndex = $(obj.tr).attr("data-index");
                if (obj.event === 'del') {
@@ -305,17 +268,13 @@
                            option.data = table.cache["mainTable"];//将数据绑定到data上
                            table.reload(option);
                            layer.close(index);
                            //obj.del();
                            //layer.close(index);
                            //var oldData = table.cache["mainTable"];
                            //oldData.splice(obj.tr.data('index'), 1);
                            //table.reload('mainTable', { data: oldData });
                            //layer.close(index);
                        }
                    });
                }
            }
            //表格行内事件快捷键筛选
            function set_GridCellCheck(obj) {
                $(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {
                    if (event.key == "F7") {
                        if (obj.event === 'HMaterCode')  //物料信息
@@ -487,18 +446,114 @@
                    }
                })
            }
            //初始化表格
            function set_InitGrid() {
                var columns = [
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao', title: '序号', sort: true, fixed: 'left', event: "qwe", width: 100 }
                    , { field: 'HMaterID', title: 'HMaterID', edit: 'text', width: 100, hide: true }
                    , { field: 'HMaterCode', title: '物料代码', edit: 'text', event: 'HMaterCode', width: 100 }
                    , { field: 'HMaterName', title: '物料名称', edit: 'text', width: 100 }
                    , { field: 'HMaterSpec', title: '规格型号', edit: 'text', width: 100 }
                    , { field: 'HUnitID', title: 'HUnitID', edit: 'text', width: 100, hide: true }
                    , { field: 'HUnitCode', title: '单位代码', edit: 'text', event: 'HUnitCode', width: 100 }
                    , { field: 'HUnitName', title: '单位名称', edit: 'text', width: 100 }
                    , { field: 'HSourceID', title: 'HSourceID', edit: 'text', width: 100, hide: true }
                    , { field: 'HSourceCode', title: '资源代码', edit: 'text', event: 'HSourceCode', width: 100 }
                    , { field: 'HSourceName', title: '资源名称', edit: 'text', width: 100 }
                    , { field: 'HWorkerid', title: 'HWorkerid', edit: 'text', width: 100, hide: true }
                    , { field: 'HWorkerCode', title: '操作员代码', edit: 'text', event: 'HWorkerCode', width: 100 }
                    , { field: 'HWorkerName', title: '操作员名称', edit: 'text', width: 100 }
                    , { field: 'HQty', title: '生产数量', edit: 'text', width: 100 }
                    , { field: 'HRemark', title: '表体备注', edit: 'text', width: 100 }
                    , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150 }
                ];
                option = {
                    id: 'mainTable'
                    , elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , page: false
                    , cellMinWidth: 120
                    , height: 500
                    , cols: [columns]
                    , done: function (res, curr, count) {
                    }
                };
            }
            //获取最大单据号
            function set_MAXNum() {
                var date = new Date();
                var day = date.getDate();
                var month = date.getMonth() + 1;
                var year = date.getFullYear();
                var shijian = year + "-" + month + "-" + day;
                //获取最大单据号 new
                $("#HInterID").val("0");
                $("#HBillNo").val("");
                $.ajax({
                    url: GetWEBURL() + "/Web/GetMAXNum",
                    type: "GET",
                    data: { "HBillType": '3711' },
                    success: function (d) {
                        //console.log(d.data);
                        $("#HBillNo").val(d.data[0].HBillNo);
                        $("#HDate").val(shijian);
                        $("#HInterID").val(0);
                    }
            });
            }
            //判断是源单新增、无源单新增、编辑
            function set_Type(Type) {
                console.log(Type);
                switch (Type) {
                    //无源单新增
                    case '1': set_AddFNew();
                        break;
                    //有源单新增  Â 
                    case '2': set_AddNew();
                        break;
                    //编辑 
                    case '3': set_EditFromGrid();
                        break;
                }
            }
            function RoadBillMain(hID)//加载表头
            //无源单新增
            function set_AddFNew()
            {
                //获取最大单据号
                set_MAXNum();
                $('#HMainSourceBillNo').attr("disabled", false);
                $('#XDHList').addClass("layui-btn-disabled").attr("disabled", true);
                option.data = [TabRow];
                table.render(option);
            }
            //有源单新增
            function set_AddNew() {
                //获取最大单据号
                set_MAXNum();
                option.data = [TabRow];
                table.render(option);
            }
            //编辑获取表头、获取表体
            function set_EditFromGrid() {
                set_EditForm(hID);  //编辑获取表头
                set_EditGrid(hID);  //编辑获取表体
                option.data = [TabRow];
                table.render(option);
            }
            //编辑获取表头
            function set_EditForm(hID) {
               
                //查询检验方案单是否存在
                $.ajax({
@@ -523,8 +578,9 @@
                                , "HGroupName": data.班组                //班组名称
                                , "HEmpID": data.HEmpID                  //统计员ID
                                , "HEmpName": data.统计员                //统计员名称
                                , "HSourceBillType": ""                   //源单类型
                                , "XDH": ""                               //选单号
                                , "HMainSourceBillNo": data.HMainSourceBillNo
                                , "HMainSourceInterID": data.HMainSourceInterID
                                , "HMainSourceEntryID": data.HMainSourceEntryID
                                , "HExplanation": ""                      //摘要
                                , "HRemark": data.表头备注                //备注
                            });
@@ -538,46 +594,56 @@
                });
            }
            var date = new Date();
            var day = date.getDate();
            var month = date.getMonth() + 1;
            var year = date.getFullYear();
            var shijian = year + "-" + month + "-" + day;
            //判断是否新增
            if (hID == null || hID == 0) {
                //获取最大单据号 new
                $("#HInterID").val("0");
                $("#HBillNo").val("");
            //编辑获取表体
            function set_EditGrid(hID) {
                $("#HInterID").val(hID);//修改时主表ID
                //编辑加载数据
                $.ajax({
                    url: GetWEBURL() + "/Web/GetMAXNum",
                    url: GetWEBURL() + 'Sc_ICMOReportBill/Sc_ICMOReportBillListProjectDetai',
                    type: "GET",
                    data: { "HBillType": '3711' },
                    success: function (d) {
                        //console.log(d.data);
                        $("#HBillNo").val(d.data[0].HBillNo);
                        $("#HDate").val(shijian);
                        $("#HInterID").val(0);
                    data: { "sqlWhere": "and hmainid=" + hID },
                    success: function (result) {
                        if (result.count == 1) {
                            option.data = result.data;
                            table.render(option);
                        } else {
                            layer.alert(result.code + result.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close(index0);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            else {//如果修改则走下面 new
                RoadBillMain(hID);
                /* RoadBillSub(linterid);*/
            }
            //监视下拉框是否源单
            function set_CheckSelect() {
            //获取下拉选中值
            form.on('select(HSourceBillType)', function (data) {
                form.on('select(HMainSourceBillType)', function (data) {
                Sctag = data.value;
                form.render('select');
                if (Sctag != "0") {
                    switch (Sctag) {
                        //无源单新增
                        case '1':
                            $("#HMainSourceInterID").val("0");
                            $("#HMainSourceEntryID").val("0");
                            $('#HMainSourceBillNo').attr("disabled", false);
                    $('#XDHList').addClass("layui-btn-disabled").attr("disabled", true);
                }
                else {
                            Type = 1;
                            break;
                        //有源单新增  Â 
                        case '2':
                            $("#HMainSourceInterID").val("0");
                            $("#HMainSourceEntryID").val("0");
                            $('#HMainSourceBillNo').attr("disabled", true);
                    $('#XDHList').removeClass("layui-btn-disabled").attr("disabled", false);
                            Type = 2;
                            break;
                }
            });
            }
            //表头信息车间弹窗
@@ -721,17 +787,17 @@
                        //var rowIndex = $("#mainTable").find("tbody tr").attr('data-index');//当前行的索引
                        //$(".layui-table-view .layui-table tbody tr[data-index=" + 1+ "]").remove();
                        $("#HSourceBillNo").val(checkStatus.data[0].单据号);
                        $("#HSourceInterID").val(checkStatus.data[0].hmainid);
                        $("#HSourceEntryID").val(checkStatus.data[0].HEntryID);
                        $("#HMainSourceBillNo").val(checkStatus.data[0].单据号);
                        $("#HMainSourceInterID").val(checkStatus.data[0].hmainid);
                        $("#HMainSourceEntryID").val(checkStatus.data[0].HEntryID);
                        var list = [];
                        for (var i = 0; i <checkStatus.data.length; i++) {
                            list.push(checkStatus.data[i].单据号)
                        }
                        if (isAllEqual(list))  //相同单号
                        {
                            if (checkStatus.data.length>1)
                            {
                            console.log(checkStatus.data);
                            if (checkStatus.data.length > 1) {
                                for (var i = 0; i < checkStatus.data.length-1; i++) //补行
                                {
                                    //var NewRow = { "HMaterID": 0, "HMaterCode": "", "HMaterName": "", "HMaterSpec": "", "HUnitID": 0, "HUnitCode": "", "HUnitName": "", "HSourceID": 0, "HSourceCode": "", "HSourceName": "", "HWorkerid": 0, "HWorkerCode": "", "HWorkerName": "", "HQty": 0, "HRemark": "" };
@@ -751,8 +817,7 @@
                            }
                            layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                        }
                        else
                        {
                        else {
                            layer.msg("请选择相同单号!", { time: 1 * 2000, icon: 5 });
                        }
                       
@@ -771,22 +836,13 @@
            });
            //退出
            form.on('submit(Exit)', function (data) {//
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            });
            form.on('submit(Cancel)', function () {
                //sessionStorage["SourceFlag"] = false;
                parent.location.href = "../../../views/index.html"
                //window.close();//关闭当前页
            })
            //编辑获取表体时时间格式矫正方式
            function formatDate(date) {
                var d = new Date(date),
                    month = '' + (d.getMonth() + 1),
@@ -799,6 +855,7 @@
                return [year, month, day].join('-');
            }
            //提交保存
            form.on('submit(Saver)', function (data) {//保存
                var refSav = "";
                if (hID == "" || hID == null) {
@@ -819,7 +876,6 @@
                    return false;
                }
                $.ajax(
                    {
                        type: "POST",
@@ -836,39 +892,18 @@
                                });
                            }
                            else {
                                f_alert(data.Message);
                                console.log("Reason" + sMainStr + "sub:" + JSON.stringify(layui.table.cache.mainTable));
                                layer.alert(data.Message, { icon: 5 });
                            }
                            layer.closeAll("loading");
                        },
                        error: function (err) {
                            f_alert("错误:" + err);
                            console.log("Reason" + sMainStr);
                            layer.alert(err.Message, { icon: 5 });
                        }
                    });
            });
            function f_alert(sMsg) {
                layer.alert(sMsg, { icon: 5 });
            }
            //监听提交
            form.verify({
                numberOrEmpty: function (value, item) {
                    // if (value != '') {
                    if (!/^\d+$/.test(value)) {
                        return '不能为空或数字或者0';
                    }
                    //}
                }
            })
            });
        });
        //判断数组中的值是否相同
        //判断源单带回数据数组中的值是否相同
        function isAllEqual(array) {
            if (array.length > 0) {
                return !array.some(function (value, index) {
@@ -879,61 +914,8 @@
            }
        }
        //定义全局变量
        var HReasonName, ReasonID, EmpName, SQProcName,
            ProcID, ZRProcName, QRName
            ;
        function GetHReasonValue(obj)  //返回不良原因
        {
            HReasonName = obj[0].HName;
            ReasonID = obj[0].HItemID;
        }
        //返回物料
        function GetHMaterNameValue(obj) {  //返回物料
            $("#HMater").val(obj[0].HName);
            $("#HMaterID").val(obj[0].HItemID);
            $("#HMaterNumber").val(obj[0].HNumber);
        }
        //返回工序
        function GetHProcValue(obj) {  //返回工序
            $("#HProcName").val(obj[0].工序);
            $("#HProcID").val(obj[0].HItemID);
            $("#HProcNumber").val(obj[0].工序代码);
        }
        function GetHDeptNameValue(obj) {  //返回部门
            $("#HDepName").val(obj[0].HName);
            $("#HDeptID").val(obj[0].HItemID);
            $("#HDeptNumber").val(obj[0].HNumber);
        }
        //返回单位
        function GetHUnitNameValue(obj) {
            $("#HUName").val(obj[0].HName);
            $("#HUnitID").val(obj[0].HItemID);
            $("#HUnitNumber").val(obj[0].HNumber);
        }
        function GetHKeeperValue(obj) {  //返回责任人
            EmpName = obj[0].HName;
            // $("#HEmpName").val(obj[0].HName);
            //$("#HItemID").val(obj[0].HItemID);
        }
        //function GetHProcValue(obj) {  //返回申请工序
        //    SQProcName = obj[0].工序;
        //    ProcID = obj[0].HItemID;
        //    //$("#HSQProcName").val(obj[0].工序);
        //    //$("#HProcID").val(obj[0].HItemID);
        //}
        function GetHZRValue(obj) {   //返回责任工序
            ZRProcName = obj[0].工序;
            //$("#HZRProcName").val(obj[0].工序);
            //$("#HItemID").val(obj[0].HItemID);
        }
        //HWorker
        function GetHWorkerValue(obj) {  //返回不良确认人
            QRName = obj[0].HName;
            //$("#HQRName").val(obj[0].HName);
            //$("#HItemID").val(obj[0].HItemID);
        }
        function AllowLoadData(sSubStr) {  //非空验证
            var Result = true;
            if ($("#HDeptID").val() == '' || $("#HDeptID").val() == null) {
WebTM/views/Éú²ú¹ÜÀí/Éú²ú»ã±¨µ¥/Sc_ICMOReportBillList.html
@@ -15,7 +15,7 @@
        }
    </style>
    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
</head>
<body>
    <div class="layui-fluid">
@@ -44,13 +44,13 @@
                                <div class="layui-inline">
                                    <label class="layui-form-label">开始日期</label>
                                    <div class="layui-input-block">
                                        <input type="date" class="layui-input" id="HDate" style="width:190px;">
                                        <input type="date" class="layui-input" id="HBeginDate" style="width:190px;">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">结束日期</label>
                                    <div class="layui-input-block">
                                        <input type="date" class="layui-input" id="HDate1" style="width:190px;">
                                        <input type="date" class="layui-input" id="HEndDate" style="width:190px;">
                                    </div>
                                </div>
                                <div class="layui-inline">
@@ -93,6 +93,9 @@
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Delete"><i class="layui-icon layui-icon-delete"></i>删除</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Audit"><i class="layui-icon layui-icon-radio"></i>审核</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-DeAudit"><i class="layui-icon layui-icon-circle"></i>反审核</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Print"><i class="layui-icon layui-icon-circle"></i>预览</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Cell"><i class="layui-icon layui-icon-ok"></i>保存列宽</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-RefreshCell"><i class="layui-icon layui-icon-refresh"></i>默认列宽</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-reload" style="display:none;"><i class="layui-icon layui-icon-refresh"></i>刷新</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-confirm" id="btn_confirm" style="display:none;"><i class="layui-icon layui-icon-ok-circle"></i>确认</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-back" id="btn_back" style="display:none;"><i class="layui-icon layui-icon-close-fill"></i>驳回</button>
@@ -126,15 +129,174 @@
            , element = layui.element
            , laypage = layui.laypage
            , laydate = layui.laydate
            var sWhere = "";
            var option = {
                elem: '#mainTable'
                , toolbar: '#toolbarDemo'
                ,height: 'full-50'
                , page: true
                ,cellMinWidth: 90
                , cols: [[
            //公共变量
            var sWhere = "";
            var option = [];
            var DataList;
            var Name = "ICMReportCellWidth";
            //初始化表格
            set_InitGrid();
            //加载数据到网格
            get_Display(sWhere);
            //头工具栏事件
            table.on('toolbar(mainTable)', function (obj) {
                switch (obj.event) {
                    //新增按钮
                    case 'btn-Add': set_AddNew();
                        break;
                    //编辑按钮
                    case 'btn-Edit': set_ShowBill();
                        break;
                    //删除按钮
                    case 'btn-Delete': set_DeleteBill();
                        break;
                    //审核按钮
                    case 'btn-Audit': set_CheckBill();
                        break;
                    //反审核按钮
                    case 'btn-DeAudit': set_AbandonCheck();
                        break;
                    //预览按钮
                    case 'btn-Print': get_PrintReport();
                        break;
                    //保存列宽按钮
                    case 'btn-Cell': set_SaveGridColWidth();
                        break;
                    //默认列宽按钮
                    case 'btn-RefreshCell': set_DefaultGridColWidth();
                        break;
                };
            });
            //查询按钮
            form.on('submit(btnSearch)', function (data) {
                get_FastQuery(table, option);
            });
            //重置按钮
            form.on('submit(btnReSearch)', function (data) {
                set_ClearQuery();
            });
            //获取列宽
            function getColumnsWidth() {
                var result = [];
                var colNum = $(".layui-table-header").find("tr").eq(0).find("th").length;
                //获取列宽
                $.ajax({
                    url: GetWEBURL() + '/tb_CellWidth/GetMouldScrapInHouseCellWidthList',
                    async: false,
                    type: "Get",
                    dataType: "json",
                    data: { "colNum": colNum, "Name": Name },
                    success: function (data1) {
                        if (data1.code == 1) {
                            result = data1.data;
                        }
                        else if (data1.code == -1) {
                        }
                        else {
                            layer.alert(data1.Message, { icon: 5 });
                        }
                    }, error: function (e) {
                        layer.alert(e.Message, { icon: 5 });
                    }
                });
                return result;
            }
            //加载网格
            function get_Display(sWhere) {
                //加载网格
                var wait = layer.load();//遮罩
                $.ajax({
                    url: GetWEBURL() + '/Sc_ICMOReportBill/list',
                    type: "GET",
                    data: { "sWhere": sWhere },
                    success: function (data1) {
                        if (data1.count == 1) {
                            option.data = data1.data;
                            table.render(option);
                            layer.close(wait);
                        } else {
                            layer.close(wait);
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close(wait);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //快速过滤
            function get_FastQuery(table, option) {
                var Status = $("select[name='Status']").val();//状态
                var HDate = $("#HBeginDate").val();//开始日期
                var HDate1 = $("#HEndDate").val();//结束日期
                var HBillNo = $("#HBillNo").val(); //单据号
                var Dept = $("#Dept").val();       //部门信息
                var Part = $("#Part").val();       //物料信息
                if (Status) {
                    switch (Status) {
                        case '-1':   //全部
                            sWhere += "";
                            break;
                        case '0':    //未审核
                            sWhere += " and å®¡æ ¸äºº=''";
                            break;
                        case '1':    //已审核
                            sWhere += " and å®¡æ ¸äºº<>''";
                            break;
                        case '2':    //已关闭
                            sWhere += " and å…³é—­äºº<>''";
                        default:
                    }
                }
                if (HDate) {
                    sWhere += " and CONVERT(varchar(100),日期, 23) >= '" + HDate + "'";
                }
                if (HDate1) {
                    sWhere += " and CONVERT(varchar(100),日期, 23) <= '" + HDate1 + "'";
                }
                if (HBillNo) {
                    sWhere += " and å•据号 like '%" + HBillNo + "%'";
                }
                if (Dept) {
                    sWhere += " and éƒ¨é—¨ like '%" + Dept + "%'";
                }
                if (Part) {
                    sWhere += " and concat(物料代码,物料名称,规格型号) like '%" + Part + "%'";
                }
                var index = layer.load(0);
                get_Display(sWhere);
                //调用接口后清空sWhere缓存
                sWhere = "";
            }
            //重置过滤条件
            function set_ClearQuery() {
                $('#Status').find("option[value='-1']").attr("selected", true);
                $("#HBeginDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 30), "yyyy-MM-dd"));
                $("#HEndDate").val(Format(new Date(), "yyyy-MM-dd"));
                $("#HBillNo").val("");
                $("#Dept").val("");
                $("#Part").val("");
            }
            //初始化表格
            function set_InitGrid() {
                $("#HBeginDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 30), "yyyy-MM-dd"));
                $("#HEndDate").val(Format(new Date(), "yyyy-MM-dd"));
                var columns = [
                     { type: 'checkbox', fixed: 'left' }
                    , { field: 'hmainid', title: 'hmainid', sort: true, hide: true, width: 200}
                    , { field: '日期', title: '日期', width: 160,templet: "<div>{{d.日期 ==null ?'':layui.util.toDateString(d.日期, 'yyyy-MM-dd')}}</div>"}
@@ -174,15 +336,35 @@
                    , { field: 'HGroupID', title: 'HGroupID', hide: true, width: 200}
                    , { field: 'HGroupName', title: 'HGroupName', hide: true, width: 200}
                    , { field: 'HEmpNumber', title: 'HEmpNumber', hide: true, width: 200}
                ]]
            };
                ];
                option = {
                    elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , page: true
                    , cellMinWidth: 120
                    , totalRow: true
                    , limit: 10
                    , height: 'full-50'
                    , cols: [columns]
                    , limits: [50, 500, 1000, 5000]
                    , done: function (res, curr, count) {
            //头工具栏事件
            table.on('toolbar(mainTable)', function (obj) {
                var checkStatus = table.checkStatus(obj.config.id);
                switch (obj.event) {
                    case 'btn-Add':
                        //页面层-自定义
                    }
                };
                //设置列宽
                var colWidth = getColumnsWidth();
                if (colWidth == "" || colWidth == []) {
                }
                else {
                    $.each(columns, function (x, m) {
                        m["width"] = colWidth[x];
                    });
                }
            }
            //新增
            function set_AddNew() {
                        layer.open({
                            type: 2,
                            skin: 'layui-layer-rim', //加上边框
@@ -191,7 +373,7 @@
                            shift: 2,
                            area: ['100%', '100%'],
                            maxmin: true,
                            content: '../生产汇报单/Sc_Add_ICMOReportBillList.html',
                    content: '../生产汇报单/Sc_Add_ICMOReportBillList.html?hID=&Type=1',
                            end: function () {
                                //刷新页面,
                                location.reload();
@@ -200,8 +382,11 @@
                            }
                        });
                        break;
                    case 'btn-Edit':
            }
            //编辑
            function set_ShowBill()
            {
                        var checkStatus = table.checkStatus('mainTable')
                            , data = checkStatus.data;
                        if (checkStatus.data.length === 1) {
@@ -215,7 +400,7 @@
                                , shade: 0.6 //遮罩透明度
                                , maxmin: true //允许全屏最小化
                                , anim: 0 //0-6的动画形式,-1不开启
                                , content: '../生产汇报单/Sc_Add_ICMOReportBillList.html?hID=' + hID
                        , content: '../生产汇报单/Sc_Add_ICMOReportBillList.html?hID=' + hID + '&Type=3'
                                , resize: false,
                                end: function () {
                                    //刷新页面,
@@ -229,9 +414,9 @@
                        } else {
                            layer.msg('请选择一行数据编辑!');
                        }
                        break;
                    case 'btn-Delete':
            }
            //删除
            function set_DeleteBill() {
                        var checkStatus = table.checkStatus('mainTable')
                            , data = checkStatus.data;
                        if (checkStatus.data.length === 1) {
@@ -265,9 +450,10 @@
                        else {
                            layer.msg('请选择一行数据删除!');
                        }
                        break;
            }
                    case 'btn-Audit':
            //审核
            function set_CheckBill() {
                        var checkStatus = table.checkStatus('mainTable')
                            , data = checkStatus.data;
                        if (checkStatus.data.length === 1) {
@@ -300,8 +486,10 @@
                        else {
                            layer.msg('请选择一行数据审核!');
                        }
                        break;
                    case 'btn-DeAudit':
            }
            //反审核
            function set_AbandonCheck() {
                        var checkStatus = table.checkStatus('mainTable')
                            , data = checkStatus.data;
                        if (checkStatus.data.length === 1) {
@@ -334,113 +522,121 @@
                        else {
                            layer.msg('请选择一行数据反审核!');
                        }
                        break;
                };
            });
            var index = layer.load(0, { shade: false });
            //进入页面显示的缓存列表
            }
            //预览
            function get_PrintReport() {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                if (checkStatus.data.length === 1) {
                    var InterID = data[0].hmainid.toString();
                    layer.alert("我是打印按钮!单据主ID是:" + InterID);
                    //window.open("../生产工序管理/工序汇报单/HBarPlanPrint.html?linterid=" + linterid + "&Type=HDepartMent" + "&OpenTmp=b");
                    window.open("../../基础资料/公用基础资料/HBarPlanPrint.html?linterid=" + InterID + "&Type=HDepartMent" + "&OpenTmp=b");
                }
                else {
                    layer.msg('请选择一行数据打印!');
                }
            }
            //保存列宽
            function set_SaveGridColWidth() {
                var arr = [];
                // åˆ—æ•°
                var colNum = $(".layui-table-header").find("tr").eq(0).find("th").length;
                for (var i = 0; i <= colNum; i++) {
                    var colName = $(".layui-table-header").find("tr").eq(0).find("th").eq(i).text();
                    var colWidth = $(".layui-table-header").find("tr").eq(0).find("th").eq(i).width();
                    if (colName != "" && colName != null) {
                        arr.push(colWidth == -1 ? 200 : colWidth);
                    }
                }
                arr.unshift(40); //首位追加
            $.ajax({
                //url: "http://61.130.49.162:9090/WMSAPI///Web/GetMAXNum",
                url: GetWEBURL() + '/Sc_ICMOReportBill/list',
                type: "GET",
                data: { "sWhere": sWhere },
                    url: GetWEBURL() + '/tb_CellWidth/GetMouldScrapInHouseCellWidth',
                    async: false,
                    type: "POST",
                    dataType: "json",
                    data: { "myMap": JSON.stringify(arr), "Name": Name },
                success: function (data1) {
                    if (data1.count == 1) {
                        option.data = data1.data;
                        table.render(option);
                        layer.close(index);
                            layer.alert(data1.Message, { icon: 1 });
                    } else {
                        layer.close(index);
                        layer.alert(data1.code + data1.Message, { icon: 5 });
                            layer.alert(data1.Message, { icon: 5 });
                    }
                }, error: function () {
                    layer.close(index);
                    layer.alert("接口请求失败!", { icon: 5 });
                    }, error: function (e) {
                        layer.alert(e.Message, { icon: 5 });
                }
            }); 
                //设置赋值列宽
                var colWidth = getColumnsWidth();
                if (colWidth == "" || colWidth == []) {
                }
                else {
                    $.each(columns, function (x, m) {
                        m["width"] = colWidth[x];
                    });
                }
                get_FastQuery(table, option);
            }
            //默认列宽
            function set_DefaultGridColWidth() {
                var arr = [];
                // åˆ—æ•°
                var colNum = $(".layui-table-header").find("tr").eq(0).find("th").length;
                for (var i = 0; i <= colNum; i++) {
                    var colName = $(".layui-table-header").find("tr").eq(0).find("th").eq(i).text();
                    if (colName != "" && colName != null) {
                        arr.push(200);   //默认宽度200
                    }
                }
                arr.unshift(40); //首位追加
                $.ajax({
                    url: GetWEBURL() + '/tb_CellWidth/GetMouldScrapInHouseCellWidth',
                    async: false,
                    type: "POST",
                    dataType: "json",
                    data: { "myMap": JSON.stringify(arr), "Name": Name },
                    success: function (data1) {
                        if (data1.count == 1) {
                            layer.alert(data1.Message, { icon: 1 });
                        } else {
                            layer.alert(data1.Message, { icon: 5 });
                        }
                    }, error: function (e) {
                        layer.alert(e.Message, { icon: 5 });
                    }
                });
                //设置赋值列宽
                var colWidth = getColumnsWidth();
                if (colWidth == "" || colWidth == []) {
                }
                else {
                    $.each(columns, function (x, m) {
                        m["width"] = colWidth[x];
                    });
                }
                get_FastQuery(table, option);
            }
            //重置按钮
            form.on('submit(btnReSearch)', function (data) {
                $('#Status').find("option[value='-1']").attr("selected", true);
                $("#HDate").val("");//开始日期
                $("#HDate1").val("");//结束日期
                $("#HBeginDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 30), "yyyy-MM-dd"));
                $("#HEndDate").val(Format(new Date(), "yyyy-MM-dd"));
                $("#HBillNo").val("");
                $("#Dept").val("");
                $("#Part").val("");
                $("#btnSearch").click();
            });
            //查询按钮
            form.on('submit(btnSearch)', function (data) {
                var Status = $("select[name='Status']").val();//状态
                var HDate = $("#HDate").val();//开始日期
                var HDate1 = $("#HDate1").val();//结束日期
                var HBillNo = $("#HBillNo").val(); //单据号
                var Dept = $("#Dept").val();       //部门信息
                var Part = $("#Part").val();       //物料信息
                if (Status) {
                    switch (Status) {
                        case '-1':   //全部
                            sWhere += "";
                            break;
                        case '0':    //未审核
                            sWhere += " and å®¡æ ¸äºº=''";
                            break;
                        case '1':    //已审核
                            sWhere += " and å®¡æ ¸äºº<>''";
                            break;
                        case '2':    //已关闭
                            sWhere += " and å…³é—­äºº<>''";
                        default:
                    }
                }
                if (HDate) {
                    sWhere += " and CONVERT(varchar(100),日期, 23) >= '" + HDate + "'";
                }
                if (HDate1) {
                    sWhere += " and CONVERT(varchar(100),日期, 23) <= '" + HDate1 + "'";
                }
                if (HBillNo) {
                    sWhere += " and å•据号 like '%" + HBillNo + "%'";
                }
                if (Dept) {
                    sWhere += " and éƒ¨é—¨ like '%" + Dept + "%'";
                }
                if (Part) {
                    sWhere += " and concat(物料代码,物料名称,规格型号) like '%" + Part + "%'";
                }
                $.ajax({
                    //url: "http://61.130.49.162:9090/WMSAPI///Web/GetMAXNum",
                    url: GetWEBURL() + '/Sc_ICMOReportBill/list',
                    type: "GET",
                    data: { "sWhere": sWhere },
                    success: function (data1) {
                        if (data1.count == 1) {
                            option.data = data1.data;
                            table.render(option);
                            layer.alert("查询成功", { icon: 1 });
                        } else {
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
                sWhere = "";//调用接口后清空sWhere缓存
            });
            //laydate.render({
            //    elem: '#HDate'
            //    , type: 'datetime'
            //    , trigger: 'click'
            //    , format:'yyyy-MM-dd HH:mm'
            //});
            //以上是layui模块
        });