llj
2026-02-25 025a61a9b52d5cdea1a948f1432ce524b2248e5c
成本分配类型增加子表
2个文件已修改
352 ■■■■■ 已修改文件
WebTM/WebTM.csproj 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/views/基础资料/成本基础资料/Add_Edit_Gy_CostAverageType.html 347 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
WebTM/WebTM.csproj
@@ -668,10 +668,9 @@
    <Content Include="views\成本管理\费用单引入\CB_CostProjectImport.html" />
    <Content Include="views\成本管理\费用单引入\CB_CostAccounting.html" />
    <Content Include="views\成本管理\费用单引入\CB_ItemMoneyBillImport.html" />
<<<<<<< HEAD
=======
    <Content Include="views\成本管理\费用单引入\CB_ItemMoneyBill_Excel.html" />
>>>>>>> 50ceb8be38852f1a32825a7d172bd9a4d4db241d
    <Content Include="views\条码明细\Kf_MateOutBillList_CodeDetail.html" />
    <Content Include="views\案例代码\华远\HY_HistogramReport_ForPCSCheckNote.html" />
    <Content Include="views\案例代码\华远\HY_HistogramReport.html" />
WebTM/views/»ù´¡×ÊÁÏ/³É±¾»ù´¡×ÊÁÏ/Add_Edit_Gy_CostAverageType.html
@@ -37,11 +37,15 @@
                    <div class="layui-card-header">
                        <div class="layui-btn-group">
                            <button type="button" id="set_SaveBill" class="layui-btn layui-btn-normal layui-btn-radius"
                                lay-submit="" lay-filter="set_SaveBill">保存</button>
                                    lay-submit="" lay-filter="set_SaveBill">
                                ä¿å­˜
                            </button>
                            <button type="button" class="layui-btn layui-btn-normal layui-btn-radius" lay-submit=""
                                lay-filter="Cancel">退出</button>
                                    lay-filter="Cancel">
                                é€€å‡º
                            </button>
                            <!--<button class="layui-btn layui-btn-normal" style="margin-left: 0px" type="button"
                                lay-submit="" lay-filter="set_CheckBill" id="set_CheckBill">审核</button>-->
                lay-submit="" lay-filter="set_CheckBill" id="set_CheckBill">审核</button>-->
                        </div>
                    </div>
                    <div class="layui-form-item" style="padding-top: 10px;">
@@ -54,17 +58,19 @@
                                <div class="layui-tab-item layui-show">
                                    <div class="layui-row">
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">成本分配类型代码<span
                                                    style="color: red;">*</span></label>
                                            <label class="layui-form-label">
                                                æˆæœ¬åˆ†é…ç±»åž‹ä»£ç <span style="color: red;">*</span>
                                            </label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HNumber" lay-verify="HNumber"
                                                    id="HNumber" autocomplete="off">
                                                       id="HNumber" autocomplete="off">
                                                <input id="HItemID" name="HItemID" type="hidden" />
                                            </div>
                                        </div>
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">成本分配类型名称<span
                                                    style="color: red;">*</span></label>
                                            <label class="layui-form-label">
                                                æˆæœ¬åˆ†é…ç±»åž‹åç§°<span style="color: red;">*</span>
                                            </label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HName" id="HName" autocomplete="off">
                                            </div>
@@ -73,7 +79,7 @@
                                            <label class="layui-form-label">短代码</label>
                                            <div class="layui-input-inline">
                                                <input class="layui-input" name="HShortNumber" id="HShortNumber"
                                                    autocomplete="off">
                                                       autocomplete="off">
                                            </div>
                                        </div>
@@ -93,10 +99,10 @@
                                                       autocomplete="off">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="layui-row">
                                        <div class="layui-col-xs4 layui-inline">
                                            <label class="layui-form-label">使用状态:</label>
@@ -133,21 +139,21 @@
                                            <label class="layui-form-label" style="width: 85px;">创建人</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HMakeEmp" id="HMakeEmp"
                                                    style="background-color:#efefef4d;" readonly>
                                                       style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">禁用人</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HStopEmp" id="HStopEmp"
                                                    style="background-color:#efefef4d;" readonly>
                                                       style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">审核人</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HCheckEmp" id="HCheckEmp"
                                                    style="background-color:#efefef4d;" readonly>
                                                       style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                    </div>
@@ -156,21 +162,21 @@
                                            <label class="layui-form-label" style="width: 85px;">创建日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HMakeTime" id="HMakeTime"
                                                    style="background-color:#efefef4d;" readonly>
                                                       style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">禁用日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HStopTime" id="HStopTime"
                                                    style="background-color:#efefef4d;" readonly>
                                                       style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">审核日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HCheckTime" id="HCheckTime"
                                                    style="background-color:#efefef4d;" readonly>
                                                       style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                    </div>
@@ -179,7 +185,7 @@
                                            <label class="layui-form-label" style="width: 85px;">修改人</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HModifyEmp" id="HModifyEmp"
                                                    style="background-color:#efefef4d;" readonly>
                                                       style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                    </div>
@@ -188,11 +194,29 @@
                                            <label class="layui-form-label" style="width: 85px;">修改日期</label>
                                            <div class="layui-input-block" style="margin-left: 120px;">
                                                <input type="text" class="layui-input" name="HModifyTime"
                                                    id="HModifyTime" style="background-color:#efefef4d;" readonly>
                                                       id="HModifyTime" style="background-color:#efefef4d;" readonly>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-tab" lay-filter="tab-POStockInBill">
                        <ul class="layui-tab-title" lay-filter="tab-all">
                            <li lay-id="1" style="padding:1px;" class="layui-this">项目</li>
                        </ul>
                        <div class="layui-tab-content">
                            <!--子表-->
                            <div class="layui-tab-item layui-show">
                                <table class="layui-hide" 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-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>
                    </div>
@@ -225,7 +249,8 @@
                ;
            //#endregion
            //模块名
            var HModName = "Gy_CostAverageType";
            //#region è¿›å…¥é¡µé¢å³åŠ è½½
            Organ();
            //判断是否登录 æœªç™»å½•则跳到登录页
@@ -249,6 +274,7 @@
                $("#HUseFlag").attr("disabled", true);
                $("#HMakeEmp").val(sessionStorage["HUserName"]);; //根据登录用户带出创建人
                $("#HMakeTime").val(Format(new Date(), "yyyy-MM-dd"));
                get_InitGrid();
            }
            else if (OperationType == 2) {//复制
@@ -269,6 +295,7 @@
            }
            else if (OperationType == 3) {//编辑
                get_InitGrid();
                //禁用组织选项
                $("#HUSEORGID").attr("disabled", true);
                $("#HCREATEORGID").attr("disabled", true);
@@ -397,7 +424,24 @@
                                "HModifyEmp": data.修改人,
                                "HModifyTime": data.修改时间 ? util.toDateString(data.修改时间, 'yyyy-MM-dd') : ""
                            });
                            // 2. åŠ è½½å­è¡¨æ•°æ®
                            var rowdata = [];
                            if (data && result.data.length > 0) {
                                for (var i = 0; i < result.data.length; i++) {
                                    var row = result.data[i];
                                    rowdata.push({
                                        "HMaterTypeID": row["HMaterTypeID"] || 0,
                                        "HMaterType": row["HName"] || "",
                                        "HWeight": row["权重"] || 0,
                                    });
                                }
                            } else {
                                console.log("没有子表数据");
                            }
                            // 3. é‡æ–°æ¸²æŸ“表格
                            option.data = rowdata;
                            table.render(option);
                            layer.close(ajaxLoad);
                        } else {
                            layer.close(ajaxLoad);
@@ -451,9 +495,15 @@
                    layer.msg("请输入成本分配类型名称!", { icon: 5, btn: ['确认'], time: 100000, offset: 't', skin: 'layui-layer-lan', title: "温馨提示" });
                    return;
                }
                var sMainStr = JSON.stringify(data.field) + ";" + sessionStorage["HUserName"];
                var num = [];
                for (var i = 0; i < table.cache["mainTable"].length; i++) {
                    if (table.cache["mainTable"][i] != "") {
                        table.cache["mainTable"][i].LAY_TABLE_INDEX = i;
                        num.push(table.cache["mainTable"][i])
                    }
                }
                var sSubStr = JSON.stringify(num);
                var sMainStr = JSON.stringify(data.field) + ";" + sSubStr + ";"+sessionStorage["HUserName"];
                $.ajax({
                    type: "POST",
                    url: GetWEBURL() + "/Gy_CostAverageType/SaveGy_CostAverageType", //方法所在页面和方法名
@@ -489,9 +539,258 @@
            //#endregion
            //#region å­è¡¨ï¼šå¤´å·¥å…·æ äº‹ä»¶
            table.on('toolbar(mainTable)', function (obj) {
                var checkStatus = table.checkStatus('mainTable')
                    , data = checkStatus.data;
                //新增行表格数据
                var NewRow =
                {
                    "HWeight": "0"
                    , "HMaterTypeID": "0"
                    , "HMaterType": ""
                };
                switch (obj.event) {
                    case 'btn-AddLine':
                        table.cache["mainTable"].push(NewRow);
                        option.data = table.cache["mainTable"];
                        table.render(option);
                        for (var i = 1; i <= option.data.length; i++) {
                            $('#HTransType' + i + '').find("option[value='" + option.data[i - 1].HTransType + "']").attr("selected", true);
                        }
                        form.render('select');
                        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["mainTable"].push(JSON.parse(copyrow));//将复制的行强转成json追加到表格上
                            option.data = table.cache["mainTable"];//将数据绑定到data上
                            table.render(option);//将数据渲染到表格上
                            for (var i = 1; i <= option.data.length; i++) {
                                $('#HTransType' + i + '').find("option[value='" + option.data[i - 1].HTransType + "']").attr("selected", true);
                            }
                            form.render('select');
                        }
                        break;
                    //列设置
                    case 'set_HideColumn':
                        get_HideColumn();
                        break;
                }
            });
            //#endregion
            //#region å­è¡¨åˆå§‹åŒ–
            function get_InitGrid() {
                option = {
                    elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , totalRow: true
                    , cellMinWidth: 120
                    , height: 400
                    , limit: 100
                    , cols: [[
                        { type: 'checkbox', totalRowText: '合计行' }
                        , { type: 'numbers', field: '序号', title: '序号', style: 'background-color: #f9f9f9;' }
                        , { field: 'HMaterTypeID', title: 'HMaterTypeID', hide: true, style: 'background-color: #f9f9f9;' }
                        , { field: 'HMaterType', title: '物料分类', edit: 'text', event: "HMaterTypeList", style: 'background-color: #f9f9f9;' }
                        , { field: 'HWeight', title: '权重', edit: 'text', style: 'background-color: #f9f9f9;' }
                    ]]
                }
                var rowdata = [
                    {
                        "HMaterTypeID": "0"
                        , "HMaterType": ""
                        , "HWeight": "0"
                    }
                ];
                option.data = rowdata;
                table.render(option);
              //  DisPlay_HideColumn();
            }
            //#endregion
            //#region å­è¡¨ï¼šè¡Œå†…事件
            table.on('tool(mainTable)', function (obj) {
                set_GridDelete(obj);   //行内删除
                set_GridCellCheck(obj); //行内快捷键筛选
            });
            //#endregion
            //#region è¡Œå†…删除
            function set_GridDelete(obj) {
                var data = obj.data;
                var rowIndex = $(obj.tr).attr("data-index");
                if (obj.event === 'del') {
                    layer.confirm('真的删除行吗?', function (index) {
                        //if (rowIndex === '0') {
                        //    layer.msg('首行无法删除!!!');
                        //} else {
                        var oldData = table.cache["mainTable"];
                        oldData.splice(obj.tr.data('index'), 1)
                        option.data = oldData;//将数据绑定到data上
                        table.render(option);
                        //for (var i = 0; i < oldData.length; i++) {
                        //    //发票类型
                        //    $('#HTransType' + (i + 1)).find("option[value='" + oldData[i].HTransType + "']").attr("selected", true);
                        //}
                        //form.render('select');
                        layer.close(index);
                        /*}*/
                    });
                }
            }
            //#endregion
            //#region å­è¡¨ï¼šå¿«æ·é”®(F7)打开弹窗
            function set_GridCellCheck(obj) {
                window.tableEditObj = obj;
                $(document).off('keydown', ".layui-table-edit").on('keydown', '.layui-table-edit', function (e) {
                    if (event.key == "F7") {
                        if (obj.event == "HMaterTypeList") {
                            //CusType = 2;
                            // æ–°å¢žï¼šå°†ç¼–辑对象obj赋值给全局变量,供GetProjectMoneyValue使用
                            //tableEditObj = obj;
                            // æ‰“开器具管理小窗体(原有代码不变)
                            layer.open({
                                type: 2,
                                skin: 'layui-layer-rim',
                                area: ['90%', '90%'],
                                title: '项目费用列表',
                                shift: 2,
                                content: ["../../基础资料/公用基础资料/Gy_MaterType.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('请选择数据');
                                    }
                                    //OptionData = checkStatus.data[0];
                                    obj.update({
                                        "HMaterTypeID": checkStatus.data[0].HItemID
                                        , "HMaterType": checkStatus.data[0].物料分类名称
                                    })
                                    layer.close(index);//关闭弹窗
                                }
                                , end: function () {
                                    //obj.update({
                                    //    "HBeginAddr": OptionData.HItemID
                                    //    , "HBeginAddrName": OptionData.地区名称
                                    //})
                                }
                            })
                        }
                        // æ¸…空事件标识,避免重复触发
                        obj.event = "";
                        // é˜»æ­¢äº‹ä»¶å†’泡和默认行为
                        e.preventDefault();
                        e.stopPropagation();
                        return false;
                    }
                });
            }
            //#endregion
            //以上是layui模块
        });
        ////显示列数据
        //function DisPlay_HideColumn() {
        //    $.ajax({
        //        url: GetWEBURL() + '/Xt_grdAlignment_WMES/grdAlignmentWMESList',
        //        type: "GET",
        //        async: false,
        //        data: { "HModName": HModName, "user": sessionStorage["HUserName"] },
        //        success: function (data1) {
        //            if (data1.data.length != 0) {
        //                var dataCol = [];//数据库查询出的列数据
        //                var titleData = [];//不需要显示的字段 å¯æ‰©å±•
        //                dataCol = data1.data[0].HGridString.split(',');
        //                for (var i = 0; i < option.cols[0].length - 2; i++) {
        //                    var dataCols = dataCol[i].split('|');
        //                    //隐藏列
        //                    if (dataCols[1] == 1) {
        //                        option.cols[0][i + 1]["hide"] = true;
        //                    }
        //                    //设置内容字体大小
        //                    if (data1.data[0].HFontSize != 0) {
        //                        option.cols[0][i + 1]["style"] = "font-size:" + data1.data[0].HFontSize + "px;";
        //                    } else {
        //                        option.cols[0][i + 1]["style"] = "font-size:100%";
        //                    }
        //                    //设置列宽
        //                    if (dataCols[3] > 0) {
        //                        option.cols[0][i + 1]["width"] = dataCols[3];
        //                    }
        //                    //显示列
        //                    if (dataCols[1] == 0 && $.inArray(option.cols[0][i + 1]["title"], titleData) == -1) {
        //                        option.cols[0][i + 1]["hide"] = false;
        //                    }
        //                    //字体所在位置(å·¦ å±…中 å³)
        //                    switch (dataCols[2]) {
        //                        case "L":
        //                            option.cols[0][i + 1]["align"] = "left";
        //                            break;
        //                        case "M":
        //                            option.cols[0][i + 1]["align"] = "center";
        //                            break;
        //                        case "R":
        //                            option.cols[0][i + 1]["align"] = "right";
        //                            break;
        //                    }
        //                    //设置表格title属性显示别名
        //                    if (dataCols[4] != null && dataCols[4] != "") {
        //                        option.cols[0][i + 1]["title"] = dataCols[4];
        //                    }
        //                }
        //                //取消冻结列
        //                for (var i = 1; i < option.cols[0].length - 1; i++) {
        //                    if (option.cols[0][i]["fixed"] != null) {
        //                        option.cols[0][i]["fixed"] = null;
        //                    }
        //                    else {
        //                        break;
        //                    }
        //                }
        //                //冻结列
        //                if (data1.data[0].HFixCols != 0) {
        //                    for (var i = 0; i < data1.data[0].HFixCols; i++) {
        //                        if ($.inArray(option.cols[0][i + 1]["title"], titleData) != -1) {
        //                            data1.data[0].HFixCols += 1;
        //                        }
        //                        option.cols[0][i + 1]["fixed"] = "left";
        //                    }
        //                }
        //                table.render(option);
        //            } else {
        //                table.render(option);
        //            }
        //        }, error: function () {
        //            layer.alert("接口请求失败!", { icon: 5 });
        //        }
        //    })
        //}
        function getCar(data) {
            $("#HParentID").val(data[0]["HItemID"])
            $("#HParentName").val(data[0]["HItemName"])