SelectorCard.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  1. <template>
  2. <div
  3. class="selector-card"
  4. :class="{
  5. 's-card': cardType === 'card',
  6. 's-line': cardType === 'line',
  7. }"
  8. >
  9. <div class="selector-card-header">
  10. <slot name="header"></slot>
  11. </div>
  12. <div class="selector-card-content scrollbar">
  13. <slot name="default"></slot>
  14. </div>
  15. <div class="selector-card-footer" v-if="cardType === 'card'">
  16. <slot name="footer">
  17. <el-button type="primary" class="confirm" @click="onConfirm">保存</el-button>
  18. <el-button class="cancel" @click="onCancel">取消</el-button>
  19. </slot>
  20. </div>
  21. </div>
  22. </template>
  23. <script>
  24. import { Button } from 'element-ui'
  25. export default {
  26. name: 'selector-card',
  27. components: {
  28. [Button.name]: Button
  29. },
  30. props: {
  31. cardType: {
  32. type: String,
  33. default: 'card'
  34. }
  35. },
  36. methods: {
  37. onCancel () {
  38. this.$emit('onCancel')
  39. },
  40. onConfirm () {
  41. this.$emit('onConfirm')
  42. }
  43. }
  44. }
  45. </script>
  46. <style lang="scss" scoped>
  47. .selector-card {
  48. display: flex;
  49. color: #1d1d1d;
  50. background-color: #fff;
  51. .selector-card-content {
  52. position: relative;
  53. display: flex;
  54. flex: 1;
  55. &::v-deep {
  56. // 子组件按钮公共样式
  57. .j-button-item {
  58. display: flex;
  59. align-items: center;
  60. margin: 6px 5px;
  61. padding: 2px 6px;
  62. line-height: 20px;
  63. border-radius: 4px;
  64. font-size: 14px;
  65. text-align: center;
  66. background-color: #fff;
  67. border: 1px solid rgba(0,0,0,.05);
  68. cursor: pointer;
  69. &.global { // s-card中的全部按钮使用
  70. padding: 6px 8px;
  71. height: 24px;
  72. line-height: 24px;
  73. font-weight: 700;
  74. color: inherit;
  75. border-color: rgba(0,0,0,.05);
  76. }
  77. &.all { // s-line中的全部按钮使用
  78. font-weight: 700;
  79. border-color: transparent;
  80. }
  81. &.hover:hover {
  82. color: #2abed1;
  83. }
  84. // 选中状态
  85. &.active { // 默认蓝色边框蓝色字体
  86. color: #2abed1;
  87. border-color: #2abed1;
  88. &.bgc { // 默认蓝色背景白色字体
  89. color: #fff;
  90. background-color: $color-text--highlight;
  91. }
  92. &.bgc-opacity { // 默认蓝色边框蓝色字体蓝色半透明背景
  93. background-color: rgba(44,183,202,0.10);
  94. }
  95. }
  96. }
  97. [class^=el-icon-] {
  98. transition: transform 0.2s ease;
  99. }
  100. .rotate180 {
  101. transform: rotate(180deg);
  102. }
  103. }
  104. }
  105. }
  106. .selector-card.s-card {
  107. width: 460px;
  108. height: 582px;
  109. flex-direction: column;
  110. align-items: center;
  111. justify-content: space-between;
  112. box-shadow: 0 0 28px rgb(0 0 0 / 16%);
  113. border-radius: 5px;
  114. .selector-card-header,
  115. .selector-card-content,
  116. .selector-card-footer {
  117. width: 100%;
  118. }
  119. .selector-card-header {
  120. padding-top: 30px;
  121. margin: 0 0 40px;
  122. font-size: 20px;
  123. line-height: 26px;
  124. text-align: center;
  125. background: linear-gradient(180deg,#e0e0e0, #fff);
  126. border-radius: 5px 5px 0 0;
  127. }
  128. .selector-card-content {
  129. align-items: center;
  130. overflow: hidden;
  131. }
  132. .selector-card-footer {
  133. display: flex;
  134. align-items: center;
  135. justify-content: center;
  136. padding-top: 20px;
  137. padding-bottom: 40px;
  138. ::v-deep {
  139. .el-button--primary {
  140. color: #2cb7ca;
  141. background: none;
  142. border-color: #2cb7ca;
  143. &:hover {
  144. color: #fff;
  145. background-color: #2cb7ca;
  146. }
  147. }
  148. .el-button--default {
  149. &:hover,
  150. &:active {
  151. color: #2cb7ca;
  152. border-color: #2cb7ca;
  153. }
  154. }
  155. }
  156. .confirm,
  157. .cancel {
  158. padding: 10px 50px;
  159. margin: 0 20px;
  160. }
  161. }
  162. &::v-deep {
  163. .j-button-item {
  164. color: #606266;
  165. }
  166. .search-container {
  167. margin: 20px auto;
  168. width: 360px;
  169. // 输入框公共样式
  170. .el-input__inner {
  171. padding-left: 42px;
  172. background-color: #f7f7f7;
  173. border-radius: 22px;
  174. }
  175. .el-input__prefix {
  176. display: flex;
  177. align-items: center;
  178. justify-content: center;
  179. }
  180. .el-icon-search {
  181. margin-left: 6px;
  182. font-size: 18px;
  183. }
  184. }
  185. // 子组件卡片布局样式
  186. .selector-content {
  187. display: flex;
  188. flex-direction: column;
  189. margin: 0 auto;
  190. width: 400px;
  191. height: 100%;
  192. border-radius: 5px;
  193. border: 1px solid rgba(0,0,0,.05);
  194. }
  195. // 搜索框下的列表
  196. .select-list {
  197. position: relative;
  198. flex: 1;
  199. overflow-y: scroll;
  200. }
  201. // indexBar样式
  202. .index-anchor {
  203. margin-top: 10px;
  204. padding: 0 20px;
  205. height: 30px;
  206. line-height: 30px;
  207. background-color: #f5f5fb;
  208. text-align: left;
  209. }
  210. }
  211. }
  212. .selector-card.s-line {
  213. padding: 12px 40px;
  214. .s-header {
  215. line-height: 36px;
  216. }
  217. .selector-card-header {
  218. margin-right: 10px;
  219. min-width: 100px;
  220. }
  221. .selector-content {
  222. position: relative;
  223. }
  224. ::v-deep{
  225. .j-button-item {
  226. border-color: transparent;
  227. }
  228. .action-button.show-more {
  229. display: flex;
  230. align-items: center;
  231. position: absolute;
  232. top: 8px;
  233. right: 0;
  234. font-size: 12px;
  235. line-height: 20px;
  236. color: #686868;
  237. cursor: pointer;
  238. .action-text {
  239. margin-right: 4px;
  240. }
  241. }
  242. }
  243. }
  244. </style>