asset_save.blade.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. @extends('admin/layout')
  2. @section('header')
  3. <link href="{{asset('css/plugins/chosen/chosen.css')}}" rel="stylesheet">
  4. <link href="{{asset('css/plugins/switchery/switchery.css')}}" rel="stylesheet">
  5. @endsection
  6. @section('content')
  7. <body class="gray-bg">
  8. <div class="wrapper wrapper-content animated fadeInRight">
  9. <div class="row">
  10. <div class="col-sm-12">
  11. <div class="ibox float-e-margins">
  12. <div class="ibox-content">
  13. <form method="get" class="form-horizontal" id="form">
  14. <div class="form-group">
  15. <label class="col-sm-2 control-label" for="type_id">资源类型:</label>
  16. <div class="col-sm-8 ">
  17. <select class="form-control" id="type" name="type_id" id="type_id">
  18. <option value="">请选择资源类型</option>
  19. @foreach ($assetTypes as $item)
  20. <option value="{{$item->id}}"
  21. @if(($data->type_id??null)==$item->id) selected @endif>
  22. {{$item->title}}
  23. </option>
  24. @endforeach
  25. </select>
  26. </div>
  27. </div>
  28. <div class="form-group">
  29. <label class="col-sm-2 control-label">请选择文件:</label>
  30. <div class="col-sm-6">
  31. {{--<input type="file" id="up_file">--}}
  32. <input type="file" id="upload_file" class="form-control" >
  33. <input class="form-control" title="" type="text" id="original_name" value="{{$data->original_name??''}}" disabled style="margin-top: 10px">
  34. <input type="hidden" id="file_url" value="{{$data->file_url??''}}">
  35. </div>
  36. <div class="col-sm-4">
  37. <button class="btn btn-info btn-sm" type="button" onclick="units.fileUpload()">上传
  38. </button>
  39. </div>
  40. </div>
  41. <div class="form-group">
  42. <label class="col-sm-2 control-label" for="describe">描述:</label>
  43. <div class="col-sm-8">
  44. <textarea class="form-control" id="describe" name="describe"
  45. rows="3">{{$data->describe??''}}</textarea>
  46. </div>
  47. </div>
  48. <div class="hr-line-dashed"></div>
  49. <div class="form-group">
  50. <div class="col-sm-4 col-sm-offset-2">
  51. <button class="btn btn-primary" type="button"
  52. onclick="units.save({{$data->id??0}})">
  53. 保存
  54. </button>
  55. <button class="btn btn-white closeLayer" type="button">取消</button>
  56. </div>
  57. </div>
  58. </form>
  59. </div>
  60. </div>
  61. </div>
  62. </div>
  63. </div>
  64. </body>
  65. @endsection
  66. @section('footer')
  67. <script>
  68. var units = {
  69. save: function (id) {
  70. var url = '/admin/school/assets/' + id;
  71. var data = tips.getFormValues('#form');
  72. data.original_name = $("#original_name").val();
  73. data.file_url = $("#file_url").val();
  74. var ajaxConfig = {
  75. url: url,
  76. type: 'post',
  77. data: data,
  78. success: function (result) {
  79. layer.msg(result.message, {icon: 6, time: 1000}, function () {
  80. tips.closeParentLayer();
  81. window.parent.tips.tableRefresh('#table');
  82. });
  83. }
  84. };
  85. tips.ajax(ajaxConfig);
  86. },
  87. fileUpload: function () {
  88. var config = {
  89. url: '/admin/tool/upload?notAsset=1'
  90. };
  91. config.success = function (result) {
  92. $("#file_url").val(result.data.file_url);
  93. $("#original_name").val(result.data.original_name);
  94. layer.msg(result.message, {icon: 6, time: 1500});
  95. };
  96. tips.fileUpload($("#upload_file"), config);
  97. }
  98. };
  99. </script>
  100. @endsection