| xqd
@@ -2,7 +2,47 @@
|
|
|
|
|
|
@section('header')
|
|
|
<style>
|
|
|
+ .sg-search-box {
|
|
|
+ display: flex;
|
|
|
+ align-items: center;
|
|
|
+ justify-content: space-between;
|
|
|
+ }
|
|
|
+ .sg-import-box {
|
|
|
+ display: none;
|
|
|
+ }
|
|
|
+ .sg-import-box.sg-show {
|
|
|
+ display: block;
|
|
|
+ }
|
|
|
+ .sg-import-box .layui-col-sm8 {
|
|
|
+ float: none;
|
|
|
+ }
|
|
|
+ .layui-card .layui-form-item .layui-inline {
|
|
|
+ margin-bottom: 0;
|
|
|
+ }
|
|
|
+ .sg-export-list {
|
|
|
+ margin: 50px 0;
|
|
|
+ }
|
|
|
+ .sg-export-list .sg-item {
|
|
|
+ margin: 20px 0;
|
|
|
+ }
|
|
|
+ .sg-export-list .sg-item .sg-title {
|
|
|
+ margin: 20px 0;
|
|
|
+ }
|
|
|
+ .sg-export-list .sg-item .sg-desc,
|
|
|
+ .sg-export-list .sg-item ul {
|
|
|
+ color: rgb(140, 140, 140);
|
|
|
+ margin-left: 30px;
|
|
|
+ }
|
|
|
+ .sg-down-link {
|
|
|
+ color: blue;
|
|
|
+ text-decoration: underline;
|
|
|
+ }
|
|
|
+ .sg-down-link:hover {
|
|
|
+ color: blue;
|
|
|
+ }
|
|
|
+ #sg-import-all{
|
|
|
|
|
|
+ }
|
|
|
</style>
|
|
|
@endsection
|
|
|
|
| xqd
@@ -15,19 +55,22 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="layui-card-body">
|
|
|
- <form class="layui-form" id="sg-search-form">
|
|
|
- <div class="layui-form-item layui-row">
|
|
|
- @include('share.device-select', ['device_id' => '', 'device_name_id' => '', 'spec_id' => '', 'options' => $options, 'hide_spec' => true])
|
|
|
- <div class="layui-inline">
|
|
|
- <div class="layui-input-inline">
|
|
|
- <input type="text" name="name" placeholder="请输入规格型号" autocomplete="off" class="layui-input" value="{{ request('name') }}">
|
|
|
+ <form class="layui-form layui-inline" id="sg-search-form">
|
|
|
+ <div class="layui-form-item layui-row">
|
|
|
+ @include('share.device-select', ['device_id' => '', 'device_name_id' => '', 'spec_id' => '', 'options' => $options, 'hide_spec' => true])
|
|
|
+ <div class="layui-inline">
|
|
|
+ <div class="layui-input-inline">
|
|
|
+ <input type="text" name="name" placeholder="请输入规格型号" autocomplete="off" class="layui-input" value="{{ request('name') }}">
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ <div class="layui-inline">
|
|
|
+ <div class="layui-btn" id="sg-search-btn">搜索</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <div class="layui-inline">
|
|
|
- <div class="layui-btn" id="sg-search-btn">搜索</div>
|
|
|
- </div>
|
|
|
+ </form>
|
|
|
+ <div>
|
|
|
+ <button id="sg-import-all" class="layui-btn layui-btn-normal">导入</button>
|
|
|
</div>
|
|
|
- </form>
|
|
|
<table id="sg-main-table" class="layui-hide" lay-filter="tableEvent"></table>
|
|
|
<script type="text/html" id="sg-table-bar">
|
|
|
<div class="layui-btn-group">
|
| xqd
@@ -39,6 +82,28 @@
|
|
|
</script>
|
|
|
</div>
|
|
|
</div>
|
|
|
+
|
|
|
+ <div id="sg-import-box" class="sg-import-box">
|
|
|
+ <div class="layui-row">
|
|
|
+ {{--<input type="file" id="sg-upload-file">--}}
|
|
|
+ <div class="layui-col-sm8 layui-col-sm-offset2">
|
|
|
+ <div class="sg-export-list">
|
|
|
+ <div class="sg-item">
|
|
|
+ <h3 class="sg-title">一、请按照数据模板的格式准备要导入的数据。<a href="{{ $pre_uri . 'exportTemplate?t=' . time() }}" class="sg-down-link">点击下载</a>《设备导入模板》</h3>
|
|
|
+ <ul>
|
|
|
+ <li>注意事项</li>
|
|
|
+ <li>1、模板中的表头名称不能更改,表头行不能删除</li>
|
|
|
+ <li>2、导入文件请勿超过 20 MB</li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ <div class="sg-item">
|
|
|
+ <h3 class="sg-title">二、请选择需要导入的文件</h3>
|
|
|
+ <div class="sg-desc"><input type="file" id="sg-upload-file"></div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
+ </div>
|
|
|
@endsection
|
|
|
|
|
|
@section('footer')
|
| xqd
@@ -52,6 +117,69 @@
|
|
|
laydate = layui.laydate,
|
|
|
top_window = window;
|
|
|
|
|
|
+
|
|
|
+ $('#sg-import-all').click(function() {
|
|
|
+ layer.open({
|
|
|
+ title: '导入设备',
|
|
|
+ type: 1,
|
|
|
+ area: ['90%', '90%'],
|
|
|
+ content: $('#sg-import-box'),
|
|
|
+ btn: ['导入', '取消'],
|
|
|
+ yes: function () {
|
|
|
+ importFile();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ // $('#sg-upload-file').click();
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ function importFile() {
|
|
|
+ var file = $('#sg-upload-file')[0].files[0];
|
|
|
+ if(file) {
|
|
|
+ var name = file['name'];
|
|
|
+ var ext = name.split('.').pop();
|
|
|
+ if(['xls', 'xlsx'].indexOf(ext) !== -1) {
|
|
|
+ var formData = new FormData();
|
|
|
+ formData.append('file', file);
|
|
|
+ $.ajax({
|
|
|
+ method: 'POST',
|
|
|
+ url: '{{ $pre_uri }}' + 'import',
|
|
|
+ headers: {
|
|
|
+ 'X-CSRF-TOKEN': '{{ csrf_token() }}'
|
|
|
+ },
|
|
|
+ data: formData,
|
|
|
+ contentType: false,
|
|
|
+ cache: false,
|
|
|
+ processData: false,
|
|
|
+ success: function (data) {
|
|
|
+ if(data.status === 'success') {
|
|
|
+ layer.msg('上传成功', {
|
|
|
+ icon: 1
|
|
|
+ });
|
|
|
+ setTimeout(function() {
|
|
|
+ top_window.location.reload();
|
|
|
+ }, 1000)
|
|
|
+ } else {
|
|
|
+ layer.alert(data.info, {
|
|
|
+ icon: 2
|
|
|
+ });
|
|
|
+ }
|
|
|
+ },
|
|
|
+ error: function () {
|
|
|
+ layer.msg('导入失败', {
|
|
|
+ icon: 2
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ layer.msg('只支持xls,xlsx格式的文件', {
|
|
|
+ icon: 2
|
|
|
+ });
|
|
|
+ }
|
|
|
+ this.value = '';
|
|
|
+ }
|
|
|
+
|
|
|
table.render({
|
|
|
elem: '#sg-main-table',
|
|
|
url: '{{ $pre_uri }}' + 'get',
|