create.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title><?=$form->getTitle()?></title>
  6. <script src="{__PLUG_PATH}vue/dist/vue.min.js"></script>
  7. <link href="{__PLUG_PATH}iview/dist/styles/iview.css" rel="stylesheet">
  8. <script src="{__PLUG_PATH}iview/dist/iview.min.js"></script>
  9. <script src="{__PLUG_PATH}jquery/jquery.min.js"></script>
  10. <script src="{__PLUG_PATH}form-create/province_city.js"></script>
  11. <script src="{__PLUG_PATH}form-create/form-create.min.js"></script>
  12. <link href="{__PLUG_PATH}layui/css/layui.css" rel="stylesheet">
  13. <script src="{__PLUG_PATH}layui/layui.all.js"></script>
  14. <style>
  15. /*弹框样式修改*/
  16. .ivu-modal{top: 20px;}
  17. .ivu-modal .ivu-modal-body{padding: 10px;}
  18. .ivu-modal .ivu-modal-body .ivu-modal-confirm-head{padding:0 0 10px 0;}
  19. .ivu-modal .ivu-modal-body .ivu-modal-confirm-footer{display: none;padding-bottom: 10px;}
  20. .ivu-date-picker {display: inline-block;line-height: normal;width: 280px;}
  21. .ivu-modal-footer{display: none;}
  22. .coupon_form .ivu-input-number{width: 150px; !important;}
  23. </style>
  24. </head>
  25. <body>
  26. <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
  27. <ul class="layui-tab-title">
  28. <li {if condition="$get['type'] eq 0"}class="layui-this"{/if}><a href="{:Url('create',array('tab_id'=>$Request.param.tab_id,'type'=>0))}">通用券</a> </li>
  29. <li {if condition="$get['type'] eq 1"}class="layui-this"{/if}><a href="{:Url('create',array('tab_id'=>$Request.param.tab_id,'type'=>1))}">品类券</a> </li>
  30. <li {if condition="$get['type'] eq 2"}class="layui-this"{/if}><a href="{:Url('create',array('tab_id'=>$Request.param.tab_id,'type'=>2))}">商品券</a></li>
  31. </ul>
  32. <div class="layui-tab-content" style="height: 100px;">
  33. <div class="layui-tab-item layui-show coupon_form" id="formdiv">
  34. </div>
  35. </div>
  36. </div>
  37. <script>
  38. // formCreate.formSuccess = function(form,$r){
  39. // <?//=$form->getSuccessScript()?>
  40. // $f.btn.loading(false)();
  41. // };
  42. window.$f = null;
  43. (function () {
  44. var create = (function () {
  45. var getRule = function () {
  46. var rule = <?=json_encode($form->getRules())?>;
  47. rule.forEach(function (c) {
  48. if ((c.type == 'cascader' || c.type == 'tree') && Object.prototype.toString.call(c.props.data) == '[object String]') {
  49. if (c.props.data.indexOf('js.') === 0) {
  50. c.props.data = window[c.props.data.replace('js.', '')];
  51. }
  52. }
  53. });
  54. return rule;
  55. }, vm = new Vue,name = 'formBuilderExec<?= !$form->getId() ? '' : '_'.$form->getId() ?>';
  56. var _b = false;
  57. window[name] = function create(el, callback) {
  58. if(_b) return ;
  59. _b = true;
  60. if (!el) el = document.getElementById('formdiv');
  61. window.$f = formCreate.create(getRule(), {
  62. el: el,
  63. form:<?=json_encode($form->getConfig('form'))?>,
  64. row:<?=json_encode($form->getConfig('row'))?>,
  65. submitBtn:<?=$form->isSubmitBtn() ? '{}' : 'false'?>,
  66. resetBtn:<?=$form->isResetBtn() ? 'true' : '{}'?>,
  67. iframeHelper:true,
  68. global:{
  69. upload: {
  70. props:{
  71. onExceededSize: function (file) {
  72. vm.$Message.error(file.name + '超出指定大小限制');
  73. },
  74. onFormatError: function () {
  75. vm.$Message.error(file.name + '格式验证失败');
  76. },
  77. onError: function (error) {
  78. vm.$Message.error(file.name + '上传失败,(' + error + ')');
  79. },
  80. onSuccess: function (res, file) {
  81. if (res.code == 200) {
  82. file.url = res.data.filePath;
  83. } else {
  84. vm.$Message.error(res.msg);
  85. }
  86. },
  87. },
  88. },
  89. },
  90. //表单提交事件
  91. onSubmit: function (formData) {
  92. $f.btn.loading(true);
  93. $.ajax({
  94. url: '<?=$form->getAction()?>',
  95. type: '<?=$form->getMethod()?>',
  96. dataType: 'json',
  97. data: formData,
  98. success: function (res) {
  99. if (res.code == 200) {
  100. vm.$Message.success(res.msg);
  101. $f.btn.loading(false);
  102. formCreate.formSuccess && formCreate.formSuccess(res, $f, formData);
  103. callback && callback(0, res, $f, formData);
  104. parent.layer.close(parent.layer.getFrameIndex(window.name));
  105. //TODO 表单提交成功!
  106. } else {
  107. vm.$Message.error(res.msg || '表单提交失败');
  108. $f.btn.loading(false);
  109. callback && callback(1, res, $f, formData);
  110. //TODO 表单提交失败
  111. }
  112. },
  113. error: function () {
  114. vm.$Mesclsage.error('表单提交失败');
  115. $f.btn.loading(false);
  116. }
  117. });
  118. }
  119. });
  120. return $f;
  121. };
  122. return window[name];
  123. }());
  124. create();
  125. })();
  126. </script>
  127. </body>
  128. </html>