0

$(function () {

        $('#datagrid-2').bootstrapTable({
            loadMsg: '正在加载...',
            url: window.webapi + "/BridgeDaliyReport/DamageList",
            method: 'post',
            async: false,
            pagination: true,
            height: $(window).height() - $(".hei1").height() - $(".hei2").height() - 100,
            pageSize: 15,
            pageList: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
            clickToSelect: false,
            showColumns: true,
            minimumCountColumns: 2,
            clickToSelect: true,
            sidePagination: "server", //服务端处理分页
            queryParamsType: "limit",
            contentType: "application/x-www-form-urlencoded",
            dataType: "json",

            columns: [
                //{
                //    field: "state",
                //    checkbox: true,
                //    align: 'center',
                //},
                { field: 'BRIDGENAME', title: '名称', sortable: true },
                { field: 'CheckName', title: '项目', sortable: true },
                {
                    field: 'CreateTime',
                    title: '时间',
                    sortable: true,
                    formatter: function (val) {
                        if (val)
                            return val.split("T")[0];
                        else return val;
                    }
                },
                { field: 'DefectDegreeName', title: '病害', sortable: true },

                {
                    field: 'State',
                    title: '状态',
                    sortable: true,
                    width: 200,
                    formatter: function (val, rowData, index) {
                        
                        if (val == 0) {
                            return "<input type='checkbox' checked='checked'>已结案</input>";
                        } else {
                            return "<input type='checkbox' >未结案</input>";
                        }
                    }
                },
                 {
                     field: 'CHECKDATE',
                     title: '结案时间',
                     sortable: true,
                     formatter: function (val, rowData, index) {
                         if (rowData.State != 0) return;
                         if (val)
                             return val.split("T")[0];
                         else return val;
                     }
                 },

                {
                    field: 'Description', title: '详情', sortable: true,
                    formatter: function (val, rowData, index) {
                        if (val == null || val == "undefined" || val == "无") val = "";
                        if (val == "") return '&nbsp;<a  href="#" class="btnDetail" style="color:#337AB7" onclick="getDetail()" data-id="' + rowData.ReportId + '"  data-toggle="modal" data-target=".checkitemList">详情</a>&nbsp;&nbsp;';
                        else return '&nbsp;<a  href="#" class="btnDetail" style="color:#337AB7" onclick="getDetail()" data-id="' + rowData.ReportId + '"  data-toggle="modal" data-target=".checkitemList">' + val + '</a>&nbsp;&nbsp;';
                    }
                }
            ],
            
            
            queryParams: function (params) {
                //var conck = $.trim($("th-inner checkbox").val());
                var searchString;
                if ($.trim($(".txt_search").val()) == $(".txt_search").attr("placeholder")) {
                    searchString = "";
                } else searchString = $(".txt_search").val().trim();
                var date;
                if ($.trim($(".datepicker").val()) == $(".datepicker").attr("placeholder")) {
                    date = "";
                } else date = $(".datepicker").val().trim();
                //检查项 病害值 状态
                var checkItem = [];
                $(".sickSearchItem li.selected.checkitem").each(function (index) {
                    checkItem.push($(this).data('id'));
                });
                var checknames = checkItem.join(",");
                var damageDegree = [];
                $(".sickSearchItem li.selected.damage").each(function (index) {
                    damageDegree.push($(this).text());
                });
                var damageDegree = damageDegree.join(",");

                var state = 3; //0 1 2

                if ($(".sickSearchItem li.selected.state").length == 1) {
                    if ($(".sickSearchItem li.selected.state").text() == "已结案") state = 0;
                    else state = 1;
                }

                var columns = [];
                $('#datagrid-2').find("thead tr th").each(function (index) {

                    var column = $(this).attr('data-field');
                    if (column != null || column != undefined || column != "") {
                        columns.push(column);
                    }
                });
                columns.push("ReportId");
                var columns = columns.join(",");
                var bridgeID = window.location.search.replace('?', '').split('=')[1];
                //var bridgeID = $(".id_search").val().trim();
                return {
                    pageNumber: params.offset / params.limit + 1,
                    pageSize: params.limit,
                    type: 2,
                    damageDegree: damageDegree,
                    bridgename: searchString,
                    date: date,
                    columns: columns,
                    checknames: checknames,
                    state: state,
                    bridgeID: bridgeID
                };
            }
            /**
            index父表当前行的行索引
            row:父表当前行的Json数据对象。
            $detail:当前行下面创建的新行里面的td对象。
            */

        });

        $('#datagrid-1').bootstrapTable({
            loadMsg: '正在加载...',
            url: window.webapi + "/BridgeDaliyReport/DamageList",
            method: 'post',
            async: false,
            pagination: true,
            height: $(window).height() - $(".hei1").height() - $(".hei2").height() - 100,
            pageSize: 15,
            pageList: [10, 20, 30, 40, 50, 60, 70, 80, 90, 100],
            sidePagination: "server", //服务端处理分页
            queryParamsType: "limit",
            contentType: "application/x-www-form-urlencoded",
            dataType: "json",
            columns: [
                  { field: 'BRIDGENAME', title: '桥梁名称', sortable: true },
                { field: 'CheckName', title: '检查项目', sortable: true },
                {
                    field: 'CreateTime',
                    title: '检查时间',
                    sortable: true,
                    formatter: function (val) {
                        if (val)
                            return val.split("T")[0];
                        else return val;
                    }
                },
                { field: 'DefectDegreeName', title: '病害', sortable: true },                    
                {
                    field: 'State',
                    title: '状态',                       
                    formatter: function (val)
                    {
                        if (val == 0) return "已结案";
                        else return "未结案";
                    }                        
                },

                 {
                     field: 'CHECKDATE',
                     title: '结案时间',
                     sortable: true,
                     formatter: function (val, rowData, index) {
                         if (rowData.State != 0) return;
                         if (val)
                             return val.split("T")[0];
                         else return val;
                     }
                 },
                {
                    field: 'Description', title: '详情', sortable: true,
                    formatter: function (val, rowData, index) {
                        if (val == null || val == "undefined" || val == "无") val = "";
                        if (val == "") return '&nbsp;<a  href="#" class="btnDetail" style="color:#337AB7" onclick="getDetail2()" data-id="' + rowData.ReportId + '"  data-toggle="modal" data-target=".checkitemList">详情</a>&nbsp;&nbsp;';
                        else return '&nbsp;<a  href="#" class="btnDetail" style="color:#337AB7" onclick="getDetail2()" data-id="' + rowData.ReportId + '"  data-toggle="modal" data-target=".checkitemList">' + val + '</a>&nbsp;&nbsp;';

                    }
                }
            ],
            queryParams: function (params) {
                var searchString;
                if ($.trim($(".txt_search").val()) == $(".txt_search").attr("placeholder")) {
                    searchString = "";
                } else searchString = $(".txt_search").val().trim();
                var date;
                if ($.trim($(".datepicker").val()) == $(".datepicker").attr("placeholder")) {
                    date = "";
                } else date = $(".datepicker").val().trim();
                //检查项 病害值 状态
                var checkItem = [];

                $(".sickSearchItem li.selected.checkitem1").each(function (index) {
                    checkItem.push($(this).data('id'));
                });
                var checknames = checkItem.join(",");
                var damageDegree = [];
                $(".sickSearchItem li.selected.damage").each(function (index) {
                    damageDegree.push($(this).text());
                });
                var damageDegree = damageDegree.join(",");

                var state = 3; //0 1 2
                if ($(".sickSearchItem li.selected.state").length == 1) {
                    if ($(".sickSearchItem li.selected.state").text() == "已结案") state = 0;
                    else state = 1;
                }

                var columns = [];
                $('#datagrid-1').find("thead tr th").each(function (index) {

                    var column = $(this).attr('data-field');
                    if (column != null || column != undefined || column != "") {
                        columns.push(column);
                    }
                });
                columns.push("ReportId");
                var columns = columns.join(",");


                var bridgeID = window.location.search.replace('?', '').split('=')[1];
                //var bridgeID = $(".id_search").val().trim();
                return {
                    pageNumber: params.offset / params.limit + 1,
                    pageSize: params.limit,
                    type: 1,
                    damageDegree: damageDegree,
                    bridgename: searchString,
                    date: date,
                    columns: columns,
                    checknames: checknames,
                    state: state,
                    bridgeID: bridgeID
                };
            }
            /**
            index父表当前行的行索引
            row:父表当前行的Json数据对象。
            $detail:当前行下面创建的新行里面的td对象。
            */

        });
    });

1个回答

0

不加入复选框呢? 查一下netwotk接口是否获取成功 还有一年返回数据是否符合bootstrap-table的填充规范

撰写答案