edit.php 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. use yii\widgets\ActiveForm;
  3. use common\helpers\Url;
  4. use common\enums\StatusEnum;
  5. $this->title = $model->isNewRecord ? '创建' : '编辑';
  6. $this->params['breadcrumbs'][] = ['label' => '角色管理', 'url' => ['index', 'merchant_id' => $merchant_id]];
  7. $this->params['breadcrumbs'][] = ['label' => $this->title];
  8. ?>
  9. <div class="row">
  10. <div class="col-12">
  11. <div class="box">
  12. <div class="box-header with-border">
  13. <h3 class="box-title">基本信息</h3>
  14. </div>
  15. <?php $form = ActiveForm::begin([
  16. 'fieldConfig' => [
  17. 'template' => "<div class='row'><div class='col-sm-2 text-right'>{label}</div><div class='col-sm-10'>{input}\n{hint}\n{error}</div></div>",
  18. ]
  19. ]); ?>
  20. <div class="box-body">
  21. <?= $form->field($model, 'pid')->dropDownList($dropDownList) ?>
  22. <?= $form->field($model, 'title')->textInput(); ?>
  23. <?= $form->field($model, 'sort')->textInput(); ?>
  24. <?= $form->field($model, 'status')->radioList(StatusEnum::getMap()); ?>
  25. <div class="row">
  26. <div class="col-2 col-sm-2"></div>
  27. <div class="col-5 col-sm-5">
  28. <?= \common\widgets\jstree\JsTreeCheckBox::widget([
  29. 'name' => "userTree",
  30. 'defaultData' => $defaultFormAuth,
  31. 'selectIds' => $defaultCheckIds,
  32. ]) ?>
  33. </div>
  34. <div class="col-5 col-sm-5">
  35. <?= \common\widgets\jstree\JsTreeCheckBox::widget([
  36. 'name' => "plugTree",
  37. 'defaultData' => $addonsFormAuth,
  38. 'selectIds' => $addonsCheckIds,
  39. ]) ?>
  40. </div>
  41. </div>
  42. </div>
  43. <!-- /.box-body -->
  44. <div class="box-footer">
  45. <div class="col-12 col-sm-12 text-center">
  46. <button class="btn btn-primary" type="button" onclick="submitForm()">保存</button>
  47. <span class="btn btn-white" onclick="history.go(-1)">返回</span>
  48. </div>
  49. </div>
  50. <?php ActiveForm::end(); ?>
  51. </div>
  52. </div>
  53. </div>
  54. <script>
  55. // 提交表单
  56. function submitForm() {
  57. var userTreeIds = getCheckTreeIds("userTree");
  58. var plugTreeIds = getCheckTreeIds("plugTree");
  59. rfAffirm('保存中...');
  60. $.ajax({
  61. type: "post",
  62. url: "<?= Url::to(['edit', 'id' => $model->id, 'pid' => $model->pid, 'merchant_id' => $merchant_id])?>",
  63. dataType: "json",
  64. data: {
  65. id: '<?= $model['id']?>',
  66. pid: $("#authrole-pid").val(),
  67. sort: $("#authrole-sort").val(),
  68. status: $("input[name='AuthRole[status]']:checked").val(),
  69. title: $("#authrole-title").val(),
  70. userTreeIds: userTreeIds,
  71. plugTreeIds: plugTreeIds
  72. },
  73. success: function (data) {
  74. if (parseInt(data.code) === 200) {
  75. window.location = "<?= Url::to(['index', 'merchant_id' => $merchant_id])?>";
  76. } else {
  77. rfError(data.message);
  78. }
  79. }
  80. });
  81. }
  82. </script>
粤ICP备19079148号