yangle
2023-05-20 4021d78eefc40e5beb0bfb6c2487b84cdde10431
WebTM/views/³µ¼ä¹ÜÀí/±¨±í·ÖÎö/Kf_MaterOutSumReport_Cloth.html
@@ -34,17 +34,17 @@
                                    </div>
                                </div>
                                <!--<div class="layui-inline">
                                    <label class="layui-form-label">状态</label>
                                    <div class="layui-input-block" style="margin-left: 120px;width: 184px;">
                                        <select name="HState" lay-verify="HState" id="HState">
                                            <option value="0" selected="selected">全部</option>
                                            <option value="1">未开工</option>
                                            <option value="3">已入库</option>
                                        </select>
                                    </div>
                                </div>-->
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block" style="margin-left: 120px;width: 184px;">
            <select name="HState" lay-verify="HState" id="HState">
                <option value="0" selected="selected">全部</option>
                <option value="1">未开工</option>
                <option value="3">已入库</option>
            </select>
        </div>
    </div>-->
                                <div class="layui-inline">
                                    <label class="layui-form-label">下达日期</label>
                                    <label class="layui-form-label">日期</label>
                                    <div class="layui-input-block">
                                        <input type="date" class="layui-input" id="HBeginDate" style="width:190px;">
                                    </div>
@@ -59,16 +59,22 @@
                                    <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                                </button>
                                <button class="layui-btn layuiadmin-btn-order" type="button" lay-submit="" lay-filter="btnReSearch" id="btnReSearch" style="padding:0 5px">重置</button>
                                <!--<div class="layui-inline">
                                    <div style="padding-left: 10px;">
                                        <input type="checkbox" name="checkWRuku" id="checkWRuku" lay-skin="primary" lay-filter="checkWRuku" title="未下推及已入库">
                                <div class="layui-inline">
                                    <label class="layui-form-label">合计公斤数</label>
                                    <div class="layui-input-block" style="margin-left: 120px;">
                                        <input type="text" class="layui-input" name="SumHMaterOutQty" id="SumHMaterOutQty" disabled="disabled">
                                    </div>
                                </div>-->
                                </div>
                                <!--<div class="layui-inline">
        <div style="padding-left: 10px;">
            <input type="checkbox" name="checkWRuku" id="checkWRuku" lay-skin="primary" lay-filter="checkWRuku" title="未下推及已入库">
        </div>
    </div>-->
                                <div class="layui-colla-content" style="padding: 0px; margin-left: 6%;">
                                    <div class="layui-row" style="margin-top:10px;">
                                        <!--其他条件-->
                                        <div class="layui-inline">
                                            <label class="layui-form-label" style="width: 85px;">物料代码</label>
                                            <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="HMaterNumber" id="HMaterNumber">
                                            </div>
@@ -197,7 +203,7 @@
                $("#HBeginDate").val(Format(new Date(new Date() - 1000 * 60 * 60 * 24 * 10), "yyyy-MM-dd"));//开始日期
                $("#HEndDate").val(Format(new Date(), "yyyy-MM-dd"));//结束日期
                //初始化表格
                set_InitGrid();
                //set_InitGrid();
                //加载数据到网格
                get_FastQuery();
                DisPlay_HideColumn();
@@ -205,54 +211,102 @@
            }
            //初始化表格
            function set_InitGrid() {
                option = {
                    elem: '#mainTable'
                    , toolbar: '#toolbarDemo'
                    , cellMinWidth: 120
                    , limit: Number.MAX_VALUE // æ•°æ®è¡¨æ ¼é»˜è®¤å…¨éƒ¨æ˜¾ç¤º
                    , totalRow: true
                    , height: 'full-70'
                    , cols: [[
                        { type: 'checkbox', fixed: 'left', totalRowText: '合计' }
                        , { field: '日期', title: '日期', width: 160 }
                        , { field: '单据号', title: '单据号', width: 160 }
                        , { field: '产品代码', title: '产品代码', width: 160 }
                        , { field: '产品名称', title: '产品名称', width: 160 }
                        , { field: '规格型号', title: '规格型号', width: 160 }
                        , { field: '业务员', title: '业务员', width: 160 }
                        , { field: '客户', title: '客户', width: 160 }
                        , { field: '生产任务单数量', title: '生产任务单数量', width: 200 }
                        , { field: '白坯发布', title: '白坯发布', width: 160, totalRow: true }
                        , { field: '是否下推生成流转卡', title: '是否下推生成流转卡', width: 160}
                    ]]
                    ,done: function (res) {
                        //var count = 0;
                        //var OnlyID = -1;
                        //for (var i = 0; i < res.data.length; i++) {
                        //    if (res.data[i]["唯一ID"] != OnlyID) {
                        //        count += res.data[i]["整批"];
                        //        OnlyID = res.data[i]["唯一ID"];
                        //    }
                        //}
                        //var divArr = $(".layui-table-total div.layui-table-cell");
                        //$.each(divArr, function (index, item) {
                        //    var _div = $(item);
                        //    var content = _div.html();
                        //    if (index == 9) {
                        //        content = count;
                        //    }
                        //    _div.html(content);
                        //});
                    }
                };
            function set_InitGrid(sWhere) {
                //动态列-缓存列表
                $.ajax({
                    url: GetWEBURL() + "/MaterOutSumReport/MaterOutSumReport_Cloth",
                    type: "GET",
                    async: false,
                    data: { "sWhere": sWhere },
                    //async: false,
                    success: function (data1) {
                        if (data1.count == 1) {
                            var data = [];
                            var col = [];
                            //给空的数组赋值
                            for (var key in data1.list) {
                                var width = data1.list[key].width * 23;
                                if (width < 150) {
                                    width = 150;
                                } else if (width > 300) {
                                    width = 300;
                                }
                                data.push({ "id": data1.list[key].ColmCols, "name": data1.list[key].ColmCols, "Type": data1.list[key].ColmType, "width": width});
                            }
                            for (var i = 0; i < data.length; i++) {
                                if ($.inArray(data[i].name, "") > -1) {
                                    col.push({ field: data[i].id, title: data[i].name, align: 'center', hide: true, width: data[i].width }); //隐藏id列
                                }
                                else if (data[i].ColName == '白坯发布') {
                                    col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, width: data[i].width, totalRow: true });
                                }
                                else {
                                    switch (data[i].Type) {
                                        //int
                                        case 'DateTime':
                                            col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, width: data[i].width });
                                            break;
                                        default:
                                            col.push({ field: data[i].id, title: data[i].name, align: 'center', sort: true, width: data[i].width });
                                    }
                                }
                            }
                            option = {
                                elem: '#mainTable'
                                , toolbar: '#toolbarDemo'
                                , cellMinWidth: 120
                                , limit: Number.MAX_VALUE // æ•°æ®è¡¨æ ¼é»˜è®¤å…¨éƒ¨æ˜¾ç¤º
                                , totalRow: true
                                , height: 'full-70'
                                , cols: [col]
                                , data: data1.data
                            };
                            table.render(option);
                        } else {
                            option = {
                                elem: '#mainTable'
                                , toolbar: '#toolbarDemo'
                                , cellMinWidth: 120
                                , limit: Number.MAX_VALUE // æ•°æ®è¡¨æ ¼é»˜è®¤å…¨éƒ¨æ˜¾ç¤º
                                , totalRow: true
                                , height: 'full-70'
                                , cols: [[
                                    { type: 'checkbox', fixed: 'left', totalRowText: '合计' }
                                    , { field: '日期', title: '日期', width: 160 }
                                    , { field: '单据号', title: '单据号', width: 160 }
                                    , { field: '产品代码', title: '产品代码', width: 160 }
                                    , { field: '产品名称', title: '产品名称', width: 160 }
                                    , { field: '规格型号', title: '规格型号', width: 160 }
                                    , { field: '业务员', title: '业务员', width: 160 }
                                    , { field: '客户', title: '客户', width: 160 }
                                    , { field: '生产任务单数量', title: '生产任务单数量', width: 200 }
                                    , { field: '白坯发布', title: '白坯发布', width: 160, totalRow: true }
                                    , { field: '是否下推生成流转卡', title: '是否下推生成流转卡', width: 160 }
                                ]]
                                , done: function (res) {
                                }
                            };
                            table.render(option);
                        }
                    },
                    error: function (err) {
                        layer.msg('错误' + err, {
                            icon: 5,
                            time: 20000
                        }, function () {
                            //do something
                        });
                    }
                })
            }
            //列明显示下拉框
            function ColFilter() {
                var Organization = '<option  value="0" selected="selected" ></option>';
                for (var i = 1; i < option.cols[0].length; i++) {
                for (var i = 0; i < option.cols[0].length; i++) {
                    if (option.cols[0][i].hide != true) {
                        Organization += '<option  style="color:blue;" value="' + option.cols[0][i].field + '">' + option.cols[0][i].field + '</option>';
                    }
@@ -272,6 +326,12 @@
                    data: { "sWhere": sWhere },
                    success: function (data1) {
                        if (data1.count == 1) {
                            //调整日期格式:显示 å¹´æœˆæ—¥ å’Œ æ—¶
                            for (var i = 0; i < data1.data.length; i++) {
                                data1.data[i].日期 = data1.data[i]["日期"].split(":")[0];
                                data1.data[i].日期 = data1.data[i]["日期"].replace("T", " ");
                            }
                            option.data = data1.data;
                            //var num = 0;
                            //for (let i = 0; i < data1.data.length; i++) {
@@ -286,12 +346,22 @@
                            //    }
                            //}
                            table.render(option);
                            //计算合计公斤数
                            var sumHMaterOutQty = 0;
                            for (var i = 0; i < data1.data.length; i++) {
                                sumHMaterOutQty += data1.data[i]["白坯发布"];
                            }
                            $("#SumHMaterOutQty").val(sumHMaterOutQty);
                            layer.close(wait);
                        } else {
                            $("#SumHMaterOutQty").val("");
                            layer.close(wait);
                            layer.alert(data1.Message, { icon: 5 });
                        }
                    }, error: function () {
                        $("#SumHMaterOutQty").val("");
                        layer.close(wait);
                        layer.alert("接口请求失败!", { icon: 5 });
                    }
@@ -311,26 +381,28 @@
                var ColName = $("#ColName").val();//复选框
                var Comparator = $("#Comparator").val()
                var ColContent = $("#ColContent").val();
                //拼接任一字段过滤查询条件
                var com = "";
                if (ColName != 0 && Comparator != 0) {
                    var com = "";
                    switch (Comparator) {
                        case "7":
                            com = "like'%" + ColContent + "%'";
                            com = "like ''%" + ColContent + "%''";
                            break;
                        case "8":
                            com = "like'%" + ColContent + "'";
                            com = "like ''%" + ColContent + "''";
                            break;
                        case "9":
                            com = "like'" + ColContent + "%'";
                            com = "like ''" + ColContent + "%''";
                            break;
                        case "10":
                            com = "not like'%" + ColContent + "%'";
                            com = "not like ''%" + ColContent + "%''";
                            break;
                        default:
                            com = "" + Comparator + "'" + ColContent + "'";
                            com = "" + Comparator + " ''" + ColContent + "''";
                            break;
                    }
                    sWhere += " and " + ColName + " " + com;
                    com = " and (" + ColName + " " + com + ")";
                }
                sWhere = {
@@ -340,8 +412,9 @@
                    , HBillNo: HBillNo
                    , HProductName: HProductName
                    , HProductModel: HProductModel
                    , RandomSearch:com
                }
                set_InitGrid(JSON.stringify(sWhere));
                get_Display(JSON.stringify(sWhere));
                //调用接口后清空sWhere缓存
                sWhere = "";
@@ -469,7 +542,6 @@
                    }
                })
            }
            //#endregion
        });