1
wangbin
2024-07-08 3dfe7dfe993869c8a44e9ccf177849abe98ca8d0
WebTM/views/É豸¹ÜÀí/É豸µµ°¸/Gy_EquipFileMainEdit.html
@@ -9,6 +9,11 @@
    <link rel="stylesheet" href="../../../layuiadmin/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../../../layuiadmin/style/admin.css" media="all">
    <script src="../../../layuiadmin/zgqCustom/zgqCustom.js"></script>
    <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/PubCustom.js"></script>
    <script src="../../../layuiadmin/PageTitle.js"></script>
    <style type="text/css">
        /*begin æ­¤æ ·å¼ç”¨äºŽæ¶ˆé™¤è¡Œå…ƒç´ ä¸­å¸ƒå±€å®½åº¦ä¸å¤Ÿçš„问题*/
@@ -379,12 +384,55 @@
                                </div>-->
                            </div>
                        </div>
                        <div class="layui-tab" lay-filter="table">
                            <ul class="layui-tab-title" lay-filter="tab-all">
                                <li style="padding:1px;" class="layui-this">保养规程</li>
                                <li style="padding:1px;">点检规程</li>
                            </ul>
                            <div class="layui-tab-content">
                                <div class="layui-tab-item layui-show">
                                    <!--保养规程详细-->
                                    <table class="layui-hide" id="mainTableMaintainRule" lay-filter="mainTableMaintainRule"></table>
                                    <script type="text/html" id="toolbarDemoMaintainRule">
                                        <div class="layui-btn-container">
                                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-AddLine"><i class="layui-icon layui-icon-form"></i>增加一行</button>
                                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine"><i class="layui-icon layui-icon-form"></i>复制一行</button>
                                            <!--<button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn"><i class="layui-icon layui-icon-form"></i>列设置</button>-->
                                        </div>
                                    </script>
                                </div>
                                <div class="layui-tab-item">
                                    <!--点检规程列表-->
                                    <table class="layui-hide" id="mainTableDotCheckRule" lay-filter="mainTableDotCheckRule"></table>
                                    <script type="text/html" id="toolbarDemoDotCheckRule">
                                        <div class="layui-btn-container">
                                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-AddLine2"><i class="layui-icon layui-icon-form"></i>增加一行</button>
                                            <button type="button" class="layui-btn layui-btn-sm" lay-event="btn-CopyLine2"><i class="layui-icon layui-icon-form"></i>复制一行</button>
                                            <!--<button type="button" class="layui-btn layui-btn-sm" lay-event="set_HideColumn2"><i class="layui-icon layui-icon-form"></i>列设置</button>-->
                                        </div>
                                    </script>
                                </div>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <!--//子表删除-->
    <script type="text/html" id="barDemo">
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <script type="text/html" id="barDemo2">
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>
    <!--//复选框-->
    <script type="text/html" id="HStdFlag">
        <input type="checkbox" name="checkbox" value="{{d.HStdFlag}}" lay-skin="primary" lay-filter="HStdFlag" {{ d.HStdFlag == true ? 'checked' : '' }}>
    </script>
    <script type="text/html" id="HStdFlag2">
        <input type="checkbox" name="checkbox" value="{{d.HStdFlag}}" lay-skin="primary" lay-filter="HStdFlag2" {{ d.HStdFlag == true ? 'checked' : '' }}>
    </script>
    <script src="../../../layuiadmin/layui/layui.js"></script>
    <script src="../../../layuiadmin/Scripts/json2.js"></script>
    <script src="../../../layuiadmin/Scripts/jquery-1.4.1.js"></script>
@@ -421,6 +469,7 @@
                ;
            var sBillType = "3308";
            $("#HMakeSupID").val(0);
            var tabIndex = 1;
            //#endregion
            //#region è¿›å…¥é¡µé¢å³åŠ è½½
@@ -440,6 +489,157 @@
            else {
                layer.alert("未知操作类型!", { icon: 5 });
            }
            //#endregion
            //#region åˆå§‹åŒ–子表
            var optionMaintainRule;
            var optionDotCheckRule;
            var rowdataMaintainRule = [{
                "HMaintainRuleID": 0, "保养规程单据号": "", "HStdFlag": false, "HRemark": ""
                , "HSourceInterID": "0"
                , "HSourceEntryID": "0"
                , "HSourceBillNo": ""
                , "HSourceBillType": ""
            }];
            var rowdataDotCheckRule = [{
                "HDotCheckRuleID": 0, "点检规程单据号": "", "HStdFlag": false, "HRemark": ""
                , "HSourceInterID": "0"
                , "HSourceEntryID": "0"
                , "HSourceBillNo": ""
                , "HSourceBillType": ""
            }];
            set_InitGrid();
            //保养规程头工具栏事件
            table.on('toolbar(mainTableMaintainRule)', function (obj) {
                var checkStatus = table.checkStatus('mainTableMaintainRule')
                    , data = checkStatus.data;
                //新增行表格数据
                var NewRow = {
                    "HMaintainRuleID": 0, "保养规程单据号": "", "HStdFlag": false, "HRemark": ""
                    , "HSourceInterID": "0"
                    , "HSourceEntryID": "0"
                    , "HSourceBillNo": ""
                    , "HSourceBillType": ""
                };
                switch (obj.event) {
                    case 'btn-AddLine':
                        table.cache["mainTableMaintainRule"].push(NewRow);
                        optionMaintainRule.data = table.cache["mainTableMaintainRule"];
                        table.render(optionMaintainRule);
                        //刷新复选框
                        //checkRefresh();
                        break;
                    case 'btn-CopyLine':
                        var copydata = JSON.stringify(data);
                        if (data.length <= 0) {
                            layer.msg("请选择需要复制的一行!");
                        }
                        else if (data.length > 1) {
                            layer.msg("只能选择复制一行!");
                        }
                        else {
                            var copydata2 = copydata.substring(1, copydata.length);//去除首行字符'['
                            var copyrow = copydata2.substring(0, copydata2.length - 1);//去除末尾字符']'
                            table.cache["mainTableMaintainRule"].push(JSON.parse(copyrow));//将复制的行强转成json追加到表格上
                            optionMaintainRule.data = table.cache["mainTableMaintainRule"];//将数据绑定到data上
                            table.render(optionMaintainRule);//将数据渲染到表格上
                            //刷新复选框
                            //checkRefresh();
                        }
                        break;
                    //列设置
                    //case 'set_hidecolumn':
                    //    get_hidecolumn();
                    //    break;
                }
            });
            //点检规程头工具栏事件
            table.on('toolbar(mainTableDotCheckRule)', function (obj) {
                var checkStatus = table.checkStatus('mainTableDotCheckRule')
                    , data = checkStatus.data;
                //新增行表格数据
                var NewRow = {
                    "HDotCheckRuleID": 0, "点检规程单据号": "", "HStdFlag": false, "HRemark": ""
                    , "HSourceInterID": "0"
                    , "HSourceEntryID": "0"
                    , "HSourceBillNo": ""
                    , "HSourceBillType": ""
                };
                switch (obj.event) {
                    case 'btn-AddLine2':
                        table.cache["mainTableDotCheckRule"].push(NewRow);
                        optionDotCheckRule.data = table.cache["mainTableDotCheckRule"];
                        table.render(optionDotCheckRule);
                        //刷新复选框
                        //checkRefresh();
                        break;
                    case 'btn-CopyLine2':
                        var copyschemedata = JSON.stringify(data);
                        if (data.length <= 0) {
                            layer.msg("请选择需要复制的一行!");
                        }
                        else if (data.length > 1) {
                            layer.msg("只能选择复制一行!");
                        }
                        else {
                            var copyschemedata2 = copyschemedata.substring(1, copyschemedata.length);//去除首行字符'['
                            var copyschemerow = copyschemedata2.substring(0, copyschemedata2.length - 1);//去除末尾字符']'
                            table.cache["mainTableDotCheckRule"].push(JSON.parse(copyschemerow));//将复制的行强转成json追加到表格上
                            optionDotCheckRule.data = table.cache["mainTableDotCheckRule"];//将数据绑定到data上
                            table.render(optionDotCheckRule);//将数据渲染到表格上
                            console.log(optionDotCheckRule.data);
                            //刷新复选框
                            //checkRefresh();
                        }
                        break;
                    //列设置
                    //case 'set_hidecolumn':
                    //    get_hidecolumn();
                    //    break;
                }
            });
            //行内事件
            table.on('tool(mainTableMaintainRule)', function (obj) {
                set_GridDelete(obj);   //行内删除
                set_GridCellCheck(obj); //行内快捷键筛选
            });
            table.on('tool(mainTableDotCheckRule)', function (obj) {
                set_GridDelete(obj);   //行内删除
                set_GridCellCheck(obj); //行内快捷键筛选
            });
            //#region å®Œæˆæ ‡è®°
            form.on('checkbox(HStdFlag)', function (data) {
                //获取下拉框选中的值
                var elem = data.othis.parents('tr');
                var dataindex = elem.attr("data-index");
                $.each(optionMaintainRule.data, function (index, value) {
                    if (value.LAY_TABLE_INDEX == dataindex) {
                        value.HStdFlag = data.elem.checked;//把选中下拉框id值赋值给表格缓存
                    }
                });
            });
            form.on('checkbox(HStdFlag2)', function (data) {
                //获取下拉框选中的值
                var elem = data.othis.parents('tr');
                var dataindex = elem.attr("data-index");
                $.each(optionDotCheckRule.data, function (index, value) {
                    if (value.LAY_TABLE_INDEX == dataindex) {
                        value.HStdFlag = data.elem.checked;//把选中下拉框id值赋值给表格缓存
                    }
                });
            });
            //#endregion
            // ç›‘听Tab切换,切换时触发
            element.on('tab(table)', function (data) {
                // èŽ·å–è¢«åˆ‡æ¢åˆ°çš„é¢æ¿çš„ç´¢å¼•
                var index = data.index;
                // æ‰§è¡Œä¸€äº›æ“ä½œï¼Œä¾‹å¦‚改变页面内容
                tabIndex = index + 1;
            });
            //#endregion
            //#region é¡µé¢æŒ‰é’®è§¦å‘事件
@@ -902,8 +1102,59 @@
            });
            //#endregion
            //子表初始化
            function set_InitGrid() {
                optionMaintainRule = {
                    elem: '#mainTableMaintainRule'
                    , toolbar: '#toolbarDemoMaintainRule'
                    //, page: true
                    //, limit: 500
                    //, limits: [50, 500, 5000, 50000]
                    , totalRow: true
                    , cellMinWidth: 120
                    , height: 400
                    , cols: [[
                        { type: 'checkbox', totalRowText: '合计行' }
                        , { type: 'numbers', title: '序号', style: 'background-color: #f9f9f9;' }
                        , { field: 'HMaintainRuleID', title: 'HMaintainRuleID', hide: true, style: 'background-color: #f9f9f9;' }
                        , { field: '保养规程单据号', title: '保养规程单据号', edit: 'text', style: 'background-color: #f9f9f9;', event: "HMaintainRuleID" }     //f7
                        , { field: 'HRemark', title: '备注', edit: 'text' }
                        , { field: 'HStdFlag', title: '默认标记', templet: "#HStdFlag" }//checkbox
                        , { field: 'HSourceInterID', title: '源单内码', hide: true, style: 'background-color: #f9f9f9;' }     //f7
                        , { field: 'HSourceEntryID', title: '源单子内码', hide: true, style: 'background-color: #f9f9f9;' }     //f7
                        , { field: 'HSourceBillNo', title: '源单单号', hide: true, style: 'background-color: #f9f9f9;' }     //f7
                        , { field: 'HSourceBillType', title: '源单类型', hide: true, style: 'background-color: #f9f9f9;' }     //f7
                        , { fixed: 'right', title: '操作', toolbar: '#barDemo' }
                    ]]
                };
                optionMaintainRule.data = rowdataMaintainRule;
                table.render(optionMaintainRule);
                optionDotCheckRule = {
                    elem: '#mainTableDotCheckRule'
                    , toolbar: '#toolbarDemoDotCheckRule'
                    //, page: true
                    //, limit: 500
                    //, limits: [50, 500, 5000, 50000]
                    , totalRow: true
                    , cellMinWidth: 120
                    , height: 400
                    , cols: [[
                        { type: 'checkbox', totalRowText: '合计行' }
                        , { type: 'numbers', title: '序号', style: 'background-color: #f9f9f9;' }
                        , { field: 'HDotCheckRuleID', title: 'HDotCheckRuleID', hide: true, style: 'background-color: #f9f9f9;' }
                        , { field: '点检规程单据号', title: '点检规程单据号', edit: 'text', style: 'background-color: #f9f9f9;', event: "HDotCheckRuleID" }     //f7
                        , { field: 'HRemark', title: '备注', edit: 'text' }
                        , { field: 'HStdFlag', title: '默认标记', templet: "#HStdFlag2" }//checkbox
                        , { field: 'HSourceInterID', title: '源单内码', hide: true, style: 'background-color: #f9f9f9;' }     //f7
                        , { field: 'HSourceEntryID', title: '源单子内码', hide: true, style: 'background-color: #f9f9f9;' }     //f7
                        , { field: 'HSourceBillNo', title: '源单单号', hide: true, style: 'background-color: #f9f9f9;' }     //f7
                        , { field: 'HSourceBillType', title: '源单类型', hide: true, style: 'background-color: #f9f9f9;' }     //f7
                        , { fixed: 'right', title: '操作', toolbar: '#barDemo' }
                    ]]
                }
                optionDotCheckRule.data = rowdataDotCheckRule;
                table.render(optionDotCheckRule);
            }
            //初始化表单插件
            function set_InitFrom() {
                //常规用法
@@ -916,7 +1167,100 @@
                $("#HEquipMaintainRuleInterID").val(0);
                $("#HEquipDotCheckRuleInterID").val(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 == "HMaintainRuleID") {
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '设备保养规程',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../设备规程单/Sb_EquipMaintainRuleList.html', 'yes'],
                                btn: ['确定', '取消']
                                , btn1: function (index, laero) {
                                    //按钮一  çš„回调
                                    var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
                                    var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
                                    if (checkStatus.data.length != 1) {
                                        return layer.msg("请选择一条数据");
                                    }
                                    OptionData = checkStatus.data[0];
                                    //更新表格缓存的数据
                                    obj.update({
                                        "HMaintainRuleID": OptionData.hmainid
                                        , "保养规程单据号": OptionData.单据号
                                    })
                                    layer.close(index);//关闭弹窗
                                }
                                , end: function () {
                                }
                            })
                        }
                        if (obj.event == "HDotCheckRuleID") {
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim', //加上边框
                                title: '设备点检规程',
                                closeBtn: 1,
                                shift: 2,
                                area: ['80%', '80%'],
                                maxmin: true,
                                content: ['../设备规程单/Sb_EquipDotCheckRuleList.html', 'yes'],
                                btn: ['确定', '取消']
                                , btn1: function (index, laero) {
                                    //按钮一  çš„回调
                                    var iframeWindow = window["layui-layer-iframe" + index];//获取弹框页面
                                    var checkStatus = iframeWindow.layui.table.checkStatus("mainTable");//获取选中的数据
                                    if (checkStatus.data.length != 1) {
                                        return layer.msg("请选择一条数据");
                                    }
                                    OptionData = checkStatus.data[0];
                                    //更新表格缓存的数据
                                    obj.update({
                                        "HDotCheckRuleID": OptionData.hmainid
                                        , "点检规程单据号": OptionData.单据号
                                    })
                                    layer.close(index);//关闭弹窗
                                }
                                , end: function () {
                                }
                            })
                        }
                        obj.event = "";
                        return false;
                    }
                })
            }
            //行内删除
            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();
                            optionMaintainRule.data = table.cache["mainTableMaintainRule"];//将数据绑定到data上
                            table.reload(optionMaintainRule);
                            optionDotCheckRule.data = table.cache["mainTableDotCheckRule"];
                            table.reload(optionDotCheckRule);
                            layer.close(index);
                        }
                    });
                }
            }
            //新增
            function set_AddFNew() {
                //获取最大单据号
@@ -932,7 +1276,7 @@
                    type: "GET",
                    data: { "HBillType": sBillType },
                    success: function (d) {
                        $("#HInterID").val(0);
                        $("#HInterID").val(d.data[0].HInterID);
                        $("#HBillNo").val(d.data[0].HBillNo);
                        $("#HDate").val(Format(new Date(), "yyyy-MM-dd"));
                        $("#HOutComDate").val(Format(new Date(), "yyyy-MM-dd"));
@@ -1000,6 +1344,55 @@
                        form.render("select");
                    }
                });
                $.ajax({
                    url: GetWEBURL() + "/Gy_EquipFileMain/Gy_EquipFileSubDetai",
                    type: "GET",
                    data: {
                        "HInterID": linterid
                    },
                    success: function (data) {
                        if (data.code == 1) {
                            var dataMaintainRule = data.data[0];
                            var dataDotCheckRule = data.data[1];
                            //子表1赋值
                            var rowdata = [];
                            for (var i = 0; i < dataMaintainRule.length; i++) {
                                rowdata.push(
                                    {
                                        "HMaintainRuleID": dataMaintainRule[i].HMaintainRuleID, "保养规程单据号": dataMaintainRule[i].HBillNo, "HStdFlag": dataMaintainRule[i].HStdFlag, "HRemark": dataMaintainRule[i].HRemark
                                        , "HSourceInterID": dataMaintainRule[i].HSourceInterID
                                        , "HSourceEntryID": dataMaintainRule[i].HSourceEntryID
                                        , "HSourceBillNo": dataMaintainRule[i].HSourceBillNo
                                        , "HSourceBillType": dataMaintainRule[i].HSourceBillType
                                    }
                                )
                            }
                            optionMaintainRule.data = rowdata;
                            table.render(optionMaintainRule);
                            //子表2赋值
                            var rowdata = [];
                            for (var i = 0; i < dataDotCheckRule.length; i++) {
                                rowdata.push(
                                    {
                                        "HDotCheckRuleID": dataDotCheckRule[i].HDotCheckRuleID, "点检规程单据号": dataDotCheckRule[i].HBillNo, "HStdFlag": dataDotCheckRule[i].HStdFlag, "HRemark": dataDotCheckRule[i].HRemark
                                        , "HSourceInterID": dataDotCheckRule[i].HSourceInterID
                                        , "HSourceEntryID": dataDotCheckRule[i].HSourceEntryID
                                        , "HSourceBillNo": dataDotCheckRule[i].HSourceBillNo
                                        , "HSourceBillType": dataDotCheckRule[i].HSourceBillType
                                    }
                                )
                            }
                            optionDotCheckRule.data = rowdata;
                            table.render(optionDotCheckRule);
                        } else {
                            layer.close(ajaxLoad);
                            layer.alert(result.msg, { icon: 5, btn: ['退出'], time: 100000, offset: 't' });
                        }
                    }, error: function () {
                        layer.close(ajaxLoad);
                        layer.alert("发生错误!", { icon: 5 });
                    }
                });
            }
            // ç¼–辑获取表头时时间格式矫正方式
@@ -1021,7 +1414,22 @@
                $("#HMaker").val(sessionStorage["HUserName"]);
                var user = sessionStorage["HUserName"];
                var ModRightNameAdd = 'Gy_MouldFile_Edit';
                //保养规格
                var mainTableMaintainRuleStr = [];
                for (var i = 0; i < table.cache["mainTableMaintainRule"].length; i++) {
                    if (table.cache["mainTableMaintainRule"][i] != "") {
                        table.cache["mainTableMaintainRule"][i].LAY_TABLE_INDEX = i;
                        mainTableMaintainRuleStr.push(table.cache["mainTableMaintainRule"][i])
                    }
                }
                //点检规格
                var mainTableDotCheckRuleStr = [];
                for (var i = 0; i < table.cache["mainTableDotCheckRule"].length; i++) {
                    if (table.cache["mainTableDotCheckRule"][i] != "") {
                        table.cache["mainTableDotCheckRule"][i].LAY_TABLE_INDEX = i;
                        mainTableDotCheckRuleStr.push(table.cache["mainTableDotCheckRule"][i])
                    }
                }
                if (!AllowLoadData())//数据验证
                {
                    return false;
@@ -1029,7 +1437,7 @@
                if (Stverf == "Add") {
                    data.field.HMaker = sessionStorage["HUserName"];//制单人
                    var sMainStr = JSON.stringify(data.field);
                    var oMain = sMainStr + ";" + ModRightNameAdd + ";" + user;
                    var oMain = sMainStr + ";" + JSON.stringify(mainTableMaintainRuleStr) + ";" + JSON.stringify(mainTableDotCheckRuleStr)+";"+ user;
                    //新增
                    $.ajax({
                        type: "POST",
@@ -1062,7 +1470,7 @@
                    //修改
                    data.field.HUpDater = sessionStorage["HUserName"];//修改人
                    var sMainStr = JSON.stringify(data.field);
                    var oMain = sMainStr + ";" + ModRightNameAdd + ";" + user;
                    var oMain = sMainStr + ";" + JSON.stringify(mainTableMaintainRuleStr) + ";" + JSON.stringify(mainTableDotCheckRuleStr) + ";" + user;
                    $.ajax({
                        type: "POST",
                        url: GetWEBURL() + "/Gy_EquipFileMain/EditBill",