From: marina Date: Mon, 26 May 2025 09:37:18 +0000 (+0300) Subject: ERP-417 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=e6576ba207622371d4858259739cf0700325c226;p=erp24_rep%2Fyii-erp24%2F.git ERP-417 --- diff --git a/erp24/views/write_offs_erp/_form.php b/erp24/views/write_offs_erp/_form.php index 4f21d663..1aa13999 100644 --- a/erp24/views/write_offs_erp/_form.php +++ b/erp24/views/write_offs_erp/_form.php @@ -186,22 +186,24 @@ JS 'capture' => '', 'class' => 'file', 'required' => true, - ], + ], 'pluginOptions' => [ -// 'previewFileType' => ['jpg','png'], -// 'allowedFileExtensions'=>['jpg','png'], - 'showPreview' => false, - 'showCaption' => true, - 'showRemove' => true, - 'showUpload' => false, - //'uploadClass' => 'hide', -// 'initialPreview'=> $initalImages, - 'overwriteInitial' => true, - -// 'initialPreviewAsData'=>true, - //initialPreviewAsData: false, -// 'bsColCssPrefixes'=>3, - // 'uploadUrl' => Url::to(['/site/image-manager-upload']), + 'showPreview' => true, + 'showCaption' => true, // ✅ Должно быть true + 'initialCaption' => '55656', + 'initialPreview' => '809', +// 'initialPreviewConfig' => function($data) { +// if (!$data || !isset($data['id'])) return []; +// $file = Files::findOne([ +// 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, +// 'entity_id' => $data['id'] +// ]); +// return $file ? [[ +// 'caption' => basename($file->url), // ✅ Обязательно! +// 'type' => 'video', +// 'size' => @filesize(Yii::getAlias('@webroot') . $file->url), +// ]] : []; +// }, 'browseIcon' => '+', 'cancelIcon' => 'x', 'removeIcon' => '-', @@ -257,25 +259,50 @@ JS ] ], [ - 'name' => 'video', - 'title' => 'Видео', - 'type' => 'fileInput', - 'options' => [ - 'options' => [ - 'accept' => 'video/*', - 'multiple' => false, - ], - ], + 'name' => 'videoFiles', + 'title' => 'Видео: mp4, mov, avi', + 'type' => FileInput::className(), 'value' => function ($data) { - if (empty($data['id'])) return null; + if (!$data || !isset($data['id'])) return null; $file = Files::findOne([ 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, 'entity_id' => $data['id'] ]); - return $file ? basename($file->url) : null; - } + if (!$file) return null; + + $initialPreview = [$file->url]; + $initialPreviewConfig = [[ + 'type' => 'video', + 'caption' => basename($file->url), + 'url' => Url::to(['delete-video', 'id' => $data['id']]) + ]]; + + return [ + 'caption' => basename($file->url), + 'url' => $file->url, + 'initialPreview' => $initialPreview, + 'initialPreviewConfig' => $initialPreviewConfig + ]; + }, + 'options' => [ + 'options' => [ + 'multiple' => false, + 'accept' => 'video/*', + 'name' => 'video_name' + ], + 'pluginOptions' => [ + 'showPreview' => true, + 'showCaption' => true, + 'showRemove' => true, + 'showUpload' => true, + 'previewFileType' => 'video', + 'allowedFileTypes' => ['video'], + 'allowedFileExtensions' => ['mp4', 'mov', 'avi'], + 'maxFileSize' => 10240, + ], + ], ], [ 'name' => 'comment', @@ -283,7 +310,6 @@ JS 'title' => 'Комментарий', ], - ], 'addButtonPosition' => MultipleInput::POS_FOOTER, // show add button in the header ])->label(false); ?>