import.blade.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. <div id="configs">
  2. <el-form action="{{ route('admin.withdraw.addExcel') }}" method="post" id="form-create">
  3. <!-- 文件上传 -->
  4. <el-row class="form-group">
  5. <el-col :span="3" style="min-height:50px;padding-top:10px;">
  6. <label style="margin-left:10px;vertical-align: middle;" class="control-label">交易导出Excel</label>
  7. </el-col>
  8. <el-col :span="14" style="min-height:50px;padding-top:10px;">
  9. <el-upload
  10. class="upload-demo"
  11. action="{{ route('admin.file') }}?type=local"
  12. :on-success="handleSuccess"
  13. :headers="headers"
  14. :before-upload="beforeAvatarUpload"
  15. accept=".xls,.xlsx"
  16. name="file"
  17. :file-list="fileList">
  18. <el-button size="small" type="primary">点击上传</el-button>
  19. <div slot="tip" class="el-upload__tip">上传Excel文件</div>
  20. </el-upload>
  21. </el-col>
  22. <el-col :span="7" style="min-height:50px;padding-top:10px;">
  23. </el-col>
  24. </el-row>
  25. <input type="hidden" id="excel_str" name="excel_str" value="">
  26. <!-- 是否显示 -->
  27. <!-- 文件上传 -->
  28. {{ csrf_field() }}
  29. <hr>
  30. <ui-submit></ui-submit>
  31. </el-form>
  32. </div>
  33. <script type="application/javascript">
  34. $(function () {
  35. // 注意:Vue组件一定放在jQuery.validator前面验证
  36. new Vue({
  37. el: '#configs',
  38. data :function () {
  39. return {
  40. fileList: [{
  41. name: "{{ config('admins.android_apk') }}",
  42. url: "{{ config('admins.android_apk') }}"
  43. }],
  44. headers: {
  45. 'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
  46. },
  47. };
  48. },
  49. methods: {
  50. handleSuccess:function(response, file, fileList) {
  51. if( response.code >= 1 ){
  52. // 消息 response.message
  53. this.$message.error(response.message);
  54. }else{
  55. this.fileList = fileList.slice(-1);
  56. $('#excel_str').val(response.url);
  57. // 消息 response.message
  58. this.$message.success("文件上传成功");
  59. }
  60. },
  61. handleSuccessIOS:function(response, file, fileList) {
  62. if( response.code >= 1 ){
  63. // 消息 response.message
  64. this.$message.error(response.message);
  65. }else{
  66. this.fileListIOS = fileList.slice(-1);
  67. $('#ios_apk').val(response.url);
  68. // 消息 response.message
  69. this.$message.success("文件上传成功");
  70. }
  71. },
  72. beforeAvatarUpload:function(file) {
  73. const isJPG = (file.type === 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' || file.type=='application/vnd.ms-excel');
  74. const isLt2M = file.size / 1024 / 1024 < 200;
  75. console.log(file);
  76. if (!isJPG) {
  77. this.$message.error('上传文件支持.xls,.xlsx');
  78. }
  79. if (!isLt2M) {
  80. this.$message.error('上传文件最大 200MB!');
  81. }
  82. return isJPG && isLt2M;
  83. },
  84. beforeAvatarUploadIOS:function(file) {
  85. console.log(file.type);
  86. // const isJPG = file.type === 'application/vnd.android.package-archive';
  87. const isLt2M = file.size / 1024 / 1024 < 200;
  88. // if (!isJPG) {
  89. // this.$message.error('上传文件支持apk');
  90. // }
  91. if (!isLt2M) {
  92. this.$message.error('上传文件最大 200MB!');
  93. return false;
  94. }
  95. return true;
  96. }
  97. }
  98. });
  99. // 编辑保存变量
  100. window.formDatum = $('form').serialize();
  101. });
  102. </script>