<template>
    <view v-if="list.length">
        <view class="control-title">设备状态</view>
        <u-subsection :list="list" :current="current" @change="onChange" />
        <My_input ref="MyInput" />
    </view>
</template>
<script>
export default {
    name: "state",
    data() {
        return {
            list: [],
            current: -1,
            options: []
        }
    },
    methods: {
        onChange(index) {
            if (index == this.current) return;
            let item = this.options[index],
                that = this;
            uni.showModal({
                title: '提示',
                content: `是否确定将设备更改为${item.funcname}状态`,
                success: ({ confirm }) => {
                    if (confirm) that.$refs.MyInput.submit(item.w_functionid, {
                        [item.paramName]: 1
                    })
                },
            })

        },
    }
}
</script>

<style lang="scss" scoped>
/deep/.u-subsection__item__text {
    span {
        font-size: 10px;
    }
}
</style>