Files
FiDA_Front/src/views/home/components/Input.vue

392 lines
9.3 KiB
Vue
Raw Normal View History

2026-02-03 13:15:39 +08:00
<template>
<div class="assist-input-wrapper flex flex-col">
2026-02-03 14:51:43 +08:00
<textarea
class="input"
type="text"
v-model="inputValue"
:placeholder="$t('Input.placeholder')"
/>
2026-02-03 13:15:39 +08:00
<div class="operate flex align-center">
<div class="attach flex flex-center">
<img src="@/assets/icons/attach.svg" alt="" />
</div>
2026-02-03 15:46:05 +08:00
<el-select v-model="typeValue" :placeholder="$t('Input.typePlaceholder')">
2026-02-03 13:15:39 +08:00
<el-option
v-for="item in typeOptions"
2026-02-03 14:51:43 +08:00
class="input-option"
2026-02-03 13:15:39 +08:00
:key="item.value"
2026-02-03 14:51:43 +08:00
:label="$t(item.label)"
:value="item.value"
/>
</el-select>
2026-02-03 15:46:05 +08:00
<el-select v-model="areaValue" :placeholder="$t('Input.areaPlaceholder')">
2026-02-03 14:51:43 +08:00
<el-option
v-for="item in areaOptions"
class="input-option"
:key="item.value"
:label="$t(item.label)"
:value="item.value"
/>
</el-select>
2026-02-03 15:46:05 +08:00
<div class="fida-style-select-wrapper">
<el-select
v-model="styleValue"
:placeholder="$t('Input.stylePlaceholder')"
@focus="openStylePopup"
2026-02-03 13:15:39 +08:00
/>
2026-02-03 15:46:05 +08:00
<el-popover
v-model:visible="stylePopupVisible"
2026-02-04 15:08:52 +08:00
placement="top"
2026-02-03 15:46:05 +08:00
:width="342"
:show-arrow="false"
trigger="click"
popper-class="fida-style-select-popover"
>
<template #reference>
<div class="fida-style-select-trigger"></div>
</template>
2026-02-04 15:08:52 +08:00
<div class="fida-style-popover-content flex flex-col">
2026-02-03 15:46:05 +08:00
<div class="fida-style-popover-header">{{ $t('Input.chooseStyle') }}</div>
<div class="fida-style-popover-grid">
<div
v-for="item in styleOptions"
:key="item.value"
class="fida-style-popover-item"
:class="{ 'is-selected': tempSelectedValue === item.value }"
@click="selectStyle(item.value)"
>
<span class="fida-option-label">{{ $t(item.label) }}</span>
</div>
</div>
2026-02-04 15:08:52 +08:00
<div class="fida-style-popover-footer flex flex-center">
2026-02-03 15:46:05 +08:00
<button class="fida-confirm-btn" @click="confirmStyle">
{{ $t('Input.confirm') }}
</button>
</div>
</div>
</el-popover>
</div>
2026-02-04 15:08:52 +08:00
<el-popover
v-model:visible="settingPopupVisible"
placement="top"
:width="342"
:show-arrow="false"
trigger="click"
popper-class="fida-setting-popover"
>
<template #reference>
<img src="@/assets/images/setting.png" class="setting-icon" />
</template>
<div class="fida-setting-popover-content flex flex-col">
<div class="fida-setting-popover-header">{{ $t('Input.setting') }}</div>
<div class="fida-setting-slider-list">
<div v-for="item in settingOptions" :key="item.label" class="fida-setting-slider-item">
<div class="fida-slider-label">{{ $t(item.label) }}</div>
<div class="fida-slider-row flex align-center">
<el-slider v-model="item.value" :show-tooltip="false" />
<span class="fida-slider-value">{{ item.value }}%</span>
</div>
</div>
</div>
</div>
</el-popover>
2026-02-03 13:15:39 +08:00
</div>
</div>
</template>
<script setup lang="ts">
import { computed, ref } from 'vue'
2026-02-03 14:51:43 +08:00
import { areaList } from '@/utils/area'
2026-02-03 15:46:05 +08:00
const styleKeys: string[] = [
'Coastal',
'Verdant',
'Traditional',
'CenturyChrome',
'ModernRevival',
'Tuscan2000s',
'Bauhaus',
'Constructivism',
'NordicNoir'
]
2026-02-03 13:15:39 +08:00
const inputValue = ref<string>('')
const typeValue = ref<string>('')
2026-02-03 14:51:43 +08:00
const areaValue = ref<string>('')
const styleValue = ref<string>('')
2026-02-03 15:46:05 +08:00
const tempSelectedValue = ref<string>('')
const stylePopupVisible = ref(false)
2026-02-04 15:08:52 +08:00
const settingPopupVisible = ref(false)
const settingOptions = ref([
{ label: 'Input.settingOptions.creativity', value: 50 },
{ label: 'Input.settingOptions.diversity', value: 75 },
{ label: 'Input.settingOptions.relevance', value: 60 }
])
2026-02-03 15:46:05 +08:00
const openStylePopup = () => {
// 打开弹窗时初始化临时选中值为当前选中值
tempSelectedValue.value = styleValue.value
stylePopupVisible.value = true
}
const selectStyle = (value: string) => {
tempSelectedValue.value = value
}
const confirmStyle = () => {
// 点击确认后才真正赋值
styleValue.value = tempSelectedValue.value
stylePopupVisible.value = false
}
2026-02-04 15:08:52 +08:00
const confirmSetting = () => {
settingPopupVisible.value = false
}
2026-02-03 13:15:39 +08:00
const typeOptions = ref<any[]>([
{
2026-02-03 14:51:43 +08:00
label: 'Input.types.sofa',
2026-02-03 13:15:39 +08:00
value: 'Sofa'
},
{
2026-02-03 14:51:43 +08:00
label: 'Input.types.desk',
2026-02-03 13:15:39 +08:00
value: 'Desk'
},
{
2026-02-03 14:51:43 +08:00
label: 'Input.types.chair',
2026-02-03 13:15:39 +08:00
value: 'Chair'
}
])
2026-02-03 14:51:43 +08:00
const areaOptions = ref<any[]>(areaList)
2026-02-03 15:46:05 +08:00
const styleOptions = ref<any[]>(
styleKeys.map((key) => ({
label: `Input.styles.${key}`,
value: key
}))
)
2026-02-03 13:15:39 +08:00
</script>
<style lang="less" scoped>
.assist-input-wrapper {
height: 23.5rem;
width: 106.3rem;
border-radius: 2.8rem;
background-color: #fff;
border: 0.1rem solid #00000005;
box-shadow: 0px 5px 14px 0px #0000001a;
margin: 0 auto;
padding: 3.4rem 1.7rem 1.7rem 2rem;
.input {
flex: 1;
border: none;
outline: none;
padding: 0 1.4rem;
font-size: 2rem;
font-family: 'InterRegular';
font-weight: 400;
color: #000000;
resize: none;
}
.operate {
column-gap: 2rem;
.attach {
width: 4rem;
height: 4rem;
border: 1px solid rgba(0, 0, 0, 0.1);
border-radius: 50%;
}
.el-select {
width: 13.9rem;
height: 4rem;
:deep(.el-select__wrapper) {
border-radius: 0.8rem;
height: 100%;
box-shadow: none;
border: 0.1rem solid rgba(0, 0, 0, 0.1);
2026-02-03 14:51:43 +08:00
font-family: 'GeneralMedium';
font-weight: 500;
font-size: 1.4rem;
.el-select__placeholder {
color: #000;
}
.el-select__icon {
color: #000;
2026-02-03 13:15:39 +08:00
}
}
}
2026-02-03 15:46:05 +08:00
.fida-style-select-wrapper {
position: relative;
width: 13.9rem;
height: 4rem;
}
.fida-style-select-trigger {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: 1;
2026-02-04 15:08:52 +08:00
cursor: pointer;
}
.setting-icon {
width: 2.4rem;
height: 2.4rem;
cursor: pointer;
2026-02-03 15:46:05 +08:00
}
2026-02-03 13:15:39 +08:00
}
}
2026-02-03 14:51:43 +08:00
.input-option {
// padding: 0 1rem;
margin: 0 0.6rem;
padding: 0 0.8rem 0 1rem;
color: #0d0d0d;
font-weight: 510;
font-size: 1.3rem;
height: 3rem;
line-height: 3rem;
&.el-select-dropdown__item.is-hovering {
background-color: rgba(13, 13, 13, 0.02);
// border-radius: 0.6rem;
}
}
2026-02-03 13:15:39 +08:00
</style>
2026-02-03 15:46:05 +08:00
<style lang="less">
.fida-style-select-popover {
width: 34.2rem !important;
padding: 0 !important;
border-radius: 0.6rem !important;
box-shadow: 0px 5px 20px 0px rgba(0, 0, 0, 0.15) !important;
background-color: #fff !important;
border: none !important;
}
.fida-style-popover-content {
2026-02-04 15:08:52 +08:00
padding: 2rem 2.4rem 2.4rem;
2026-02-03 15:46:05 +08:00
}
.fida-style-popover-header {
font-family: 'GeneralMedium';
font-weight: 500;
font-size: 1.6rem;
color: #000;
2026-02-04 15:08:52 +08:00
margin-bottom: 2rem;
// padding: 1.8rem 2rem 1.5rem;
// border-bottom: 0.1rem solid #f0f0f0;
2026-02-03 15:46:05 +08:00
}
.fida-style-popover-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 1rem;
}
.fida-style-popover-item {
2026-02-04 15:08:52 +08:00
height: 9.1rem;
width: 9.1rem;
background-color: #a6a6a6;
2026-02-03 15:46:05 +08:00
border-radius: 0.8rem;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
transition: all 0.2s ease;
}
.fida-style-popover-item:hover {
background-color: #e8e8e8;
}
.fida-style-popover-item.is-selected {
background-color: #e3f2fd;
2026-02-04 15:08:52 +08:00
.fida-option-label {
color: #000;
}
// border-color: #2196f3;
2026-02-03 15:46:05 +08:00
}
.fida-style-popover-item .fida-option-label {
font-family: 'GeneralMedium';
font-weight: 500;
2026-02-04 15:08:52 +08:00
font-size: 1.2rem;
color: #fff;
2026-02-03 15:46:05 +08:00
text-align: center;
padding: 0.5rem;
}
.fida-style-popover-footer {
2026-02-04 15:08:52 +08:00
// border-top: 0.1rem solid #f0f0f0;
margin-top: 2.4rem;
.fida-confirm-btn {
margin: 0 auto;
width: 15.7rem;
height: 3.4rem;
line-height: 3.4rem;
background-color: #ff7a51;
color: #fff;
border: none;
border-radius: 3.8rem;
font-family: 'GeneralMedium';
font-weight: 500;
font-size: 1.4rem;
cursor: pointer;
}
2026-02-03 15:46:05 +08:00
}
2026-02-04 15:08:52 +08:00
.fida-setting-popover {
width: 34.2rem !important;
padding: 0 !important;
border-radius: 0.6rem !important;
box-shadow: 0px 5px 20px 0px rgba(0, 0, 0, 0.15) !important;
background-color: #fff !important;
border: none !important;
}
// .fida-setting-popover-content {
// padding: 2rem 2.4rem 2.4rem;
// }
.fida-setting-popover-header {
2026-02-03 15:46:05 +08:00
font-family: 'GeneralMedium';
font-weight: 500;
2026-02-04 15:08:52 +08:00
font-size: 1.6rem;
color: #000;
margin-bottom: 2rem;
2026-02-03 15:46:05 +08:00
}
2026-02-04 15:08:52 +08:00
.fida-setting-slider-list {
display: flex;
flex-direction: column;
gap: 2rem;
2026-02-03 15:46:05 +08:00
}
2026-02-04 15:08:52 +08:00
.fida-setting-slider-item {
.fida-slider-label {
font-family: 'GeneralMedium';
font-weight: 500;
font-size: 1.4rem;
color: #000;
margin-bottom: 0.8rem;
}
.fida-slider-row {
gap: 1rem;
.el-slider {
flex: 1;
}
.fida-slider-value {
font-family: 'GeneralMedium';
font-weight: 500;
font-size: 1.4rem;
color: #000;
min-width: 3.5rem;
text-align: right;
}
}
// :deep(.el-slider) {
// }
2026-02-03 15:46:05 +08:00
}
</style>