template.vue 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <template>
  2. <view
  3. class="padding_20rpx_30rpx position_relative"
  4. :class="[getLayout]"
  5. :style="'font-size:' + fontSize + 'rpx;width:' + width + ';'">
  6. <text
  7. class="marginRight5 text_nowrap padding_10rpx_15rpx"
  8. :class="[getTitleLayout, getWidthMode]"
  9. :style="'flex:' + (titleFlex||1) + ';' + 'color:' + (titleColor||'#999') + ';' + (titleStyle||'')"
  10. v-if="title&&!titleHide">
  11. <text
  12. class="fontColorF1505C"
  13. v-if="required">
  14. {{requiredSign || '*'}}
  15. </text>
  16. {{title}}
  17. </text>
  18. <view :class="itemDisabled?'pe_none': 'pe_auto'" :style="'flex:' + (contentFlex||4) + ';' + (contentStyle||'')">
  19. <slot></slot>
  20. </view>
  21. <view
  22. class="flex_row_c_c itemDisabled"
  23. :class="itemDisabled?'show': ''" />
  24. </view>
  25. </template>
  26. <script>
  27. export default {
  28. props: {
  29. title: {
  30. type: String,
  31. default: ''
  32. },
  33. titleHide: {
  34. type: Boolean,
  35. default: false
  36. },
  37. fontSize: {
  38. type: Number,
  39. default: 30
  40. },
  41. width: {
  42. type: String,
  43. default: '100%'
  44. },
  45. titleLayout: {
  46. type: String,
  47. default: 'default'
  48. },
  49. titleFlex: {
  50. type: Number,
  51. default: 1
  52. },
  53. contentFlex: {
  54. type: Number,
  55. default: 4
  56. },
  57. titleStyle: {
  58. type: String,
  59. default: ''
  60. },
  61. contentStyle: {
  62. type: String,
  63. default: ''
  64. },
  65. layout: {
  66. type: String,
  67. default: 'row'
  68. },
  69. required: {
  70. type: Boolean,
  71. default: false
  72. },
  73. requiredSign: {
  74. type: String,
  75. default: '*'
  76. },
  77. itemDisabled: {
  78. type: Boolean,
  79. default: false
  80. },
  81. titleColor: {
  82. type: String,
  83. default: '#999'
  84. }
  85. },
  86. computed: {
  87. getLayout() {
  88. if(this.layout === 'column') {
  89. return 'flex_column';
  90. }else {
  91. return 'flex_row';
  92. }
  93. },
  94. getTitleLayout() {
  95. switch (this.titleLayout){
  96. case 'left':
  97. return 'flex_row_none_c';
  98. break;
  99. case 'center':
  100. return 'flex_row_c_c';
  101. break;
  102. case 'right':
  103. return 'flex_row_e_c';
  104. break;
  105. default:
  106. if(this.layout === 'column') {
  107. return 'flex_row_none_c';
  108. }else{
  109. return 'flex_row_e_c';
  110. }
  111. break;
  112. }
  113. },
  114. getWidthMode() {
  115. if(this.layout === 'column') {
  116. return 'width100';
  117. }else{
  118. return 'maxWidth40';
  119. }
  120. }
  121. },
  122. methods: {
  123. voidFc() {}
  124. }
  125. }
  126. </script>
  127. <style scoped>
  128. @import url("../css/inputs.css");
  129. </style>