<template>
    <view>
        <view class="control-title">控制面板</view>
        <basics ref="basics" />
        <division ref="division" />
    </view>
</template>

<script>
import basics from "./modules/basics"
import division from "./modules/division"
export default {
    name: 'prodnum-MT02',
    components: { basics, division },
    props: {
        control: Object
    },
    watch: {
        control: function (newVal) {
            if (newVal) {
                try {
                    this.$refs.basics.ctrlModel = this.__proto__.getControlItem(['Control'], newVal, { Control: "radioNum" })[0];
                    this.$refs.basics.list = ["MostBad", "FaWei", "NowFlow", "CumFlow"].map(v => newVal.params[v])
                    try {
                        const replenish = {
                            TimeConOFF: 1,
                            TimeConON: 0
                        };
                        const TimeConON = this.__proto__.getControlItem(["TimeCon"], JSON.parse(JSON.stringify(newVal)))[0].paramName.TimeConON;
                        if (TimeConON == 1) {
                            this.$refs.basics.ctrlModel.showValue = '分时控制模式'
                            // replenish.TimeConON = 1;
                        } else {
                            // replenish.TimeConOFF = 1;
                        }
                        this.$refs.basics.replenish = replenish;
                    } catch (error) {
                        console.log('获取分时补充字段失败', error)
                    }
                    console.log(this.$refs.basics.ctrlModel)
                    switch (this.$refs.basics.ctrlModel.showValue) {
                        case '远程不利点模式':
                            this.$refs.basics.subcontrol = this.__proto__.getControlItem(['Tarb'], newVal)[0];
                            break;
                        case '远程开关阀模式':
                            this.$refs.basics.subcontrol = this.__proto__.getControlItem(['RC'], newVal)[0];
                            break;
                        case '恒压控制启动':
                            this.$refs.basics.subcontrol = this.__proto__.getControlItem(['DownTar'], newVal)[0];
                            break;
                        default:
                            this.$refs.basics.subcontrol = null;
                            break;
                    }
                } catch (error) {
                    console.error("MT02控制模式", error)
                }
                try {
                    let division = this.$refs.division;
                    division && division.loadData(newVal)
                } catch (error) {
                    console.error("MT02分时控制", error)
                }
            } else {
            }
        }
    },
    data() {
        return {

        }
    },
}
</script>

<style></style>