123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373 |
- {extend name="public/layout" /} {block name="title"}客户导入{/block} {block name="body"}
- <style type="text/css">
- html,
- body {
- display: block;
- width: 100%;
- background-color: #fff;
- }
- .layui-icon {
- font-size: 18px !important;
- line-height: 38px;
- }
- .layui-table-view .layui-table th,
- .layui-table-view .layui-table td {
- text-align: center;
- border-color: #B6CADE;
- }
- .upload-img .area i {
- font-size: 50px;
- color: #009688;
- }
- .evi-block {
- float: left;
- margin-right: 10px;
- }
- /*///*/
- .addImages {
- display: inline-block;
- width: 140px;
- height: 125px;
- -webkit-box-sizing: border-box;
- -moz-box-sizing: border-box;
- box-sizing: border-box;
- border: 1px dashed darkgray;
- background: #f8f8f8;
- position: relative;
- overflow: hidden;
- }
- .text-detail {
- margin-top: 40px;
- text-align: center;
- }
- .text-detail>span {
- font-size: 40px;
- }
- .imageDiv div {
- width: 100%;
- height: 100%;
- position: absolute;
- top: 0px;
- background-color: #e6e6e600;
- }
- .imageDiv div i {
- display: none;
- font-size: 31px;
- position: absolute;
- top: 37%;
- left: 40%;
- }
- .imageDiv div:hover {
- background-color: #e6e6e680;
- }
- .imageDiv div:hover i {
- display: block;
- cursor: pointer;
- }
- .layui-card-header p a:hover {
- text-decoration-line: underline;
- }
- .clearfix::after {
- clear: both;
- content: ' ';
- display: table;
- }
- .clearfix::before {
- content: ' ';
- display: table;
- }
- .left {
- float: left;
- }
- .templetbox {
- display: block;
- width: 80px;
- height: 80px;
- border:unset;
- text-align: center;
- background-color: #fff;
- box-shadow: 0 0 10px 6px rgba(209,205,205,0.2);
- cursor: pointer;
- }
- .templetbox img {
- display: block;
- width: 40px;
- margin: 14px auto 4px;
- }
- .templetbox span,
- .templetbox button {
- display: block;
- width: 100%;
- text-align: center;
- font-size: 12px;
- color: #384855;
- height: 20px;
- background-color: transparent;
- line-height: 20px;
- }
- .leftextbox {
- color: #249efb;
- font-size: 14px;
- line-height: 88px;
- margin-right: 32px;
- }
- .uploadbox {
- margin-left: 40px;
- }
- .noticebox {
- margin-top: 40px;
- }
- .sourcebox {
- margin-top: 40px;
- }
- .sourcebtn {
- padding-left: 0;
- width: auto;
- }
- .sourceinput {
- margin-left: 84px;
- }
- .width33_3{
- width: 33.333%;
- }
- .resultbox{
- display: block;
- border: 1px solid #e6e6e6;
- margin-top: 24px;
- padding: 16px 0;
- }
- .everyresultbox{
- height: 48px;
- border-right: 1px solid #e6e6e6;
- box-sizing: border-box;
- text-align: center;
- line-height: 48px;
- }
- .resultbox .everyresultbox:last-child{
- border: unset;
- }
- .numbox{
- height: 18px;
- font-size: 12px;
- padding: 0 2px;
- background-color: #249efb;
- color: #fff;
- line-height: 18px;
- margin-right: 4px;
- border-radius: 4px;
- }
- .sourcebox .layui-form-select{width:50%;display: inline-block;}
- .layui-form-select dl{max-height: 200px;}
- </style>
- <body>
- <div class="layui-fluid">
- <div class="layui-card">
- <div class="layui-card-body">
- <form class="layui-form">
- <div class="layui-upload">
- <div class="clearfix">
- <div class="left clearfix">
- <div class="left leftextbox">客户信息模板</div>
- <a class="left templetbox" href="../../static/customerRemove.xlsx" download>
- <img src="__STATIC__/img/file.png" />
- <span>下载模板</span>
- </a>
- </div>
- <div class="left uploadbox">
- <div class="left leftextbox">导入客户</div>
- <div class="left templetbox" id="excelfile" style="cursor: pointer;" href>
- <img src="__STATIC__/img/upload.png" />
- <span>上传文档</span>
- <input type="file" hidden id="xlsx-file" accept=".xls,.xlsx" />
- </div>
- <span class="layui-inline layui-upload-choose filename" style="line-height: 80px;"></span>
- </div>
- </div>
- <p class="noticebox" style="color:red"><span>注意:仅支持xlsx、xls格式,若未按照规范,则可能造成导入失败</span></p>
- </div>
- <div class="layui-form-item ">
- <button class="layui-btn submitbox" lay-submit style="float:right"
- lay-filter="submit">上传</button>
- <div class="layui-btn reloadTable" style="float: right;margin-right: 6px;">刷新</div>
- </div>
- </form>
- </div>
- </div>
- <div id="loadings" class="layui-hide"><span style="color:black;margin: 43%;white-space: nowrap;">正在上传数据,需要一些时间,请稍后...</span></div>
- <table id="cluelist" lay-filter="cluelist"></table>
- </div>
- </body>
- {/block} {block name="js"}
- <script src="__STATIC__/js/xlsx.core.min.js"></script>
- <script type="text/html" id="status">
- {{# if(d.status == 0){ }}
- <span>未开始</span>
- {{# } }}
- {{# if(d.status == 1){ }}
- <span style="color: orange;">导入中</span>
- {{# } }}
- {{# if(d.status == 2){ }}
- <span style="color: #009688;">已完成</span>
- {{# } }}
- {{# if(d.status == 3){ }}
- <span style="color: red;">导入失败</span>
- {{# } }}
- </script>
- <script type="text/html" id="act">
- {{# if(d.status == 0){ }}
- <a class="layui-btn layui-btn-xs" lay-event="add">导入</a>
- {{# } }}
- </script>
- <script>
- layui.config({
- base: '__LAYUI__/' //静态资源所在路径
- ,
- urlbase: '/sys'
- }).extend({
- index: 'lib/index' //主入口模块
- }).use(['index', 'form', 'upload', 'table'], function () {
- var $ = layui.$,
- form = layui.form,
- upload = layui.upload,
- table = layui.table;
- $('#excelfile').click(function(){
- $('#xlsx-file')[0].click()
- })
- var fileobj='';
- $('#xlsx-file').change(function(e) {
- fileobj = e.target.files;
- var fileReader = new FileReader();
- $('.filename').html(fileobj[0].name);
- fileReader.readAsDataURL(document.querySelector('#xlsx-file').files[0])
- fileReader.onload = function(ev) {
- try {
- // console.log( ev.target.result)
- } catch (e) {
- console.log('文件类型不正确');
- return;
- }
- };
- });
- table.render({
- elem: '#cluelist'
- , url: '{:url("crm_remove/importing")}' //数据接口
- , page: true //开启分页
- ,height: 'full-160'
- ,limit:30
- , autoSort: false
- , cols: [[ //表头
- { field: 'name', title: '导入文件名'}
- , { field: 'count', title: '读取资源数'}
- , { field: 'avaliable_count', title: '有效线索资源数'}
- , { field: 'bad_phone_num', title: '无效线索资源数'}
- , { field: 'addtime', title: '导入时间',}
- , { field: 'status', title: '导入状态' ,templet:'#status'}
- , { field: '', title: '操作' ,templet:'#act'}
- ]]
- });
- $(".reloadTable").click(function() {
- table.reload('cluelist');
- })
-
- table.on('tool(cluelist)', function (obj) {
- var id = obj.data.id;
- var layEvent = obj.event;
- if (layEvent === 'add') {
- //layer.msg("数据上传中,请手动刷新上传结果", {time: 1000});
- add_on(id);
- setTimeout(function(){
- table.reload('cluelist');
- }, 1000)
- //myMsg(1)
- }
- })
- function add_on(log_id) {
- $.ajax({
- url: '{:url("crm_remove/add")}',
- type: 'post',
- data: {log_id: log_id},
- success: function (res) {
- if (res.code == 0) {
- layer.msg(res.msg);
- } else if (res.code == 1) {
- $("#loadings").addClass('layui-hide');
- layer.msg(res.msg)
- }
- }
- });
- }
-
- var allnum=0,invalidnum=0,repeatnum=0,avaliablenum=0;
- form.on('submit(submit)', function (obj) {
- if(!fileobj){
- layer.msg("数据不能为空!", {time: 1000});
- return false;
- }
- $(obj.elem).addClass('layui-btn layui-btn-disabled');
- let formData = new FormData();
- formData.append("file", fileobj[0]);
- $.ajax({
- url: '{:url("crm_remove/importLog")}',
- type: 'post',
- data: formData,
- dataType: 'json',
- processData: false,
- contentType: false,
- success: function (res) {
- $(obj.elem).removeClass('layui-btn-disabled');
- $("#loadings").addClass('layui-hide');
- if (res.code === 0) {
- setTimeout(() => {
- table.reload('cluelist');
- },2000)
- fileobj = null;
- $("#xlsx-file").val("");
- $(".filename").html("")
- layer.msg(res.msg);
- } else {
- layer.msg(res.msg, {
- anim: 6
- , time: 2000
- });
- }
- }
- });
- return false;
- })
- });
- </script>
- {/block}
|