WebTM/views/É豸¹ÜÀí/Sb_Add_EqpMaintenanceBillList.html
@@ -17,7 +17,7 @@
<body>
    <div id="layout1" class="layui-fluid">
        <div class="layui-row layui-col-space15">
        <div class="layui-row layui-col-space15">
            <div class="layui-col-md12">
                <div class="layui-card">
                    <form id="form0" class="layui-form" lay-filter="component-form-group" action="">
@@ -152,6 +152,28 @@
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <label class="layui-form-label">源单类型</label>
                                                <div class="layui-input-inline">
                                                    <select name="HMainSourceBillType" lay-filter="HMainSourceBillType" id="HMainSourceBillType">
                                                        <option value="设备维修登记单" selected="selected">设备维修登记单</option>
                                                        <option value="手工录入">手工录入</option>
                                                    </select>
                                                </div>
                                            </div>
                                            <div class="layui-inline">
                                                <label class="layui-form-label">选单号</label>
                                                <div class="layui-input-inline">
                                                    <input type="text" name="HMainSourceBillNo" id="HMainSourceBillNo" class="layui-input" value="" style="float:left;width:150px;">
                                                    <input type="hidden" name="HMainSourceInterID" id="HMainSourceInterID" class="layui-input" value="" style="float:left;width:150px;">
                                                    <input type="hidden" name="HMainSourceEntryID" id="HMainSourceEntryID" class="layui-input" value="" style="float:left;width:150px;">
                                                    <button type="button" lay-submit="" class="layui-btn" lay-filter="XDHList" id="XDHList" style="width:40px;">
                                                        <i class="layui-icon layui-icon-search layuiadmin-button-btn" style="margin-left:-9px;"></i>
                                                    </button>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="layui-form-item">
                                            <div class="layui-inline">
                                                <label class="layui-form-label">维修内容</label>
                                                <div class="layui-input-inline">
                                                    <textarea placeholder="请输入维修内容" class="layui-textarea" name="HRepairContent" id="HRepairContent"></textarea>
@@ -226,7 +248,7 @@
            var option;
            var sBillType = "3910";
            var TabRow = { "HRepairID1": 0, "HRepairCode": "", "HRepairName": "", "HManagerID1": 0, "HManagerCode": "", "HManagerName": "", "HRepairExplanation": "", "HRemark": "" };
            //var TabRow = { "HRepairID1": 0, "HRepairCode": "", "HRepairName": "", "HManagerID1": 0, "HManagerCode": "", "HManagerName": "", "HRepairExplanation": "", "HRemark": "" };
            //#endregion
            //#region è¿›å…¥é¡µé¢å³åŠ è½½
@@ -246,13 +268,34 @@
            }
            //#endregion
            //获取下拉选中值
            form.on('select(HMainSourceBillType)', function (data) {
                Sctag = data.value;
                form.render('select');
                switch (Sctag) {
                    //无源单新增
                    case '1':
                        $('#HMainSourceBillNo').attr("disabled", false);
                        $('#XDHList').addClass("layui-btn-disabled").attr("disabled", true);
                        break;
                    //有源单新增  Â 
                    case '2':
                        $('#HMainSourceBillNo').attr("disabled", true);
                        $('#XDHList').removeClass("layui-btn-disabled").attr("disabled", false);
                        break;
                }
            });
            //#region è§¦å‘事件:包括form.on(){}格式的所有点击事件、选择事件等
            //头工具栏事件
            table.on('toolbar(mainTable)', function (obj) {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;;
                var NewRow = TabRow;
                var NewRow = { "HRepairID": 0, "HRepairCode": "", "HRepairName": "", "HManagerID": 0, "HManagerCode": "", "HManagerName": "", "HRepairExplanation": "", "HRemark": ""/*, "HSourceInterID": 0, "HSourceEntryID": 0, "HSourceBillNo": " ", "HSourceBillType": " " */};
                switch (obj.event) {
                    //增加一行
                    case 'btn-AddLine': set_AddLine(NewRow);
@@ -331,7 +374,7 @@
                            return layer.msg('请选择数据');
                        }
                        $("#HEquipName").val(checkStatus.data[0].HName);
                        $("#HEquipID").val(checkStatus.data[0].HItemID);
                        $("#HEquipID").val(checkStatus.data[0].HInterID);
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
@@ -461,6 +504,86 @@
                });
            });
            //表头信息选择单据弹窗
            form.on('submit(XDHList)', function () {
                //页面层-自定义
                layer.open({
                    type: 2,
                    skin: 'layui-layer-rim', //加上边框
                    title: '设备维修登记单',
                    shift: 2,
                    area: ['90%', '90%'],
                    content: ['../设备管理/Sb_EqpConkBookBillList.html', 'yes'],
                    btn: ['确定', '取消']
                    , btn1: function (index, layero) {
                        //var NewRow = { "HRepairID": 0, "HRepairCode": "", "HRepairName": "", "HManagerID": 0, "HManagerCode": "", "HManagerName": "", "HRepairExplanation": "", "HRemark": "", "HSourceInterID": 0, "HSourceEntryID": 0, "HSourceBillNo": " ", "HSourceBillType": " " };
                        ////按钮【按钮一】的回调
                        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('请选择单据数据');
                        }
                        $("#HMainSourceBillNo").val(checkStatus.data[0].单据号);
                        $("#HMainSourceInterID").val(checkStatus.data[0].hmainid);
                        $("#HMainSourceEntryID").val(checkStatus.data[0].hsubid);
                        ////按选单号加载表体数据
                        //$.ajax({
                        //    url: GetWEBURL() + 'Sb_EqpRepairWorkBill/Sb_EqpRepairWorkBillSubByHMainSourceBillNo',
                        //    type: "GET",
                        //    data: { "HMainSourceBillNo": checkStatus.data[0].单据号 },
                        //    success: function (result) {
                        //        if (result.count == 1) {
                        //            var EndData = result.data;
                        //            var rowdate = layui.table.cache["mainTable"];
                        //            if (rowdate.length == 0)  //表体数据为空时
                        //            {
                        //                buttonArr = [];//清空数组
                        //                for (var i = 0; i < checkStatus.data.length; i++) {
                        //                    var checkrow = { "HRepairID": 0, "HRepairCode": "", "HRepairName": "", "HManagerID": 0, "HManagerCode": "", "HManagerName": "", "HRepairExplanation": "", "HRemark": "", "HSourceInterID": EndData[i].hmainid, "HSourceEntryID": EndData[i].hsubid, "HSourceBillNo": EndData[i].单据号, "HSourceBillType": EndData[i].HBillType };
                        //                    buttonArr.push(checkrow);  //将之前的数据存储
                        //                }
                        //                table.reload("mainTable", {
                        //                    data: buttonArr    //将数据重新载入表格
                        //                })
                        //            }
                        //            else {
                        //                buttonArr = [];//清空数组
                        //                for (var i = 0; i < EndData.length; i++) {
                        //                    var checkrow = {
                        //                        "HRepairID": rowdate[i].HRepairID, "HRepairCode": rowdate[i].HRepairCode, "HRepairName": rowdate[i].HRepairName,
                        //                        "HRepairExplanation": rowdate[i].HRepairExplanation, "HManagerID": rowdate[i].HManagerID, "HManagerCode": rowdate[i].HManagerCode,
                        //                        "HManagerName": rowdate[i].HManagerName, "HMoney": rowdate[i].HMoney, "HRemark": rowdate[i].HRemark,
                        //                        "HSourceInterID": EndData[i].hmainid, "HSourceEntryID": EndData[i].hsubid,
                        //                        "HSourceBillNo": EndData[i].单据号, "HSourceBillType": EndData[i].HBillType
                        //                    };
                        //                    buttonArr.push(checkrow);  //将之前的数据存储
                        //                }
                        //                table.reload("mainTable", {
                        //                    data: buttonArr    //将数据重新载入表格
                        //                })
                        //            }
                        //        } else {
                        //            layer.alert(result.code + result.Message, { icon: 5 });
                        //        }
                        //    }, error: function () {
                        //        layer.alert("接口请求失败!", { icon: 5 });
                        //    }
                        //});
                        layer.close(layer.index); //它获取的始终是最新弹出的某个层,值是由layer内部动态递增计算的
                    }
                    , btn2: function (index, layero) {
                        //按钮【按钮二】的回调
                        //return false å¼€å¯è¯¥ä»£ç å¯ç¦æ­¢ç‚¹å‡»è¯¥æŒ‰é’®å…³é—­
                    },
                    end: function () {
                    },
                    success: function (layero, index) {
                        //layer.full(index);
                    }
                });
            });
            //保存
            form.on('submit(Saver)', function (data) {
                //debugger;
@@ -482,11 +605,11 @@
                                    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); //再执行关闭 Â  Â  Â  Â  Â Â  Â Â Â  Â 
                                        parent.layer.close(index); //再执行关闭
                                    });
                                }
                                else {
                                    f_alert(data.Message);
                                    layui.alert("保存失败")
                                    console.log("Reason" + sMainStr + "sub:" + JSON.stringify(layui.table.cache.mainTable));
                                }
                                layer.closeAll("loading");
@@ -537,14 +660,18 @@
                columns = [
                    { type: 'checkbox', fixed: 'left' }
                    , { templet: '#xuhao', title: '序号', sort: true, fixed: 'left', event: "qwe" }
                    , { field: 'HRepairID1', title: 'HRepairID1', edit: 'text', event: "", hide: true }
                    , { field: 'HRepairID', title: 'HRepairID', edit: 'text', event: "", hide: true }
                    , { field: 'HRepairCode', title: '维修项目代码', edit: 'text', event: "", event: "HRepairCode" }
                    , { field: 'HRepairName', title: '维修项目', edit: 'text', event: "" }
                    , { field: 'HManagerID1', title: 'HManagerID1', edit: 'text', hide: true }
                    , { field: 'HManagerID', title: 'HManagerID', edit: 'text', hide: true }
                    , { field: 'HManagerCode', title: '负责人代码', edit: 'text', event: "HManagerCode" }
                    , { field: 'HManagerName', title: '负责人', edit: 'text' }
                    , { field: 'HRepairExplanation', title: '维修要求', edit: 'text' }
                    , { field: 'HRemark', title: '备注', event: "", edit: 'text' }
                    //, { field: 'HSourceInterID', title: '源单主内码' }
                    //, { field: 'HSourceEntryID', title: '源单子内码' }
                    //, { field: 'HSourceBillNo', title: '源单单号' }
                    //, { field: 'HSourceBillType', title: '源单类型' }
                    , { fixed: 'right', title: '操作', toolbar: '#barDemo', width: 150 }
                ];
                option = {
@@ -565,7 +692,7 @@
            function set_AddFNew() {
                //获取最大单据号
                get_MAXNum();
                option.data = [TabRow];
                option.data = [{ "HRepairID": 0, "HRepairCode": "", "HRepairName": "", "HManagerID": 0, "HManagerCode": "", "HManagerName": "", "HRepairExplanation": "", "HRemark": ""/*, "HSourceInterID": 0, "HSourceEntryID": 0, "HSourceBillNo": " ", "HSourceBillType": " "*/ }];
                table.render(option);
            }
@@ -593,7 +720,7 @@
            function set_EditFromGrid() {
                set_EditForm(linterid);  //编辑获取表头
                set_EditGrid(linterid);  //编辑获取表体
                option.data = [TabRow];
                option.data = [{ "HRepairID": 0, "HRepairCode": "", "HRepairName": "", "HManagerID": 0, "HManagerCode": "", "HManagerName": "", "HRepairExplanation": "", "HRemark": ""/*, "HSourceInterID": 0, "HSourceEntryID": 0, "HSourceBillNo": " ", "HSourceBillType": " " */}];
                table.render(option);
            }
@@ -631,6 +758,10 @@
                                , "HRepairContent": data.维修内容         //维修内容
                                , "HExplanation": data.维修要求           //维修要求
                                , "HRemark": data.表头备注                //备注
                                , "HMainSourceBillType": data.HMainSourceBillType
                                , "HMainSourceBillNo": data.HMainSourceBillNo
                                , "HMainSourceInterID": data.HMainSourceInterID
                                , "HMainSourceEntryID": data.HMainSourceEntryID
                            });
                        } else {
@@ -724,7 +855,7 @@
                                    }
                                    //同步更新表格和缓存对应的值
                                    obj.update({
                                        HRepairID1: checkStatus.data[0].HItemID,
                                        HRepairID: checkStatus.data[0].HItemID,
                                        HRepairCode: checkStatus.data[0].HNumber,
                                        HRepairName: checkStatus.data[0].HName,
                                    });
@@ -765,7 +896,7 @@
                                    //同步更新表格和缓存对应的值
                                    obj.update({
                                        HManagerID1: checkStatus.data[0].HItemID,
                                        HManagerID: checkStatus.data[0].HItemID,
                                        HManagerCode: checkStatus.data[0].HNumber,
                                        HManagerName: checkStatus.data[0].HName
                                    });
@@ -817,6 +948,17 @@
                    option.data = table.cache["mainTable"];//将数据绑定到data上
                    table.render(option);//将数据渲染到表格上
                    //layer.alert(copyrow);
                }
            }
            //判断源单带回数据数组中的值是否相同
            function isAllEqual(array) {
                if (array.length > 0) {
                    return !array.some(function (value, index) {
                        return value !== array[0];
                    });
                } else {
                    return true;
                }
            }
@@ -882,9 +1024,7 @@
                        }
                    }
                }
                else {
                    return true;
                }
                return true;
            }
            //#endregion