| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169 |
- <template>
- <!--
- ss-search-button 搜索按钮组件
- 基于原JSP中的mobileSearch-button样式封装
- -->
- <button
- class="ss-search-button"
- :style="buttonStyle"
- @click="handleClick"
- :disabled="disabled"
- >
- <!-- 前置图标插槽 -->
- <view v-if="preIcon || $slots.preIcon" class="ss-search-button__pre-icon">
- <slot name="preIcon">
- <Icon v-if="preIcon" :name="preIcon" :size="iconSize" :color="iconColor" />
- </slot>
- </view>
- <!-- 按钮文本 -->
- <text class="ss-search-button__text">{{ text }}</text>
- <!-- 后置图标插槽 -->
- <view v-if="suffixIcon || $slots.suffixIcon" class="ss-search-button__suffix-icon">
- <slot name="suffixIcon">
- <Icon v-if="suffixIcon" :name="suffixIcon" :size="iconSize" :color="iconColor" />
- </slot>
- </view>
- </button>
- </template>
- <script setup>
- import { computed } from 'vue'
- import Icon from '@/components/icon/index.vue'
- const props = defineProps({
- // 按钮文本
- text: {
- type: String,
- default: '增加'
- },
- // 是否禁用
- disabled: {
- type: Boolean,
- default: false
- },
- // 按钮高度
- height: {
- type: [String, Number],
- default: '36px'
- },
- // 前置图标名称
- preIcon: {
- type: String,
- default: ''
- },
- // 后置图标名称
- suffixIcon: {
- type: String,
- default: ''
- },
- // 图标大小
- iconSize: {
- type: [String, Number],
- default: '32'
- },
- // 图标颜色
- iconColor: {
- type: String,
- default: '#585d6e'
- },
- // 自定义按钮样式
- customStyle: {
- type: Object,
- default: () => ({})
- },
- // 跳转链接(兼容原JSP用法)
- href: {
- type: String,
- default: ''
- }
- })
- const emit = defineEmits(['click'])
- // 按钮样式
- const buttonStyle = computed(() => ({
- height: typeof props.height === 'number' ? `${props.height}px` : props.height,
- ...props.customStyle
- }))
- const handleClick = () => {
- // 触发点击事件
- emit('click')
- }
- </script>
- <style lang="scss" scoped>
- .ss-search-button {
- height: auto;
- padding: 0 1rem;
- border: 1px solid #eceded;
- outline: none;
- background-color: #fff;
- text-align: center;
- font-size: 1rem;
- color: #585d6e;
- letter-spacing: 0.1rem;
- border-radius: 4px;
- display: flex;
- align-items: center;
- justify-content: center;
- -webkit-appearance: none;
- appearance: none;
- box-sizing: border-box;
- transition: all 0.2s ease;
- &:active {
- background-color: #eceded;
- color: #fff;
- border-color: #eceded;
- transform: scale(0.98);
- transition: all 0.1s ease;
- // active 状态下图标样式
- .ss-search-button__pre-icon,
- .ss-search-button__suffix-icon {
- :deep(.iconfont) {
- color: #fff !important;
- }
- :deep(text) {
- color: #fff !important;
- }
- }
- }
- &:disabled {
- opacity: 0.6;
- cursor: not-allowed;
- }
- &__pre-icon {
- margin-right: 0.3rem;
- display: flex;
- align-items: center;
- }
- &__suffix-icon {
- margin-left: 0.3rem;
- display: flex;
- align-items: center;
- }
- &__text {
- font-size: inherit;
- color: inherit;
- }
- }
- // 响应式适配
- @media screen and (max-width: 750px) {
- .ss-search-button {
- font-size: 14px;
- padding: 0 0.8rem;
- }
- }
- </style>
|