|
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+<!DOCTYPE html>
|
|
|
2
|
+<html>
|
|
|
3
|
+
|
|
|
4
|
+ <head>
|
|
|
5
|
+ <meta charset="UTF-8">
|
|
|
6
|
+ <link href="../js/bootstrap-select/css/bootstrap-select.css" rel="stylesheet" />
|
|
|
7
|
+ <script src="../Script/Common/huayi.load.js"></script>
|
|
|
8
|
+ <script src="../Script/Common/huayi.config.js"></script>
|
|
|
9
|
+ <title>导入客户信息</title>
|
|
|
10
|
+ <style>
|
|
|
11
|
+ .btn-success {
|
|
|
12
|
+ color: #fff;
|
|
|
13
|
+ background-color: #1ab394;
|
|
|
14
|
+ border-color: #4cae4c;
|
|
|
15
|
+ border-radius: 4px;
|
|
|
16
|
+ cursor: pointer;
|
|
|
17
|
+ }
|
|
|
18
|
+
|
|
|
19
|
+ .btn-success.active,
|
|
|
20
|
+ .btn-success:active,
|
|
|
21
|
+ .btn-success:focus,
|
|
|
22
|
+ .btn-success:hover {
|
|
|
23
|
+ border-color: #4cae4c;
|
|
|
24
|
+ background-color: #1ab394;
|
|
|
25
|
+ }
|
|
|
26
|
+
|
|
|
27
|
+ .btn-success[disabled],
|
|
|
28
|
+ .btn-success[disabled]:active,
|
|
|
29
|
+ .btn-success[disabled]:focus,
|
|
|
30
|
+ .btn-success[disabled]:hover {
|
|
|
31
|
+ background-color: #1ab394;
|
|
|
32
|
+ }
|
|
|
33
|
+
|
|
|
34
|
+ #importNum {
|
|
|
35
|
+ width: 130px;
|
|
|
36
|
+ margin: 60px auto 0 auto;
|
|
|
37
|
+ }
|
|
|
38
|
+
|
|
|
39
|
+ .progress {
|
|
|
40
|
+ width: 80%;
|
|
|
41
|
+ margin: 20px auto 0 auto;
|
|
|
42
|
+ display: none;
|
|
|
43
|
+ }
|
|
|
44
|
+
|
|
|
45
|
+ div.drop_down {
|
|
|
46
|
+ position: relative;
|
|
|
47
|
+ line-height: 34px;
|
|
|
48
|
+ }
|
|
|
49
|
+
|
|
|
50
|
+ .drop_down .caret {
|
|
|
51
|
+ position: absolute;
|
|
|
52
|
+ right: 10px;
|
|
|
53
|
+ top: 15px;
|
|
|
54
|
+ }
|
|
|
55
|
+
|
|
|
56
|
+ .form-group {
|
|
|
57
|
+ margin-bottom: 10px!important;
|
|
|
58
|
+ }
|
|
|
59
|
+
|
|
|
60
|
+ @media (min-width: 768px) {
|
|
|
61
|
+ .drop_down .form-control {
|
|
|
62
|
+ width: 818px;
|
|
|
63
|
+ }
|
|
|
64
|
+ }
|
|
|
65
|
+ </style>
|
|
|
66
|
+ </head>
|
|
|
67
|
+
|
|
|
68
|
+ <body>
|
|
|
69
|
+
|
|
|
70
|
+ <div style="padding: 10px; margin-bottom: 20px;">
|
|
|
71
|
+ <div class="alert alert-info" role="alert">
|
|
|
72
|
+ <span class="glyphicon glyphicon-exclamation-sign" aria-hidden="true"></span>
|
|
|
73
|
+ <span class="sr-only">tips:</span> 上传文件需要严格按照下载的EXCEL模板进行填写!上传后点击导入即可!
|
|
|
74
|
+ </div>
|
|
|
75
|
+ <div class="form-inline clearfix">
|
|
|
76
|
+ <!--<div class="form-group">
|
|
|
77
|
+ <select class="form-control selectpicker" id="head_form_rengin" data-live-search="true">
|
|
|
78
|
+ <option value="0">请选择区域</option>
|
|
|
79
|
+ </select>
|
|
|
80
|
+ </div>
|
|
|
81
|
+ <div class="form-group">
|
|
|
82
|
+ <select class="form-control selectpicker" id="head_form_pro" data-live-search="true">
|
|
|
83
|
+ <option value="0">请选择项目</option>
|
|
|
84
|
+ </select>
|
|
|
85
|
+ </div>
|
|
|
86
|
+ <div class="form-group">
|
|
|
87
|
+ <select class="form-control selectpicker" id="head_form_floor" data-live-search="true">
|
|
|
88
|
+ <option value="0">请选择期号</option>
|
|
|
89
|
+ </select>
|
|
|
90
|
+ </div>-->
|
|
|
91
|
+
|
|
|
92
|
+ <div class="form-group">
|
|
|
93
|
+ <a id="excelMod" class="btn btn-success form-control" title="点击下载EXCEL模板" href="javascript:void(0)" onclick="ExcelMod()" rel="nofollow">下载EXCEL模板</a>
|
|
|
94
|
+ </div>
|
|
|
95
|
+ <div class="form-group">
|
|
|
96
|
+ <input class="hidden" type="file" id="upFile" name="upFile" accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel,application/x-xls,application/x-xlsx" />
|
|
|
97
|
+ <input class="form-control btn btn-success" title="点击上传Excel文件" type="button" value="上传Excel文件" id="upFileExcel" />
|
|
|
98
|
+ <span class="excelName"></span>
|
|
|
99
|
+ </div>
|
|
|
100
|
+ </div>
|
|
|
101
|
+ <div class="progress">
|
|
|
102
|
+ <div class="progress-bar progress-bar-striped" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100">
|
|
|
103
|
+
|
|
|
104
|
+ </div>
|
|
|
105
|
+ </div>
|
|
|
106
|
+ <div class="form-group text-center">
|
|
|
107
|
+ <input type="button" id="importNum" class="form-control btn btn-success" value="导入" />
|
|
|
108
|
+ </div>
|
|
|
109
|
+ </div>
|
|
|
110
|
+
|
|
|
111
|
+ <script src="../js/bootstrap-select/js/bootstrap-select.js"></script>
|
|
|
112
|
+ <script src="../js/bootstrap-select/js/i18n/defaults-zh_CN.js"></script>
|
|
|
113
|
+ <script>
|
|
|
114
|
+ var percents = 0; //长传文件进度值
|
|
|
115
|
+ $(document).ready(function() {
|
|
|
116
|
+ //上传EXCEL文件
|
|
|
117
|
+ $("#upFileExcel").click(function() {
|
|
|
118
|
+ $("#upFile").trigger("click");
|
|
|
119
|
+ });
|
|
|
120
|
+ $("#upFile").change(function() {
|
|
|
121
|
+ var Files = document.getElementById("upFile").files;
|
|
|
122
|
+ $('.excelName').html(Files[0].name); //文件名称
|
|
|
123
|
+ });
|
|
|
124
|
+ $("#importNum").click(function() {
|
|
|
125
|
+ uploads();
|
|
|
126
|
+ });
|
|
|
127
|
+
|
|
|
128
|
+ });
|
|
|
129
|
+ //下载模板
|
|
|
130
|
+ function ExcelMod() {
|
|
|
131
|
+ window.location.href = "MiExcel.xls";
|
|
|
132
|
+ }
|
|
|
133
|
+
|
|
|
134
|
+ //上传Excel文件 模拟实时进度
|
|
|
135
|
+ function uploads() {
|
|
|
136
|
+ var txtName = $('.excelName').text();
|
|
|
137
|
+ if(txtName == '') {
|
|
|
138
|
+ layer.confirm('你还没有上传文件', {
|
|
|
139
|
+ icon: 2,
|
|
|
140
|
+ btn: ['确定']
|
|
|
141
|
+ });
|
|
|
142
|
+ return;
|
|
|
143
|
+ }
|
|
|
144
|
+ //一般情况下,excel后缀是".xls",在2007以及以后的版本中又增加了".xlsx"。excel的模板文件后缀名是".xlt",启动宏的工作簿后缀名是".xlsm"。
|
|
|
145
|
+ if(txtName.indexOf('.xls') != -1 ||
|
|
|
146
|
+ txtName.indexOf('.xlsx') != -1 ||
|
|
|
147
|
+ txtName.indexOf('.xlt') != -1 ||
|
|
|
148
|
+ txtName.indexOf('.xlsm') != -1
|
|
|
149
|
+ ) {
|
|
|
150
|
+ var formData = new FormData();
|
|
|
151
|
+ var Files = document.getElementById("upFile").files;
|
|
|
152
|
+ formData.append("upFile", Files[0]); //是 HttpPostedFile Excel文件
|
|
|
153
|
+ formData.append("token", $.cookie("token"));
|
|
|
154
|
+ $.ajax({
|
|
|
155
|
+ url: huayi.config.callcenter_url + "WorkOrder/ImportExcel",
|
|
|
156
|
+ type: "POST",
|
|
|
157
|
+ data: formData,
|
|
|
158
|
+ /**
|
|
|
159
|
+ *必须false才会自动加上正确的Content-Type
|
|
|
160
|
+ */
|
|
|
161
|
+ contentType: false,
|
|
|
162
|
+ /**
|
|
|
163
|
+ * 必须false才会避开jQuery对 formdata 的默认处理
|
|
|
164
|
+ * XMLHttpRequest会对 formdata 进行正确的处理
|
|
|
165
|
+ */
|
|
|
166
|
+ processData: false,
|
|
|
167
|
+ xhr: function() {
|
|
|
168
|
+ var xhr = jQuery.ajaxSettings.xhr();
|
|
|
169
|
+ xhr.upload.onload = function() {
|
|
|
170
|
+ updateProgress(88);
|
|
|
171
|
+ }
|
|
|
172
|
+ xhr.upload.onprogress = function(ev) {
|
|
|
173
|
+ updateProgress(70);
|
|
|
174
|
+ }
|
|
|
175
|
+ return xhr;
|
|
|
176
|
+ },
|
|
|
177
|
+ beforeSend: function(request) {
|
|
|
178
|
+ $('.progress').show();
|
|
|
179
|
+ $("#importNum").attr("disabled", true);
|
|
|
180
|
+ $("#importNum").val('导入中...');
|
|
|
181
|
+ updateProgress(50);
|
|
|
182
|
+
|
|
|
183
|
+ },
|
|
|
184
|
+ success: function(result) {
|
|
|
185
|
+ updateProgress(100);
|
|
|
186
|
+ var r = $.parseJSON(result);
|
|
|
187
|
+ $("#importNum").attr("disabled", false);
|
|
|
188
|
+ $("#importNum").val('导入');
|
|
|
189
|
+ if(r.state.toLowerCase() == "success") {
|
|
|
190
|
+ var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
|
|
|
191
|
+ parent.layer.close(index); //再执行关闭
|
|
|
192
|
+ parent.$('#workorderlist').bootstrapTable('refresh');
|
|
|
193
|
+ parent.layer.alert(r.message, {
|
|
|
194
|
+ icon: 1,
|
|
|
195
|
+ btn: ['确定']
|
|
|
196
|
+ });
|
|
|
197
|
+
|
|
|
198
|
+ }
|
|
|
199
|
+ },
|
|
|
200
|
+ error: function(textStatus) {
|
|
|
201
|
+ percents = 0;
|
|
|
202
|
+ $('.progress').hide();
|
|
|
203
|
+ layer.confirm('网络繁忙,请稍后再试...', {
|
|
|
204
|
+ btn: ['确定'] //按钮
|
|
|
205
|
+ });
|
|
|
206
|
+ $("#importNum").attr("disabled", false);
|
|
|
207
|
+ $("#importNum").val('导入');
|
|
|
208
|
+ },
|
|
|
209
|
+ complete: function(XMLHttpRequest, textStatus) {
|
|
|
210
|
+ percents = 0;
|
|
|
211
|
+ $('.progress').hide();
|
|
|
212
|
+ if(textStatus == 'timeout') {
|
|
|
213
|
+ var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp");
|
|
|
214
|
+ xmlhttp.abort();
|
|
|
215
|
+ layer.confirm('网络超时,请稍后再试...', {
|
|
|
216
|
+ btn: ['确定'] //按钮
|
|
|
217
|
+ });
|
|
|
218
|
+ }
|
|
|
219
|
+ $("#importNum").attr("disabled", false);
|
|
|
220
|
+ $("#importNum").val('导入');
|
|
|
221
|
+ },
|
|
|
222
|
+ });
|
|
|
223
|
+
|
|
|
224
|
+ } else {
|
|
|
225
|
+ layer.confirm('请上传EXCEL文件', {
|
|
|
226
|
+ icon: 2,
|
|
|
227
|
+ btn: ['确定']
|
|
|
228
|
+ });
|
|
|
229
|
+ return;
|
|
|
230
|
+ }
|
|
|
231
|
+ }
|
|
|
232
|
+
|
|
|
233
|
+ //更新进度条
|
|
|
234
|
+ function updateProgress(p) {
|
|
|
235
|
+ while(percents < p) {
|
|
|
236
|
+ percents++;
|
|
|
237
|
+ $('.progress-bar').css('width', percents + '%');
|
|
|
238
|
+ $('.progress-bar').text(percents + '%');
|
|
|
239
|
+ }
|
|
|
240
|
+
|
|
|
241
|
+ }
|
|
|
242
|
+ </script>
|
|
|
243
|
+ </body>
|
|
|
244
|
+
|
|
|
245
|
+</html>
|