zoukankan      html  css  js  c++  java
  • 去除数组中文件名类似的数据

    需求:

          1. 获取vta端上传的所有文件,一般都是图片和txt文件、pdf文件。

           2.获取的文件中teller给vtm端推送pdf,vtm端客户没确认之前pdf文件名不变,客户确认后文件名变为_signature.pdf,当客户确认了pdf后,确认后的  _signature.pdf   的  pdf  将原来没有确认的 pdf 覆盖掉。

    代码:

    <!DOCTYPE html>
    <html>
    
    <head>
        <meta charset="utf-8">
        <title></title>
        <script src="jquery.js" charset="utf-8"></script>
        <script type="text/javascript">
            $(function() {
                $("#btncc").click(function() {
                    var data = [
                        "610121_IDcheck.jpg",
                        "Customer Declaration for VTM A.pdf",
                        "Customer Declaration for VTM A_signature.pdf",
                        "ebanking.pdf",
                        "ebanking_signature.pdf",
                        "ebankingggg.pdf",
                        "HFE.pdf",
                        "HFESupplementInffffffffffffffffffffffffffdddddddddddddddddddddddddddddddddddddddddddddddddddddfffffffffffffffffffffformation.pdf",
                        "HFESupplementInfffffffffffffffffffffffffffffffffffffffffffffffformation.pdf",
                        "HFESupplementInformation.pdf",
                        "HFESupplementInformation_signature.pdf",
                        "HFE_signature.pdf",
                        "ebankingggg_signature.pdf"
                    ]
                    var html = [],
                        arr1 = [],
                        arr2 = [],
                        arr3 = [],
                        arr4 = [],
                        arr5 = [],
                        linkArray = [];
                    arr1 = data.filter(function(item) {
                        return item.lastIndexOf('.pdf') == -1;
                    });
                    arr2 = data.filter(function(item) {
                        return item.lastIndexOf('.pdf') != -1 && item.lastIndexOf('_signature.pdf') == -1;
                    });
                    arr3 = data.filter(function(item) {
                        return item.lastIndexOf('_signature.pdf') != -1;
                    });
    
                    arr3.map(function(valSignature) {
                        arr2.map(function(valPdf, inx) {
                            if (valSignature.substring(0, valSignature.length - 14) == valPdf.substring(0, valPdf.length - 4)) {
                                arr2.splice(inx, 1);
                            }
                        });
                    });
                    arr4 = arr1.concat(arr2);
                    arr5 = arr4.concat(arr3);
                    arr5.map(function(val, inx) {
                        html.push("<tr><td><a class='file-link file-visited' href= 'xxxx' title='" + val + "' target='_blank' >" + val + "</a></td></tr>");
    
                    });
                    $("#check-list-table").empty().append(html.join());
                });
            });
        </script>
    </head>
    
    <body>
        <button type="button" name="button" id="btncc">点我啊</button>
        <div class="dialog-content">
            <table id="check-list-table">
            </table>
        </div>
    </body>
    
    </html>

    效果图:

  • 相关阅读:
    Java中Collections的min和max方法
    Java中Collections的frequency方法
    Java中Collections的binarySearch方法
    uniapp 样式记录
    uniapp记录
    uniapp 弹窗输入
    uniapp 扫描
    uniapp for显示数据改变时,绑定的list值同时改变
    dev随笔记录
    easyui 使用技巧
  • 原文地址:https://www.cnblogs.com/yingzi1028/p/7235534.html
Copyright © 2011-2022 走看看