微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Javascript从有条件的数据表中获取特定数据

如何解决Javascript从有条件的数据表中获取特定数据

我有一个这样的数据表

enter image description here

我想要的是在单击上面的复制摘要报告按钮时获取带有相应shipment_id(最上面的注释)的最新注释,并将其粘贴到电子邮件模板的一些文本编辑器中。但我得到的是

Hi,Below are the updates on the reimbursement requests for 3 shipment/s: 
//first row
FBA15MQMW8BB: 23-Feb-21 06:08,PM Super Updated
 23-Feb-21 06:06 PM :New Notes (updated) ----> not included
 23-Feb-21 06:06 PM Invoice and BOL ----> not included
//2nd row
FBA15TX03JTX: 23-Feb-21 07:01 PM,Latest
 23-Feb-21 07:01 PM New Notesss ----> not included
//3rd row
FBA15M1SQ8VH: 23-Feb-21 07:01 PM,Invoice and BOL

Will be sending updates again once I have additional information.

Thank you.

我尝试的是

        Swal.fire({
            title: '<h2>Email Template copied to clipboard!</h2>',icon: 'info',html: '<p>You can Now paste them anywhere completely.</p>',confirmButtonText: 'Send Updates',showCancelButton: true,showCloseButton: true,showLoaderOnConfirm: true,preConfirm: (confirm) => {
                var str='';
                var emailBody='';
                var count_shipments = $(".data-row").length;
                var SearchFieldsTable = $("#tbl-inbound-shipments-in-progress tbody");
                var trows = SearchFieldsTable.children(".data-row");

                $.each(trows,function (index,row) {
                    var shipment_id=$(row).attr("data-shipment-id");
                    var notes = $(row).attr("data-notes");

                    //this is the code for copying the notes
                    str += shipment_id + ": " + (notes ? notes : "No notes") + "\n\n";
                });

                //the email body/template to be pasted
                emailBody = 'Hi,\n\nBelow are the updates on the reimbursement requests for '+ count_shipments +' shipment/s: \n\n' + str + 
                    'Will be sending updates again once I have additional information.\n\nThank you.'
                
                var el = document.createElement('textarea');
                el.value = emailBody;
                el.setAttribute('readonly','');
                el.style = {position: 'absolute',left: '-9999px'};
                document.body.appendChild(el);
                el.select();
                document.execCommand('copy');
                document.body.removeChild(el);
            },

编辑:按要求包含表结构和数据提取

                                    <table class="table table-bordered table-striped table-hover display compact" id="tbl-inbound-shipments-in-progress" style="width:100%">
                                        <thead class="text-primary">
                                            <tr>
                                                <th>#</th>
                                                <th>{{ __('Client') }}</th>
                                                <th>{{ __('SHIPMENT ID') }}</th>
                                                <th>{{ __('Case ID') }}</th>
                                                {{-- <th>{{ __('P/A/R') }}</th> --}}
                                                <th>{{ __('Updated Date') }}</th>
                                                <th>{{ __('maturity') }}</th>
                                                <th>{{ __('Action') }}</th>
                                            </tr>
                                        </thead>
                                    </table>

表格数据

 function load_inbound_shipment_in_progress() {
        window.ISIP = $('#tbl-inbound-shipments-in-progress').DataTable({
            //processing: true,serverSide: true,"fnInitComplete": function (oSettings,json) {
                toastr.options.progressBar = true;
                // toastr.info('Requested Inbound Shipment data is Now loaded.');
                $('#loading').hide();
            },"lengthMenu": [[10,25,50,-1],[10,"All"]],idisplayLength: 10,ajax: "{{ route('admin.clients.inbound-shipment-in-progress',['client'=>$client->id]) }}",createdRow: function( row,data,dataIndex ) {
                var red = ((data.maturity > 5) && (data.pending > 0)) ? 'bg-danger' : '',notes = (data.notes!='') ? data.notes : '',shipment_id = (data.shipment_id_nolink !='') ? data.shipment_id_nolink : '';
                $(row).attr('data-row_id',data.id).attr('data-notes',notes).attr('data-shipment-id',shipment_id).attr('data-case_id',data.case_id).attr('data-pending',data.pending).attr('data-shipment_id',data.shipment_id).addClass(red);
                $(row).addClass('data-row');
            },dom: 'lBfrtip<"actions">',buttons: [
                {
                    extend: 'copy',className: 'btn btn-custom-summary',text: 'copy Summary Report',action: function ( e,dt,node,config ) {
                        copyEmail();
                    }
                }
            ],columns: [
                { data: 'notes',name: 'notes',"class": "text-Nowrap text-center",render: function(data) { return ''; },fnCreatedCell: function (nTd,sData,oData,iRow,iCol) {
                        if (oData.notes != '') $(nTd).addClass('details-control');
                    },orderable: false
                },{ data: 'client',name: 'client',"class": "text-Nowrap text-center" },{ data: 'shipment_id',name: 'shipment_id',{ data: 'case_id',name: 'case_id',render: function(data,type,full) {
                    console.log(this)
                    var link = '<a href="https://sellercentral.amazon.com/cu/case-dashboard/view-case?ref=sc_cd_lobby_vc_v3&ie=UTF&caseID=' + (data ) + '&View+or+Respond=Submit" target="_blank" class="underlined">'+(data )+'</a>';
                    return '<span class="link-mode-'+full.id+'">' + link + '</span><input style="display: none;" id="edit-mode" class="edit-mode-'+full.id+'" type="text" value="'+ data +'">' + '    <button onclick="popup_save_case_id(this)" id="edit-case-id" class="btn btn-primary btn-xs"> <i class="fas fa-edit"></i> Edit<input type="hidden" class="case_id" value="'+data+'"> </button>';
                }},// { data: 'p_a_r',name: 'p_a_r',{ data: 'updated_at',name: 'updated_at',{ data: 'maturity',name: 'maturity',{ data: 'action',name: 'action',"class": "text-Nowrap text-center bg-light",orderable: false,searchable: false }
            ]
        });
    }

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。