yxj
2025-01-03 30a3bd621ecb96b109bc5a743f2acfdd89a8c75c
WebTM/views/ϵͳ¹ÜÀí/ϵͳÅäÖÃ/Xt_AutoLoadBillList.html
@@ -30,10 +30,8 @@
            <div class="layui-card-body" style="padding: 1px;">
                <form class="layui-form" action="" lay-filter="formData" style="background-color:white;">
                    <div style="padding: 10px; ">
                        <!--<button class="layui-btn layui-btn-normal" type="button" lay-submit="" lay-filter="CheckAll" id="CheckAll">全选</button>
                        <button class="layui-btn layui-btn-normal" type="button" lay-submit="" lay-filter="ClearBill" id="ClearBill">全清</button>
                        <button class="layui-btn layui-btn-normal" type="button" lay-submit="" lay-filter="btnSave" id="btnSave">保存</button>
                        <button class="layui-btn layui-btn-normal" type="button" lay-submit="" lay-filter="Exit" id="Exit">退出</button>-->
                        <button class="layui-btn layui-btn-normal" type="button" lay-submit="" lay-filter="Exit" id="Exit">退出</button>
                    </div>
                    <div class="layui-collapse">
                        <div class="layui-colla-item">
@@ -125,14 +123,13 @@
        //获取参数
        var params = getUrlVars();
        var HSetMainModName = params[params[0]];                //表头加载模块名称
        HSetMainModName = "PM_WorkTaskBill";
        var HTableName = "";                                    //主表名
        var HDataViewName = params[params[1]];                  //视图名
        var HDataProcName = params[params[2]];                  //存储过程名
        var HRowElementCount = params[params[3]];               //每行元素数
        var HTableName = params[params[1]];                                    //主表名
        var HDataViewName = params[params[2]];                  //视图名
        var HDataProcName = params[params[3]];                  //存储过程名
        var HRowElementCount = params[params[4]];               //每行元素数
        var HUserName = sessionStorage["HUserName"];            //用户名
        var HInterID = 0;
        //元素ID与元素数据类型对照列表
        var HFieldDataTypeForElementID = [];
@@ -191,6 +188,85 @@
        //#endregion
        //#endregion
        //#region ä¸‹æ‹‰æ¡†è§¦å‘事件相关监听
        //#region è¡¨æ ¼è¡Œé€‰æ‹©å¤„理(元素ID)
        form.on('select(HElementID)', function (data) {
            //获取下拉框选中的值
            var elem = data.othis.parents('tr');
            var dataindex = elem.attr("data-index");
            $.each(option.data, function (index, value) {
                if (index == dataindex) {
                    value.HElementID = data.value;//把选中下拉框id值赋值给表格缓存
                    for (var i = 0; i < HFieldDataTypeForElementID.length; i++) {
                        if (value.HElementID == HFieldDataTypeForElementID[i].HElementID) {
                            value.HFieldDataType = HFieldDataTypeForElementID[i].HFieldDataType;
                            value.HElementIDAdditionalName = value.HElementID;
                            $('#HFieldDataType' + (index+1) + '').val(value.HFieldDataType);
                            form.render('select');
                            table.render(option);
                            //根据option中的数据,设置子表中的下拉列表、复选框
                            setSelectByTableRender();
                            break;
                        }
                    }
                }
            });
        });
        //#endregion
        //#region è¡¨æ ¼è¡Œé€‰æ‹©å¤„理(父级元素ID)
        form.on('select(HParentElementID)', function (data) {
            //获取下拉框选中的值
            var elem = data.othis.parents('tr');
            var dataindex = elem.attr("data-index");
            $.each(option.data, function (index, value) {
                if (index == dataindex) {
                    value.HParentElementID = data.value;//把选中下拉框id值赋值给表格缓存
                }
            });
        });
        //#endregion
        //#region è¡¨æ ¼è¡Œé€‰æ‹©å¤„理(组件类型)
        form.on('select(HElementType)', function (data) {
            //获取下拉框选中的值
            var elem = data.othis.parents('tr');
            var dataindex = elem.attr("data-index");
            $.each(option.data, function (index, value) {
                if (index == dataindex) {
                    value.HElementType = data.value;//把选中下拉框id值赋值给表格缓存
                }
            });
        });
        //#endregion
        //#region è¡¨æ ¼è¡Œé€‰æ‹©å¤„理(字段名)
        form.on('select(HFieldName)', function (data) {
            //获取下拉框选中的值
            var elem = data.othis.parents('tr');
            var dataindex = elem.attr("data-index");
            $.each(option.data, function (index, value) {
                if (index == dataindex) {
                    value.HFieldName = data.value;//把选中下拉框id值赋值给表格缓存
                }
            });
        });
        //#endregion
        //#region è¡¨æ ¼è¡Œé€‰æ‹©å¤„理(数据类型)
        form.on('select(HFieldDataType)', function (data) {
            //获取下拉框选中的值
            var elem = data.othis.parents('tr');
            var dataindex = elem.attr("data-index");
            $.each(option.data, function (index, value) {
                if (index == dataindex) {
                    value.HFieldDataType = data.value;//把选中下拉框id值赋值给表格缓存
                }
            });
        });
        //#endregion
        //#endregion
        //#region æ“ä½œæŒ‰é’®ç›¸å…³ç›‘听
        //#region ä¿å­˜æäº¤
        form.on('submit(btnSave)', function (data) {//提交
@@ -219,6 +295,7 @@
                "HIsDisabled": false,
                "HIsMust": false,
                "HElementID": "",
                "HElementIDAdditionalName": "",
                "HElementLabel": "",
                "HElementType": "",
                "HFieldMaxLength": "0",
@@ -280,11 +357,19 @@
        //#region åˆå§‹åŒ–界面
        function set_ClearBill() {
            getBaseDataByURLParams();
            ////根据url参数获取加载页面的数据[主表名、视图名、存储过程名]
            //getBaseDataByURLParams();
            //初始化子表
            set_InitGrid();
            setSelectInit();
            //查询历史设置记录,设置子表
            if (RoadBillMain() == true) {
            } else {
                //初始化子表中的下拉列表
                setSelectInit();
            }
        }
        //#endregion
@@ -301,12 +386,13 @@
                    , { type: 'numbers', title: '序号', width: 100 }
                    , { field: 'HArrangeOrder', title: '一级次序', width: 100, edit: true }
                    , { field: 'HArrangeOrderSub', title: '二级次序', width: 100, edit: true }
                    , { field: 'HParentElementID', title: '父级元素ID', width: 100, edit: true }
                    , { field: 'HParentElementID', title: '父级元素ID', width: 100, templet: '#HParentElementID' }
                    , { field: 'HIsHide', title: '隐藏', width: 100, templet: '#HIsHide' }
                    , { field: 'HIsDisabled', title: '禁用', width: 100, templet: '#HIsDisabled' }
                    , { field: 'HIsMust', title: '必填', width: 100, templet: '#HIsMust' }
                    , { field: 'HElementID', title: '元素ID', width: 100, templet: '#HElementID' }
                    , { field: 'HElementLabel', title: '元素标签', width: 100, templet: '#HElementLabel' }
                    , { field: 'HElementIDAdditionalName', title: '元素ID附加字段', width: 100, edit: true, event:"HElementIDAdditionalName" }
                    , { field: 'HElementLabel', title: '元素标签', width: 100, edit: true }
                    , { field: 'HElementType', title: '元素类型', width: 100, templet: '#HElementType' }
                    , { field: 'HFieldMaxLength', title: '最大长度', width: 100, edit: true }
                    , { field: 'HDefaultValue', title: '默认值', width: 100, edit: true }
@@ -328,6 +414,7 @@
                "HIsDisabled": false,
                "HIsMust": false,
                "HElementID": "",
                "HElementIDAdditionalName": "",
                "HElementLabel": "",
                "HElementType": "",
                "HFieldMaxLength": "0",
@@ -343,7 +430,7 @@
            option.data = rowdata;
            table.render(option);
            //设置下拉列表和复选框
            //根据option中的数据,设置子表中的下拉列表、复选框
            setSelectByTableRender();
        }
        //#endregion
@@ -365,6 +452,53 @@
                    }
                }
            })
        }
        //#endregion
        //#region æŸ¥è¯¢åŽ†å²è®¾ç½®è®°å½•ï¼Œè®¾ç½®å­è¡¨
        function RoadBillMain() {
            var returnResult = false;
            var ajaxLoad = layer.load();
            $.ajax({
                url: GetWEBURL() + '/Xt_DefineBillMainSet/getDefineBillMainSet',
                type: "GET",
                async: false,
                data: { "HModName": HSetMainModName, "user": sessionStorage["HUserName"] },
                success: function (data1) {
                    if (data1.count == 1) {
                        var data = data1.data;
                        if (data.length > 0) {
                            for (var i = 0; i < data.length; i++) {
                                if (data[i].HUser == sessionStorage["HUserName"]) {
                                    HInterID = data[i].HInterID;
                                }
                                data[i].HElementIDAdditionalName = data[i].HElementID;
                            }
                        }
                        option.data = data;
                        table.render(option);
                        //根据option中的数据,设置子表中的下拉列表、复选框
                        setSelectByTableRender();
                        layer.close(ajaxLoad);
                        DisPlay_HideColumn();
                        returnResult = true;
                    } else {
                        layer.close(ajaxLoad);
                    }
                }, error: function () {
                    layer.close(ajaxLoad);
                    layer.alert("接口请求失败!", { icon: 5 });
                }
            });
            return returnResult;
        }
        //#endregion
@@ -397,16 +531,15 @@
                        //获取下拉列表的列表数据
                        for (var key in data1.list) {
                            if ($.inArray(data1.list[key].ColmCols, HElementIDList) == -1) {
                                HElementIDList.push(data1.list[key].ColmCols);
                            }
                            if ($.inArray(data1.list[key].ColmType, HFieldDataTypeList) == -1) {
                                HFieldDataTypeList.push(data1.list[key].ColmType);
                                HFieldDataTypeForElementID.push({
                                    "HElementID": data1.list[key].ColmCols
                                    , "HFieldDataType": data1.list[key].ColmType
                                })
                                HElementIDList.push(data1.list[key].ColmCols);
                                if ($.inArray(data1.list[key].ColmType, HFieldDataTypeList) == -1) {
                                    HFieldDataTypeList.push(data1.list[key].ColmType);
                                }
                            }
                        }
                        //根据下拉列表的列表数据,设置下拉列表的列表
@@ -439,7 +572,18 @@
        //#region çˆ¶çº§å…ƒç´ ID
        function setSelectInit_HParentElementID() {
            var HElementIDList = ["HBaseInfo", "HFileInfo","HOtherInfo"];
            var HProTypeList = ["基本信息","附件信息","其他信息"];
            for (var i = 0; i < option.data.length; i++) {
                var Organization = "";
                Organization += '<option  style="color:blue;" selected="selected" value=""></option>';
                for (var j = 0; j < HProTypeList.length; j++) {
                    Organization += '<option  style="color:blue;" value="' + HElementIDList[j] + '">' + HProTypeList[j] + '</option>';
                }
                $('#HParentElementID' + (i + 1) + '').empty();
                $('#HParentElementID' + (i + 1) + '').append(Organization);
            }
            form.render('select');
        }
        //#endregion
@@ -461,7 +605,38 @@
        //#region å­—段名
        function setSelectInit_HFieldName() {
            $.ajax({
                type: "get",
                async: false,
                url: GetWEBURL() + "/Xt_DefineBillMainSet/getColsListByName",
                data: { "HName": HDataViewName },
                success: function (data1) {
                    if (data1.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                        var HFieldNameList = [];                                    //字段名下拉列表数据
                        //获取下拉列表的列表数据
                        for (var key in data1.list) {
                            if ($.inArray(data1.list[key].ColmCols, HFieldNameList) == -1) {
                                HFieldNameList.push(data1.list[key].ColmCols);
                            }
                        }
                        //根据下拉列表的列表数据,设置下拉列表的列表
                        for (var i = 0; i < option.data.length; i++) {
                            var Organization = "";
                            Organization += '<option  style="color:blue;" selected="selected" value=""></option>';
                            for (var j = 0; j < HFieldNameList.length; j++) {
                                Organization += '<option  style="color:blue;" value="' + HFieldNameList[j] + '">' + HFieldNameList[j] + '</option>';
                            }
                            $('#HFieldName' + (i + 1) + '').empty();
                            $('#HFieldName' + (i + 1) + '').append(Organization);
                        }
                        form.render('select');
                    } else {
                    }
                }
            })
        }
        //#endregion
@@ -476,110 +651,42 @@
        //#region æ­¤é¡µé¢æ‰€æœ‰çš„æ–¹æ³•
        //#region æ“ä½œæŒ‰é’®è°ƒç”¨æ–¹æ³•
        //#region æŸ¥è¯¢
        function get_Display() {
            var ajaxLoad = layer.load();
            $.ajax({
                url: GetWEBURL() + '/Xt_ModuleButtonSet_WMES/moduleButtonSetWMESList',
                type: "GET",
                data: { "HModName": HModName, "HBillType": HBillType, "HUserName": HUserName },
                success: function (data1) {
                    var btnIdLists = btnIdList.split(',');      //相对单据传过来的按钮id
                    var btnNameLists = btnNameList.split(',');    //相对单据传过来的按钮名称
                    var btnOrderLists = btnOrderList.split(',');   //相对单据传过来的按钮次序
                    var data = [];                              //需要传进表格的数据
                    no_edit = [];                               //清空不可编辑按钮的信息列表
                    for (var i = 0; i < btnIdLists.length; i++) {
                        for (var j = 0; j < data1.count; j++) {
                            if (btnIdLists[i] == data1.data[j]["HButtonID"]) {
                                if (data1.data[j]["HEditFlag"] == false) {
                                    no_edit.push({ "HBillType": data1.data[j]["HBillType"], "HModuleName": data1.data[j]["HModuleName"], "HButtonID": data1.data[j]["HButtonID"], "HButtonName": data1.data[j]["HButtonName"], "HOrder": data1.data[j]["HOrder"], "HHideFlag": data1.data[j]["HHideFlag"], "HEditFlag": data1.data[j]["HEditFlag"], "HOtherName": data1.data[j]["HOtherName"] });
                                } else {
                                    data.push({ "BtnID": btnIdLists[i], "BtnName": btnNameLists[i], "IsHide": data1.data[j]["HHideFlag"], "HOrder": btnOrderLists[i], "HOtherName": data1.data[j]["HOtherName"] });
                                }
                                break;
                            }
                        }
                        if (data.length + no_edit.length == i) {
                            data.push({ "BtnID": btnIdLists[i], "BtnName": btnNameLists[i], "IsHide": false, "HOrder": btnOrderLists[i], "HOtherName": "" });
                        }
                    }
                    option.data = data;
                    table.render(option);
                    //页面多选框 é‡æ–°æ¸²æŸ“
                    for (var i = 0; i < btnIdLists.length; i++) {
                        for (var j = 0; j < data1.count; j++) {
                            if (btnIdLists[i] == data1.data[j]["HButtonID"] && data1.data[j]["HHideFlag"] == true) {
                                $("#IsHide" + (i + 1)).attr("checked", true);
                                break;
                            }
                        }
                    }
                    form.render('checkbox');
                    layer.close(ajaxLoad);
                }, error: function () {
                    layer.close(ajaxLoad);
                    layer.alert("接口请求失败!", { icon: 5 });
                }
            });
        }
        //#endregion
        //#region ä¿å­˜
        //#region ä¿å­˜æ–¹æ³•
        function set_AddNew(data) {
            data.field.HInterID = HInterID;
            data.field.HModName = HSetMainModName;
            data.field.HUser = sessionStorage["HUserName"];
            data.field.HTableName = HTableName;
            data.field.HDataViewName = HDataViewName;
            data.field.HDataProcName = HDataProcName;
            data.field.HRowElementCount = HRowElementCount;
            var tableData = [];                         //获取表格数据
            var btnIdLists = btnIdList.split(',');      //相对单据传过来的按钮id
            var btnNameLists = btnNameList.split(',');  //相对单据传过来的按钮名称
            var btnOrderLists = btnOrderList.split(',');//相对单据传过来的按钮次序
            //获取表格数据
            for (var i = 0; i < table.cache["mainTable"].length; i++) {
                if (table.cache["mainTable"][i] != "") {
                    table.cache["mainTable"][i].LAY_TABLE_INDEX = i;
                    tableData.push(table.cache["mainTable"][i])
            //序列化表头信息和子表信息
            var sMainStr = JSON.stringify(data.field);
            var sSubStr = JSON.stringify(option.data);
            //拼接参数
            var sMainSub = sMainStr + ';' + sSubStr + ";" + sessionStorage["HUserName"];
                    //更新次序列表
                    var index_temp = $.inArray(table.cache["mainTable"][i].BtnID, btnIdLists);
                    if (index_temp != -1) {
                        btnOrderLists[index_temp] = (table.cache["mainTable"][i].HOrder == "" ? 0 : table.cache["mainTable"][i].HOrder);
                    }
                }
            }
            //将数组序列化为字符串,传递给后端
            var sTableData = JSON.stringify(tableData);
            var sBtnIdLists = JSON.stringify(btnIdLists);
            var sBtnNameLists = JSON.stringify(btnNameLists);
            var sBtnOrderLists = JSON.stringify(btnOrderLists);
            var sNo_EditLists = JSON.stringify(no_edit);
            //拼接需要传递的参数
            var sMainSub = sTableData + ';' + sBtnIdLists + ';' + sBtnNameLists + ';' + sBtnOrderLists + ';' + HModName + ';' + HBillType + ";" + sNo_EditLists + ";" + HUserName;
            var index = layer.load();
            $.ajax({
                type: "POST",
                url: GetWEBURL() + "/Xt_ModuleButtonSet_WMES/AddModuleButtonSetWMES",
                url: GetWEBURL() + "/Xt_DefineBillMainSet/SaveXt_DefineBillMainSet", //方法所在页面和方法名
                async: true,
                data: { "sMainSub": sMainSub },
                data: { "msg": sMainSub },
                dataType: "json",
                success: function (data) {
                    if (data.count == 1) {
                    if (data.count == 1) { // è¯´æ˜ŽéªŒè¯æˆåŠŸäº†ï¼Œ
                        layer.msg(data.Message, { icon: 1 });
                        layer.close(index);
                        layer.msg("提交成功");
                    }
                    else {
                        layer.alert(data.Message, { icon: 5 });
                        layer.close(index);
                        layer.msg(data.Message, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    }
                },
                error: function (err) {
                    layer.alert("错误:" + err, { icon: 5 });
                    layer.close(index);
                    layer.msg("错误:" + err, { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                }
            });
        }
@@ -587,8 +694,11 @@
        //#endregion
        //#region å­è¡¨ç›¸å…³æ–¹æ³•
        //#region æ ¹æ®option中的数据,设置子表中的下拉列表
        //#region æ ¹æ®option中的数据,设置子表中的下拉列表、复选框
        function setSelectByTableRender() {
            //下拉框列表初始化
            setSelectInit();
            for (var i = 1; i <= option.data.length; i++) {
                $('#HElementID' + i + '').val(option.data[i - 1].HElementID);
                $('#HParentElementID' + i + '').val(option.data[i - 1].HParentElementID);
@@ -625,6 +735,10 @@
                        option.data[i - 1] = data[0];
                        option.data[i] = tables[0];
                        table.render(option);
                        //根据option中的数据,设置子表中的下拉列表、复选框
                        setSelectByTableRender();
                        break;
                    }
                }
@@ -656,6 +770,9 @@
                        option.data[i + 1] = data[0];
                        option.data[i] = tables[0];
                        table.render(option);
                        //根据option中的数据,设置子表中的下拉列表、复选框
                        setSelectByTableRender();
                        break;
                    }
                }
@@ -670,8 +787,11 @@
            table.cache["mainTable"].push(NewRow);
            option.data = table.cache["mainTable"];
            table.render(option);
            //根据option中的数据,设置子表中的下拉列表、复选框
            setSelectByTableRender();
            //rows++;
            layer.msg('增加一行按钮!')
            //layer.msg('增加一行按钮!')
        }
        //#endregion
@@ -691,6 +811,9 @@
                }
                option.data = tables;
                table.render(option);
                //根据option中的数据,设置子表中的下拉列表、复选框
                setSelectByTableRender();
            } else {
                layer.msg('请选择一行数据编辑!');
            }
@@ -715,6 +838,9 @@
                option.data[option.data.length - 1].HWeight = "0";
                table.render(option);//将数据渲染到表格上
                //根据option中的数据,设置子表中的下拉列表、复选框
                setSelectByTableRender();
            }
        }
        //#endregion
@@ -751,6 +877,33 @@
                }
            })
        }
        //#endregion
        //#region ç›‘听单元格编辑  å•元格编辑后 å˜æ›´
        table.on('edit(mainTable)', function (obj) {
            //数值格式校验工具
            var ref = /^\d+(\.\d+)?$/;          //非负数正则表达式
            var temp = "";
            // å•元格编辑之前的值
            var oldText = $(this).prev().text();
            var value = obj.value //得到修改后的值
                , data = obj.data //得到所在行所有键值
                , field = obj.field; //得到字段
            switch (field) {
                case "HElementIDAdditionalName":                                                       //元素ID附加字段
                    obj.update({
                        HElementID: ""
                        , HFieldDataType: ""
                    });
                    table.render(option);
                    //根据option中的数据,设置子表中的下拉列表、复选框
                    setSelectByTableRender();
                    break;
                default:
            }
        });
        //#endregion
        //#region å­è¡¨1:隐藏列设置
@@ -870,8 +1023,14 @@
                            }
                        }
                        table.render(option);
                        //根据option中的数据,设置子表中的下拉列表、复选框
                        setSelectByTableRender();
                    } else {
                        table.render(option);
                        //根据option中的数据,设置子表中的下拉列表、复选框
                        setSelectByTableRender();
                    }
                }, error: function () {
                    layer.alert("接口请求失败!", { icon: 5 });