| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <%@ page language="java" import="java.util.*"
- contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
- <%@include file="/context/mytags.jsp" %>
- <t:base type="jquery,easyui,tools"></t:base>
- <!DOCTYPE html>
- <html>
- <head>
- <title>Excel导入</title>
- <style>
- .loading {
- width: 95px;
- height: 7px;
- font-size: 7px;
- margin: 5px auto;
- background: url(/images/loading.gif) no-repeat
- }
- </style>
- </head>
- <body style="overflow: hidden" scroll="no">
- <div id="content">
- <!-- <div id="wrapper"> -->
- <div class="loading upload-icon" style="display:none;position: absolute;left: 150px;top: 50%"></div>
- <div id="steps">
- <form id="formobj" action="null" name="formobj" method="post">
- <input type="hidden" id="btn_sub" class="btn_sub"/>
- <%-- <fieldset class="step">--%>
- <div class="form" style="width: 97%;">
- <link rel="stylesheet" href="plug-in/uploadify/css/uploadify.css"
- type="text/css"></link>
- <script type="text/javascript"
- src="plug-in/uploadify/jquery.uploadify-3.1.js"></script>
- <script type="text/javascript" src="plug-in/tools/Map.js"></script>
- <script type="text/javascript">
- function upload() {
- postData();
- }
- function cancel() {
- }
- </script>
- <span id="file_uploadspan">
- <input type="file" id="file" multiple="multiple" onchange="handleFile()">
- </span>
- </div>
- <div class="form" id="filediv">
- <p><span>说明:导入文件必须基于系统格式,您可以先点击下载模板:
- <c:if test="${empty carType}">
- <a href="${controller_name}.do?exportXlsByT" style="width: 81px;margin-top: 10px;" class="l-btn l-btn-plain" plain="true" icon="icon-putout" operationCode="putout" >模板下载</a>
- </c:if>
- <c:if test="${!empty carType}">
- <a href="${controller_name}.do?exportXlsByT&carType=${carType}" style="width: 81px;margin-top: 10px;" class="l-btn l-btn-plain" plain="true" icon="icon-putout" operationCode="putout" >模板下载</a>
- </c:if>
- </span></p>
- </div>
- <script type="text/javascript">
- $(function () {
- $("#filediv").attr("style", "height:200px;overflow:auto;width: 97%;");
- $("#filediv").parent("td").attr("style", "width: 650px; height: 400px;");
- });
- </script>
- <%-- </fieldset>--%>
- </form>
- </div>
- <!-- </div> -->
- </div>
- <script type="text/javascript">
- var formData, fs;
- function handleFile() {
- formData = new FormData(),
- fs = $("#file")[0].files;
- let max_size = 1024 * 1024 * 30;
- for (let i = 0; i < fs.length; i++) {
- let d = fs[0]
- if (d.size <= max_size) { //文件必须小于30M
- if (/.(xls|XLS|xlsx|XLSX)$/.test(d.name)) { //文件必须为文档
- formData.append("files", fs[i]); //文件上传处理
- } else {
- alert('上传文件必须是XLS!')
- return false
- }
- } else {
- alert('上传文件过大!')
- return false
- }
- }
- // var formData = new FormData();
- // formData.append("photo",$("#photo")[0].files[0]);
- // formData.append("service",'App.Passion.UploadFile');
- // formData.append("token",token);
- }
- function postData() {
- let $icon = $(".upload-icon");
- $icon.show();
- let ajaxUrl = '${controller_name}.do?importExcel'
- if(${!empty carType}){
- ajaxUrl += '&carType=' + '${carType}';
- }
- $.ajax({
- url: ajaxUrl, /*接口域名地址*/
- type: 'post',
- data: formData,
- contentType: false,
- processData: false,
- success: function (res) {
- //{"success":true,"msg":"文件导入失败!","obj":null,"attributes":null,"jsonStr":"{\"msg\":\"文件导入失败!\",\"success\":true}"}
- W.tip(res.msg);
- $icon.hide();
- if (res.success) {
- W.reloadTable();
- windowapi.close();
- } else {
- console.log(res);
- }
- }
- })
- }
- function zhaohual(d) {
- // console.log(d);
- if (d.success == false) {
- if (d.msg == "导入模板错误") {
- layer.alert(d.msg);
- } else if (d.msg == "文件导入失败,请查看日志" || d.msg == "导入模板数据错误") {
- layer.alert(d.msg);
- // window.location.href="export/template/员工基本档案列表.xls";
- var downsrc = d.obj;
- location.href = downsrc;
- } else {
- layer.alert(d.msg);
- }
- }
- }
- </script>
- </body>
- </html>
|