Browse Source

细节优化

moshaorui 2 months ago
parent
commit
84a74a9b53

+ 20 - 4
app/Admin/Controllers/SiteAlbumController.php

@@ -39,8 +39,7 @@ class SiteAlbumController extends AdminController
             ->header(admin_trans( 'admin.album'))
             ->body($this->indexForm());
         $html = $html->render();
-        //把post请求改为get请求
-        $html = preg_replace('/<form(.*?)method="post"(.*?)>/s', '<form$1method="get"$2>', $html, 1);
+
         //删除第一个formID对应的JS代码
         preg_match('/<form[^>]*id="([^"]*)"[^>]*>/', $html, $matches);
         if (isset($matches[1])) {
@@ -51,7 +50,8 @@ class SiteAlbumController extends AdminController
             $html = preg_replace($pattern, '', $html);
         }
 
-
+        //把第一个form标签替换成div标签
+        $html = preg_replace('/<form([^>]*)>(.*?)<\/form>/s', '<div$1>$2</div>', $html, 1);
 
         return $html;
     }
@@ -103,6 +103,12 @@ const firstCheckbox = document.querySelector('.vs-checkbox-primary');
 if (firstCheckbox) {
     firstCheckbox.style.display = 'none';
 }
+//清空_previous_
+const input = document.querySelector('input[name="_previous_"]');
+if (input) {
+    // 清空其值
+    input.value = '';
+}
 JS
                 );
         });
@@ -187,7 +193,15 @@ JS
                 $folderId = getTempValue('folderId');
                 $form->select('folder_id')->options(SiteAlbumFolder::selectOptions())->default($folderId)->required();
                 $form->text('model')->required();
+                $form->table('parameters',admin_trans_label('attribute_name'), function (Form\NestedForm $table) {
+                    $table->text('key')->required();
+                    $table->text('value')->required();
+                })->setView('admin.form_custom.hasmanytable')
+                ->saving(function ($input) {
+                    return json_encode($input);
+                });
                 $form->switch('enabled')->default(1);
+
             })->tab(admin_trans_label('cover'), function (Form $form) {
                 $form->multipleImage('cover')
                     ->retainable()//禁止删OSS图
@@ -252,7 +266,8 @@ JS
                         ->retainable()//禁止删OSS图
                         ->removable() // 可移除图片
                         ->autoUpload() // 自动上传
-                        ->uniqueName()
+                        ->uniqueName()//
+                        ->downloadable()
                         ->accept(config('admin.upload.oss_video.accept'))
                         ->maxSize(config('admin.upload.oss_video.max_size'))
                         ->dir(config("admin.upload.directory.video").'/uploads/'.date("Ymd"))
@@ -306,6 +321,7 @@ JS
                          ->removable() // 可移除图片
                          ->autoUpload() // 自动上传
                          ->uniqueName()
+                         ->downloadable()
                          ->accept(config('admin.upload.oss_pdf.accept'))
                          ->maxSize(config('admin.upload.oss_pdf.max_size'))
                          ->dir(config("admin.upload.directory.pdf").'/uploads/'.date("Ymd"))

+ 0 - 2
app/Exceptions/Form/TradFile.php

@@ -10,6 +10,4 @@ class TradFile extends File
 {
     protected $view = 'admin.form_custom.trad-file';
 
-
-
 }

+ 3 - 2
resources/views/admin/form_custom/hasmanytable.blade.php

@@ -2,11 +2,12 @@
     .table-has-many .input-group{flex-wrap: nowrap!important}
     .table-has-many  th{vertical-align: middle!important;}
     .table-has-many  td{vertical-align: middle!important;height: 102px;}
-    .table-has-many .remove{margin-bottom: 1.5rem}
+    .table-has-many .remove{margin-bottom: 0px;}
+    .table-has-many .fields-group .form-group .remove {margin-bottom: 0px;}
 </style>
 
 <div class="row form-group">
-    <div class="{{$viewClass['label']}} "><label class="control-label pull-right">{!! $label !!}</label></div>
+    <div class="{{$viewClass['label']}} control-label"><label class="control-label pull-right">{!! $label !!}</label></div>
     <div class="{{$viewClass['field']}}">
         @include('admin::form.error')