zzr99
2021-08-31 f4ddaae11d44c6d19fccd702277317b6b89cf29b
客户列表+供应商+不良原因最终完善整合
11个文件已修改
3975 ■■■■ 已修改文件
WebTM/layuiadmin/PubCustom.js 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/IpadIndex.html 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/基础资料/销售基础资料/Gy_Customer.html 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/基础资料/销售基础资料/Gy_Customer_Edit.html 42 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/模治具管理/模治具管理/Sc_Add_MouldConkBookBillList.html 850 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/模治具管理/模治具管理/Sc_Add_MouldRepairCheckBillList.html 979 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/模治具管理/模治具管理/Sc_MouldConkBookBillList.html 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/模治具管理/模治具管理/Sc_MouldRepairCheckBillList.html 484 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/生产管理/质量汇报单/Sc_QualityReportBill.html 222 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/设备管理/Sb_Add_EqpConkBookBillList.html 855 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/设备管理/Sb_EqpConkBookBillList.html 470 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/layuiadmin/PubCustom.js
@@ -50,6 +50,18 @@
    return flag;
}
function Pub_judgeMorPC() {
    var userAgentInfo = navigator.userAgent;
    var Agents = new Array("Android", "iPhone", "SymbianOS", "Windows Phone", "iPad", "iPod");
    var flag = true;
    for (var v = 0; v < Agents.length; v++) {
        if (userAgentInfo.indexOf(Agents[v]) > 0) {
            flag = false;
            break;
        }
    }
    return flag;
}
/**
 *处理树形展示数据,要求有ID和ParentID、title字段
 *by zgq
@@ -88,6 +100,17 @@
    }
    return vars;
}
function Pub_getUrlVars() {
    var vars = [], hash;
    var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
}
//接收方式样例:
//var params = getUrlVars();
//if (typeof (params[params[0]]) == "undefined") {
WebTM/views/IpadIndex.html
@@ -789,6 +789,31 @@
            })
        }
        //不良采集
        function BadGather()
        {
            if (wktag == 0) {
                layer.alert("请选择工单列表", { icon: 5 });
                return false;
            }
            layer.open({
                type: 2
                , area: ['100%', '100%']
                , title: '质量汇报单-编辑'
                , shade: 0.6
                , maxmin: false
                , anim: 0
                , content: ['生产管理/质量汇报单/Sc_QualityReportBill.html?OperationType=2&linterid=' + HSourceInterID + '&HSouceBillType=' + HBillType, 'yes']
                , resize: false
                , cancel: function () {
                }
                , end: function () {
                }
            })
        }
        //退出
        function Esc(event, obj)
        {
@@ -966,7 +991,7 @@
                                    <span class="imgtitle">上料防呆</span>
                                </div>
                            </div>
                            <div class="layui-col-sm12 layui-col-md4">
                            <div class="layui-col-sm12 layui-col-md4" onclick="BadGather(event,this)">
                                <div class="cnt bottomright" style="pointer-events:none; background-color:rgb(0 0 0 / 10%)">
                                    <span class="layui-icon layui-icon-chart imgicon"></span>
                                    <span class="imgtitle">不良采集</span>
WebTM/views/»ù´¡×ÊÁÏ/ÏúÊÛ»ù´¡×ÊÁÏ/Gy_Customer.html
@@ -151,7 +151,10 @@
                        , { field: '组织名称', title: '组织名称' }
                        , { field: '明细标记', title: '明细标记' }
                        , { field: '禁用标记', title: '禁用标记' }
                    ]]
                    ]],
                    done: function (res, curr, count) {
                        $("#mainTable").css("width", "100%");
                    },
                };
            }
            //查询
WebTM/views/»ù´¡×ÊÁÏ/ÏúÊÛ»ù´¡×ÊÁÏ/Gy_Customer_Edit.html
@@ -687,27 +687,27 @@
                    },
                    success: function (d) {
                        ajaxReturnData = JSON.parse(JSON.stringify(d)).data;
                        $("#HNumber").val(d.data[0].客户代码);
                        $("#HName").val(d.data[0].客户名称);
                        $("#HHelpCode").val(d.data[0].助记码);
                        $("#HShortName").val(d.data[0].简称);
                        $("#HAddress").val(d.data[0].地址);
                        $("#HLinkMan").val(d.data[0].联系人);
                        $("#HLinkPhone").val(d.data[0].联系电话);
                        $("#HMobilePhone").val(d.data[0].手机);
                        $("#HFax").val(d.data[0].传真);
                        $("#HPostalCode").val(d.data[0].邮编);
                        $("#HEmail").val(d.data[0].电子邮件);
                        $("#HCorMan").val(d.data[0].法人代表);
                        $("#HBank").val(d.data[0].开户银行);
                        $("#HBankAccount").val(d.data[0].银行账号);
                        $("#HTaxNum").val(d.data[0].税务登记号);
                        $("#HTaxRate").val(d.data[0].增值税率);
                        $("#HEnglishName").val(d.data[0].英文名称);
                        $("#HEnglishAddress").val(d.data[0].英文地址);
                        $("#HCountry").val(d.data[0].国家);
                        $("#HCusStatus").val(d.data[0].客户状态);
                        $("input[name='HStopflag']").prop("checked", d.data[0].禁用标志);//true:选中 false:不选中
                        $("#HNumber").val(d.data[0].HNumber);
                        $("#HName").val(d.data[0].HName);
                        $("#HHelpCode").val(d.data[0].HHelpCode);
                        $("#HShortName").val(d.data[0].HShortName);
                        $("#HAddress").val(d.data[0].HAddress);
                        $("#HLinkMan").val(d.data[0].HLinkMan);
                        $("#HLinkPhone").val(d.data[0].HLinkPhone);
                        $("#HMobilePhone").val(d.data[0].HMobilePhone);
                        $("#HFax").val(d.data[0].HFax);
                        $("#HPostalCode").val(d.data[0].HPostalCode);
                        $("#HEmail").val(d.data[0].HEmail);
                        $("#HCorMan").val(d.data[0].HCorMan);
                        $("#HBank").val(d.data[0].HBank);
                        $("#HBankAccount").val(d.data[0].HBankAccount);
                        $("#HTaxNum").val(d.data[0].HTaxNum);
                        $("#HTaxRate").val(d.data[0].HTaxRate);
                        $("#HEnglishName").val(d.data[0].HEnglishName);
                        $("#HEngLishAddress").val(d.data[0].HEngLishAddress);
                        $("#HCountry").val(d.data[0].HCountry);
                        $("#HCusStatus").val(d.data[0].HCusStatus);
                        $("input[name='HStopflag']").prop("checked", d.data[0].HStopflag);//true:选中 false:不选中
                        layui.form.render();//实时渲染选中和不选中的样式,最好添加这句话
                        $("#HRemark").val(d.data[0].备注);
                        $("#HUpDater").val(sessionStorage["HUserName"]);//修改人
WebTM/views/Ä£Öξ߹ÜÀí/Ä£Öξ߹ÜÀí/Sc_Add_MouldConkBookBillList.html
@@ -91,7 +91,7 @@
                                                    <button type="button" lay-submit="" class="layui-btn" lay-filter="HEmpList" style="width:40px;">
                                                        <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                    </button>
                                                </div>
                                            </div>
                                            <div class="layui-inline">
@@ -106,7 +106,7 @@
                                                    <input class="layui-input" name="HEndDate" id="HEndDate" autocomplete="off" timeFormat="yyyy-MM-dd">
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
@@ -172,22 +172,17 @@
    <script src="../../../layuiadmin/Scripts/json2.js"></script>
    <script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
    <script src="../../../layuiadmin/Scripts/webConfig.js"></script>
    <script>//获取参数
        function getUrlVars() {
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for (var i = 0; i < hashes.length; i++) {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
    <script src="../../../layuiadmin/PubCustom.js"></script>
    <script>
        //获取参数
        var params = get_UrlVars();
        if (typeof (params[params[0]]) == "undefined") {
            var OperationType = 1;//操作类型
        } else {
            var OperationType = params[params[0]];//操作类型
            var linterid = params[params[1]];//源单id
            var HSouceBillType = params[params[2]];//源单类型
        }
        var params = getUrlVars();
        var hID = params[params[0]];//编辑查看
        layui.config({
@@ -195,6 +190,8 @@
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'table', 'element'], function () {
            //#region  å…¬å…±å˜é‡
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
@@ -202,302 +199,55 @@
                , form = layui.form
                , laydate = layui.laydate
                , element = layui.element;
            var sBillType = "3807";
            var TabRow = { "HConkReasonID": 0, "HConkReasonCode": "", "HConkReasonName": "", "HConkExplanation": "", "HManagerID": 0, "HManagerCode": "", "HManagerName": "", "HRemark": "" };
            //#endregion
            //常规用法
            laydate.render({
                elem: '#HDate'
            //#region  è¿›å…¥é¡µé¢åˆå§‹åŒ–
            });
            laydate.render({
                elem: '#HConkBeginDate'
            });
            laydate.render({
                elem: '#HEndDate'
            });
            //判断是否登录 æœªç™»å½•则跳到登录页
            //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 = {
                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" }
                    , { field: 'HConkReasonID', title: 'HConkReasonID', edit: 'text', hide: true }
                    , { field: 'HConkReasonCode', title: '故障原因代码', edit: 'text', event: "HConkReasonCode"}
                    , { field: 'HConkReasonName', title: '故障原因', edit: 'text'}
                    , { field: 'HConkExplanation', title: '故障原因描述', edit: 'text'}
                    , { field: 'HManagerID', title: 'HManagerID', edit: 'text', hide: true }
                    , { field: 'HManagerCode', title: '负责人代码', edit: 'text', event: "HManagerCode"}
                    , { field: 'HManagerName', title: '负责人', edit: 'text'}
                    , { field: 'HRemark', title: '备注', event: "", edit: 'text'}
                    , { fixed: 'right', title: '操作', toolbar: '#barDemo'}
                ]]
                , limit: 500 //每页默认显示的数量
            };
            //判断是否新增
            if (hID == null || hID == 0) {
                //初始加载表格{ "ID": 0, "HWasterReasonName": " ","HBadReasonID":0,"HEmpName": "  ", "HSQProcName": "   ","HProcID":0, "HZRProcName": "  ", "HMRBChecker": "  ", "HRemark": "  ", "HPSProcName": "  ", "HCloseMan": "   " }
                option.data = [{ "HConkReasonID": 0, "HConkReasonCode": "", "HConkReasonName": "", "HConkExplanation": "", "HManagerID": 0,"HManagerCode":"", "HManagerName": "", "HRemark": "" }];
                table.render(option);
            //初始化表格
            set_InitGrid();
            //初始化表单插件
            set_InitFrom();
            //判断操作类型
            if (OperationType == 1) {//无源单
                set_AddFNew();
            }
            else if (OperationType == 3) {//编辑
                set_EditFromGrid();
            }
            else {
                $("#HInterID").val(hID);//修改时主表ID
                //编辑加载数据
                $.ajax({
                    url: GetWEBURL() + 'Sc_MouldConkBookBill/Sb_MouldConkBookBillListProjectDetai',
                    type: "GET",
                    //data: { "sqlWhere": "and HInterID=" + hID },
                    data: { "sqlWhere": "and hmainid=" + hID },
                    success: function (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 });
                    }
                });
                layer.alert("未知操作类型!", { icon: 5 });
            }
            //#endregion
            //#region è§¦å‘事件:
            //头工具栏事件
            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 = { "HConkReasonID": 0, "HConkReasonCode": "", "HConkReasonName": "", "HConkExplanation": "", "HManagerID": 0, "HManagerCode": "", "HManagerName": "", "HRemark": "" };
                var NewRow = TabRow;
                switch (obj.event) {
                    case 'btn-AddLine':
                        //table.cache["mainTable"].push(AddRow[rows]);
                        table.cache["mainTable"].push(NewRow);
                        option.data = table.cache["mainTable"];
                        table.render(option);
                        rows++;
                        layer.msg('增加一行按钮!')
                    //增加一行
                    case 'btn-AddLine': set_AddLine(NewRow);
                        break;
                    case 'btn-CopyLine':
                        var copydata = JSON.stringify(data);
                        if (data.length <= 0) {
                            layer.alert("请选择需要复制的一行!");
                        }
                        else if (data.length > 1) {
                            layer.alert("只能选择复制一行!");
                        }
                        else {
                            var copydata2 = copydata.substring(1, copydata.length);//去除首行字符'['
                            var copyrow = copydata2.substring(0, copydata2.length - 1);//去除末尾字符']'
                            table.cache["mainTable"].push(JSON.parse(copyrow));//将复制的行强转成json追加到表格上
                            option.data = table.cache["mainTable"];//将数据绑定到data上
                            table.render(option);//将数据渲染到表格上
                            //layer.alert(copyrow);
                        }
                    //复制一行
                    case 'btn-CopyLine': set_CopyLine(data);
                        break;
                }
            });
            //行内事件
            table.on('tool(mainTable)', function (obj) {
                var data = obj.data;
                var rowIndex = $(obj.tr).attr("data-index");
                if (obj.event === 'del') {
                    layer.confirm('真的删除行么', function (index) {
                        console.log("索引为:" + rowIndex);
                        if (rowIndex === '0') {
                            layer.msg('首行无法删除!!!');
                        } else {
                            //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);
                        }
                    });
                }
                $(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {
                    if (event.key == "F7") {
                        if (obj.event === 'HConkReasonCode')  //故障原因代码
                        {
                            //页面层-自定义
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '故障原因列表',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../../PublicPage/FaultReasonInformation.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({
                                        HConkReasonID: checkStatus.data[0].HItemID,
                                        HConkReasonCode: checkStatus.data[0].HNumber,
                                        HConkReasonName: checkStatus.data[0].HName,
                                    });
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                                },
                                end: function () {
                                }
                            });
                        }
                        if (obj.event === 'HManagerCode')  //负责人信息
                        {
                            //页面层-自定义
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '负责人信息列表',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../../PublicPage/UserInformation.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({
                                        HManagerID: checkStatus.data[0].HItemID,
                                        HManagerCode: checkStatus.data[0].HNumber,
                                        HManagerName: checkStatus.data[0].HName
                                    });
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                                },
                                end: function () {
                                }
                            });
                        }
                        obj.event = "";
                        return false;
                    }
                })
                set_GridDelete(obj);   //行内删除
                set_GridCellCheck(obj); //行内快捷键筛选
            });
            function RoadBillMain(hID)//加载表头
            {
                alert(hID);
                //查询检验方案单是否存在
                $.ajax({
                    url: GetWEBURL() + "Sc_MouldConkBookBill/Sb_MouldConkBookBillListCheckDetai",
                    type: "GET",
                    data: {
                        "HID": hID
                    },
                    success: function (result) {
                        if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            var data = result.data.h_v_Sc_MouldConkBookBillList_Edit[0];
                            form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                                "HBillNo": data.单据号
                                , "HDate": formatDate(data.日期)
                                , "HInnerBillNo": data.内部单据号
                                , "HMouldID": data.HMouldID        //模具ID
                                , "HName": data.产品模具      //模具名称
                                , "HConkTypeID": data.HConkTypeID  //故障类别ID
                                , "HConkTypeName": data.故障类别  //故障类别名称
                                , "HEmpID": data.HEmpID            //发现人ID
                                , "HEmpName": data.发现人            //发现人名称
                                , "HConkBeginDate": formatDate(data.故障发生日期)
                                , "HEndDate": formatDate(data.要求完善日期)
                                , "HManagerID": data.HManagerID    //负责人ID
                                , "HManagerName": data.负责人    //负责人名称
                                , "HDeptID": data.HDeptID        //使用部门ID
                                , "HDeptName": data.使用部门     //使用部门
                                , "HExplanation": data.摘要
                                , "HRemark": data.备注
                            });
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
            }
            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("");
                $.ajax({
                    url: GetWEBURL() + "/Web/GetMAXNum",
                    type: "GET",
                    data: { "HBillType": '3815' },
                    success: function (d) {
                        //console.log(d.data);
                        $("#HBillNo").val(d.data[0].HBillNo);
                        $("#HDate").val(shijian);
                        $("#HConkBeginDate").val(shijian);
                        $("#HEndDate").val(shijian);
                        $("#HInterID").val(0);
                    }
                });
            }
            else {//如果修改则走下面 new
                RoadBillMain(hID);
                /* RoadBillSub(linterid);*/
            }
            //成品模具弹窗
            form.on('submit(ProductModulList)', function () {
@@ -575,7 +325,7 @@
                });
            });
            //表头信息发现人弹窗
            //表头信息发现人弹窗
            form.on('submit(HEmpList)', function () {
                //页面层-自定义
                layer.open({
@@ -613,7 +363,7 @@
                });
            });
            //表头信息负责人弹窗
            //表头信息负责人弹窗
            form.on('submit(HManagerList)', function () {
                //页面层-自定义
                layer.open({
@@ -651,7 +401,7 @@
                });
            });
            //表头信息部门弹窗
            //表头信息部门弹窗
            form.on('submit(Department)', function () {
                //页面层-自定义
                layer.open({
@@ -689,24 +439,184 @@
                });
            });
            //退出
            form.on('submit(Exit)', function (data) {//
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
                if (linterid == undefined) {
                    //关闭页签
                    Pub_Close(2);
                }
                else {
                    //关闭页签
                    Pub_Close(1);
                }
            });
            //保存
            form.on('submit(Saver)', function (data) {
                //debugger;
                var sMainStr = JSON.stringify(data.field);
                var sSubStr = JSON.stringify(table.cache['mainTable']);
                var sMainSub = sMainStr + ';' + sSubStr;
                //对数据进行验证
                if (AllowLoadData(sSubStr)) {
                    $.ajax(
                        {
                            type: "POST",
                            url: GetWEBURL() + "/Sc_MouldConkBookBill/SaveGetMouldConkBookBillList", //方法所在页面和方法名
                            async: true,
                            data: { "msg": sMainSub },
                            dataType: "json",
                            success: function (data) {
                                if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                                    layer.msg(data.Message, { time: 1 * 1000, icon: 1 }, function () {
                                        $('#add-btn').addClass("layui-btn-disabled").attr("disabled", true);
                                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                        parent.layer.close(index); //再执行关闭 Â  Â  Â  Â  Â Â  Â Â Â  Â 
                                    });
                                }
                                else {
                                    f_alert(data.Message);
                                    console.log("Reason" + sMainStr + "sub:" + JSON.stringify(layui.table.cache.mainTable));
                                }
                                layer.closeAll("loading");
                            },
                            error: function (err) {
                                f_alert("错误:" + err);
                                console.log("Reason" + sMainStr);
                            }
                        });
                }
            });
            form.on('submit(Cancel)', function () {
                //sessionStorage["SourceFlag"] = false;
                parent.location.href = "../../../views/index.html"
                //window.close();//关闭当前页
            })
             //#endregion
            //#region  å½“前页页面所有方法
            //初始化表单插件
            function set_InitFrom()
            {
                laydate.render({
                    elem: '#HDate'
                });
                laydate.render({
                    elem: '#HConkBeginDate'
                });
                laydate.render({
                    elem: '#HEndDate'
                });
            }
            //初始化表格
            function set_InitGrid() {
                //表头
                columns = [
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao', title: '序号', sort: true, fixed: 'left', event: "qwe" }
                    , { field: 'HConkReasonID', title: 'HConkReasonID', edit: 'text', hide: true }
                    , { field: 'HConkReasonCode', title: '故障原因代码', edit: 'text', event: "HConkReasonCode" }
                    , { field: 'HConkReasonName', title: '故障原因', edit: 'text' }
                    , { field: 'HConkExplanation', title: '故障原因描述', edit: 'text' }
                    , { field: 'HManagerID', title: 'HManagerID', edit: 'text', hide: true }
                    , { field: 'HManagerCode', title: '负责人代码', edit: 'text', event: "HManagerCode" }
                    , { field: 'HManagerName', title: '负责人', edit: 'text' }
                    , { field: 'HRemark', title: '备注', event: "", edit: 'text' }
                    , { fixed: 'right', title: '操作', toolbar: '#barDemo' }
                ];
                option = {
                    id: 'mainTable'
                    , elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , page: false
                    , cellMinWidth: 120
                    , height: 500
                    , cols: [columns]
                    , done: function (res, curr, count) {
                    }
                };
            }
            //无源单新增
            function set_AddFNew() {
                //获取最大单据号
                get_MAXNum();
                option.data = [TabRow];
                table.render(option);
            }
            //获取最大单据号及默认值赋值
            function get_MAXNum() {
                //获取最大单据号 new
                $("#HInterID").val("0");
                $("#HBillNo").val("");
                $.ajax({
                    url: GetWEBURL() + "/Web/GetMAXNum",
                    type: "GET",
                    data: { "HBillType": sBillType },
                    success: function (d) {
                        $("#HBillNo").val(d.data[0].HBillNo);
                        $("#HDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                        $("#HConkBeginDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                        $("#HEndDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                        $("#HInterID").val(0);
                    }
                });
            }
            //编辑
            function set_EditFromGrid() {
                set_EditForm(linterid);  //编辑获取表头
                set_EditGrid(linterid);  //编辑获取表体
                option.data = [TabRow];
                table.render(option);
            }
            //编辑加载表头
            function set_EditForm(linterid) {
                //查询检验方案单是否存在
                $.ajax({
                    url: GetWEBURL() + "Sc_MouldConkBookBill/Sb_MouldConkBookBillListCheckDetai",
                    type: "GET",
                    data: {
                        "HID": linterid
                    },
                    success: function (result) {
                        if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            var data = result.data.h_v_Sc_MouldConkBookBillList_Edit[0];
                            form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                                "HBillNo": data.单据号
                                , "HDate": formatDate(data.日期)
                                , "HInnerBillNo": data.内部单据号
                                , "HMouldID": data.HMouldID        //模具ID
                                , "HName": data.产品模具      //模具名称
                                , "HConkTypeID": data.HConkTypeID  //故障类别ID
                                , "HConkTypeName": data.故障类别  //故障类别名称
                                , "HEmpID": data.HEmpID            //发现人ID
                                , "HEmpName": data.发现人            //发现人名称
                                , "HConkBeginDate": formatDate(data.故障发生日期)
                                , "HEndDate": formatDate(data.要求完善日期)
                                , "HManagerID": data.HManagerID    //负责人ID
                                , "HManagerName": data.负责人    //负责人名称
                                , "HDeptID": data.HDeptID        //使用部门ID
                                , "HDeptName": data.使用部门     //使用部门
                                , "HExplanation": data.摘要
                                , "HRemark": data.备注
                            });
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
            }
            // ç¼–辑获取表头时时间格式矫正方式
            function formatDate(date) {
                var d = new Date(date),
                    month = '' + (d.getMonth() + 1),
@@ -719,170 +629,228 @@
                return [year, month, day].join('-');
            }
            form.on('submit(Saver)', function (data) {//保存
                //debugger;
                var sMainStr = JSON.stringify(data.field);
                var sSubStr = JSON.stringify(table.cache['mainTable']);
                var sMainSub = sMainStr + ';' + sSubStr;
            // ç¼–辑获取表体
            function set_EditGrid(linterid) {
                $("#HInterID").val(linterid);//修改时主表ID
                //编辑加载数据
                $.ajax({
                    url: GetWEBURL() + 'Sc_MouldConkBookBill/Sb_MouldConkBookBillListProjectDetai',
                    type: "GET",
                    data: { "sqlWhere": "and hmainid=" + linterid },
                    success: function (result) {
                        //console.log('gouba' + result);
                        if (result.count == 1) {
                            option.data = result.data;
                            table.render(option);
                $.ajax(
                    {
                        type: "POST",
                        url: GetWEBURL() + "/Sc_MouldConkBookBill/SaveGetMouldConkBookBillList", //方法所在页面和方法名
                        async: true,
                        data: { "msg": sMainSub },
                        dataType: "json",
                        success: function (data) {
                            if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                                layer.msg(data.Message, { time: 1 * 1000, icon:1 }, function () {
                                    $('#add-btn').addClass("layui-btn-disabled").attr("disabled", true);
                                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                    parent.layer.close(index); //再执行关闭 Â  Â  Â  Â  Â Â  Â Â Â  Â 
                                });
                            }
                            else {
                        } else {
                            layer.alert(result.code + result.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close(index0);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
                                f_alert(data.Message);
                                console.log("Reason" + sMainStr + "sub:" + JSON.stringify(layui.table.cache.mainTable));
                            }
                            layer.closeAll("loading");
                        },
                        error: function (err) {
                            f_alert("错误:" + err);
                            console.log("Reason" + sMainStr);
            //行内删除
            function set_GridDelete(obj) {
                var data = obj.data;
                var rowIndex = $(obj.tr).attr("data-index");
                if (obj.event === 'del') {
                    layer.confirm('真的删除行么', function (index) {
                        console.log("索引为:" + rowIndex);
                        if (rowIndex === '0') {
                            layer.msg('首行无法删除!!!');
                        } else {
                            //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 f_alert(sMsg) {
                layer.alert(sMsg, { icon: 5 });
                }
            }
            //监听提交
            form.verify({
                numberOrEmpty: function (value, item) {
                    // if (value != '') {
                    if (!/^\d+$/.test(value)) {
                        return '不能为空或数字或者0';
            //行内事件快捷键筛选
            function set_GridCellCheck(obj) {
                $(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {
                    if (event.key == "F7") {
                        if (obj.event === 'HConkReasonCode')  //维修代码
                        {
                            //页面层-自定义
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '故障原因列表',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../../PublicPage/FaultReasonInformation.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({
                                        HConkReasonID: checkStatus.data[0].HItemID,
                                        HConkReasonCode: checkStatus.data[0].HNumber,
                                        HConkReasonName: checkStatus.data[0].HName,
                                    });
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                                },
                                end: function () {
                                }
                            });
                        }
                        if (obj.event === 'HManagerCode')  //负责人信息
                        {
                            //页面层-自定义
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '负责人信息列表',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../../PublicPage/UserInformation.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({
                                        HManagerID: checkStatus.data[0].HItemID,
                                        HManagerCode: checkStatus.data[0].HNumber,
                                        HManagerName: checkStatus.data[0].HName
                                    });
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                                },
                                end: function () {
                                }
                            });
                        }
                        obj.event = "";
                        return false;
                    }
                    //}
                })
            }
            //增加一行
            function set_AddLine(NewRow) {
                table.cache["mainTable"].push(NewRow);
                option.data = table.cache["mainTable"];
                table.render(option);
            }
            //复制一行
            function set_CopyLine(data) {
                var copydata = JSON.stringify(data);
                if (data.length <= 0) {
                    layer.alert("请选择需要复制的一行!");
                }
            });
                else if (data.length > 1) {
                    layer.alert("只能选择复制一行!");
                }
                else {
                    var copydata2 = copydata.substring(1, copydata.length);//去除首行字符'['
                    var copyrow = copydata2.substring(0, copydata2.length - 1);//去除末尾字符']'
                    table.cache["mainTable"].push(JSON.parse(copyrow));//将复制的行强转成json追加到表格上
                    option.data = table.cache["mainTable"];//将数据绑定到data上
                    table.render(option);//将数据渲染到表格上
                    //layer.alert(copyrow);
                }
            }
            //#endregion
            //判断是否登录 æœªç™»å½•则跳到登录页
            //if (sessionStorage.login != "login") {
            //    layer.confirm("登录失效,请重新登录!", {
            //        icon: 4, skin: 'layui-layer-lan', title: "温馨提示", closeBtn: 0, btn: ['重新登录']
            //    }, function () { window.location.href = "../../user/login.html"; });
            //}
        });
        //定义全局变量
        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) {  //非空验证
            //if ($("#HSourceBillNo").val() == '') {
            //    layer.msg("请先扫源单!", { icon: 5 });
            //    return false;
            //}
            if ($("#HDeptName").val() == '') {
                layer.msg("部门没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
        function AllowLoadData(sSubStr) {
            if ($("#HMouldID").val() == ''&& $("#HName").val() == '') {
                layer.msg("成品模具没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            if ($("#HSecManager").val() == '') {
                layer.msg("验收人没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
            if ($("#HConkTypeID").val() == '' && $("#HConkTypeName").val() == '') {
                layer.msg("故障类别没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            if ($("#HKeeper").val() == '') {
                layer.msg("保管人没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
            if ($("#HEmpID").val() == '' && $("#HEmpName").val() == '') {
                layer.msg("发现人没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            //if ($("#HWHNAME").val() == '') {
            //    layer.msg("仓库没有选择!", { icon: 5 });
            //    return false;
            //}
            if ($("#HBillNo").val() == '') {
                layer.msg("错误的单据号", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
            if ($("#HManagerID").val()==''&& $("#HManagerName").val() == '') {
                layer.msg("负责人没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            if ($("#HInterID").val() == '') {
                layer.msg("错误的内码", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
            if ($("#HDeptID").val() == '' && $("#HDeptName").val() == '') {
                layer.msg("使用部门没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            if (typeof (sSubStr) == "undefined") {
                layer.msg("没有物料明细记录", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
            //判断物料明细项
            if (typeof (sSubStr) == "undefined" || sSubStr == "" || sSubStr == "[]") {
                layer.msg("没有物料明细记录", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            if (!typeof (sSubStr) == "undefined") {
                //for (var i = 0; i <= sSubStr.length - 1; i++) {  //判断扫码数量不能大于应收数量
                //    if (parseFloat(sSubStr[i].HQtyMust) > 0) {
                //        if (parseFloat(sSubStr[i].HQty) > parseFloat(sSubStr[i].HQtyMust))
                //        {
                //            layer.msg("数量不能大于应收数量", { icon: 5, btn: ['确定'], time: 100000, offset: 't' });
                //            return false;
                //        }
                //    }
                //}
                for (var i = 0; i <= sSubStr.length - 1; i++) {   //判断扫码数量不能为0
                    if (parseFloat(sSubStr[i].HQty) > 0) {
                        s = 1;
            if (typeof (sSubStr) != "undefined" && typeof (sSubStr) != "") {
                sSubStr = JSON.parse(sSubStr);
                for (var i = 0; i < sSubStr.length; i++) {
                    if (sSubStr[i].HRepairCode == "") {
                        layer.msg("明细记录第" + (i + 1) + "行,维修代码信息为空!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                        return false;
                    }
                }
                if (s == 0) {
                    layer.msg("产品入库记录未扫码", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return false;
                    if (sSubStr[i].HManagerCode == "") {
                        layer.msg("明细记录第" + (i + 1) + "行,负责人代码信息为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                        return false;
                    }
                    else {
                        return true;
                    }
                }
            }
            else {
                return true;
            }
        }</script>
        }
  </script>
</body>
</html>
WebTM/views/Ä£Öξ߹ÜÀí/Ä£Öξ߹ÜÀí/Sc_Add_MouldRepairCheckBillList.html
@@ -163,29 +163,26 @@
    <script src="../../../layuiadmin/Scripts/json2.js"></script>
    <script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
    <script src="../../../layuiadmin/Scripts/webConfig.js"></script>
    <script>//获取参数
        function getUrlVars() {
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for (var i = 0; i < hashes.length; i++) {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
    <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <script src="../../../layuiadmin/PubCustom.js"></script>
    <script>
        //获取参数
        var params = get_UrlVars();
        if (typeof (params[params[0]]) == "undefined") {
            var OperationType = 1;//操作类型
        } else {
            var OperationType = params[params[0]];//操作类型
            var linterid = params[params[1]];//源单id
            var HSouceBillType = params[params[2]];//源单类型
        }
        var params = getUrlVars();
        var hID = params[params[0]];//编辑查看
        layui.config({
            base: '../../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'table', 'element'], function () {
           //#region å…¬å…±å˜é‡
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
@@ -193,60 +190,385 @@
                , form = layui.form
                , laydate = layui.laydate
                , element = layui.element;
            var sBillType = "3817";
            var TabRow = { "HRepairCheckID": 0, "HRepairCheckCode": "", "HRepairCheckName": "  ", "HRepairCheckContent": "   ", "HManagerID": 0, "HManagerCode": "", "HManagerName": "  ", "HRemark": "  " };
            //#endregion
            //常规用法
            laydate.render({
                elem: '#HDate'
           //#region è¿›å…¥é¡µé¢å³åŠ è½½
            //初始化表格
            set_InitGrid();
            //初始化表单插件
            set_InitFrom();
            //判断操作类型
            if (OperationType == 1) {//无源单
                set_AddFNew();
            }
            else if (OperationType == 3) {//编辑
                set_EditFromGrid();
            }
            else {
                layer.alert("未知操作类型!", { icon: 5 });
            }
            //#endregion
           //#region è§¦å‘事件:包括form.on(){}格式的所有点击事件、选择事件等
            //成品模具弹窗
            form.on('submit(ProductModulList)', function () {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '成品模具列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/MouldInformation.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('请选择数据');
                        }
                        $("#HName").val(checkStatus.data[0].HName);
                        $("#HMouldID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                    },
                    end: function () {
                    },
                    success: function (layero, index) {
                    }
                });
            });
            //表头信息验收人弹窗
            form.on('submit(HEmpList)', function () {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '人员列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/UserInformation.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('请选择数据');
                        }
                        $("#HEmpName").val(checkStatus.data[0].HName);
                        $("#HEmpID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                    },
                    end: function () {
                    },
                    success: function (layero, index) {
                    }
                });
            });
            //表头信息验收部门弹窗
            form.on('submit(Department)', function () {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '部门列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/DeptInformation.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('请选择数据');
                        }
                        $("#HDeptName").val(checkStatus.data[0].HName);
                        $("#HDeptID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                    },
                    end: function () {
                    },
                    success: function (layero, index) {
                    }
                });
            });
            //表头信息负责人弹窗
            form.on('submit(HManagerList)', function () {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '人员列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/UserInformation.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('请选择数据');
                        }
                        $("#HManagerName").val(checkStatus.data[0].HName);
                        $("#HManagerID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                    },
                    end: function () {
                    },
                    success: function (layero, index) {
                    }
                });
            });
            //头工具栏事件
            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': set_AddLine(NewRow);
                        break;
                    //复制一行
                    case 'btn-CopyLine': set_CopyLine(data);
                        break;
                }
            });
            //行内事件
            table.on('tool(mainTable)', function (obj) {
                set_GridDelete(obj);   //行内删除
                set_GridCellCheck(obj); //行内快捷键筛选
            });
            laydate.render({
                elem: '#HRepairBeginDate'
            //退出
            form.on('submit(Exit)', function (data) {//
                if (linterid == undefined) {
                    //关闭页签
                    Pub_Close(2);
                }
                else {
                    //关闭页签
                    Pub_Close(1);
                }
            });
            laydate.render({
                elem: '#HRepairEndDate'
            //保存
            form.on('submit(Saver)', function (data) {
                var sMainStr = JSON.stringify(data.field);
                var sSubStr = JSON.stringify(table.cache['mainTable']);
                var sMainSub = sMainStr + ';' + sSubStr + ';' + sessionStorage["HUserName"];
                //对数据进行验证
                if (AllowLoadData(sSubStr)) {
                    $.ajax(
                        {
                            type: "POST",
                            url: GetWEBURL() + "/Sc_MouldRepairCheckBill/SaveGetMouldRepairCheckBillList", //方法所在页面和方法名
                            async: true,
                            data: { "msg": sMainSub },
                            dataType: "json",
                            success: function (data) {
                                if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                                    layer.msg(data.Message, { time: 1 * 1000, icon: 1 }, function () {
                                        $('#add-btn').addClass("layui-btn-disabled").attr("disabled", true);
                                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                        parent.layer.close(index); //再执行关闭 Â  Â  Â  Â  Â Â  Â Â Â  Â 
                                    });
                                }
                                else {
                                    layer.msg(data.Message);
                                    console.log("Reason" + sMainStr + "sub:" + JSON.stringify(layui.table.cache.mainTable));
                                }
                                layer.closeAll("loading");
                            },
                            error: function (err) {
                                layer.msg("错误:" + err.Message);
                            }
                        });
                }
            });
            //判断是否登录 æœªç™»å½•则跳到登录页
            //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 = {
                elem: '#mainTable'
                , toolbar: '#toolbarDemo'
                , height: 500
                //,url: '/demo/table/user/' //数据接口
                , page: true //开启分页
                , cols: [[ //表头
            //#endregion
           //#region  å½“前页页面所有方法
            //初始化表单插件
            function set_InitFrom() {
                //常规用法
                laydate.render({
                    elem: '#HDate'
                });
                laydate.render({
                    elem: '#HRepairBeginDate'
                });
                laydate.render({
                    elem: '#HRepairEndDate'
                });
            }
            //初始化表格
            function set_InitGrid() {
                //表头
                columns = [
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao', title: '序号', sort: true, fixed: 'left', event: "qwe" }
                    , { field: 'HRepairCheckID', title: 'HRepairCheckID', edit: 'text', hide: true }
                    , { field: 'HRepairCheckCode', title: '验收项目代码', edit: 'text', event: "HRepairCheckCode"}
                    , { field: 'HRepairCheckName', title: '验收项目', edit: 'text'}
                    , { field: 'HRepairCheckCode', title: '验收项目代码', edit: 'text', event: "HRepairCheckCode" }
                    , { field: 'HRepairCheckName', title: '验收项目', edit: 'text' }
                    , { field: 'HRepairCheckContent', title: '验收内容', edit: 'text' }
                    , { field: 'HManagerID', title: 'HManagerID', edit: 'text', hide: true}
                    , { field: 'HManagerCode', title: '负责人代码', edit: 'text', event: "HManagerCode"}
                    , { field: 'HManagerID', title: 'HManagerID', edit: 'text', hide: true }
                    , { field: 'HManagerCode', title: '负责人代码', edit: 'text', event: "HManagerCode" }
                    , { field: 'HManagerName', title: '负责人', edit: 'text' }
                    , { field: 'HRemark', title: '备注', event: "", edit: 'text' }
                    , { 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 = [{ "HRepairCheckID": 0, "HRepairCheckCode": "", "HRepairCheckName": "  ", "HRepairCheckContent": "   ", "HManagerID": 0,"HManagerCode":"", "HManagerName": "  ", "HRemark": "  " }];
                ];
                option = {
                    id: 'mainTable'
                    , elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , page: false
                    , cellMinWidth: 120
                    , height: 500
                    , cols: [columns]
                    , done: function (res, curr, count) {
                    }
                };
            }
            //无源单新增
            function set_AddFNew() {
                //获取最大单据号
                get_MAXNum();
                option.data = [TabRow];
                table.render(option);
            }
            else {
                $("#HInterID").val(hID);//修改时主表ID
            //获取最大单据号及默认值赋值
            function get_MAXNum() {
                //获取最大单据号 new
                $("#HInterID").val("0");
                $("#HBillNo").val("");
                $.ajax({
                    url: GetWEBURL() + "/Web/GetMAXNum",
                    type: "GET",
                    data: { "HBillType": sBillType },
                    success: function (d) {
                        $("#HBillNo").val(d.data[0].HBillNo);
                        $("#HDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                        $("#HCheckBeginDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                        $("#HInterID").val(0);
                    }
                });
            }
            //编辑
            function set_EditFromGrid() {
                set_EditForm(linterid);  //编辑获取表头
                set_EditGrid(linterid);  //编辑获取表体
                option.data = [TabRow];
                table.render(option);
            }
            //编辑加载表头
            function set_EditForm(linterid) {
                //查询检验方案单是否存在
                $.ajax({
                    url: GetWEBURL() + "Sc_MouldRepairCheckBill/Sb_MouldRepairCheckBillListCheckDetai",
                    type: "GET",
                    data: {
                        "HID": linterid
                    },
                    success: function (result) {
                        if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            var data = result.data.h_v_Sc_MouldRepairCheckBillList_Edit[0];
                            form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                                "HBillNo": data.单据号
                                , "HDate": formatDate(data.日期)
                                , "HInnerBillNo": data.内部单据号
                                , "HMouldID": data.HMouldID            //模具ID
                                , "HName": data.产品模具               //模具名称
                                , "HCheckResult": data.验收结论
                                , "HEmpID": data.HEmpID                //验收人ID
                                , "HEmpName": data.验收人              //验收人名称
                                , "HCheckBeginDate": formatDate(data.维修日期)
                                , "HDeptID": data.HDeptID              //验收部门ID
                                , "HDeptName": data.验收部门             //验收部门
                                , "HManagerID": data.HManagerID          //负责人ID
                                , "HManagerName": data.负责人            //负责人ID
                                , "HExplanation": data.摘要
                                , "HRemark": data.备注
                            });
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });
                    }
                })
            }
            // ç¼–辑获取表体
            function set_EditGrid(linterid) {
                $("#HInterID").val(linterid);//修改时主表ID
                //编辑加载数据
                $.ajax({
                    url: GetWEBURL() + 'Sc_MouldRepairCheckBill/Sb_MouldRepairCheckBillListProjectDetai',
                    type: "GET",
                    //data: { "sqlWhere": "and HInterID=" + hID },
                    data: { "sqlWhere": "and hmainid=" + hID },
                    //data: { "sqlWhere": "and HInterID=" + hID },
                    data: { "sqlWhere": "and hmainid=" + linterid },
                    success: function (result) {
                        //console.log('gouba' + result);
                        if (result.count == 1) {
@@ -261,48 +583,50 @@
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //头工具栏事件
            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 = { "HRepairCheckID": 0, "HRepairCheckCode": "", "HRepairCheckName": "  ", "HRepairCheckContent": "   ", "HManagerID": 0,"HManagerCode":"", "HManagerName": "  ", "HRemark": "  " };
                switch (obj.event) {
                    case 'btn-AddLine':
                        //table.cache["mainTable"].push(AddRow[rows]);
                        table.cache["mainTable"].push(NewRow);
                        option.data = table.cache["mainTable"];
                        table.render(option);
                        rows++;
                        layer.msg('增加一行按钮!')
                        break;
                    case 'btn-CopyLine':
                        var copydata = JSON.stringify(data);
                        if (data.length <= 0) {
                            layer.alert("请选择需要复制的一行!");
                        }
                        else if (data.length > 1) {
                            layer.alert("只能选择复制一行!");
                        }
                        else {
                            var copydata2 = copydata.substring(1, copydata.length);//去除首行字符'['
                            var copyrow = copydata2.substring(0, copydata2.length - 1);//去除末尾字符']'
                            table.cache["mainTable"].push(JSON.parse(copyrow));//将复制的行强转成json追加到表格上
                            option.data = table.cache["mainTable"];//将数据绑定到data上
                            table.render(option);//将数据渲染到表格上
                            //layer.alert(copyrow);
                        }
                        break;
            // ç¼–辑获取表头时时间格式矫正方式
            function formatDate(date) {
                var d = new Date(date),
                    month = '' + (d.getMonth() + 1),
                    day = '' + d.getDate(),
                    year = d.getFullYear();
                if (month.length < 2) month = '0' + month;
                if (day.length < 2) day = '0' + day;
                return [year, month, day].join('-');
            }
            //增加一行
            function set_AddLine(NewRow) {
                table.cache["mainTable"].push(NewRow);
                option.data = table.cache["mainTable"];
                table.render(option);
            }
            //复制一行
            function set_CopyLine(data) {
                var copydata = JSON.stringify(data);
                if (data.length <= 0) {
                    layer.alert("请选择需要复制的一行!");
                }
            });
            //行内事件
            table.on('tool(mainTable)', function (obj) {
                else if (data.length > 1) {
                    layer.alert("只能选择复制一行!");
                }
                else {
                    var copydata2 = copydata.substring(1, copydata.length);//去除首行字符'['
                    var copyrow = copydata2.substring(0, copydata2.length - 1);//去除末尾字符']'
                    table.cache["mainTable"].push(JSON.parse(copyrow));//将复制的行强转成json追加到表格上
                    option.data = table.cache["mainTable"];//将数据绑定到data上
                    table.render(option);//将数据渲染到表格上
                    //layer.alert(copyrow);
                }
            }
            //行内删除
            function set_GridDelete(obj) {
                var data = obj.data;
                var rowIndex = $(obj.tr).attr("data-index");
                if (obj.event === 'del') {
@@ -320,7 +644,10 @@
                        }
                    });
                }
            }
            //行内事件快捷键筛选
            function set_GridCellCheck(obj) {
                $(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {
                    if (event.key == "F7") {
                        if (obj.event === 'HRepairCheckCode')  //验收项目代码
@@ -363,7 +690,6 @@
                                }
                            });
                        }
                        if (obj.event === 'HManagerCode')  //负责人信息
                        {
                            //页面层-自定义
@@ -410,458 +736,65 @@
                    }
                })
            });
            function RoadBillMain(hID)//加载表头
            {
                alert(hID);
                //查询检验方案单是否存在
                $.ajax({
                    url: GetWEBURL() + "Sc_MouldRepairCheckBill/Sb_MouldRepairCheckBillListCheckDetai",
                    type: "GET",
                    data: {
                        "HID": hID
                    },
                    success: function (result) {
                        if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            var data = result.data.h_v_Sc_MouldRepairCheckBillList_Edit[0];
                            form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                                "HBillNo": data.单据号
                                , "HDate": formatDate(data.日期)
                                , "HInnerBillNo": data.内部单据号
                                , "HMouldID": data.HMouldID            //模具ID
                                , "HName": data.产品模具               //模具名称
                                , "HCheckResult": data.验收结论
                                , "HEmpID": data.HEmpID                //验收人ID
                                , "HEmpName": data.验收人              //验收人名称
                                , "HCheckBeginDate": formatDate(data.维修日期)
                                , "HDeptID": data.HDeptID              //验收部门ID
                                , "HDeptName": data.验收部门             //验收部门
                                , "HManagerID": data.HManagerID          //负责人ID
                                , "HManagerName": data.负责人            //负责人ID
                                , "HExplanation": data.摘要
                                , "HRemark": data.备注
                            });
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
            }
            var date = new Date();
            var day = date.getDate();
            var month = date.getMonth() + 1;
            var year = date.getFullYear();
            var shijian = year + "-" + month + "-" + day;
            //#endregion
            //判断是否新增
            if (hID == null || hID == 0) {
                //获取最大单据号 new
                $("#HInterID").val("0");
                $("#HBillNo").val("");
                $.ajax({
                    url: GetWEBURL() + "/Web/GetMAXNum",
                    type: "GET",
                    data: { "HBillType": '3817' },
                    success: function (d) {
                        //console.log(d.data);
                        $("#HBillNo").val(d.data[0].HBillNo);
                        $("#HDate").val(shijian);
                        $("#HCheckBeginDate").val(shijian);
                        $("#HInterID").val(0);
                    }
                });
            }
            else {//如果修改则走下面 new
                RoadBillMain(hID);
                /* RoadBillSub(linterid);*/
            }
            //成品模具弹窗
            form.on('submit(ProductModulList)', function () {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '成品模具列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/MouldInformation.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('请选择数据');
                        }
                        $("#HName").val(checkStatus.data[0].HName);
                        $("#HMouldID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                    },
                    end: function () {
                    },
                    success: function (layero, index) {
                    }
                });
            });
            //表头信息验收人弹窗
            form.on('submit(HEmpList)', function () {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '人员列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/UserInformation.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('请选择数据');
                        }
                        $("#HEmpName").val(checkStatus.data[0].HName);
                        $("#HEmpID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                    },
                    end: function () {
                    },
                    success: function (layero, index) {
                    }
                });
            });
            //表头信息验收部门弹窗
            form.on('submit(Department)', function () {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '部门列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/DeptInformation.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('请选择数据');
                        }
                        $("#HDeptName").val(checkStatus.data[0].HName);
                        $("#HDeptID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                    },
                    end: function () {
                    },
                    success: function (layero, index) {
                    }
                });
            });
            //表头信息负责人弹窗
            form.on('submit(HManagerList)', function () {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '人员列表',
                    closeBtn: 1,
                    shift: 2,
                    area: ['80%', '80%'],
                    maxmin: true,
                    content: ['../../PublicPage/UserInformation.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('请选择数据');
                        }
                        $("#HManagerName").val(checkStatus.data[0].HName);
                        $("#HManagerID").val(checkStatus.data[0].HItemID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                    },
                    end: function () {
                    },
                    success: function (layero, index) {
                    }
                });
            });
            form.on('submit(Exit)', function (data) {//
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            });
            //选择责任人
            form.on('submit(HEmployeeID-BT)', function () {//选择责任人
                layer.open({
                    type: 2
                    , area: ['80%', '80%']
                    , title: '职员列表'
                    , shade: 0.6 //遮罩透明度
                    , maxmin: true //允许全屏最小化
                    , anim: 0 //0-6的动画形式,-1不开启
                    , content: ['../../../views/Baseset/基础资料/Gy_EmployeeList.html?Type=HKeeper', 'yes']
                    , resize: false
                    , cancel: function () {
                        //$(".layui-btn").removeClass("layui-btn-disabled");
                    }
                })
            });
            //选择责任工序
            form.on('submit(HZRProcID-BT)', function () {//选择责任工序
                layer.open({
                    type: 2
                    , area: ['80%', '80%']
                    , title: '责任工序列表'
                    , shade: 0.6 //遮罩透明度
                    , maxmin: true //允许全屏最小化
                    , anim: 0 //0-6的动画形式,-1不开启
                    , content: ['../../../views/Baseset/基础资料/Gy_ProcList.html?Type=HZR', 'yes']
                    , resize: false
                    , cancel: function () {
                        //$(".layui-btn").removeClass("layui-btn-disabled");
                    }
                })
            });
            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),
                    day = '' + d.getDate(),
                    year = d.getFullYear();
                if (month.length < 2) month = '0' + month;
                if (day.length < 2) day = '0' + day;
                return [year, month, day].join('-');
            }
            form.on('submit(Saver)', function (data) {//保存
                //debugger;
                var sMainStr = JSON.stringify(data.field);
                var sSubStr = JSON.stringify(table.cache['mainTable']);
                var sMainSub = sMainStr + ';' + sSubStr;
                $.ajax(
                    {
                        type: "POST",
                        url: GetWEBURL() + "/Sc_MouldRepairCheckBill/SaveGetMouldRepairCheckBillList", //方法所在页面和方法名
                        async: true,
                        data: { "msg": sMainSub },
                        dataType: "json",
                        success: function (data) {
                            if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                                layer.msg(data.Message, { time: 1 * 1000, icon:1 }, function () {
                                    $('#add-btn').addClass("layui-btn-disabled").attr("disabled", true);
                                    var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                                    parent.layer.close(index); //再执行关闭 Â  Â  Â  Â  Â Â  Â Â Â  Â 
                                });
                            }
                            else {
                                f_alert(data.Message);
                                console.log("Reason" + sMainStr + "sub:" + JSON.stringify(layui.table.cache.mainTable));
                            }
                            layer.closeAll("loading");
                        },
                        error: function (err) {
                            f_alert("错误:" + err);
                            console.log("Reason" + sMainStr);
                        }
                    });
            });
            function f_alert(sMsg) {
                layer.alert(sMsg, { icon: 5 });
            }
            //监听提交
            form.verify({
                numberOrEmpty: function (value, item) {
                    // if (value != '') {
                    if (!/^\d+$/.test(value)) {
                        return '不能为空或数字或者0';
                    }
                    //}
                }
            });
        });
        //定义全局变量
        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) {  //非空验证
            //if ($("#HSourceBillNo").val() == '') {
            //    layer.msg("请先扫源单!", { icon: 5 });
            //    return false;
            //判断是否登录 æœªç™»å½•则跳到登录页
            //if (sessionStorage.login != "login") {
            //    layer.confirm("登录失效,请重新登录!", {
            //        icon: 4, skin: 'layui-layer-lan', title: "温馨提示", closeBtn: 0, btn: ['重新登录']
            //    }, function () { window.location.href = "../../user/login.html"; });
            //}
            if ($("#HDeptName").val() == '') {
                layer.msg("部门没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
        });
        //数据验证
        function AllowLoadData(sSubStr) {  //非空验证
            if ($("#HMouldID").val() == '' && $("#HName").val() == '') {
                layer.msg("产品模具没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            if ($("#HSecManager").val() == '') {
            if ($("#HEmpID").val() == '' && $("#HEmpName").val() == '') {
                layer.msg("验收人没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            if ($("#HKeeper").val() == '') {
                layer.msg("保管人没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
            if ($("#HDeptID").val() == '' && $("#HDeptName").val() == '') {
                layer.msg("验收部门没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            //if ($("#HWHNAME").val() == '') {
            //    layer.msg("仓库没有选择!", { icon: 5 });
            //    return false;
            //}
            if ($("#HBillNo").val() == '') {
                layer.msg("错误的单据号", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
            if ($("#HManagerID").val() == '' && $("#HManagerName").val() == '') {
                layer.msg("负责人没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            if ($("#HInterID").val() == '') {
                layer.msg("错误的内码", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
            //判断物料明细项
            if (typeof (sSubStr) == "undefined" || sSubStr == "" || sSubStr == "[]") {
                layer.msg("没有明细记录", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            if (typeof (sSubStr) == "undefined") {
                layer.msg("没有物料明细记录", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            if (!typeof (sSubStr) == "undefined") {
                //for (var i = 0; i <= sSubStr.length - 1; i++) {  //判断扫码数量不能大于应收数量
                //    if (parseFloat(sSubStr[i].HQtyMust) > 0) {
                //        if (parseFloat(sSubStr[i].HQty) > parseFloat(sSubStr[i].HQtyMust))
                //        {
                //            layer.msg("数量不能大于应收数量", { icon: 5, btn: ['确定'], time: 100000, offset: 't' });
                //            return false;
                //        }
                //    }
                //}
                for (var i = 0; i <= sSubStr.length - 1; i++) {   //判断扫码数量不能为0
                    if (parseFloat(sSubStr[i].HQty) > 0) {
                        s = 1;
            if (typeof (sSubStr) != "undefined" && typeof (sSubStr) != "") {
                sSubStr = JSON.parse(sSubStr);
                for (var i = 0; i < sSubStr.length; i++) {
                    if (sSubStr[i].HRepairCheckCode == "") {
                        layer.msg("明细记录第" + (i + 1) + "行,验收项目代码信息为空!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                        return false;
                    }
                }
                if (s == 0) {
                    layer.msg("产品入库记录未扫码", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return false;
                    if (sSubStr[i].HManagerCode == "") {
                        layer.msg("明细记录第" + (i + 1) + "行,负责人代码信息为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                        return false;
                    }
                    else {
                        return true;
                    }
                }
            }
            else {
                return true;
            }
        }</script>
        }
    </script>
</body>
</html>
WebTM/views/Ä£Öξ߹ÜÀí/Ä£Öξ߹ÜÀí/Sc_MouldConkBookBillList.html
@@ -220,7 +220,7 @@
                        , { field: '行关闭人', title: '行关闭人', width: 115 }
                        , { field: '关闭类型', title: '关闭类型', width: 200 }
                        , { field: '表体备注', title: '表体备注', width: 200, hide: true }
                        , { field: '制单人', title: '制单人', width: 115, hide: true }
                        , { field: '制单人', title: '制单人', width: 115}
                        , { field: '制单日期', title: '制单日期', width: 200, templet: "<div>{{d.制单日期 ==null ?'':layui.util.toDateString(d.制单日期, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                        , { field: '审核人', title: '审核人', width: 200 }
                        , { field: '审核日期', title: '审核日期', width: 200, templet: "<div>{{d.审核日期 ==null ? '':layui.util.toDateString(d.审核日期, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
@@ -241,7 +241,7 @@
            //查询
            function get_Display(sWhere) {
                var index = layer.load(0, { shade: false });
                var index = layer.load();//遮罩
                //进入页面显示的缓存列表
                $.ajax({
                    url: GetWEBURL() + '/Sc_MouldConkBookBill/GetMouldConkBookBillList',
@@ -270,16 +270,16 @@
                var BenginHCreateDate = $("#BenginHCreateDate").val();//开始制单时间
                var EndHCreateDate = $("#EndHCreateDate").val();//结束制单时间
                if (HBillNo) {
                    sWhere += " and HBillNo like '%" + HBillNo + "%'";
                    sWhere += " and å•据号 like '%" + HBillNo + "%'";
                }
                if (HCreateBy) {
                    sWhere += " and HCreateBy like '%" + HCreateBy + "%'";
                    sWhere += " and åˆ¶å•人 like '%" + HCreateBy + "%'";
                }
                if (BenginHCreateDate) {
                    sWhere += " and CONVERT(varchar(100),HCreateDate, 23) >= '" + BenginHCreateDate + "'";
                    sWhere += " and CONVERT(varchar(100),日期, 23) >= '" + BenginHCreateDate + "'";
                }
                if (EndHCreateDate) {
                    sWhere += " and CONVERT(varchar(100),HCreateDate, 23) <= '" + EndHCreateDate + "'";
                    sWhere += " and CONVERT(varchar(100),日期, 23) <= '" + EndHCreateDate + "'";
                }
                get_Display(sWhere);
                sWhere = "";//调用接口后清空sWhere缓存
@@ -296,7 +296,7 @@
                    shift: 2,
                    area: ['100%', '100%'],
                    maxmin: true,
                    content: '../模治具管理/Sc_Add_MouldConkBookBillList.html',
                    content: '../模治具管理/Sc_Add_MouldConkBookBillList.html?OperationType=1&linterid=&HSouceBillType=',
                    end: function () {
                        //刷新页面,
                        location.reload();
@@ -312,7 +312,7 @@
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                if (checkStatus.data.length === 1) {
                    var hID = data[0].hmainid.toString();
                    var linterid = data[0].hmainid.toString();
                    //if (AllowLoadData(sSubStr) != false) {//非空验证
                    layer.open({
                        type: 2
@@ -322,7 +322,7 @@
                        , shade: 0.6 //遮罩透明度
                        , maxmin: true //允许全屏最小化
                        , anim: 0 //0-6的动画形式,-1不开启
                        , content: '../模治具管理/Sc_Add_MouldConkBookBillList.html?hID=' + hID
                        , content: '../模治具管理/Sc_Add_MouldConkBookBillList.html?OperationType=3&linterid=' + linterid + '&HSouceBillType='
                        , resize: false,
                        end: function () {
                            //刷新页面,
WebTM/views/Ä£Öξ߹ÜÀí/Ä£Öξ߹ÜÀí/Sc_MouldRepairCheckBillList.html
@@ -37,7 +37,7 @@
                                            <option value="ZHSJ">上架归还单</option>
                                        </select>
                                    </div>
                                </div>
                                </div>-->
                                <div class="layui-inline">
                                    <label class="layui-form-label">单据号</label>
                                    <div class="layui-input-block">
@@ -49,39 +49,40 @@
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" name="HCreateBy" id="HCreateBy">
                                    </div>
                                </div>-->
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">开始时间</label>
                                    <div class="layui-input-block">
                                        <input type="date" class="layui-input" name="BenginHCreateDate" id="BenginHCreateDate">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">结束时间</label>
                                    <div class="layui-input-block">
                                        <input type="date" class="layui-input" name="EndHCreateDate" id="EndHCreateDate">
                                    </div>
                                </div>
                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnSearch" id="btnSearch">
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                </button>
                                <!--<button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnReSearch" id="btnReSearch" style="padding:0 5px">重置</button>-->
                                <!--<div class="layui-colla-content">
                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnReSearch" id="btnReSearch" style="padding:0 5px">重置</button>
                                <div class="layui-colla-content">
                                    <div class="layui-inline">
                                        <div class="layui-inline">
                                            <span>其他条件></span>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">开始时间</label>
                                        <div class="layui-input-block">
                                            <input type="date" class="layui-input" name="BenginHCreateDate" id="BenginHCreateDate">
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">结束时间</label>
                                        <div class="layui-input-block">
                                            <input type="date" class="layui-input" name="EndHCreateDate" id="EndHCreateDate">
                                        </div>
                                    </div>
                                </div>-->
                                </div>
                            </div>
                        </div>
                        <table class="" id="mainTable" lay-filter="mainTable"></table>
                        <script type="text/html" id="toolbarDemo">
                            <div class="layui-btn-container">
                                <!--<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-getCheckData"><i class="layui-icon layui-icon-tips"></i>预览</button>-->
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Add"><i class="layui-icon layui-icon-add-1"></i>新增</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Edit"><i class="layui-icon layui-icon-edit"></i>编辑</button>
                                <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="btnAdd"><i class="layui-icon layui-icon-add-1"></i>新增</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btnModify"><i class="layui-icon layui-icon-edit"></i>编辑</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btndelete"><i class="layui-icon layui-icon-delete"></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>
@@ -106,6 +107,7 @@
        }).extend({
            index: 'lib/index', //主入口模块
        }).use(['index', 'form', 'table', 'element', 'laypage', 'laydate'], function () {
            //#region å…¬å…±å˜é‡
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
@@ -117,254 +119,272 @@
                , util = layui.util
            //查询条件
            var sWhere = "";
            var option = [];
            //#endregion
            var option = {
                elem: '#mainTable'
                , toolbar: '#toolbarDemo'
                , height: 'full-50'
                , page: true
                , cellMinWidth: 90
                , cols: [[
                    { type: 'checkbox', fixed: 'left' }
                    , { field: 'hmainid', title: '单据ID', hide: true }
                    , { field: '日期', title: '日期', width: 160, templet: "<div>{{d.日期 ==null ?'':layui.util.toDateString(d.日期, 'yyyy-MM-dd')}}</div>" }
                    , { field: '单据号', title: '单据号', width: 160 }
                    , { field: '单据类型', title: '单据类型', width: 160, hide: true }
                    , { field: 'HEmpID', title: 'HEmpID', width: 200, hide: true }
                    , { field: '验收人代码', title: '验收人代码', width: 200 }
                    , { field: '验收人', title: '验收人', width: 200 }
                    , { field: '负责人代码', title: '负责人代码', width: 200 }
                    , { field: '负责人', title: '负责人', width: 200 }
                    , { field: 'HDeptID', title: 'HDeptID', width: 200, hide: true }
                    , { field: '验收部门代码', title: '验收部门代码', width: 200 }
                    , { field: '验收部门', title: '验收部门', width: 160 }
                    , { field: 'HMouldID', title: 'HMouldID', width: 160, hide: true }
                    , { field: '产品模具代码', title: '产品模具代码', width: 160 }
                    , { field: '产品模具', title: '产品模具', width: 200, hide: true }
                    , { field: '维修日期', title: '维修日期', width: 200, templet: "<div>{{d.维修日期 ==null ?'':layui.util.toDateString(d.维修日期, 'yyyy-MM-dd')}}</div>"}
                    , { field: '验收结论', title: '验收结论', width: 200 }
                    , { field: '摘要', title: '摘要', width: 200 }
                    , { field: '内部单据号', title: '内部单据号', width: 200 }
                    , { field: '备注', title: '备注', width: 200 }
                    , { field: 'hsubid', title: 'hsubid', width: 200, hide: true }
                    , { field: '关联数量', title: '关联数量', width: 115, hide: true }
                    , { field: '行关闭人', title: '行关闭人', width: 115 }
                    , { field: '关闭类型', title: '关闭类型', width: 200 }
                    , { field: '表体备注', title: '表体备注', width: 200, hide: true }
                    , { field: '制单人', title: '制单人', width: 115, hide: true }
                    , { field: '制单日期', title: '制单日期', width: 200, templet: "<div>{{d.制单日期 ==null ?'':layui.util.toDateString(d.制单日期, 'yyyy-MM-dd')}}</div>"}
                    , { field: '审核人', title: '审核人', width: 200 }
                    , { field: '审核日期', title: '审核日期', width: 200, hide: true, templet: "<div>{{d.审核日期 ==null ?'':layui.util.toDateString(d.审核日期, 'yyyy-MM-dd')}}</div>" }
                    , { field: '修改人', title: '修改人', width: 200, hide: true }
                    , { field: '修改日期', title: '修改日期', width: 115, hide: true, templet: "<div>{{d.修改日期 ==null ?'':layui.util.toDateString(d.修改日期, 'yyyy-MM-dd')}}</div>"}
                    , { field: '关闭人', title: '关闭人', width: 200 }
                    , { field: '关闭日期', title: '关闭日期', width: 200, templet: "<div>{{d.关闭日期 ==null ?'':layui.util.toDateString(d.关闭日期, 'yyyy-MM-dd')}}</div>"}
                    , { field: '作废人', title: '作废人', width: 200, hide: true }
                    , { field: '作废日期', title: '作废日期', width: 115, hide: true, templet: "<div>{{d.作废日期 ==null ?'':layui.util.toDateString(d.作废日期, 'yyyy-MM-dd')}}</div>"}
                    , { field: '源单主内码', title: '源单主内码', width: 200, hide: true }
                    , { field: '源单子内码', title: '源单子内码', width: 200, hide: true }
                    , { field: '源单单号', title: '源单单号', width: 200 }
                    , { field: '源单类型', title: '源单类型', width: 200 }
                    , { field: 'hbilltype', title: 'hbilltype', width: 200 }
                    , { field: 'HRepairCheckID', title: 'HRepairCheckID', width: 200, hide: true }
                    , { field: '验收项目代码', title: '验收项目代码', width: 115 }
                    , { field: '验收项目', title: '验收项目', width: 200 }
                    , { field: '验收内容', title: '验收内容', width: 200 }
                    , { field: 'HManagerID', title: 'HManagerID', width: 200, hide: true }
                    , { field: '子负责人代码', title: '子负责人代码', width: 200 }
                    , { field: '子负责人', title: '子负责人', width: 200 }
                ]]
            };
            //#region è¿›å…¥é¡µé¢æ—¢åŠ è½½
            //初始化界面
            set_ClearBill();
            //#endregion
            var index = layer.load(0);
            //#region è§¦å‘事件:包括form.on(){}格式的所有点击事件、选择事件
            //头工具栏事件
            table.on('toolbar(mainTable)', function (obj) {
                var checkStatus = table.checkStatus(obj.config.id);
                switch (obj.event) {
                    case 'btn-Add':
                        //页面层-自定义
                        layer.open({
                            type: 2,
                            skin: 'layui-layer-rim', //加上边框
                            title: '新增模具维修验收单',
                            closeBtn: 1,
                            shift: 2,
                            area: ['100%', '100%'],
                            maxmin: true,
                            content: '../模治具管理/Sc_Add_MouldRepairCheckBillList.html',
                            end: function () {
                                //刷新页面,
                                location.reload();
                            },
                            success: function (layero, index) {
                            }
                        });
                    //新增
                    case 'btnAdd': set_AddNew();
                        break;
                    case 'btn-Edit':
                        var checkStatus = table.checkStatus('mainTable')
                            , data = checkStatus.data;
                        if (checkStatus.data.length === 1) {
                            var hID = data[0].hmainid.toString();
                            //if (AllowLoadData(sSubStr) != false) {//非空验证
                            layer.open({
                                type: 2
                                , area: ['100%', '100%']
                                , title: '编辑模具维修验收单'
                                , closeBtn: 1
                                , shade: 0.6 //遮罩透明度
                                , maxmin: true //允许全屏最小化
                                , anim: 0 //0-6的动画形式,-1不开启
                                , content: '../模治具管理/Sc_Add_MouldRepairCheckBillList.html?hID=' + hID
                                , resize: false,
                                end: function () {
                                    //刷新页面,
                                    location.reload();
                                }
                                , cancel: function () {
                                    //$(".layui-btn").removeClass("layui-btn-disabled");
                                }
                            })
                        } else {
                            layer.msg('请选择一行数据编辑!');
                        }
                    //编辑
                    case 'btnModify': set_ShowBill();
                        break;
                    case 'btn-Delete':
                        var checkStatus = table.checkStatus('mainTable')
                            , data = checkStatus.data;
                        if (checkStatus.data.length === 1) {
                            var InterID = data[0].hmainid.toString();
                            //逻辑删除方法
                            layer.confirm("确认要删除吗,删除后不能恢复", { title: "删除确认" }, function (index) {
                                $.ajax({
                                    type: "GET",
                                    url: GetWEBURL() + "/Sc_MouldRepairCheckBill/DeltetMouldRepairCheckBill", //方法所在页面和方法名
                                    data: { "HInterID": InterID },
                                    success: function (result) {
                                        if (result.count == 1) {
                                            layer.msg(result.Message, { time: 1 * 1000, icon: 1 }, function () {
                                                // å¾—到frame索引
                                                var index = layer.getFrameIndex(window.name);
                                                //关闭当前frame
                                                layer.close(index);
                                                //修改为功后刷新界面
                                                window.location.reload();
                                            });
                                        } else {
                                            layer.alert(result.code + result.Message, { icon: 5 });
                                        }
                                    }, error: function () {
                                        layer.alert("接口请求失败!", { icon: 5 });
                                    }
                                });
                            })
                        }
                        else {
                            layer.msg('请选择一行数据删除!');
                        }
                    //删除
                    case 'btndelete': set_DeleteBill();
                        break;
                    //禁用
                    case 'btnJY': set_AuditBill();
                        break;
                    //反禁用
                    case 'btnFJY': set_DeAuditBill();
                        break;
                };
            });
            //进入页面显示的缓存列表
            $.ajax({
                //url: "http://61.130.49.162:9090/WMSAPI///Web/GetMAXNum",
                url: GetWEBURL() + '/Sc_MouldRepairCheckBill/GetMouldRepairCheckBillList',
                type: "GET",
                data: { "sWhere": sWhere},
                success: function (data1) {
                    if (data1.count == 1) {
                        option.data = data1.data;
                        table.render(option);
                        layer.close(index);
                    } else {
                        layer.close(index);
                        layer.alert(data1.code + data1.Message, { icon: 5 });
                    }
                }, error: function () {
                    layer.close(index);
                    layer.alert("接口请求失败!", { icon: 5 });
                }
            //查询按钮
            form.on('submit(btnSearch)', function (data) {
                get_FastQuery();
            });
            //重置按钮
            //form.on('submit(btnReSearch)', function (data) {
            //    $("#HBillType").val("");//单据类型
            //    $("#HBillNo").val("");//单据号
            //    $("#HSourceBillNo").val("");//源单号
            //    $("#HCreateBy").val("");//制单人
            //    $("#BenginHCreateDate").val("");//开始制单时间
            //    $("#EndHCreateDate").val("");//结束制单时间
            //    $("#btnSearch").click();
            //});
            // é‡ç½®æŒ‰é’®
            form.on('submit(btnReSearch)', function (data) {
                set_ClearQuery();
            });
            //#endregion
            //查询按钮
            form.on('submit(btnSearch)', function (data) {//选择仓位
                //var HBillType = $("#HBillType").val();//单据类型
                //var HBillNo = $("#HBillNo").val();//单据号
                //var HCreateBy = $("#HCreateBy").val();//制单人
                //var BenginHCreateDate = $("#BenginHCreateDate").val();//开始制单时间
                //var EndHCreateDate = $("#EndHCreateDate").val();//结束制单时间
                //if (HBillNo) {
                //    sWhere += " and HBillNo like '%" + HBillNo + "%'";
                //}
                //if (HCreateBy) {
                //    sWhere += " and HCreateBy like '%" + HCreateBy + "%'";
                //}
                //if (BenginHCreateDate) {
                //    sWhere += " and CONVERT(varchar(100),HCreateDate, 23) >= '" + BenginHCreateDate + "'";
                //}
                //if (EndHCreateDate) {
                //    sWhere += " and CONVERT(varchar(100),HCreateDate, 23) <= '" + EndHCreateDate + "'";
                //}
                var index = layer.load(0);
            //#region æ­¤é¡µé¢æ‰€æœ‰æ–¹æ³•
            // åˆå§‹åŒ–界面
            function set_ClearBill() {
                //初始化表格
                set_InitGrid();
                //查询
                get_Display(sWhere);
            }
            //初始化表格
            function set_InitGrid() {
                option = {
                    elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , height: 'full-50'
                    , page: true
                    , cellMinWidth: 90
                    , cols: [[
                        { type: 'checkbox', fixed: 'left' }
                        , { field: 'hmainid', title: '单据ID', hide: true }
                        , { field: '日期', title: '日期', width: 160, templet: "<div>{{d.日期 ==null ?'':layui.util.toDateString(d.日期, 'yyyy-MM-dd')}}</div>" }
                        , { field: '单据号', title: '单据号', width: 160 }
                        , { field: '单据类型', title: '单据类型', width: 160, hide: true }
                        , { field: 'HEmpID', title: 'HEmpID', width: 200, hide: true }
                        , { field: '验收人代码', title: '验收人代码', width: 200 }
                        , { field: '验收人', title: '验收人', width: 200 }
                        , { field: '负责人代码', title: '负责人代码', width: 200 }
                        , { field: '负责人', title: '负责人', width: 200 }
                        , { field: 'HDeptID', title: 'HDeptID', width: 200, hide: true }
                        , { field: '验收部门代码', title: '验收部门代码', width: 200 }
                        , { field: '验收部门', title: '验收部门', width: 160 }
                        , { field: 'HMouldID', title: 'HMouldID', width: 160, hide: true }
                        , { field: '产品模具代码', title: '产品模具代码', width: 160 }
                        , { field: '产品模具', title: '产品模具', width: 200, hide: true }
                        , { field: '维修日期', title: '维修日期', width: 200, templet: "<div>{{d.维修日期 ==null ?'':layui.util.toDateString(d.维修日期, 'yyyy-MM-dd')}}</div>" }
                        , { field: '验收结论', title: '验收结论', width: 200 }
                        , { field: '摘要', title: '摘要', width: 200 }
                        , { field: '内部单据号', title: '内部单据号', width: 200 }
                        , { field: '备注', title: '备注', width: 200 }
                        , { field: 'hsubid', title: 'hsubid', width: 200, hide: true }
                        , { field: '关联数量', title: '关联数量', width: 115, hide: true }
                        , { field: '行关闭人', title: '行关闭人', width: 115 }
                        , { field: '关闭类型', title: '关闭类型', width: 200 }
                        , { field: '验收项目代码', title: '验收项目代码', width: 115 }
                        , { field: '验收项目', title: '验收项目', width: 200 }
                        , { field: '验收内容', title: '验收内容', width: 200 }
                        , { field: 'HManagerID', title: 'HManagerID', width: 200, hide: true }
                        , { field: '子负责人代码', title: '子负责人代码', width: 200 }
                        , { field: '子负责人', title: '子负责人', width: 200 }
                        , { field: '表体备注', title: '表体备注', width: 200, hide: true }
                        , { field: '制单人', title: '制单人', width: 115}
                        , { field: '制单日期', title: '制单日期', width: 200, templet: "<div>{{d.制单日期 ==null ?'':layui.util.toDateString(d.制单日期, 'yyyy-MM-dd')}}</div>" }
                        , { field: '审核人', title: '审核人', width: 200 }
                        , { field: '审核日期', title: '审核日期', width: 200, templet: "<div>{{d.审核日期 ==null ?'':layui.util.toDateString(d.审核日期, 'yyyy-MM-dd')}}</div>" }
                        , { field: '修改人', title: '修改人', width: 200 }
                        , { field: '修改日期', title: '修改日期', width: 115,  templet: "<div>{{d.修改日期 ==null ?'':layui.util.toDateString(d.修改日期, 'yyyy-MM-dd')}}</div>" }
                        , { field: '关闭人', title: '关闭人', width: 200 }
                        , { field: '关闭日期', title: '关闭日期', width: 200, templet: "<div>{{d.关闭日期 ==null ?'':layui.util.toDateString(d.关闭日期, 'yyyy-MM-dd')}}</div>" }
                        , { field: '作废人', title: '作废人', width: 200 }
                        , { field: '作废日期', title: '作废日期', width: 115, templet: "<div>{{d.作废日期 ==null ?'':layui.util.toDateString(d.作废日期, 'yyyy-MM-dd')}}</div>" }
                        , { field: '源单主内码', title: '源单主内码', width: 200, hide: true }
                        , { field: '源单子内码', title: '源单子内码', width: 200, hide: true }
                        , { field: '源单单号', title: '源单单号', width: 200 }
                        , { field: '源单类型', title: '源单类型', width: 200 }
                        , { field: 'hbilltype', title: 'hbilltype', width: 200 }
                        , { field: 'HRepairCheckID', title: 'HRepairCheckID', width: 200, hide: true }
                    ]]
                };
            }
            //查询
            function get_Display() {
                var index = layer.load(0, { shade: false });
                //进入页面显示的缓存列表
                $.ajax({
                    //url: "http://61.130.49.162:9090/WMSAPI///Web/GetMAXNum",
                    url: GetWEBURL() + '/Sc_MouldRepairCheckBill/GetMouldRepairCheckBillList',
                    type: "GET",
                    data: { "sWhere": sWhere},
                    data: { "sWhere": sWhere },
                    success: function (data1) {
                        if (data1.count == 1) {
                            option.data = data1.data;
                            table.render(option);
                            layer.close(index);
                            layer.alert("查询成功", { icon: 1 });
                        } else {
                            layer.close(index);
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close(index);
                        layer.alert("接口失效!", { icon: 5 });
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
                //调用接口后清空sWhere缓存
                sWhere = "";
                //$("#HBillType").val("");//单据类型
                //$("#HBillNo").val("");//单据号
                //$("#HSourceBillNo").val("");//源单号
                //$("#HCreateBy").val("");//制单人
                //$("#BenginHCreateDate").val("");//开始制单时间
                //$("#EndHCreateDate").val("");//结束制单时间
            });
            }
            //监听行双击事件
            table.on('rowDouble(mainTable)', function (obj) {
                layer.alert("双击事件", { icon: 1 });
            });
            //新增
            function set_AddNew()
            {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '新增模具维修验收单',
                    closeBtn: 1,
                    shift: 2,
                    area: ['100%', '100%'],
                    maxmin: true,
                    content: '../模治具管理/Sc_Add_MouldRepairCheckBillList.html?OperationType=1&linterid=&HSouceBillType=',
                    end: function () {
                        //刷新页面,
                        location.reload();
                    },
                    success: function (layero, index) {
                    }
                });
            }
            //laydate.render({
            //    elem: '#HDate'
            //    , type: 'datetime'
            //    , trigger: 'click'
            //    , format:'yyyy-MM-dd HH:mm'
            //});
            //编辑
            function set_ShowBill()
            {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                if (checkStatus.data.length === 1) {
                    var hID = data[0].hmainid.toString();
                    //if (AllowLoadData(sSubStr) != false) {//非空验证
                    layer.open({
                        type: 2
                        , area: ['100%', '100%']
                        , title: '编辑模具维修验收单'
                        , closeBtn: 1
                        , shade: 0.6 //遮罩透明度
                        , maxmin: true //允许全屏最小化
                        , anim: 0 //0-6的动画形式,-1不开启
                        , content: '../模治具管理/Sc_Add_MouldRepairCheckBillList.html?OperationType=3&linterid=' + hID + '&HSouceBillType='
                        , resize: false,
                        end: function () {
                            //刷新页面,
                            location.reload();
                        }
                        , cancel: function () {
                            //$(".layui-btn").removeClass("layui-btn-disabled");
                        }
                    })
                } else {
                    layer.msg('请选择一行数据编辑!');
                }
            }
            //删除
            function set_DeleteBill()
            {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                if (checkStatus.data.length === 1) {
                    var InterID = data[0].hmainid.toString();
                    //逻辑删除方法
                    layer.confirm("确认要删除吗,删除后不能恢复", { title: "删除确认" }, function (index) {
                        $.ajax({
                            type: "GET",
                            url: GetWEBURL() + "/Sc_MouldRepairCheckBill/DeltetMouldRepairCheckBill", //方法所在页面和方法名
                            data: { "HInterID": InterID },
                            success: function (result) {
                                if (result.count == 1) {
                                    layer.msg(result.Message, { time: 1 * 1000, icon: 1 }, function () {
                                        // å¾—到frame索引
                                        var index = layer.getFrameIndex(window.name);
                                        //关闭当前frame
                                        layer.close(index);
                                        //修改为功后刷新界面
                                        window.location.reload();
                                    });
                                } else {
                                    layer.alert(result.code + result.Message, { icon: 5 });
                                }
                            }, error: function () {
                                layer.alert("接口请求失败!", { icon: 5 });
                            }
                        });
                    })
                }
                else {
                    layer.msg('请选择一行数据删除!');
                }
            }
            //快速过滤
            function get_FastQuery()
            {
                var HBillNo = $("#HBillNo").val();//单据号
                var HCreateBy = $("#HCreateBy").val();//制单人
                var BenginHCreateDate = $("#BenginHCreateDate").val();//开始制单时间
                var EndHCreateDate = $("#EndHCreateDate").val();//结束制单时间
                if (HBillNo) {
                    sWhere += " and HBillNo like '%" + HBillNo + "%'";
                }
                if (HCreateBy) {
                    sWhere += " and HCreateBy like '%" + HCreateBy + "%'";
                }
                if (BenginHCreateDate) {
                    sWhere += " and CONVERT(varchar(100),HCreateDate, 23) >= '" + BenginHCreateDate + "'";
                }
                if (EndHCreateDate) {
                    sWhere += " and CONVERT(varchar(100),HCreateDate, 23) <= '" + EndHCreateDate + "'";
                }
                get_Display(sWhere);
                sWhere = "";//调用接口后清空sWhere缓存
            }
            //重置
            function set_ClearQuery() {
                $("#HBillNo").val("");//单据号
                $("#HSourceBillNo").val("");//源单号
                $("#HCreateBy").val("");//制单人
                $("#BenginHCreateDate").val("");//开始制单时间
                $("#EndHCreateDate").val("");//结束制单时间
                $("#btnSearch").click();
            }
            //#endregion
            //以上是layui模块
        });
WebTM/views/Éú²ú¹ÜÀí/ÖÊÁ¿»ã±¨µ¥/Sc_QualityReportBill.html
@@ -272,11 +272,9 @@
                            </div>
                        </div>
                    </div>
                    <script type="text/html" id="toolbarDemo1">
                        <div class="layui-btn-container">
                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-AddLine"><i class="layui-icon layui-icon-delete"></i>删行</button>
                        </div>
                    </script>
                    <input type="hidden" name="HReportType" id="HReportType" value="1">
                    <input type="hidden" name="HBillType" id="HBillType" value="3717">
                    <input type="hidden" name="HSourceBillType" id="HSourceBillType" value="0">
                </form>
            </div>
        </div>
@@ -309,11 +307,12 @@
                elem: '#mainTable1'
                , toolbar: '#toolbarDemo1'
                , limit: 500 //每页默认显示的数量
                , height: 'full-270'
                , height: 'full-300'
                , cellMinWidth: 110
                , totalRow: true
                , cols: [[ //表头
                    { type: 'checkbox' }
                    , { type: 'numbers', title: '序号' }
                    { type: 'checkbox', totalRowText: '合计行' }
                    , { type: 'numbers', title: '序号', totalRow: true }
                    , { field: 'HBadReasonNumber', title: '不良原因代码' }
                    , { field: 'HBadReasonHName', title: '不良原因' }
                    , { field: 'HCheckMan', title: '检验员' }
@@ -327,6 +326,7 @@
            };
            var option2 = {
                elem: '#mainTable2'
                , toolbar: '#toolbarDemo2'
                , limit: 500 //每页默认显示的数量
                , height: 'full-300'
                , cellMinWidth: 110
@@ -406,6 +406,7 @@
                    }
                });
                if (HSouceBillType == 3722) {
                    $("#HSourceBillType").val(HSouceBillType);
                    //根据源单id获取源单信息
                    GetICMOBillValue(linterid);
                } else {
@@ -521,6 +522,70 @@
                    error: function (err) {
                        layer.close(ajaxLoad);
                        layer.msg("错误:" + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    }
                });
            });
            //#endregion
            //#region é€€å‡ºæŒ‰é’®
            form.on('submit(Cancel)', function () {
                if (OperationType == 1) {
                    Pub_Close(2);
                } else if (OperationType == 2) {
                    Pub_Close(1);
                }
            })
            //#endregion
            //#region è¡Œå†…事件
            table.on('tool(mainTable1)', function (obj) {
                var rowData = obj.data;
                if (obj.event === 'del') {
                    layer.confirm('确定删除' + rowData.HBadReasonNumber + '吗?', function (index) {
                        var ajaxLoad = layer.load();
                        //逻辑删除方法
                        $.ajax({
                            url: GetWEBURL() + '/Sc_QualityReportBill/del_BarCodeDetail',
                            type: "GET",
                            data: { "HItemID": rowData.HItemID },
                            success: function (result) {
                                if (result.count == 1) {
                                    get_BarCodeDetail();
                                    get_BarCodeDetailSum();
                                    layer.close(ajaxLoad);
                                } else {
                                    layer.close(ajaxLoad);
                                    layer.alert(result.Message, { icon: 5 });
                                }
                            }, error: function () {
                                layer.close(ajaxLoad);
                                layer.alert("接口请求失败!", { icon: 5 });
                            }
                        });
                        layer.close(index);
                    });
                }
            });
            //#endregion
            //#region ä¿å­˜æäº¤
            form.on('submit(btnSave)', function (data) {//提交
                var ajaxLoad = layer.load();
                $.ajax({
                    url: GetWEBURL() + '/Sc_QualityReportBill/set_SaveBill',
                    type: "GET",
                    data: { "HInterID": $("#HInterID").val() },
                    success: function (data1) {
                        if (data1.count == 1) {
                            $('#set_SaveBill').addClass("layui-btn-disabled").attr("disabled", true);
                            layer.close(ajaxLoad);
                        } else {
                            layer.close(ajaxLoad);
                        }
                    }, error: function () {
                        layer.close(ajaxLoad);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            });
@@ -662,8 +727,9 @@
                            table.render(option1);
                            layer.close(ajaxLoad);
                        } else {
                            option1.data = [];
                            table.render(option1);
                            layer.close(ajaxLoad);
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close(ajaxLoad);
@@ -686,8 +752,9 @@
                            table.render(option2);
                            layer.close(ajaxLoad);
                        } else {
                            option2.data = [];
                            table.render(option2);
                            layer.close(ajaxLoad);
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close(ajaxLoad);
@@ -698,141 +765,6 @@
            //#endregion
        //#endregion
            //行内事件
            table.on('tool(mainTable)', function (obj) {
                var data = obj.data;
                var rowIndex = $(obj.tr).attr("data-index");
                if (obj.event === 'del') {
                    layer.confirm('真的删除行吗?', function (index) {
                        console.log("索引为:" + rowIndex);
                        if (rowIndex === '0') {
                            layer.msg('首行无法删除!!!');
                        } else {
                            obj.del();
                            option.data = table.cache["mainTable"];//将数据绑定到data上
                            table.reload(option);
                            layer.close(index);
                        }
                    });
                }
            });
            //保存提交
            form.on('submit(btnSave)', function (data) {//提交
                if ($("#HICMOInterID").val() == 0) {
                    layer.msg("请选择任务单!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return;
                }
                if ($("#HQty").val() == "" || $("#HQty").val() <= 0) {
                    layer.msg("基本信息中流转卡数量不能为空且不能小于等于0!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return;
                }
                if (!$("#HPlanBeginDate").val()) {
                    layer.msg("请选择计划开工日期!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return;
                }
                if (!$("#HPlanEndDate").val()) {
                    layer.msg("请选择计划完工日期!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return;
                }
                var sSubTable = table.cache['mainTable'];
                var sMainStr = JSON.stringify(data.field);
                var sSubStr = JSON.stringify(table.cache['mainTable']);
                var sMainSub = sMainStr + ';' + sSubStr;
                var ajaxLoad = layer.load();
                $.ajax({
                    type: "POST",
                    url: GetWEBURL() + "/Sc_ProcessExchangeBill/AddBill",
                    async: true,
                    data: { "sMainSub": sMainSub },
                    dataType: "json",
                    success: function (data) {
                        if (data.count == 1) {
                            layer.close(ajaxLoad);
                            layer.msg("提交成功", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                            $('#btnSave').addClass("layui-btn-disabled").attr("disabled", true);//保存按钮禁用
                        }
                        else {
                            layer.close(ajaxLoad);
                            layer.msg(data.Message, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                        }
                    },
                    error: function (err) {
                        layer.close(ajaxLoad);
                        layer.msg("错误:" + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    }
                });
            });
            //选择产品弹窗
            form.on('submit(btnSearchMater)', function () {
                layer.open({
                    type: 2//弹窗类型
                    , skin: 'layui-layer-rim' //加上边框
                    , area: ['90%', '90%']//大小
                    , title: '物料列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../PublicPage/PartInformation.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('请选择数据');
                        }
                        $("#HMaterName2").val(checkStatus.data[0].HName);
                        $("#HMaterName2").val(checkStatus.data[0].HItemID);
                        $("#HMaterNumber2").val(checkStatus.data[0].HNumber);
                        $("#HMaterHModel2").val(checkStatus.data[0].HModel);
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
                })
            });
            //选择生产任务单
            form.on('submit(btnSearchICMOBill)', function () {
                layer.open({
                    type: 2//弹窗类型
                    , skin: 'layui-layer-rim' //加上边框
                    , area: ['90%', '90%']//大小
                    , title: '生产任务单列表'//标题
                    , shift: 2//弹出动画
                    , content: ['../../../views/Baseset/基础资料/Sc_ICMOBillListView.html', 'yes']
                    , btn: ['确定', '取消']
                    , btn1: function (index, layero) {//按钮【按钮一】的回调
                        var iframeWindow = window['layui-layer-iframe' + index]  //获取弹框页面
                        var checkStatus = iframeWindow.layui.table.checkStatus('ck-table');//获取table的elem:"#test"
                        if (checkStatus.data.length === 0) {
                            return layer.msg('请选择数据');
                        }
                        GetICMOBillValue(checkStatus.data[0].hmainid)
                        layer.close(index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) { }
                })
            });
            //退出按钮
            form.on('submit(Cancel)', function () {
                if (OperationType == 1) {
                    Pub_Close(2);
                } else if (OperationType == 2) {
                    Pub_Close(1);
                }
            })
            //以上为layui模块
WebTM/views/É豸¹ÜÀí/Sb_Add_EqpConkBookBillList.html
@@ -166,30 +166,25 @@
    <script src="../../layuiadmin/Scripts/json2.js"></script>
    <script src="../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
    <script src="../../layuiadmin/Scripts/webConfig.js"></script>
    <script src="../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <script src="../../layuiadmin/PubCustom.js"></script>
    <script>
//获取参数
        function getUrlVars() {
            var vars = [], hash;
            var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
            for (var i = 0; i < hashes.length; i++) {
                hash = hashes[i].split('=');
                vars.push(hash[0]);
                vars[hash[0]] = hash[1];
            }
            return vars;
        //获取参数
        var params = get_UrlVars();
        if (typeof (params[params[0]]) == "undefined") {
            var OperationType = 1;//操作类型
        } else {
            var OperationType = params[params[0]];//操作类型
            var linterid = params[params[1]];//源单id
            var HSouceBillType = params[params[2]];//源单类型
        }
        var params = getUrlVars();
        var hID = params[params[0]];//编辑查看
        layui.config({
            base: '../../layuiadmin/' //静态资源所在路径
        }).extend({
            index: 'lib/index' //主入口模块
        }).use(['index', 'form', 'laydate', 'table', 'element'], function () {
            //#region å…¬å…±å˜é‡
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
@@ -198,300 +193,34 @@
                , laydate = layui.laydate
                , element = layui.element;
            //常规用法
            laydate.render({
                elem: '#HDate',
                format:'yyyy-MM-dd',
            var sBillType = "3907";
            var TabRow = { "HConkReasonID": 0, "HConkReasonCode": "", "HConkReasonName": "  ", "HConkExplanation": " ", "HManagerID": 0, "HManagerCode": "", "HManagerName": "  ", "HRemark": "  " };
            //#endregion
            });
            laydate.render({
                elem: '#HConkBeginDate',
                format: 'yyyy-MM-dd',
            });
            //判断是否登录 æœªç™»å½•则跳到登录页
            //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 = {
                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" }
                    , { field: 'HConkReasonID', title: 'HConkReasonID', edit: 'text', hide: true }
                    , { field: 'HConkReasonCode', title: '故障原因代码', edit: 'text', event: "HConkReasonCode" }
                    , { field: 'HConkReasonName', title: '故障原因名称', edit: 'text' }
                    , { field: 'HConkExplanation', title: '故障原因描述', edit: 'text' }
                    , { field: 'HManagerID', title: 'HManagerID', edit: 'text', hide: true  }
                    , { field: 'HManagerCode', title: '负责人代码', edit: 'text' }
                    , { field: 'HManagerName', title: '负责人名称', edit: 'text' }
                    , { field: 'HRemark', title: '备注', event: "", edit: 'text' }
                    , { 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 = [{ "HConkReasonID": 0, "HConkReasonCode": "", "HConkReasonName": "  ", "HConkExplanation": " ", "HManagerID": 0,"HManagerCode":"", "HManagerName": "  ", "HRemark": "  " }];
                table.render(option);
            //#region  è¿›å…¥é¡µé¢å³åŠ è½½
            //初始化表格
            set_InitGrid();
            //初始化表单插件
            set_InitFrom();
            //判断操作类型
            if (OperationType == 1) {//无源单
                set_AddFNew();
            }
            else if (OperationType == 3) {//编辑
                set_EditFromGrid();
            }
            else {
                $("#HInterID").val(hID);//修改时主表ID
                //编辑加载数据
                $.ajax({
                    url: GetWEBURL() + 'Sb_EqpRepairWorkBill/Sb_EqpConkBookBillListProjectDetai',
                    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 });
                    }
                });
                layer.alert("未知操作类型!", { icon: 5 });
            }
            //#endregion
            //头工具栏事件
            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 = { "HConkReasonID": 0, "HConkReasonCode": "", "HConkReasonName": "  ", "HConkExplanation": " ", "HManagerID": 0, "HManagerCode": "", "HManagerName": "  ", "HRemark": "  " };
                switch (obj.event) {
                    case 'btn-AddLine':
                        //table.cache["mainTable"].push(AddRow[rows]);
                        table.cache["mainTable"].push(NewRow);
                        option.data = table.cache["mainTable"];
                        table.render(option);
                        rows++;
                        layer.msg('增加一行按钮!')
                        break;
                    case 'btn-CopyLine':
                        var copydata = JSON.stringify(data);
                        if (data.length <= 0) {
                            layer.alert("请选择需要复制的一行!");
                        }
                        else if (data.length > 1) {
                            layer.alert("只能选择复制一行!");
                        }
                        else {
                            var copydata2 = copydata.substring(1, copydata.length);//去除首行字符'['
                            var copyrow = copydata2.substring(0, copydata2.length - 1);//去除末尾字符']'
                            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) {
                var data = obj.data;
                var rowIndex = $(obj.tr).attr("data-index");
                if (obj.event === 'del') {
                    layer.confirm('真的删除行么', function (index) {
                        console.log("索引为:" + rowIndex);
                        if (rowIndex === '0') {
                            layer.msg('首行无法删除!!!');
                        } else {
                            //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);
                        }
                    });
                }
                $(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {
                    if (event.key == "F7") {
            //#region è§¦å‘事件:包括form.on(){}格式的所有点击事件、选择事件等
                        if (obj.event === 'HConkReasonCode')  //故障原因信息
                        {
                            //页面层-自定义
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '故障原因信息列表',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../PublicPage/FaultReasonInformation.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({
                                        HConkReasonID: checkStatus.data[0].HItemID,
                                        HConkReasonCode: checkStatus.data[0].HNumber,
                                        HConkReasonName: checkStatus.data[0].HName
                                    });
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                                },
                                end: function () {
                                }
                            });
                        }
                        if (obj.event === 'HManagerCode')  //负责人代码
                        {
                            //页面层-自定义
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '负责人列表',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../PublicPage/RepairItemInformation.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({
                                        HManagerID: checkStatus.data[0].HItemID,
                                        HManagerCode: checkStatus.data[0].HNumber,
                                        HManagerName: checkStatus.data[0].HName,
                                    });
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                                },
                                end: function () {
                                }
                            });
                        }
                        obj.event = "";
                        return false;
                    }
                })
            });
            function RoadBillMain(hID)//加载表头
            {
                alert(hID);
                //查询检验方案单是否存在
                $.ajax({
                    url: GetWEBURL() + "Sb_EqpRepairWorkBill/Sb_EqpConkBookBillListCheckDetai",
                    type: "GET",
                    data: {
                        "HID": hID
                    },
                    success: function (result) {
                        if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            var data = result.data.h_v_Sb_EquipConkBookBillList_Edit[0];
                            form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                                "HBillNo": data.单据号
                                , "HDate": formatDate(data.日期)
                                , "HInnerBillNo": data.内部单据号
                                , "HDeptID": data.HDeptID                 //使用部门ID
                                , "HDeptName": data.部门名称              //使用部门名称
                                , "HEmpID": data.HEmpID                   //发现人ID
                                , "HEmpName": data.发现人                 //发现人名称
                                , "HManagerID": data.HManagerID           //负责人ID
                                , "HManagerName": data.负责人             //负责人名称
                                , "HEquipID": data.HEquipID               //设备ID
                                , "HEquipName": data.设备名称             //设备名称
                                , "HConkTypeID": data.HEquipID            //故障类别ID
                                , "HConkTypeName": data.故障类别          //故障类别
                                , "HConkBeginDate": formatDate(data.发生日期) //故障发生日期
                                , "HExplanation": data.故障描述           //摘要
                                , "HRemark": data.表头备注                //备注
                            });
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
            }
            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("");
                $.ajax({
                    url: GetWEBURL() + "/Web/GetMAXNum",
                    type: "GET",
                    data: { "HBillType": '3907' },
                    success: function (d) {
                        //console.log(d.data);
                        $("#HBillNo").val(d.data[0].HBillNo);
                        $("#HDate").val(shijian);
                        $("#HConkBeginDate").val(shijian);
                        $("#HInterID").val(0);
                    }
                });
            }
            else {//如果修改则走下面 new
                RoadBillMain(hID);
                /* RoadBillSub(linterid);*/
            }
            //表头信息部门弹窗
            //表头信息部门弹窗
            form.on('submit(Department)', function () {
                //页面层-自定义
                layer.open({
@@ -529,7 +258,7 @@
                });
            });
            //表头信息发现人弹窗
            //表头信息发现人弹窗
            form.on('submit(HEmpList)', function () {
                //页面层-自定义
                layer.open({
@@ -567,7 +296,7 @@
                });
            });
            //表头信息负责人弹窗
            //表头信息负责人弹窗
            form.on('submit(HManagerList)', function () {
                //页面层-自定义
                layer.open({
@@ -605,7 +334,7 @@
                });
            });
            //表头信息设备弹窗
            //表头信息设备弹窗
            form.on('submit(HEquipList)', function () {
                //页面层-自定义
                layer.open({
@@ -681,47 +410,51 @@
                });
            });
            form.on('submit(Exit)', function (data) {//
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            //头工具栏事件
            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': set_AddLine(NewRow);
                        break;
                    //复制一行
                    case 'btn-CopyLine': set_CopyLine(data);
                        break;
                }
            });
            //行内事件
            table.on('tool(mainTable)', function (obj) {
                set_GridDelete(obj);   //行内删除
                set_GridCellCheck(obj); //行内快捷键筛选
            });
            //退出
            form.on('submit(Exit)', function (data) {//
                if (linterid == undefined) {
                    //关闭页签
                    Pub_Close(2);
                }
                else {
                    //关闭页签
                    Pub_Close(1);
                }
            });
            form.on('submit(Cancel)', function () {
                //sessionStorage["SourceFlag"] = false;
                parent.location.href = "../../../views/index.html"
                //window.close();//关闭当前页
            })
            //保存
            form.on('submit(Saver)', function (data) {
            function formatDate(date) {
                var d = new Date(date),
                    month = '' + (d.getMonth() + 1),
                    day = '' + d.getDate(),
                    year = d.getFullYear();
                if (month.length < 2) month = '0' + month;
                if (day.length < 2) day = '0' + day;
                return [year, month, day].join('-');
            }
            //console.log(rTime('2021-06-03T08:35:57.697'));
            //var startDate = new Date("2019-04-30 16:30:30").toLocaleDateString().split('/').join('-');
            //console.log(startDate);
            form.on('submit(Saver)', function (data) {//保存
                //debugger;
                data.field.HMaker = sessionStorage["HUserName"];//制单人
                var sMainStr = JSON.stringify(data.field);
                var sSubStr = JSON.stringify(table.cache['mainTable']);
                var sMainSub = sMainStr + ';' + sSubStr;
                $.ajax(
                    {
                //对数据进行验证
                if (AllowLoadData(sSubStr)) {
                    $.ajax({
                        type: "POST",
                        url: GetWEBURL() + "/Sb_EqpRepairWorkBill/SaveGetEqpConkBookBillList", //方法所在页面和方法名
                        async: true,
@@ -737,147 +470,379 @@
                            }
                            else {
                                f_alert(data.Message);
                                layer.msg(data.Message);
                                console.log("Reason" + sMainStr + "sub:" + JSON.stringify(layui.table.cache.mainTable));
                            }
                            layer.closeAll("loading");
                        },
                        error: function (err) {
                            f_alert("错误:" + err);
                            layer.msg("错误:" + err);
                            console.log("Reason" + sMainStr);
                        }
                    });
            });
            function f_alert(sMsg) {
                layer.alert(sMsg, { icon: 5 });
            }
            //监听提交
            form.verify({
                numberOrEmpty: function (value, item) {
                    // if (value != '') {
                    if (!/^\d+$/.test(value)) {
                        return '不能为空或数字或者0';
                    }
                    //}
                }
            });
            //#endregion
            //#region  å½“前页页面所有方法
            //初始化表单插件
            function set_InitFrom() {
                //常规用法
                laydate.render({
                    elem: '#HDate',
                    format: 'yyyy-MM-dd',
                });
                laydate.render({
                    elem: '#HConkBeginDate',
                    format: 'yyyy-MM-dd',
                });
            }
            //初始化表格
            function set_InitGrid() {
                //表头
                columns = [
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao', title: '序号', sort: true, fixed: 'left', event: "qwe" }
                    , { field: 'HConkReasonID', title: 'HConkReasonID', edit: 'text', hide: true }
                    , { field: 'HConkReasonCode', title: '故障原因代码', edit: 'text', event: "HConkReasonCode" }
                    , { field: 'HConkReasonName', title: '故障原因名称', edit: 'text' }
                    , { field: 'HConkExplanation', title: '故障原因描述', edit: 'text' }
                    , { field: 'HManagerID', title: 'HManagerID', edit: 'text', hide: true }
                    , { field: 'HManagerCode', title: '负责人代码', edit: 'text', event: "HManagerCode" }
                    , { field: 'HManagerName', title: '负责人名称', edit: 'text' }
                    , { field: 'HRemark', title: '备注', event: "", edit: 'text' }
                    , { 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_AddFNew() {
                //获取最大单据号
                get_MAXNum();
                option.data = [TabRow];
                table.render(option);
            }
            //获取最大单据号及默认值赋值
            function get_MAXNum() {
                //获取最大单据号 new
                $("#HInterID").val("0");
                $("#HBillNo").val("");
                $.ajax({
                    url: GetWEBURL() + "/Web/GetMAXNum",
                    type: "GET",
                    data: { "HBillType": sBillType },
                    success: function (d) {
                        $("#HBillNo").val(d.data[0].HBillNo);
                        $("#HDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                        $("#HConkBeginDate").val(Pub_Format(new Date(), "yyyy-MM-dd"));
                        $("#HInterID").val(0);
                    }
                });
            }
            //编辑
            function set_EditFromGrid() {
                set_EditForm(linterid);  //编辑获取表头
                set_EditGrid(linterid);  //编辑获取表体
                option.data = [TabRow];
                table.render(option);
            }
            //编辑加载表头
            function set_EditForm(linterid) {
                //查询检验方案单是否存在
                $.ajax({
                    url: GetWEBURL() + "Sb_EqpRepairWorkBill/Sb_EqpConkBookBillListCheckDetai",
                    type: "GET",
                    data: {
                        "HID": linterid
                    },
                    success: function (result) {
                        if (result.code == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                            var data = result.data.h_v_Sb_EquipConkBookBillList_Edit[0];
                            form.val("component-form-group", { //formTest å³ class="layui-form" æ‰€åœ¨å…ƒç´ å±žæ€§ lay-filter="" å¯¹åº”的值
                                "HBillNo": data.单据号
                                , "HDate": formatDate(data.日期)
                                , "HInnerBillNo": data.内部单据号
                                , "HDeptID": data.HDeptID                 //使用部门ID
                                , "HDeptName": data.部门名称              //使用部门名称
                                , "HEmpID": data.HEmpID                   //发现人ID
                                , "HEmpName": data.发现人                 //发现人名称
                                , "HManagerID": data.HManagerID           //负责人ID
                                , "HManagerName": data.负责人             //负责人名称
                                , "HEquipID": data.HEquipID               //设备ID
                                , "HEquipName": data.设备名称             //设备名称
                                , "HConkTypeID": data.HEquipID            //故障类别ID
                                , "HConkTypeName": data.故障类别          //故障类别
                                , "HConkBeginDate": formatDate(data.发生日期) //故障发生日期
                                , "HExplanation": data.故障描述           //摘要
                                , "HRemark": data.表头备注                //备注
                            });
                        } else {
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
            }
            // ç¼–辑获取表体
            function set_EditGrid(linterid) {
                $("#HInterID").val(linterid);//修改时主表ID
                //编辑加载数据
                $.ajax({
                    url: GetWEBURL() + 'Sb_EqpRepairWorkBill/Sb_EqpConkBookBillListProjectDetai',
                    type: "GET",
                    data: { "sqlWhere": "and hmainid=" + linterid },
                    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 });
                    }
                });
            }
            // ç¼–辑获取表头时时间格式矫正方式
            function formatDate(date) {
                var d = new Date(date),
                    month = '' + (d.getMonth() + 1),
                    day = '' + d.getDate(),
                    year = d.getFullYear();
                if (month.length < 2) month = '0' + month;
                if (day.length < 2) day = '0' + day;
                return [year, month, day].join('-');
            }
            //增加一行
            function set_AddLine(NewRow) {
                table.cache["mainTable"].push(NewRow);
                option.data = table.cache["mainTable"];
                table.render(option);
            }
            //复制一行
            function set_CopyLine(data) {
                var copydata = JSON.stringify(data);
                if (data.length <= 0) {
                    layer.alert("请选择需要复制的一行!");
                }
                else if (data.length > 1) {
                    layer.alert("只能选择复制一行!");
                }
                else {
                    var copydata2 = copydata.substring(1, copydata.length);//去除首行字符'['
                    var copyrow = copydata2.substring(0, copydata2.length - 1);//去除末尾字符']'
                    table.cache["mainTable"].push(JSON.parse(copyrow));//将复制的行强转成json追加到表格上
                    option.data = table.cache["mainTable"];//将数据绑定到data上
                    table.render(option);//将数据渲染到表格上
                    //layer.alert(copyrow);
                }
            }
            //行内删除
            function set_GridDelete(obj) {
                var data = obj.data;
                var rowIndex = $(obj.tr).attr("data-index");
                if (obj.event === 'del') {
                    layer.confirm('真的删除行么', function (index) {
                        console.log("索引为:" + rowIndex);
                        if (rowIndex === '0') {
                            layer.msg('首行无法删除!!!');
                        } else {
                            //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 === 'HConkReasonCode')  //故障原因信息
                        {
                            //页面层-自定义
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '故障原因信息列表',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../PublicPage/FaultReasonInformation.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({
                                        HConkReasonID: checkStatus.data[0].HItemID,
                                        HConkReasonCode: checkStatus.data[0].HNumber,
                                        HConkReasonName: checkStatus.data[0].HName
                                    });
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                                },
                                end: function () {
                                }
                            });
                        }
                        if (obj.event === 'HManagerCode')  //负责人代码
                        {
                            //页面层-自定义
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '负责人列表',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../PublicPage/RepairItemInformation.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({
                                        HManagerID: checkStatus.data[0].HItemID,
                                        HManagerCode: checkStatus.data[0].HNumber,
                                        HManagerName: checkStatus.data[0].HName,
                                    });
                                    layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                                }
                                , btn2: function (index, layero) {
                                    //按钮【按钮二】的回调
                                    //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                                },
                                end: function () {
                                }
                            });
                        }
                        obj.event = "";
                        return false;
                    }
                })
            }
            //#endregion
            //判断是否登录 æœªç™»å½•则跳到登录页
            //if (sessionStorage.login != "login") {
            //    layer.confirm("登录失效,请重新登录!", {
            //        icon: 4, skin: 'layui-layer-lan', title: "温馨提示", closeBtn: 0, btn: ['重新登录']
            //    }, function () { window.location.href = "../../user/login.html"; });
            //}
        });
        //定义全局变量
        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) {  //非空验证
            //if ($("#HSourceBillNo").val() == '') {
            //    layer.msg("请先扫源单!", { icon: 5 });
            //    return false;
            //}
            if ($("#HDeptName").val() == '') {
                layer.msg("部门没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
            if ($("#HDeptID").val() == '' && $("#HDeptName").val() == '') {
                layer.msg("使用部门没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            if ($("#HSecManager").val() == '') {
                layer.msg("验收人没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
            if ($("#HEmpID").val() == '' && $("#HEmpName").val() == '') {
                layer.msg("发现人没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            if ($("#HKeeper").val() == '') {
                layer.msg("保管人没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
            if ($("#HManagerID").val() == '' && $("#HManagerName").val() == '') {
                layer.msg("负责人没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            //if ($("#HWHNAME").val() == '') {
            //    layer.msg("仓库没有选择!", { icon: 5 });
            //    return false;
            //}
            if ($("#HBillNo").val() == '') {
                layer.msg("错误的单据号", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
            if ($("#HEquipID").val() == '' && $("#HEquipName").val() == '') {
                layer.msg("设备没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            if ($("#HInterID").val() == '') {
                layer.msg("错误的内码", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
            if ($("#HConkTypeID").val() == '' && $("#HConkTypeName").val() == '') {
                layer.msg("故障类别没有选择", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            if (typeof (sSubStr) == "undefined") {
                layer.msg("没有物料明细记录", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
            //判断物料明细项
            if (typeof (sSubStr) == "undefined" || sSubStr == "" || sSubStr == "[]") {
                layer.msg("没有明细记录", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                return false;
            }
            if (!typeof (sSubStr) == "undefined") {
                //for (var i = 0; i <= sSubStr.length - 1; i++) {  //判断扫码数量不能大于应收数量
                //    if (parseFloat(sSubStr[i].HQtyMust) > 0) {
                //        if (parseFloat(sSubStr[i].HQty) > parseFloat(sSubStr[i].HQtyMust))
                //        {
                //            layer.msg("数量不能大于应收数量", { icon: 5, btn: ['确定'], time: 100000, offset: 't' });
                //            return false;
                //        }
                //    }
                //}
                for (var i = 0; i <= sSubStr.length - 1; i++) {   //判断扫码数量不能为0
                    if (parseFloat(sSubStr[i].HQty) > 0) {
                        s = 1;
            if (typeof (sSubStr) != "undefined" && typeof (sSubStr) != "") {
                sSubStr = JSON.parse(sSubStr);
                for (var i = 0; i < sSubStr.length; i++) {
                    if (sSubStr[i].HConkReasonCode == "") {
                        layer.msg("明细记录第" + (i + 1) + "行,故障原因代码信息为空!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                        return false;
                    }
                }
                if (s == 0) {
                    layer.msg("产品入库记录未扫码", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return false;
                    if (sSubStr[i].HManagerCode == "") {
                        layer.msg("明细记录第" + (i + 1) + "行,负责人代码信息为空!", { icon: 5, btn: ['确认'], time: 2000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                        return false;
                    }
                    else {
                        return true;
                    }
                }
            }
            else {
                return true;
            }
        }</script>
        }
    </script>
</body>
</html>
WebTM/views/É豸¹ÜÀí/Sb_EqpConkBookBillList.html
@@ -49,19 +49,14 @@
                                            <option value="ZHSJ">上架归还单</option>
                                        </select>
                                    </div>
                                </div>
                                </div>-->
                                <div class="layui-inline">
                                    <label class="layui-form-label">单据号</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" name="HBillNo" id="HBillNo">
                                    </div>
                                </div>
                                <div class="layui-inline">
                                    <label class="layui-form-label">制单人</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" name="HCreateBy" id="HCreateBy">
                                    </div>
                                </div>-->
                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnSearch" id="btnSearch">
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                </button>
@@ -72,12 +67,7 @@
                                            <span>其他条件></span>
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">单据号</label>
                                        <div class="layui-input-block">
                                            <input type="text" class="layui-input" name="HBillNo" id="HBillNo">
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
@@ -85,9 +75,9 @@
                        <script type="text/html" id="toolbarDemo">
                            <div class="layui-btn-container">
                                <!--<button type="button" class="layui-btn layui-btn-sm" lay-event="btn-getCheckData"><i class="layui-icon layui-icon-tips"></i>预览</button>-->
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Add"><i class="layui-icon layui-icon-add-1"></i>新增</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-Edit"><i class="layui-icon layui-icon-edit"></i>编辑</button>
                                <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="btnAdd"><i class="layui-icon layui-icon-add-1"></i>新增</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btnModify"><i class="layui-icon layui-icon-edit"></i>编辑</button>
                                <button type="button" class="layui-btn layui-btn-sm" lay-event="btndelete"><i class="layui-icon layui-icon-delete"></i>删除</button>
                            </div>
@@ -107,6 +97,7 @@
        }).extend({
            index: 'lib/index', //主入口模块
        }).use(['index', 'form', 'table', 'element', 'laypage', 'laydate'], function () {
            //#region  å…¬å…±å˜é‡
            var $ = layui.$
                , admin = layui.admin
                , layer = layui.layer
@@ -118,193 +109,240 @@
                , util = layui.util
            //查询条件
            var sWhere = "";
            var option = [];
            //#endregion
            var option = {
                elem: '#mainTable'
                , toolbar: '#toolbarDemo'
                , height: 'full-50'
                , page: true
                , cellMinWidth: 90
                , cols: [[
                    { type: 'checkbox', fixed: 'left' }
                    ,{ field: 'hmainid', title: '单据ID', hide: true }
                    , { field: '日期', title: '日期', width: 160, templet: "<div>{{d.日期 ==null ?'':layui.util.toDateString(d.日期, 'yyyy-MM-dd')}}</div>"}
                    , { field: '单据号', title: '单据号', width: 160 }
                    , { field: '单据类型', title: '单据类型', width: 160, hide: true }
                    , { field: 'HEquipID', title: 'HEquipID', width: 200, hide: true }
                    , { field: '设备代码', title: '设备代码', width: 200 }
                    , { field: '设备名称', title: '设备名称', width: 200 }
                    , { field: 'HConkTypeID', title: 'HConkTypeID', width: 200, hide: true }
                    , { field: '故障类别代码', title: '故障类别代码', width: 200 }
                    , { field: '故障类别', title: '故障类别', width: 200 }
                    , { field: 'HEmpID', title: 'HEmpID', width: 200, hide: true }
                    , { field: '发现人代码', title: '发现人代码', width: 200 }
                    , { field: '发现人', title: '发现人', width: 200 }
                    , { field: 'HDeptID', title: 'HDeptID', width: 200, hide: true }
                    , { field: '部门代码', title: '部门代码', width: 115 }
                    , { field: '部门名称', title: '部门名称', width: 200 }
                    , { field: 'HManagerID', title: 'HManagerID', width: 115, hide: true }
                    , { field: '负责人代码', title: '负责人代码', width: 115 }
                    , { field: '负责人', title: '负责人', width: 200 }
                    , { field: '发生日期', title: '发生日期', width: 160, templet: "<div>{{d.发生日期 ==null ?'':layui.util.toDateString(d.发生日期, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                    , { field: '故障描述', title: '故障描述', width: 200 }
                    , { field: '表头备注', title: '表头备注', width: 200 }
                    , { field: '内部单据号', title: '内部单据号', width: 115 }
                    , { field: '制单人', title: '制单人', width: 200 }
                    , { field: '制单日期', title: '制单日期', width: 200, templet: "<div>{{d.制单日期 ==null ?'':layui.util.toDateString(d.制单日期, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                    , { field: '审核人', title: '审核人', width: 200 }
                    , { field: '审核日期', title: '审核日期', width: 200, templet: "<div>{{d.审核日期 ==null ? '':layui.util.toDateString(d.审核日期, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                    , { field: '修改人', title: '修改人', width: 200 }
                    , { field: '修改日期', title: '修改日期', width: 200, templet: "<div>{{d.修改日期 ==null ?'':layui.util.toDateString(d.修改日期, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                    , { field: '关闭人', title: '关闭人', width: 200 }
                    , { field: '关闭日期', title: '关闭日期', width: 200, templet: "<div>{{d.关闭日期 ==null ?'':layui.util.toDateString(d.关闭日期, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                    , { field: '作废人', title: '作废人', width: 200 }
                    , { field: '作废日期', title: '作废日期', width: 200, templet: "<div>{{d.作废日期 ==null ?'':layui.util.toDateString(d.作废日期, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                    , { field: 'hsubid', title: 'hsubid', width: 200, hide: true }
                    , { field: 'HConkReasonID', title: 'HConkReasonID', width: 115, hide: true }
                    , { field: '故障原因代码', title: '故障原因代码', width: 200 }
                    , { field: '故障原因名称', title: '故障原因名称', width: 200 }
                    , { field: '故障原因描述', title: '故障原因描述', width: 200 }
                    , { field: 'HManagerID', title: 'HManagerID', width: 115, hide: true }
                    , { field: '表体负责人代码', title: '表体负责人代码', width: 200 }
                    , { field: '表体负责人', title: '表体负责人', width: 200 }
                    , { field: '行关闭人', title: '行关闭人', width: 200 }
                    , { field: '关闭类型', title: '关闭类型', width: 200 }
                    , { field: '表体备注', title: '表体备注', width: 200 }
                    , { field: '源单主内码', title: '源单主内码', width: 200, hide: true }
                    , { field: '源单子内码', title: '源单子内码', width: 200, hide: true }
                    , { field: '源单单号', title: '源单单号', width: 200 }
                    , { field: '源单类型', title: '源单类型', width: 200 }
                    , { field: '关联数量', title: '关联数量', width: 200 }
                    , { field: 'HBillType', title: 'HBillType', width: 200, hide: true }
                ]]
            };
            //#region è¿›å…¥é¡µé¢æ—¢åŠ è½½
            //初始化界面
            set_ClearBill();
            //#endregion
            var index = layer.load(0);
            //#region è§¦å‘事件:包括form.on(){}格式的所有点击事件、选择事件
            //头工具栏事件
            table.on('toolbar(mainTable)', function (obj) {
                var checkStatus = table.checkStatus(obj.config.id);
                switch (obj.event) {
                    case 'btn-Add':
                        //页面层-自定义
                        layer.open({
                            type: 2,
                            skin: 'layui-layer-rim', //加上边框
                            title: '新增设备故障登记单',
                            closeBtn: 1,
                            shift: 2,
                            area: ['100%', '100%'],
                            maxmin: true,
                            content: '../设备管理/Sb_Add_EqpConkBookBillList.html',
                            end: function () {
                                //刷新页面,
                                location.reload();
                            },
                            success: function (layero, index) {
                            }
                        });
                    //新增
                    case 'btnAdd': set_AddNew();
                        break;
                    case 'btn-Edit':
                        var checkStatus = table.checkStatus('mainTable')
                            , data = checkStatus.data;
                        if (checkStatus.data.length === 1) {
                            var hID = data[0].hmainid.toString();
                            //if (AllowLoadData(sSubStr) != false) {//非空验证
                            layer.open({
                                type: 2
                                , area: ['100%', '100%']
                                , title: '编辑设备故障登记单'
                                , closeBtn: 1
                                , shade: 0.6 //遮罩透明度
                                , maxmin: true //允许全屏最小化
                                , anim: 0 //0-6的动画形式,-1不开启
                                , content: '../设备管理/Sb_Add_EqpConkBookBillList.html?hID=' + hID
                                , resize: false,
                                end: function () {
                                    //刷新页面,
                                    location.reload();
                                }
                                , cancel: function () {
                                    //$(".layui-btn").removeClass("layui-btn-disabled");
                                }
                            })
                        } else {
                            layer.msg('请选择一行数据编辑!');
                        }
                    //编辑
                    case 'btnModify': set_ShowBill();
                        break;
                    case 'btn-Delete':
                        var checkStatus = table.checkStatus('mainTable')
                            , data = checkStatus.data;
                        if (checkStatus.data.length === 1) {
                            var InterID = data[0].hmainid.toString();
                            //逻辑删除方法
                            layer.confirm("确认要删除吗,删除后不能恢复", { title: "删除确认" }, function (index) {
                                $.ajax({
                                    type: "GET",
                                    url: GetWEBURL() + "Sb_EqpRepairWorkBill/DeltetEqpConkBookBill", //方法所在页面和方法名
                                    data: { "HInterID": InterID },
                                    success: function (result) {
                                        if (result.count == 1) {
                                            layer.msg(result.Message, { time: 1 * 1000, icon: 1 }, function () {
                                                // å¾—到frame索引
                                                var index = layer.getFrameIndex(window.name);
                                                //关闭当前frame
                                                layer.close(index);
                                                //修改为功后刷新界面
                                                window.location.reload();
                                            });
                                        } else {
                                            layer.alert(result.code + result.Message, { icon: 5 });
                                        }
                                    }, error: function () {
                                        layer.alert("接口请求失败!", { icon: 5 });
                                    }
                                });
                            })
                        }
                        else {
                            layer.msg('请选择一行数据删除!');
                        }
                    //删除
                    case 'btndelete': set_DeleteBill();
                        break;
                    //禁用
                    case 'btnJY': set_AuditBill();
                        break;
                    //反禁用
                    case 'btnFJY': set_DeAuditBill();
                        break;
                };
            });
            //进入页面显示的缓存列表
            $.ajax({
                //url: "http://61.130.49.162:9090/WMSAPI///Web/GetMAXNum",
                url: GetWEBURL() + '/Sb_EqpRepairWorkBill/GetEqpConkBookBillList',
                type: "GET",
                data: { "sWhere": sWhere},
                success: function (data1) {
                    if (data1.count == 1) {
                        option.data = data1.data;
                        table.render(option);
                        layer.close(index);
                    } else {
                        layer.close(index);
                        layer.alert(data1.code + data1.Message, { icon: 5 });
                    }
                }, error: function () {
                    layer.close(index);
                    layer.alert("接口请求失败!", { icon: 5 });
                }
            });
            //重置按钮
            form.on('submit(btnReSearch)', function (data) {
                $("#HDate").val("");//开始日期
                $("#HDate1").val("");//结束日期
                $("#HBillNo").val("");//单据号
                $("#btnSearch").click();
            });
            //查询按钮
            form.on('submit(btnSearch)', function (data) {//选择仓位
            form.on('submit(btnSearch)', function (data) {
                get_FastQuery();
            });
            // é‡ç½®æŒ‰é’®
            form.on('submit(btnReSearch)', function (data) {
                set_ClearQuery();
            });
            //#endregion
            //#region æ­¤é¡µé¢æ‰€æœ‰æ–¹æ³•
            // åˆå§‹åŒ–界面
            function set_ClearBill() {
                //初始化表格
                set_InitGrid();
                //查询
                get_Display(sWhere);
            }
            //初始化表格
            function set_InitGrid() {
                option = {
                    elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , height: 'full-50'
                    , page: true
                    , cellMinWidth: 90
                    , cols: [[
                        { type: 'checkbox', fixed: 'left' }
                        , { field: 'hmainid', title: '单据ID', hide: true }
                        , { field: '日期', title: '日期', width: 160, templet: "<div>{{d.日期 ==null ?'':layui.util.toDateString(d.日期, 'yyyy-MM-dd')}}</div>" }
                        , { field: '单据号', title: '单据号', width: 160 }
                        , { field: '单据类型', title: '单据类型', width: 160, hide: true }
                        , { field: 'HEquipID', title: 'HEquipID', width: 200, hide: true }
                        , { field: '设备代码', title: '设备代码', width: 200 }
                        , { field: '设备名称', title: '设备名称', width: 200 }
                        , { field: 'HConkTypeID', title: 'HConkTypeID', width: 200, hide: true }
                        , { field: '故障类别代码', title: '故障类别代码', width: 200 }
                        , { field: '故障类别', title: '故障类别', width: 200 }
                        , { field: 'HEmpID', title: 'HEmpID', width: 200, hide: true }
                        , { field: '发现人代码', title: '发现人代码', width: 200 }
                        , { field: '发现人', title: '发现人', width: 200 }
                        , { field: 'HDeptID', title: 'HDeptID', width: 200, hide: true }
                        , { field: '部门代码', title: '部门代码', width: 115 }
                        , { field: '部门名称', title: '部门名称', width: 200 }
                        , { field: 'HManagerID', title: 'HManagerID', width: 115, hide: true }
                        , { field: '负责人代码', title: '负责人代码', width: 115 }
                        , { field: '负责人', title: '负责人', width: 200 }
                        , { field: '发生日期', title: '发生日期', width: 160, templet: "<div>{{d.发生日期 ==null ?'':layui.util.toDateString(d.发生日期, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                        , { field: '故障描述', title: '故障描述', width: 200 }
                        , { field: '表头备注', title: '表头备注', width: 200 }
                        , { field: '内部单据号', title: '内部单据号', width: 115 }
                        , { field: '制单人', title: '制单人', width: 200 }
                        , { field: '制单日期', title: '制单日期', width: 200, templet: "<div>{{d.制单日期 ==null ?'':layui.util.toDateString(d.制单日期, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                        , { field: '审核人', title: '审核人', width: 200 }
                        , { field: '审核日期', title: '审核日期', width: 200, templet: "<div>{{d.审核日期 ==null ? '':layui.util.toDateString(d.审核日期, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                        , { field: '修改人', title: '修改人', width: 200 }
                        , { field: '修改日期', title: '修改日期', width: 200, templet: "<div>{{d.修改日期 ==null ?'':layui.util.toDateString(d.修改日期, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                        , { field: '关闭人', title: '关闭人', width: 200 }
                        , { field: '关闭日期', title: '关闭日期', width: 200, templet: "<div>{{d.关闭日期 ==null ?'':layui.util.toDateString(d.关闭日期, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                        , { field: '作废人', title: '作废人', width: 200 }
                        , { field: '作废日期', title: '作废日期', width: 200, templet: "<div>{{d.作废日期 ==null ?'':layui.util.toDateString(d.作废日期, 'yyyy-MM-dd HH:mm:ss')}}</div>" }
                        , { field: 'hsubid', title: 'hsubid', width: 200, hide: true }
                        , { field: 'HConkReasonID', title: 'HConkReasonID', width: 115, hide: true }
                        , { field: '故障原因代码', title: '故障原因代码', width: 200 }
                        , { field: '故障原因名称', title: '故障原因名称', width: 200 }
                        , { field: '故障原因描述', title: '故障原因描述', width: 200 }
                        , { field: 'HManagerID', title: 'HManagerID', width: 115, hide: true }
                        , { field: '表体负责人代码', title: '表体负责人代码', width: 200 }
                        , { field: '表体负责人', title: '表体负责人', width: 200 }
                        , { field: '行关闭人', title: '行关闭人', width: 200 }
                        , { field: '关闭类型', title: '关闭类型', width: 200 }
                        , { field: '表体备注', title: '表体备注', width: 200 }
                        , { field: '源单主内码', title: '源单主内码', width: 200, hide: true }
                        , { field: '源单子内码', title: '源单子内码', width: 200, hide: true }
                        , { field: '源单单号', title: '源单单号', width: 200 }
                        , { field: '源单类型', title: '源单类型', width: 200 }
                        , { field: '关联数量', title: '关联数量', width: 200 }
                        , { field: 'HBillType', title: 'HBillType', width: 200, hide: true }
                    ]]
                };
            }
            //查询
            function get_Display() {
                var index = layer.load(0, { shade: false });
                //进入页面显示的缓存列表
                $.ajax({
                    url: GetWEBURL() + '/Sb_EqpRepairWorkBill/GetEqpConkBookBillList',
                    type: "GET",
                    data: { "sWhere": sWhere },
                    success: function (data1) {
                        if (data1.count == 1) {
                            option.data = data1.data;
                            table.render(option);
                            layer.close(index);
                        } else {
                            layer.close(index);
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close(index);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
                });
            }
            //新增
            function set_AddNew() {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '新增设备故障登记单',
                    closeBtn: 1,
                    shift: 2,
                    area: ['100%', '100%'],
                    maxmin: true,
                    content: '../设备管理/Sb_Add_EqpConkBookBillList.html?OperationType=1&linterid=&HSouceBillType=',
                    end: function () {
                        //刷新页面,
                        location.reload();
                    },
                    success: function (layero, index) {
                    }
                });
            }
            //编辑
            function set_ShowBill() {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                if (checkStatus.data.length === 1) {
                    var hID = data[0].hmainid.toString();
                    //if (AllowLoadData(sSubStr) != false) {//非空验证
                    layer.open({
                        type: 2
                        , area: ['100%', '100%']
                        , title: '编辑设备故障登记单'
                        , closeBtn: 1
                        , shade: 0.6 //遮罩透明度
                        , maxmin: true //允许全屏最小化
                        , anim: 0 //0-6的动画形式,-1不开启
                        , content: '../设备管理/Sb_Add_EqpConkBookBillList.html?OperationType=3&linterid=' + hID + '&HSouceBillType='
                        , resize: false,
                        end: function () {
                            //刷新页面,
                            location.reload();
                        }
                        , cancel: function () {
                            //$(".layui-btn").removeClass("layui-btn-disabled");
                        }
                    })
                } else {
                    layer.msg('请选择一行数据编辑!');
                }
            }
            //删除
            function set_DeleteBill() {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                if (checkStatus.data.length === 1) {
                    var InterID = data[0].hmainid.toString();
                    //逻辑删除方法
                    layer.confirm("确认要删除吗,删除后不能恢复", { title: "删除确认" }, function (index) {
                        $.ajax({
                            type: "GET",
                            url: GetWEBURL() + "Sb_EqpRepairWorkBill/DeltetEqpConkBookBill", //方法所在页面和方法名
                            data: { "HInterID": InterID },
                            success: function (result) {
                                if (result.count == 1) {
                                    layer.msg(result.Message, { time: 1 * 1000, icon: 1 }, function () {
                                        // å¾—到frame索引
                                        var index = layer.getFrameIndex(window.name);
                                        //关闭当前frame
                                        layer.close(index);
                                        //修改为功后刷新界面
                                        window.location.reload();
                                    });
                                } else {
                                    layer.alert(result.code + result.Message, { icon: 5 });
                                }
                            }, error: function () {
                                layer.alert("接口请求失败!", { icon: 5 });
                            }
                        });
                    })
                }
                else {
                    layer.msg('请选择一行数据删除!');
                }
            }
            //快速过滤
            function get_FastQuery() {
                var HDate = $("#HDate").val();//开始日期
                var HDate1 = $("#HDate1").val();//结束日期
                var HBillNo = $("#HBillNo").val();//单据号
@@ -317,55 +355,23 @@
                if (HBillNo) {
                    sWhere += " and å•据号 like '%" + HBillNo + "%'";
                }
                var index = layer.load(0);
                $.ajax({
                    //url: "http://61.130.49.162:9090/WMSAPI///Web/GetMAXNum",
                    url: GetWEBURL() + '/Sb_EqpRepairWorkBill/GetEqpConkBookBillList',
                    type: "GET",
                    data: { "sWhere": sWhere},
                    success: function (data1) {
                        if (data1.count == 1) {
                            option.data = data1.data;
                            table.render(option);
                            layer.close(index);
                            layer.alert("查询成功", { icon: 1 });
                        } else {
                            layer.close(index);
                            layer.alert(data1.code + data1.Message, { icon: 5 });
                        }
                    }, error: function () {
                        layer.close(index);
                        layer.alert("接口失效!", { icon: 5 });
                    }
                });
                //调用接口后清空sWhere缓存
                sWhere = "";
                //$("#HBillType").val("");//单据类型
                //$("#HBillNo").val("");//单据号
                //$("#HSourceBillNo").val("");//源单号
                //$("#HCreateBy").val("");//制单人
                //$("#BenginHCreateDate").val("");//开始制单时间
                //$("#EndHCreateDate").val("");//结束制单时间
            });
                get_Display(sWhere);
                sWhere = "";//调用接口后清空sWhere缓存
            }
            //监听行双击事件
            table.on('rowDouble(mainTable)', function (obj) {
                layer.alert("双击事件", { icon: 1 });
            });
            //重置
            function set_ClearQuery() {
                $("#HDate").val("");//开始日期
                $("#HDate1").val("");//结束日期
                $("#HBillNo").val("");//单据号
                $("#btnSearch").click();
            }
            //laydate.render({
            //    elem: '#HDate'
            //    , type: 'datetime'
            //    , trigger: 'click'
            //    , format:'yyyy-MM-dd HH:mm'
            //});
            //#endregion
            //以上是layui模块
        });
    </script>