preview.php 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. use common\helpers\AddonHelper;
  4. if(AddonHelper::has('SmartForm')){
  5. ComponentHelper::loadComponentView('form-diy-model', AddonHelper::getAddonRootPath('SmartForm') . 'backend/views/components/formDiy');
  6. }
  7. ?>
  8. <template id="smart-form-preview">
  9. <div class="form_diy_model_box" :style="{background:activeItem.computedStyle.bodyBg ? activeItem.computedStyle.bodyBg :'#fff',
  10. paddingTop:activeItem.computedStyle.padTop ? activeItem.computedStyle.padTop+'px' : 0, paddingBottom:activeItem.computedStyle.padBot ? activeItem.computedStyle.padBot+'px' : 0,
  11. paddingLeft:activeItem.computedStyle.padLr ? activeItem.computedStyle.padLr+'px' : 0,
  12. paddingRight:activeItem.computedStyle.padLr ? activeItem.computedStyle.padLr+'px' : 0,}">
  13. <div class="form_diy_model_box_body"
  14. :style="{
  15. borderTopLeftRadius:activeItem.computedStyle.radiusTop ? activeItem.computedStyle.radiusTop+'px' : 0,
  16. borderTopRightRadius:activeItem.computedStyle.radiusTop ? activeItem.computedStyle.radiusTop+'px' : 0,
  17. borderBottomLeftRadius:activeItem.computedStyle.radiusBot ? activeItem.computedStyle.radiusBot+'px' : 0,
  18. borderBottomRightRadius:activeItem.computedStyle.radiusBot ? activeItem.computedStyle.radiusBot+'px' : 0,}">
  19. <form-diy-model :tool-list="list" :active-Item="activeItem"></form-diy-model>
  20. </div>
  21. <el-button class="form_mofrlsave_btn" :style="{background:btnBg}">{{btnTitle}}</el-button>
  22. </div>
  23. </template>
  24. <script>
  25. /**
  26. * @descriptions
  27. * 1. 组件名字必须对应模板形式 - 递归组件name
  28. * 2. 样式内容方法尽量内部维护 - 前端方便通用
  29. * 3. 父级组件会传预览数据 - activeItem
  30. */
  31. Vue.component('smart-form-preview', {
  32. name: "smart-form-preview",
  33. props: {
  34. activeItem: {
  35. type: Object,
  36. default () {
  37. return {}
  38. }
  39. }
  40. },
  41. computed:{
  42. list(){
  43. if(!this.activeItem.funcListItem.columns){
  44. return this.toolList
  45. }
  46. else{
  47. return this.activeItem.funcListItem.columns
  48. }
  49. },
  50. btnBg(){
  51. if(!this.activeItem.computedStyle.btnBg){
  52. return '#F10009'
  53. }
  54. else{
  55. return this.activeItem.computedStyle.btnBg
  56. }
  57. },
  58. btnTitle(){
  59. if(!this.activeItem.data.btnTitle){
  60. return '提交'
  61. }
  62. else{
  63. return this.activeItem.data.btnTitle
  64. }
  65. }
  66. },
  67. template: '#smart-form-preview',
  68. data() {
  69. return {
  70. toolList:[]
  71. }
  72. }
  73. });
  74. </script>
  75. <style>
  76. .form_diy_model_box{
  77. width: 100%;
  78. }
  79. .form_diy_model_box_body{
  80. width: 100%;
  81. overflow: hidden;
  82. }
  83. .form_mofrlsave_btn{
  84. width: 100%;
  85. height: 50px;
  86. line-height: 1.5;
  87. color: #fff;
  88. font-size: 12px;
  89. border-radius: 0;
  90. margin-top: 50px;
  91. }
  92. </style>