SelectorCard.vue 6.1 KB

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