buli
2023-07-14 e6068da47c1bef5517c9e5fdc8c726766867ad4e
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<!--
     * [FrameNumUploadController description]
     * @Author   lijinhuan
     * @DateTime 2022-11-04T18:31:03+0800
     * @return   [进口单证上传]
-->
<apex:page controller="FrameNumUploadController"   showHeader="false"   sidebar="false" id="allPage"  title="进口单证上传">
<!-- action="{!init}"  -->
<apex:stylesheet value="{!URLFOR($Resource.blockUIcss)}"/>
<apex:includeScript value="{!URLFOR($Resource.jquery183minjs)}"/>
<apex:includeScript value="{!URLFOR($Resource.PleaseWaitDialog)}"/>
<script type="text/javascript">
    // var popupBox;
    // popupBox = new SimpleDialog("CSVImportDialogId", false);  // 不可拖动
    // popupBox.createDialog();
    // function openPopupCSV() {
 //        popupBox.setTitle("导入CSV文件");
 //        popupBox.importContentNode(document.getElementById("{!$Component.allForm.popupBox}"));
 //        popupBox.show(document.getElementById("{!$Component.allForm.popupBox}"));
 //    }
    // 显示文件名
  //   function show(){
        // var fbody = document.getElementById("file_input").files[0];
  //       if (typeof fbody === "undefined") {
  //           alert("请选择CSV文件");
        // }else{
        //     document.getElementById('uploadFile').placeholder = fbody.name;
  //           popupBox.hide();
        // }
        
  //   }
    // 取消
  //   function cancle(){
        // var obj = document.getElementById('file_input');
        // obj.outerHTML = obj.outerHTML;
        // document.getElementById('uploadFile').placeholder = '请选择文件...';
        // popupBox.hide();
  //   }
 
    function remoteLocationPost() {
        var fbody = document.getElementById("file_input").files[0];
        if (typeof fbody === "undefined") {
            alert("请选择CSV文件");
            return;
        }
        else {
            var reader = new FileReader();
            reader.readAsText(fbody,"gb2312");//在前台改乱码问题
            reader.onload = function(val) {
                if(this.result.split("\n").length - 1 > {!detailCountLimit}){
                    alert("文件不可超过" + {!detailCountLimit} + "行");
                    return;
                }
                // 判断CSV文件BOM,若包含BOM,则删除。
                if (this.result.charCodeAt(0) === 0xFEFF) {  // 如果第一个字符的编码为utf8
                    this.result = this.result.substr(1);  // 在utf-8编码中,三个隐藏的字节 0xEF 0xBB 0xBF被视为一个字符 EFBBBF(UTF8) FEFF(unicode) 65279
                }
                blockme();
                passToController(this.result);
            }
            // popupBox.hide();
        }
    }
    function showErr(){
        var flag = j$("#haveErr").val();
        if(flag == 'true'){
            j$("#ErrFile").css("display", "");
        } 
    }
    function exportJs(){
        exportcsv();
        j$("#ErrFile").css("display", "none");
    }
</script>
<div style="margin:50px auto;width: 350px;">
<!-- Replace parentId attribute with Id of an object that supports attachments -->
<!-- parentId 机身号管理表名 用来视图、匹配 -->
<c:fileUpload parentId="FrameNumManage"/>
<apex:form id="allForm">
    <apex:outputPanel id="message">
        <apex:pageMessages />
    </apex:outputPanel>
    <apex:actionFunction name="passToController" action="{!importCSVFile}" rerender="allForm, message, checEventFrame" oncomplete="showErr(),unblockUI();">
        <apex:param name="csvData" value="" />
    </apex:actionFunction>
    <apex:actionFunction name="exportcsv" action="{!exportBycsv}"/>
    <!-- <apex:outputPanel style="display:none">
        <apex:outputPanel id="popupBox" layout="block">
            <input type="file" id="file_input" name="attFile" accept=".csv" /><br/>
            <center>
                <apex:commandButton value="确认" onclick="show();return false;" style="width: 20%; margin: 20px 10px 0px 10px" />
                <apex:commandButton value="取消" onclick="cancle();return false;" style="width: 20%; margin: 20px 10px 0px 10px" />
            </center>
        </apex:outputPanel>
    </apex:outputPanel> -->
    <apex:outputPanel id="pageallPanel">
    <input type="hidden" id="haveErr" name="haveErr" value="{!haveErr}" />
    <div style="
        background-color: #F8F8F8;
        border: 1px solid #EAEAEA;
        border-radius: 4px 4px 4px 4px;
        color: #333333;
        font-size: 12px;
        padding: 6px;
        width: 400px;
    ">
        <table cellpadding="0" cellspacing="0" class="uploadTable">
            <tbody>
            <tr>
                <td style="padding-right:5px;">数据导入</td>
                <td>
                    <input type="file" id="file_input" name="attFile" accept=".csv" />
                </td>
                <td class="buttonTD">
                    <apex:commandButton onclick="remoteLocationPost(); return false;" value="导入" rerender="allForm,checEventFrame"/>
                </td>
                <td class="buttonTD">
                    <apex:commandButton value="导入"  style="pointer-events: none; cursor: default; opacity: 0;" /><!--为了样式统一好看 -->
                </td>
            </tr>
            <tr id="ErrFile" style="display:none" >
                <td colspan="4">
                   <apex:commandbutton onclick="exportJs();return false;" value="查看"/>
                </td>
            </tr>
        </tbody></table>
    </div>
    <!-- <table style="margin-left: 10px;">
        <tr><th colspan="4" >&nbsp;</th></tr>
        <tr>
        <td>数据导入</td>
        <td>
            <input name="suitDepartment"  id="uploadFile" size="20" type="text" placeholder = "请选择文件..." onclick="openPopupCSV(); return false;" />
        </td>
        <td>
            <apex:commandButton onclick="remoteLocationPost(); return false;" value="导入" rerender="allForm,checEventFrame"/>
        </td>
        </tr>
    </table> -->
    </apex:outputPanel>
</apex:form>
</div>
</apex:page>