edit-all.php 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. use common\helpers\Url;
  3. use common\helpers\Html;
  4. use yii\bootstrap4\ActiveForm;
  5. use common\helpers\StringHelper;
  6. $this->title = '网站设置';
  7. $this->params['breadcrumbs'][] = ['label' => $this->title];
  8. ?>
  9. <div class="row">
  10. <div class="col-2 col-sm-2" style="padding-right: 0">
  11. <div class="nav flex-column nav-tabs h-100" role="tablist" aria-orientation="vertical">
  12. <?php foreach ($cates as $k => $cate) { ?>
  13. <a
  14. class="nav-link <?php if ($k == 0){ ?>active<?php } ?>"
  15. data-toggle="pill"
  16. href="#vert-tabs-<?= $cate['id'] ?>"
  17. role="tab"
  18. aria-selected="false">
  19. <?= Html::encode($cate['title']); ?>
  20. </a>
  21. <?php } ?>
  22. </div>
  23. </div>
  24. <div class="col-7 col-sm-7" style="padding-left: 0">
  25. <div class="tab-content p-3" id="vert-tabs-tabContent">
  26. <?php foreach ($cates as $k => $cate) { ?>
  27. <div class="tab-pane fade <?php if ($k == 0) { ?>active show<?php } ?>"
  28. id="vert-tabs-<?= $cate['id'] ?>"
  29. role="tabpanel"
  30. >
  31. <?php $form = ActiveForm::begin([
  32. 'id' => 'form-tab-' . $cate['id']
  33. ]); ?>
  34. <?php foreach ($cate['-'] as $item) { ?>
  35. <h2 style="font-size: 18px;padding-top: 0;margin-top: 0">
  36. <i class="icon iconfont iconshangquan"></i>
  37. <?= $item['title'] ?>
  38. </h2>
  39. <div class="col-sm-12" style="padding-left: 18px;">
  40. <?php foreach ($item['config'] as $row) { ?>
  41. <?= $this->render($row['type'], [
  42. 'row' => $row,
  43. 'option' => StringHelper::parseAttr($row['extra']),
  44. ]) ?>
  45. <?php } ?>
  46. </div>
  47. <?php } ?>
  48. <div class="form-group">
  49. <div class="col-sm-12 text-center">
  50. <span type="submit" class="btn btn-primary" onclick="present(<?= $cate['id'] ?>)">保存</span>
  51. </div>
  52. </div>
  53. <?php ActiveForm::end(); ?>
  54. </div>
  55. <?php } ?>
  56. </div>
  57. </div>
  58. <div class="col-3 col-sm-3" id="explain">
  59. <div class="box">
  60. <div class="box-body">
  61. <h4>说明:</h4>
  62. <h6>单击标题名称获取配置标识</h6>
  63. <div class="hr-line-dashed"></div>
  64. <h5 class="tag-title"></h5>
  65. <?= Html::input('text', 'demo', '', ['class' => 'form-control', 'id' => 'demo', 'readonly' => 'readonly']); ?>
  66. <div class="hr-line-dashed"></div>
  67. <div class="clearfix">当前显示 : <span id="demo-title">无</span></div>
  68. </div>
  69. </div>
  70. </div>
  71. </div>
  72. <script type="text/javascript">
  73. $(document).ready(function () {
  74. if ($(this).width() < 769 || config.isMobile == true) {
  75. $("#explain").addClass('hide');
  76. return;
  77. }
  78. // 当前高度
  79. $(window).scroll(function () {
  80. let offsetTop = $(window).scrollTop() - 40 + "px";
  81. $("#explain").animate({'padding-top': offsetTop}, {duration: 600, queue: false});
  82. if ($(window).scrollTop() < 60) {
  83. $("#explain").animate({'padding-top': 0}, {duration: 600, queue: false});
  84. }
  85. });
  86. });
  87. $(window).resize(function () {
  88. if ($(this).width() < 769 || config.isMobile == true) {
  89. $("#explain").addClass('hide');
  90. } else {
  91. $("#explain").removeClass('hide');
  92. }
  93. });
  94. // 单击
  95. $('.demo').click(function () {
  96. $('#demo').val($(this).attr('for'));
  97. $('#demo-title').text($(this).text());
  98. });
  99. function present(obj) {
  100. // 获取表单内信息
  101. let values = $("#form-tab-" + obj).serializeObject();
  102. $.ajax({
  103. type: "post",
  104. url: "<?= Url::to(['update-info'])?>",
  105. dataType: "json",
  106. data: values,
  107. success: function (data) {
  108. if (data.code === 200) {
  109. rfAffirm(data.message);
  110. } else {
  111. rfAffirm(data.message);
  112. }
  113. }
  114. });
  115. }
  116. $.fn.serializeObject = function () {
  117. var o = {};
  118. var a = this.serializeArray();
  119. $.each(a, function () {
  120. if (o[this.name] !== undefined) {
  121. if (!o[this.name].push) {
  122. o[this.name] = [o[this.name]];
  123. }
  124. o[this.name].push(this.value || '');
  125. } else {
  126. o[this.name] = this.value || '';
  127. }
  128. });
  129. var $radio = $('input[type=radio],input[type=checkbox]',this);
  130. $.each($radio,function(){
  131. if(!o.hasOwnProperty(this.name)){
  132. o[this.name] = '';
  133. }
  134. });
  135. return o;
  136. };
  137. </script>
粤ICP备19079148号