| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255 |
- <template>
- <div class="volumn-box" :class="lampData.isOpen ? 'active' : ''">
- <div>
- <div class="top">
- <img :src="parseImgUrl('taiguv1/envmonitor', lampData.isOpen ? 'active/lamp.svg' : 'lamp.svg')" alt="" />
- <div class="top-right">
- <SwitchButton
- :loading="allLampStatus.all?.loading"
- @click.stop
- v-model="lampData.isOpen"
- @change="setLampStatus('isOpen')" />
- </div>
- </div>
- <div class="filter-box">
- <div class="filter-item" @click="searchMore">
- <img :src="FilterIcon" alt="" />
- </div>
- </div>
- </div>
- <div class="bottom">
- <div class="bottom-box">
- <div class="bottom-left">
- <div class="text">光照</div>
- <div class="status">{{ lampData.lampStatusText }}</div>
- </div>
- <div class="bottom-right" v-if="lampData.isOpen">
- {{ lampData.brightValue }}
- </div>
- </div>
- <div class="lamp-slider" v-if="lampData.isOpen">
- <Slider v-model="lampData.brightValue" :min="min" :max="max" @onEnd="setLampStatus('bright')"></Slider>
- </div>
- </div>
- </div>
- </template>
- <script setup>
- import FilterIcon from '@/assets/taiguv1/svg/filter_icon.svg'
- import Slider from '@/components/slider/Slider.vue'
- import SwitchButton from '@/components/switch-button/SwitchButton.vue'
- import { parseImgUrl } from '@/utils'
- import { ref, watch, computed } from 'vue'
- import { useStore } from '@/store'
- import useDeviceControl from '@/hooks/useDeviceControl'
- const min = 0
- const max = 100
- const emit = defineEmits(['getStatus', 'showMore'])
- // 接收父组件传递的开关状态
- const props = defineProps({
- lampStatus: {
- type: Object,
- default: () => {
- return {
- isOpen: false,
- brightValue: 0
- }
- }
- },
- equipList: {
- type: Array,
- default: () => {
- return []
- }
- }
- })
- const store = useStore()
- const deviceControl = useDeviceControl()
- const allLampStatus = computed(() => store.state.taiguv1.lampSwitchStatus)
- const searchMore = () => {
- emit('showMore', 'lamp', true)
- }
- const lampData = ref({
- isOpen: false,
- brightValue: 0
- })
- watch(
- () => props.lampStatus,
- (newVal, oldVal) => {
- if (!newVal) {
- return
- }
- console.log('props.lampStaus')
- compareStatus(newVal)
- },
- { deep: true } // 添加深度监听
- )
- const compareStatus = data => {
- if (allLampStatus.value.all) {
- if (allLampStatus.value.all.lastSwitchStatus == data.isOpen) {
- store.dispatch('taiguv1/setLampStatus', {
- id: 'all',
- status: {
- loading: false,
- lastSwitchStatus: data.isOpen
- }
- })
- lampData.value = {
- ...data,
- isOpen: data.isOpen
- }
- } else {
- lampData.value = {
- ...data,
- isOpen: allLampStatus.value.all.lastSwitchStatus
- }
- }
- } else {
- lampData.value = {
- ...data,
- isOpen: data.isOpen
- }
- }
- emit('getStatus', lampData.value.isOpen)
- }
- const setLampStatus = type => {
- if (type == 'isOpen') {
- store.dispatch('taiguv1/setLampStatus', {
- id: 'all',
- status: {
- loading: true,
- lastSwitchStatus: lampData.value.isOpen
- }
- })
- }
- const params = deviceControl.assemblyLampCommand(lampData.value[type], type, props.equipList)
- deviceControl.sendCommands(params)
- emit('getStatus', lampData.value.isOpen)
- }
- </script>
- <style lang="scss" scoped>
- .volumn-box {
- box-sizing: border-box;
- display: flex;
- flex-direction: column;
- justify-content: space-between;
- padding: 16px;
- width: 100%;
- height: 100%;
- border-radius: 24px 24px 44px 24px;
- background-color: rgba(255, 255, 255, 0.2);
- backdrop-filter: blur(40px);
- box-shadow: 0px 10px 20px 0px rgba(0, 20, 40, 0.1);
- .top {
- display: flex;
- justify-content: space-between;
- align-items: center;
- img {
- width: 30px;
- height: 30px;
- }
- }
- .filter-box {
- margin-top: 10px;
- display: flex;
- justify-content: flex-end;
- gap: 10px;
- .filter-item {
- display: flex;
- width: 36px;
- height: 36px;
- justify-content: center;
- align-items: center;
- gap: 10px;
- flex-shrink: 0;
- border-radius: 60px;
- background: var(--White-White-40, rgba(255, 255, 255, 0.4));
- }
- }
- .bottom {
- .bottom-box {
- flex: 1;
- display: flex;
- justify-content: space-between;
- }
- .text {
- width: 100%;
- //styleName: Chi/Body Large;
- font-family: PingFang SC;
- font-size: 16px;
- font-weight: 300;
- line-height: 22px;
- letter-spacing: 0.02em;
- text-align: left;
- text-underline-position: from-font;
- text-decoration-skip-ink: none;
- color: rgba(255, 255, 255, 1);
- padding-bottom: 2px;
- }
- .status {
- width: 100%;
- //styleName: Chi/Body XS;
- font-family: PingFang SC;
- font-size: 11px;
- font-weight: 400;
- line-height: 14px;
- letter-spacing: 0.02em;
- color: rgba(255, 255, 255, 0.4);
- }
- .bottom-right {
- text-align: center;
- font-size: 20px;
- width: 50px;
- height: 30px;
- // color: var(--Blue, #001428);
- align-self: end;
- line-height: 100%;
- display: flex;
- align-items: center;
- justify-content: end;
- }
- .lamp-slider {
- margin-top: 8px;
- background: rgba(255, 255, 255, 0.6);
- width: 100%;
- height: 34px;
- border-radius: 12px;
- }
- }
- // .switch-btn {
- // // margin-top: 0;
- // // width: 50px !important;
- // // height: 28px !important;
- // // border: none;
- // }
- }
- .active {
- background: rgba(255, 255, 255, 0.8);
- backdrop-filter: blur(40px);
- box-shadow: 0px 10px 20px 0px rgba(0, 20, 40, 0.1);
- .bottom {
- .text {
- color: rgba(0, 20, 40, 1);
- }
- .status {
- color: rgba(116, 128, 141, 1);
- }
- .bottom-right {
- font-family: Jost;
- color: rgba(0, 20, 40, 1);
- }
- }
- }
- </style>
|