select.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. use common\helpers\Url;
  3. use yii\helpers\Html;
  4. ?>
  5. <div class="form-group required">
  6. <div class="rf-select-list" id="<?= $boxId; ?>">
  7. <div class="img-box" data-toggle="modal" data-target="#ajaxModalMax" href="<?= Url::to(['selector/list', 'boxId' => $boxId, 'media_type' => $type]) ?>">
  8. <?php if ($type == 'news' || $type == 'image') { ?>
  9. <?php if (!empty($model->media_url)) { ?>
  10. <?= Html::img(Url::to(['analysis/image', 'attach' => $model->media_url])) ?>
  11. <?php } else { ?>
  12. <?= Html::img('@baseResources/img/default-image-bg.png', ['style' => 'height:auto;padding-top:40px',
  13. ]) ?>
  14. <?php } ?>
  15. <?php } else { ?>
  16. <i class="fa fa-file" style="font-size: 35px;margin:0 auto;padding-top: 40px"></i>
  17. <?php } ?>
  18. <div class="bottomBar"><?= !empty($model->file_name) ? $model->file_name : '点击选择' ?></div>
  19. </div>
  20. <div class="hint-block"><?= $block ?></div>
  21. <?= Html::hiddenInput($name, $value) ?>
  22. </div>
  23. </div>
  24. <script>
  25. // 选择回调
  26. var boxId = "<?= $boxId; ?>";
  27. $(document).on('select-file-' + boxId, function (e, boxId, data) {
  28. if (data.length === 0) {
  29. return;
  30. }
  31. var dataFirst = data[0];
  32. if (dataFirst.type == 'image') {
  33. $('#' + boxId).find('img').attr('src', dataFirst.url);
  34. $('#' + boxId).find('img').attr('style', '');
  35. }
  36. $('#' + boxId).find('input').attr('value', dataFirst.key);
  37. $('#' + boxId).find('.bottomBar').text(dataFirst.title);
  38. });
  39. </script>
粤ICP备19079148号