CzrButton.vue 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <template>
  2. <div style="display: flex; align-items: center">
  3. <template v-if="type == 'table'">
  4. <div class="czr-button-table __hover">{{ title }}</div>
  5. </template>
  6. <template v-else-if="type == 'table-del'">
  7. <div class="czr-button-table _del __hover">{{ title || '删除' }}</div>
  8. </template>
  9. <template v-else-if="type == 'export'">
  10. <div class="czr-button __hover">
  11. <SvgIcon name="czr_export" color="var(--czr-main-color)" />{{
  12. title || '导出'
  13. }}
  14. </div>
  15. </template>
  16. <template v-else-if="type == 'add'">
  17. <div class="czr-button _add __hover">
  18. <SvgIcon name="czr_add2" color="#fffff" />{{ title || '新增' }}
  19. </div>
  20. </template>
  21. <template v-else-if="type == 'del'">
  22. <div class="czr-button __hover del">
  23. <SvgIcon :name="icon || 'czr_del'" color="var(--czr-error-color)" />{{
  24. title || '删除'
  25. }}
  26. </div>
  27. </template>
  28. <template v-else-if="type == 'primary'">
  29. <div class="czr-button __hover primary">
  30. <SvgIcon
  31. v-if="icon"
  32. :name="icon"
  33. color="#ffffff"
  34. :rotate="rotate"
  35. :size="size"
  36. />
  37. {{ title }}
  38. </div>
  39. </template>
  40. <template v-else-if="type == 'normal'">
  41. <div class="czr-button __hover normal">
  42. <SvgIcon
  43. v-if="icon"
  44. :name="icon"
  45. color="var(--czr-main-color)"
  46. :rotate="rotate"
  47. :size="size"
  48. />
  49. {{ title }}
  50. </div>
  51. </template>
  52. <template v-else>
  53. <div class="czr-button __hover">
  54. <SvgIcon v-if="icon" :name="icon" :rotate="rotate" />{{ title }}
  55. </div>
  56. </template>
  57. </div>
  58. </template>
  59. <script setup lang="ts">
  60. defineOptions({
  61. name: 'CzrButton',
  62. })
  63. const props = defineProps({
  64. type: {},
  65. title: {},
  66. icon: {},
  67. rotate: { default: 0 },
  68. size: { default: 12 },
  69. })
  70. </script>
  71. <style lang="scss" scoped>
  72. .czr-button {
  73. width: fit-content;
  74. height: 2rem;
  75. background: #ffffff;
  76. border-radius: 0.25rem;
  77. display: flex;
  78. align-items: center;
  79. justify-content: center;
  80. padding: 0 1rem;
  81. border: 0.06rem solid #c0c4cc;
  82. font-weight: 400;
  83. font-size: 0.88rem;
  84. color: #606266;
  85. line-height: 1;
  86. word-break: keep-all;
  87. .svg-icon {
  88. margin-right: 6px;
  89. }
  90. &.del {
  91. background: rgba(var(--czr-error-color-rgb), 0.1);
  92. border-color: rgba(var(--czr-error-color-rgb), 1);
  93. color: var(--czr-error-color);
  94. }
  95. &._add {
  96. color: #ffffff;
  97. background-color: var(--czr-main-color);
  98. border-color: var(--czr-main-color);
  99. }
  100. &.primary {
  101. background: var(--czr-main-color);
  102. border-color: var(--czr-main-color);
  103. color: #ffffff;
  104. }
  105. &.normal {
  106. background: #ffffff;
  107. border-color: var(--czr-main-color);
  108. color: var(--czr-main-color);
  109. }
  110. }
  111. .czr-button-table {
  112. font-weight: 400;
  113. font-size: 14px;
  114. color: var(--czr-main-color);
  115. &._del {
  116. color: var(--czr-error-color);
  117. }
  118. }
  119. </style>