From: marina Date: Tue, 27 May 2025 06:42:56 +0000 (+0300) Subject: ERP-417 X-Git-Url: https://gitweb.erp-flowers.ru/?a=commitdiff_plain;h=41f24988347f631012498f8918fe291fe935f4cd;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 8ca58128..d0baaebf 100644 --- a/erp24/views/write_offs_erp/_form.php +++ b/erp24/views/write_offs_erp/_form.php @@ -246,68 +246,44 @@ JS 'name' => 'videoFiles', 'title' => 'Видео: mp4, mov, avi', 'type' => FileInput::class, - 'value' => function ($row) { - if (!isset($row['id'])) return null; - - $file = Files::findOne([ - 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, - 'entity_id' => $row['id'], - ]); - - return $file ? $file->url : null; - }, - 'columnOptions' => function ($rowModel, $index, $context) { - $file = null; - $initialPreviewConfig = []; - - if (isset($rowModel['id'])) { - $file = Files::findOne([ - 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, - 'entity_id' => $rowModel['id'], - ]); - - if ($file) { - $initialPreviewConfig = [[ - 'caption' => basename($file->url), - 'url' => \yii\helpers\Url::to(['delete-video', 'id' => $rowModel['id']]), - ]]; - } - } - - return [ - 'attribute' => 'videoFiles', - 'options' => [ - 'multiple' => false, - 'accept' => 'video/*', - 'name' => 'video_name', - 'class' => 'file', - ], - 'pluginOptions' => [ - 'showPreview' => false, // отключаем превью видео - 'showCaption' => true, // показываем название файла - 'showRemove' => true, - 'showUpload' => true, - 'initialPreview' => [], // без превью - 'initialPreviewAsData' => false, // без превью как данные - 'initialPreviewConfig' => $initialPreviewConfig, - 'browseLabel' => '+', - 'removeLabel' => '-', - 'cancelLabel' => 'x', - 'layoutTemplates' => [ - 'actions' => '
{remove} {upload} {cancel}
', - 'actionUpload' => '', - 'actionRemove' => '', - 'actionCancel' => '', - ], - 'fileActionSettings' => [ - 'showUpload' => true, - 'showRemove' => true, - 'showZoom' => false, - 'showDrag' => false, - ], - ], - ]; - }, + 'options' => [ + 'options' => [ + 'multiple' => false, + 'accept' => 'video/*', + 'name' => 'video_name', + ], + 'pluginOptions' => [ + 'showPreview' => true, + 'showCaption' => true, + 'showRemove' => true, + 'showUpload' => false, + 'previewFileType' => 'video', + 'allowedFileExtensions' => ['mp4', 'mov', 'avi'], + 'initialPreview' => isset($model->id) ? [ // или $row['id'], если это в цикле + Files::find() + ->select('url') + ->where([ + 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, + 'entity_id' => $model->id // или $row['id'] + ]) + ->scalar() + ] : [], + 'initialPreviewAsData' => true, + 'initialPreviewConfig' => isset($model->id) ? [[ + 'type' => 'video', + 'caption' => basename( + Files::find() + ->select('url') + ->where([ + 'entity' => WriteOffsProductsErp::WRITE_OFFS_VIDEO, + 'entity_id' => $model->id + ]) + ->scalar() + ), + 'url' => Url::to(['delete-video', 'id' => $model->id]), + ]] : [], + ] + ] ], [ 'name' => 'comment',