SFilterItem2.js 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. const n = `<template>
  2. <div
  3. class="filter-item"
  4. :class="{ 'is-full': props.full, 'is-default': isNormal }"
  5. :style="itemStyle"
  6. >
  7. <div
  8. class="label"
  9. :style="{
  10. width: props.labelWidth + 'px',
  11. maxWidth: props.labelWidth + 'px',
  12. minWidth: props.labelWidth + 'px'
  13. }"
  14. >
  15. {{ label }}{{ props.colon ? ':' : '' }}
  16. </div>
  17. <div class="value">
  18. <slot />
  19. </div>
  20. </div>
  21. </template>
  22. <script setup>
  23. import { computed, onMounted } from 'vue'
  24. const props = defineProps({
  25. // 标签文案(必填)
  26. label: {
  27. required: true,
  28. type: String
  29. },
  30. // 标签宽度,单位 px
  31. labelWidth: {
  32. type: Number,
  33. default: 70
  34. },
  35. // 标签后是否带冒号
  36. colon: {
  37. type: Boolean,
  38. default: false
  39. },
  40. // 表单项宽度,单位 px(full 为 true 时失效)
  41. width: {
  42. type: Number,
  43. default: 280
  44. },
  45. // 独占一行:父级 SFilterWrap 是 flex-wrap 容器,宽度拉满即整行
  46. full: {
  47. type: Boolean,
  48. default: false
  49. },
  50. // 底部外边距,单位 px
  51. mb: {
  52. type: Number,
  53. default: 0
  54. },
  55. // 默认描边样式;false 为无边框样式
  56. isNormal: {
  57. type: Boolean,
  58. default: true
  59. }
  60. })
  61. const itemStyle = computed(() => ({
  62. width: props.full ? '100%' : props.width + 'px',
  63. marginBottom: props.mb + 'px'
  64. }))
  65. onMounted(() => {})
  66. <\/script>
  67. <style lang="less" scoped>
  68. .filter-item {
  69. display: flex;
  70. justify-content: flex-start;
  71. align-items: center;
  72. &.is-full {
  73. flex: 1 1 100%;
  74. min-width: 0;
  75. }
  76. .label {
  77. height: 32px;
  78. display: flex;
  79. justify-content: flex-start;
  80. align-content: center;
  81. line-height: 1;
  82. display: flex;
  83. align-items: center;
  84. text-overflow: ellipsis;
  85. overflow: hidden;
  86. white-space: nowrap;
  87. word-break: break-all;
  88. // margin-right: 8px;
  89. }
  90. .value {
  91. flex: 1;
  92. overflow: hidden;
  93. :deep(.ant-select) {
  94. width: 100%;
  95. }
  96. }
  97. &.is-default {
  98. border: 1px solid var(--s-border-color-light);
  99. border-radius: 4px;
  100. .label {
  101. margin-right: 0;
  102. justify-content: center;
  103. color: var(--s-text-color-regular);
  104. background-color: var(--s-menu-bg);
  105. }
  106. .value {
  107. :deep(.ant-select) {
  108. border-radius: 0;
  109. }
  110. :deep(*) {
  111. background-color: transparent;
  112. border: none;
  113. outline: none;
  114. border-radius: 0;
  115. .ant-select-selector {
  116. background-color: transparent;
  117. border: none;
  118. outline: none;
  119. border-radius: 0;
  120. }
  121. }
  122. }
  123. }
  124. }
  125. </style>
  126. `;
  127. export {
  128. n as default
  129. };