9dfdf9bc52bc53b5bd5a31c025971e91.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php /*a:1:{s:64:"D:\phpstudy_pro\WWW\CRMEB\app\admin\view\public\form-builder.php";i:1595820902;}*/ ?>
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="UTF-8">
  6. <title><?=$form->getTitle()?></title>
  7. <script src="/static/plug/vue/dist/vue.min.js"></script>
  8. <link href="/static/plug/iview/dist/styles/iview.css" rel="stylesheet">
  9. <script src="/static/plug/iview/dist/iview.min.js"></script>
  10. <script src="/static/plug/jquery/jquery.min.js"></script>
  11. <script src="/static/plug/form-create/province_city.js"></script>
  12. <script src="/static/plug/form-create/province_city_area.js"></script>
  13. <script src="/static/plug/form-create/form-create.min.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. body{padding: 20px;}
  23. </style>
  24. </head>
  25. <body>
  26. <script>
  27. window.$f = null
  28. formCreate.formSuccess = function(form,$r){
  29. <?=$form->getSuccessScript()?>
  30. //刷新父级页面
  31. // parent.$(".J_iframe:visible")[0].contentWindow.location.reload();
  32. //关闭当前窗口
  33. // var index = parent.layer.getFrameIndex(window.name);
  34. // parent.layer.close(index);
  35. //提交成功后按钮恢复
  36. console.log($r);
  37. // $r.loading(false);
  38. };
  39. (function () {
  40. var create = (function () {
  41. var getRule = function () {
  42. var rule = <?=json_encode($form->getRules())?>;
  43. rule.forEach(function (c) {
  44. if ((c.type == 'cascader' || c.type == 'tree') && Object.prototype.toString.call(c.props.data) == '[object String]') {
  45. if (c.props.data.indexOf('js.') === 0) {
  46. c.props.data = window[c.props.data.replace('js.', '')];
  47. }
  48. }
  49. });
  50. return rule;
  51. }, vm = new Vue,name = 'formBuilderExec<?= !$form->getId() ? '' : '_'.$form->getId() ?>';
  52. var _b = false;
  53. window[name] = function create(el, callback) {
  54. if(_b) return ;
  55. _b = true;
  56. if (!el) el = document.body;
  57. $f = formCreate.create(getRule(), {
  58. el: el,
  59. form:<?=json_encode($form->getConfig('form'))?>,
  60. row:<?=json_encode($form->getConfig('row'))?>,
  61. submitBtn:<?=$form->isSubmitBtn() ? '{}' : 'false'?>,
  62. resetBtn:<?=$form->isResetBtn() ? 'true' : '{}'?>,
  63. iframeHelper:true,
  64. global:{
  65. upload: {
  66. props:{
  67. onExceededSize: function (file) {
  68. vm.$Message.error(file.name + '超出指定大小限制');
  69. },
  70. onFormatError: function () {
  71. vm.$Message.error(file.name + '格式验证失败');
  72. },
  73. onError: function (error) {
  74. vm.$Message.error(file.name + '上传失败,(' + error + ')');
  75. },
  76. onSuccess: function (res, file) {
  77. if (res.code == 200) {
  78. file.url = res.data.filePath;
  79. } else {
  80. vm.$Message.error(res.msg);
  81. }
  82. },
  83. },
  84. },
  85. },
  86. //表单提交事件
  87. onSubmit: function (formData) {
  88. $f.btn.loading(true);
  89. $.ajax({
  90. url: '<?=$form->getAction()?>',
  91. type: '<?=$form->getMethod()?>',
  92. dataType: 'json',
  93. data: formData,
  94. success: function (res) {
  95. if (res.code == 200) {
  96. vm.$Message.success(res.msg);
  97. $f.btn.loading(false);
  98. formCreate.formSuccess && formCreate.formSuccess(res, $f, formData);
  99. callback && callback(0, res, $f, formData);
  100. //TODO 表单提交成功!
  101. } else {
  102. vm.$Message.error(res.msg || '表单提交失败');
  103. $f.btn.loading(false);
  104. callback && callback(1, res, $f, formData);
  105. //TODO 表单提交失败
  106. }
  107. },
  108. error: function () {
  109. vm.$Message.error('表单提交失败');
  110. $f.btn.loading(false);
  111. }
  112. });
  113. }
  114. });
  115. return $f;
  116. };
  117. return window[name];
  118. }());
  119. window.$f = create();
  120. // create();
  121. })();
  122. </script>
  123. </body>
  124. </html>