123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <div id="configs">
- <el-form action="{{ route('admin.withdraw.addExcel') }}" method="post" id="form-create">
- <!-- 文件上传 -->
- <el-row class="form-group">
- <el-col :span="3" style="min-height:50px;padding-top:10px;">
- <label style="margin-left:10px;vertical-align: middle;" class="control-label">交易导出Excel</label>
- </el-col>
- <el-col :span="14" style="min-height:50px;padding-top:10px;">
- <el-upload
- class="upload-demo"
- action="{{ route('admin.file') }}?type=local"
- :on-success="handleSuccess"
- :headers="headers"
- :before-upload="beforeAvatarUpload"
- accept=".xls,.xlsx"
- name="file"
- :file-list="fileList">
- <el-button size="small" type="primary">点击上传</el-button>
- <div slot="tip" class="el-upload__tip">上传Excel文件</div>
- </el-upload>
- </el-col>
- <el-col :span="7" style="min-height:50px;padding-top:10px;">
- </el-col>
- </el-row>
- <input type="hidden" id="excel_str" name="excel_str" value="">
- <!-- 是否显示 -->
- <!-- 文件上传 -->
- {{ csrf_field() }}
- <hr>
- <ui-submit></ui-submit>
- </el-form>
- </div>
- <script type="application/javascript">
- $(function () {
- // 注意:Vue组件一定放在jQuery.validator前面验证
- new Vue({
- el: '#configs',
- data :function () {
- return {
- fileList: [{
- name: "{{ config('admins.android_apk') }}",
- url: "{{ config('admins.android_apk') }}"
- }],
- headers: {
- 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
- },
- };
- },
- methods: {
- handleSuccess:function(response, file, fileList) {
- if( response.code >= 1 ){
- // 消息 response.message
- this.$message.error(response.message);
- }else{
- this.fileList = fileList.slice(-1);
- $('#excel_str').val(response.url);
- // 消息 response.message
- this.$message.success("文件上传成功");
- }
- },
- handleSuccessIOS:function(response, file, fileList) {
- if( response.code >= 1 ){
- // 消息 response.message
- this.$message.error(response.message);
- }else{
- this.fileListIOS = fileList.slice(-1);
- $('#ios_apk').val(response.url);
- // 消息 response.message
- this.$message.success("文件上传成功");
- }
- },
- beforeAvatarUpload:function(file) {
- const isJPG = (file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type=='application/vnd.ms-excel');
- const isLt2M = file.size / 1024 / 1024 < 200;
- console.log(file);
- if (!isJPG) {
- this.$message.error('上传文件支持.xls,.xlsx');
- }
- if (!isLt2M) {
- this.$message.error('上传文件最大 200MB!');
- }
- return isJPG && isLt2M;
- },
- beforeAvatarUploadIOS:function(file) {
- console.log(file.type);
- // const isJPG = file.type === 'application/vnd.android.package-archive';
- const isLt2M = file.size / 1024 / 1024 < 200;
- // if (!isJPG) {
- // this.$message.error('上传文件支持apk');
- // }
- if (!isLt2M) {
- this.$message.error('上传文件最大 200MB!');
- return false;
- }
- return true;
- }
- }
- });
- // 编辑保存变量
- window.formDatum = $('form').serialize();
- });
- </script>
|