123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194 |
- @extends('admin/layout')
- @section('content')
- <body class="gray-bg">
- <div class="wrapper wrapper-content animated fadeInRight">
- <div class="row">
- <div class="col-sm-12">
- <div class="ibox float-e-margins">
- {{--如果已经处理过此流程处于处理中状态显示文件上传--}}
- {{--@if($siteProcess->active==2)--}}
- <div class="ibox-content">
- <form class="form-horizontal">
- <div class="form-group">
- <label class="col-sm-2 control-label">请选择文件:</label>
- <div class="col-sm-6">
- <input type="file" id="upload_file" class="form-control" onchange="units.fileUpload()">
- <input type="hidden" id="file_path">
- </div>
- <div class="col-sm-4">
- {{--<button class="btn btn-info" type="button" onclick="units.fileUpload()">上传--}}
- {{--</button>--}}
- <button class="btn btn-success" type="button" onclick="units.save()"
- style="margin-left: 40px">保存
- </button>
- </div>
- </div>
- </form>
- </div>
- {{--@endif--}}
- <div class="ibox-content" id="file_list">
- {{--@forelse ($siteProcess->file_list??[] as $item)--}}
- {{--<div class="alert alert-info">--}}
- {{--<a class="alert-link" href="{{$item['file_url']}}"--}}
- {{--download="{{$item['origin_name']}}">{{$item['origin_name']}}</a>--}}
- {{--</div>--}}
- {{--@empty--}}
- {{--<div class="alert alert-info no-data">--}}
- {{--<a class="alert-link">无数据</a>--}}
- {{--</div>--}}
- {{--@endforelse--}}
- <div class="alert alert-info">
- @php
- $fileList=$siteProcess->file_list??[];
- $latestFile=array_shift($fileList);
- @endphp
- <a class="alert-link" id="fileArea"
- @if($latestFile)
- href="{{$latestFile['file_url']??''}}"
- download="{{$latestFile['origin_name']}}"
- @endif
- >{{$latestFile['origin_name']??'无数据'}}</a>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </body>
- @endsection
- @section('footer')
- <script>
- var units = {
- fileUpload: function () {
- var config = {
- url: '/admin/tool/upload'
- };
- config.success = function (result) {
- $("#file_path").val(result.data.file_url);
- layer.msg(result.message, {icon: 6, time: 1500});
- // var str = '<div class="alert alert-info">' +
- // '<a class="alert-link" href="' + result.data.file_url + '" name="file_list">' + result.data.original_name + '</a>' +
- // '</div>';
- // var file_list = $("#file_list");
- //
- // var noData = file_list.find(".no-data");
- // if (noData.length > 0) {
- // noData.remove();
- // }
- // file_list.prepend(str);
- $("#fileArea").text(result.data.original_name).attr('href', result.data.file_url).attr('download', result.data.original_name);
- };
- tips.fileUpload($("#upload_file"), config);
- },
- save: function () {
- var fileList = [];
- // $("[name=file_list]").each(function () { //只记录上传新增的
- // fileList.push({
- // file_url: $(this).attr('href'),
- // origin_name: $(this).text()
- // });
- // });
- var fileArea = $("#fileArea");
- fileList.push({
- file_url: fileArea.attr('href'),
- origin_name: fileArea.text()
- });
- if (fileList.length < 1) {
- layer.alert('请先上传文件再保存', {icon: 0});
- return;
- }
- var ajaxConfig = {
- url: '/admin/process/file-upload/{{$siteProcess->id}}',
- type: 'post',
- data: {file_list: fileList},
- success: function (result) {
- layer.msg(result.message, {icon: 6, time: 1000}, function () {
- parent.window.location.reload();
- tips.closeParentLayer();
- });
- }
- };
- tips.ajax(ajaxConfig);
- }
- };
- var siteProcessId = "{{$siteProcess->id}}";
- $(document).on('click', '[name=file_upload]', function () {
- $(this).next().trigger('click');
- });
- // $(document).on('change', '[name=uploadFile]', function () {
- //
- // if (!$(this)[0].files[0]) {
- // return;
- // }
- //
- // var formData = new FormData();
- // formData.append('file', $(this)[0].files[0]);
- //
- // formData.append('siteProcessId', siteProcessId);
- // var ln;
- // $.ajax({
- // url: '/admin/process/file-upload',
- // type: 'POST',
- // cache: false,
- // data: formData,
- // processData: false,
- // contentType: false,
- // beforeSend: function () {
- // ln = layer.load();
- // },
- // complete: function () {
- // layer.close(ln);
- // },
- // success: function (result) {
- // var data = result.data;
- // console.log(units);
- // return;
- // $("#file").append(units.generateHtml(data.file_url, data.original_name));
- // },
- // error: function (XMLHttpRequest) {
- // if (XMLHttpRequest.status === 500) {
- // layer.alert("异步请求失败", {icon: 5});
- // return;
- // }
- // layer.alert(JSON.parse(XMLHttpRequest.responseText).message, {icon: 0});
- // }
- // });
- // });
- $(document).on('click', '#confirm', function () {
- var config = {};
- config.url = '/admin/process/confirm';
- config.type = 'put';
- config.data = {siteProcessId: siteProcessId};
- tips.ajax(config);
- });
- </script>
- @endsection
|