<!-- 远程配置组件---批量配置任务 -->
<template>
    <div>
        <el-form ref="addFormRef" :model="formAddData">
            <el-row style="height: 45px;margin-top: -10px;">
                <el-col :span="7">
                    <el-form-item label="遥测站编码:" label-width="150px">
                        <el-input v-model="formAddData.stationCode" placeholder="10位编码" :disabled="!stationCode" />
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="stationCode" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="通道1地址:" label-width="150px">
                        <el-input v-model="formAddData.ip1Port1" placeholder="IP址址:端口" :disabled="!ip1Port1"
                            maxlength="21" />
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="ip1Port1" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="域名地址:" label-width="150px">
                        <el-input v-model="formAddData.domainNamePort" placeholder="例:www.web.com:6090"
                            :disabled="!domainNamePort" maxlength="50" />
                    </el-form-item>
                </el-col>
                <el-col :span="1" :offset="0">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="domainNamePort" />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-divider style="margin-top: 0;" />

            <el-row style="height: 45px;margin-top: -17px;">
                <el-col :span="7">
                    <el-form-item label="采样间隔:" label-width="150px">
                        <el-input v-model.number="formAddData.sampleInterval" placeholder="采样时间间隔(分钟)" maxlength="4"
                            onkeyup="value=value.replace(/[^\-\d.]/g, '').replace(/\b(0+){2,}/g, '0').replace(/\-{2,}/g, '-').replace(/^\./g, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.')"
                            :disabled="!sampleInterval" />
                    </el-form-item>
                </el-col>
                <el-col :span="1" :offset="0">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="sampleInterval" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="上报间隔:" label-width="150px">
                        <el-input v-model.number="formAddData.sampleInterval" placeholder="定时报时间间隔(分钟)"
                            :disabled="!sampleInterval" maxlength="4"
                            onkeyup="value=value.replace(/[^\-\d.]/g, '').replace(/\b(0+){2,}/g, '0').replace(/\-{2,}/g, '-').replace(/^\./g, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.')" />
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="sampleInterval" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="低温采样间隔:" label-width="150px">
                        <el-input v-model.number="formAddData.ltSampleInterval" placeholder="低温采样时间间隔(小时)" type="number"
                            maxlength="3" :disabled="!ltSampleInterval" />
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="ltSampleInterval" />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-divider style="margin-top: 0;" />

            <!-- 水表专用配置 -->
            <el-row v-if="state.deviceType !== '2'" style="height: 45px;margin-top: -17px;">
                <el-col :span="7">
                    <el-form-item label="数字个数:" label-width="150px">
                        <el-input v-model.number="formAddData.digitNum" placeholder="数字个数" type="number" maxlength="2"
                            :disabled="!digitNum" />
                    </el-form-item>
                </el-col>
                <el-col :span="1" :offset="0">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="digitNum" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="字轮个数:" label-width="150px">
                        <el-input v-model.number="formAddData.wheelNum" placeholder="字轮个数" type="number" maxlength="2"
                            :disabled="!digitNum" />
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="digitNum" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="尾数单位:" label-width="150px">
                        <el-select v-model="formAddData.uintType" class="filter-item" placeholder="尾数单位(m³)"
                            :disabled="!uintType">
                            <el-option v-for="item in Dic.unitTypeMap" :key="item.value" :label="item.label"
                                :value="item.value" />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="uintType" />
                    </el-form-item>
                </el-col>
            </el-row>
            <!-- 水表专用配置 -->

            <!-- 压力表专用配置 -->
            <el-row v-if="state.deviceType === '2'" style="height: 45px;margin-top: -17px;">
                <el-col :span="5">
                    <el-form-item label="量程范围:" label-width="150px">
                        <el-input v-model="formAddData.pgRangeMin" placeholder="量程下限" :disabled="!pgRange"
                            maxlength="10"
                            onkeyup="value=value.replace(/[^\-\d.]/g, '').replace(/\b(0+){2,}/g, '0').replace(/\-{2,}/g, '-').replace(/^\./g, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.')" />
                    </el-form-item>
                </el-col>

                <el-col :span="2">
                    <el-form-item label-width="0px">
                        <el-input v-model="formAddData.pgRangeMax" placeholder="量程上限" :disabled="!pgRange"
                            maxlength="10"
                            onkeyup="value=value.replace(/[^\-\d.]/g, '').replace(/\b(0+){2,}/g, '0').replace(/\-{2,}/g, '-').replace(/^\./g, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.')" />
                    </el-form-item>
                </el-col>

                <el-col :span="1" :offset="0">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="pgRange" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="数据精度:" label-width="150px">
                        <el-select v-model="formAddData.pgPrecisionType" class="filter-item" placeholder="数据精度类型"
                            :disabled="!pgPrecisionType">
                            <el-option v-for="item in Dic.pgPrecisionTypeMap" :key="item.value" :label="item.label"
                                :value="item.value" />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="pgPrecisionType" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="校正参数:" label-width="150px">
                        <el-input v-model="formAddData.pgCorrectvalue" placeholder="压力表系统校正参数"
                            :disabled="!pgCorrectvalue" maxlength="10"
                            onkeyup="value=value.replace(/[^\-\d.]/g, '').replace(/\b(0+){2,}/g, '0').replace(/\-{2,}/g, '-').replace(/^\./g, '').replace(/\.{2,}/g, '.').replace('.', '$#$').replace(/\./g, '').replace('$#$', '.')" />
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="pgCorrectvalue" />
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row v-if="state.deviceType === '2'" style="margin-bottom: -10px;">
                <el-col :span="7">
                    <el-form-item label="坐标点赋值:" label-width="150px">
                        <el-input v-model="formAddData.originx" placeholder="origin-x" :disabled="!pgManualConfig"
                            maxlength="4" onkeyup="value=value.replace(/[^\d]/g, '')" style="width: 105px;" />
                        <el-input v-model="formAddData.originy" placeholder="origin-y" :disabled="!pgManualConfig"
                            maxlength="4" onkeyup="value=value.replace(/[^\d]/g, '')" style="width: 107px;" />
                        <el-input v-model="formAddData.endx" placeholder="end-x" :disabled="!pgManualConfig"
                            v-if="pgManualConfig" maxlength="4" onkeyup="value=value.replace(/[^\d]/g, '')"
                            style="width: 105px;" />
                        <el-input v-model="formAddData.endy" placeholder="end-y" :disabled="!pgManualConfig"
                            v-if="pgManualConfig" maxlength="4" onkeyup="value=value.replace(/[^\d]/g, '')"
                            style="width: 107px;" />
                        <el-input v-model="formAddData.centerx" placeholder="center-x" :disabled="!pgManualConfig"
                            v-if="pgManualConfig" maxlength="4" onkeyup="value=value.replace(/[^\d]/g, '')"
                            style="width: 105px;" />
                        <el-input v-model="formAddData.centery" placeholder="center-y" :disabled="!pgManualConfig"
                            v-if="pgManualConfig" maxlength="4" onkeyup="value=value.replace(/[^\d]/g, '')"
                            style="width: 107px;" />
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="pgManualConfig" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="图片是否描点:" label-width="150px">
                        <el-radio-group v-model="formAddData.pgIsDebug" :disabled="!pgIsDebug">
                            <el-radio label='1'>是</el-radio>
                            <el-radio label='0'>否</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="pgIsDebug" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="目标历史初始化:" label-width="150px">
                        <el-radio-group v-model="formAddData.pgInitTargetRegion" :disabled="!pgInitTargetRegion">
                            <el-radio label=1>是</el-radio>
                            <el-radio label=0>否</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="pgInitTargetRegion" />
                    </el-form-item>
                </el-col>
            </el-row>
            <!-- 压力表专用配置 -->

            <el-divider style="margin-top: 0;" />
            <el-row style="height: 45px;margin-top: -17px;">
                <el-col :span="7">
                    <el-form-item label="入网超时时间:" label-width="150px">
                        <el-input v-model.number="formAddData.networkRegTimeout" placeholder="注册入网超时时间(秒)" type="number"
                            maxlength="4" :disabled="!networkRegTimeout" />
                    </el-form-item>
                </el-col>
                <el-col :span="1" :offset="0">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="networkRegTimeout" />
                    </el-form-item>
                </el-col>
                <el-col :span="7">
                    <el-form-item label="数传类型:" label-width="150px">
                        <el-radio-group v-model="formAddData.tongxunWay" :disabled="!tongxunWay">
                            <el-radio label='2'>NB</el-radio>
                            <el-radio label="1">CAT1</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="tongxunWay" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="天线类型:" label-width="150px">
                        <el-select v-model="formAddData.tianxianType" class="filter-item" placeholder="内置/外置"
                            :disabled="!tianxianType">
                            <el-option v-for="(key, value) in Dic.tianxianType" :key="key" :label="key" :value="value" />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="tianxianType" />
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row style="height: 45px;">
                <el-col :span="7" v-if="state.deviceType == '1'">
                    <el-form-item label="设备口径:" label-width="150px">
                        <el-select v-model="formAddData.dnType" class="filter-item" placeholder="设备口径"
                            :disabled="!dnType">
                            <el-option v-for="item in Dic.dnTypeMap" :key="item.value" :label="item.label"
                                :value="item.value" />
                        </el-select>
                    </el-form-item>
                </el-col>
                <el-col :span="1" :offset="0" v-if="state.deviceType == '1'">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="dnType" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="安装方向:" label-width="150px">
                        <el-radio-group v-model="formAddData.setupDir" :disabled="!setupDir">
                            <el-radio label="0" style="height: 25px;">正向</el-radio>
                            <el-radio label="1">反向</el-radio>
                            <el-radio label="2">左90</el-radio>
                            <el-radio label="3">右90</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="setupDir" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="安装年份:" label-width="150px">
                        <el-input v-model.number="formAddData.setupYear" placeholder="设备安装年份" type="number"
                            maxlength="4" minlength="4" :disabled="!setupYear" />
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" />
                        <!-- v-model="setupYear"  -->
                    </el-form-item>
                </el-col>
            </el-row>
            <el-divider style="margin-top: 0;" />

            <el-row style="height: 45px;margin-top: -17px;">
                <el-col :span="5">
                    <el-form-item label="工作温度范围:" label-width="150px">
                        <el-input v-model.number="formAddData.workLt" placeholder="最低温度" :disabled="!workLt"
                            maxlength="4" />
                    </el-form-item>
                </el-col>

                <el-col :span="2">
                    <el-form-item label-width="0px">
                        <el-input v-model.number="formAddData.workHt" placeholder="最高温度" :disabled="!workLt"
                            maxlength="4" />
                    </el-form-item>
                </el-col>

                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="workLt" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="低电压报警值:" label-width="150px">
                        <el-input v-model="formAddData.batAlarmVt" placeholder="工作电压下限报警值" maxlength="4" type="number"
                            :disabled="!batAlarmVt" />
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="batAlarmVt" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="余电报警值:" label-width="150px">
                        <el-input v-model.number="formAddData.batAlarmSoc" placeholder="剩余电量报警值(百分比)"
                            :disabled="!batAlarmSoc" maxlength="2" />
                    </el-form-item>
                </el-col>
                <el-col :span="1" :offset="0">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="batAlarmSoc" />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-divider style="margin-top: 0;" v-if="state.deviceType !== '2'" />

            <!-- 水表专用 -->
            <el-row v-if="state.deviceType !== '2'" style="height: 45px;margin-top: -17px;">
                <el-col :span="7">
                    <el-form-item label="强制拉回概率:" label-width="150px">
                        <el-input v-model.number="formAddData.aiPullBack" placeholder="强制拉回概率值(%)"
                            :disabled="!aiPullBack" maxlength="4" />
                    </el-form-item>
                </el-col>

                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="aiPullBack" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="识别概率阈值:" label-width="150px">
                        <el-input v-model.number="formAddData.aiPass" placeholder="识别可信度的概率阈值" type="number"
                            maxlength="4" :disabled="!aiPass" />
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="aiPass" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="位概率阈值:" label-width="150px">
                        <el-input v-model.number="formAddData.aiSinglePass" placeholder="位概率阈值"
                            :disabled="!aiSinglePass" maxlength="4" />
                    </el-form-item>
                </el-col>
                <el-col :span="1" :offset="0">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="aiSinglePass" />
                    </el-form-item>
                </el-col>
            </el-row>
            <!-- 水表专用 -->

            <el-divider style="margin-top: 0;" />
            <el-row style="height: 45px;margin-top: -17px;">
                <el-col :span="7">
                    <el-form-item label="背光频率:" label-width="150px">
                        <el-input v-model.number="formAddData.pwmHz" placeholder="摄像头背光屏闪频率(HZ)" :disabled="!pwmHz"
                            maxlength="4" />
                    </el-form-item>
                </el-col>

                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="pwmHz" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="背光占空比:" label-width="150px">
                        <el-input v-model.number="formAddData.pwmDuty" placeholder="背光占空比(%)" type="number"
                            maxlength="4" :disabled="!pwmDuty" />
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="pwmDuty" />
                    </el-form-item>
                </el-col>

                <el-col :span="5">
                    <el-form-item label="补光灯亮度:" label-width="150px">
                        <el-input v-model.number="formAddData.flashBrightMin" placeholder="最小亮度"
                            :disabled="!flashBrightMin" maxlength="3" />
                    </el-form-item>
                </el-col>

                <el-col :span="2">
                    <el-form-item label-width="0px">
                        <el-input v-model.number="formAddData.flashBrightMax" placeholder="最大亮度"
                            :disabled="!flashBrightMin" maxlength="3" />
                    </el-form-item>
                </el-col>
                <el-col :span="1" :offset="0">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="flashBrightMin" />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-divider style="margin-top: 0;" />
            <el-row style="height: 45px;margin-top: -17px;">
                <el-col :span="7">
                    <el-form-item label="CPU版本号:" label-width="150px">
                        <el-input v-model="formAddData.cpuVersion" placeholder="4位CPU版本号" :disabled="!cpuVersion"
                            maxlength="4" />
                    </el-form-item>
                </el-col>

                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="cpuVersion" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="通信板版本号:" label-width="150px">
                        <el-input v-model="formAddData.tongxunVersion" placeholder="4位通信板版本号" type="number"
                            maxlength="4" :disabled="!tongxunVersion" />
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="tongxunVersion" />
                    </el-form-item>
                </el-col>

                <el-col :span="7" v-if="state.deviceType !== '2'">
                    <el-form-item label="当前读数:" label-width="150px">
                        <el-input v-model.number="formAddData.lastVal" placeholder="当前读数" type="number" maxlength="10"
                            :disabled="!lastVal" />
                    </el-form-item>
                </el-col>
                <el-col :span="1" v-if="state.deviceType !== '2'">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="lastVal" />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-divider style="margin-top: 0;" />
            <el-row v-if="state.deviceType !== '2'" style="height: 45px;margin-top: -17px;">
                <el-col :span="15">
                    <el-form-item label="整图上报周规则:" label-width="150px">
                        <el-checkbox label="一" size="small" v-model="week1" :disabled="!upWholeImgWeekRule"
                            @change="WeekRuleChange" />
                        <el-checkbox label="二" size="small" v-model="week2" :disabled="!upWholeImgWeekRule" @change="WeekRuleChange" />
                        <el-checkbox label="三" size="small" v-model="week3" :disabled="!upWholeImgWeekRule" @change="WeekRuleChange" />
                        <el-checkbox label="四" size="small" v-model="week4" :disabled="!upWholeImgWeekRule" @change="WeekRuleChange" />
                        <el-checkbox label="五" size="small" v-model="week5" :disabled="!upWholeImgWeekRule" @change="WeekRuleChange" />
                        <el-checkbox label="六" size="small" v-model="week6" :disabled="!upWholeImgWeekRule" @change="WeekRuleChange" />
                        <el-checkbox label="日" size="small" v-model="week7" :disabled="!upWholeImgWeekRule" @change="WeekRuleChange" />
                    </el-form-item>
                </el-col>

                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="upWholeImgWeekRule" @change="weekRuleSwitchChange"/>
                    </el-form-item>
                </el-col>
                <el-col :span="7">
                    <el-form-item label="手动触发传大图:" label-width="150px">
                        <el-radio-group v-model="formAddData.wiTaskManwakeupFlag" :disabled="!wiTaskManwakeupFlag">
                            <el-radio label=1>是</el-radio>
                            <el-radio label=0>否</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>

                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="wiTaskManwakeupFlag" />
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row v-if="state.deviceType !== '2'" style="height: 45px;">
                <el-col :span="5">
                    <el-form-item label="月初月末传大图:" label-width="140px">
                        <el-radio-group v-model="formAddData.wiTaskMonthFlag" :disabled="!wiTaskMonthFlag">
                            <el-radio label=1>是</el-radio>
                            <el-radio label=0>否</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="wiTaskMonthFlag" />
                    </el-form-item>
                </el-col>
                <el-col :span="5">
                    <el-form-item label="指定日期发大图:" label-width="150px">
                        <el-radio-group v-model="formAddData.wiTaskSpecdateEnable" :disabled="!wiTaskSpecdateFlag">
                            <el-radio label='1'>是</el-radio>
                            <el-radio label='0'>否</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>

                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="wiTaskSpecdateFlag" />
                    </el-form-item>
                </el-col>

                <el-col :span="5">
                    <el-form-item label="开始日期:" label-width="100px">
                        <el-date-picker v-model="formAddData.wiTaskSpecdateDate" type="date" placeholder="开始日期"
                            value-format="YYYYMMDD" size="small" style="max-width: 130px;" :shortcuts="shortcuts"
                            :disabled="!wiTaskSpecdateFlag" />
                    </el-form-item>
                </el-col>

                <el-col :span="4">
                    <el-form-item label="天数/次数:" label-width="100px">
                        <el-input v-model="formAddData.wiTaskSpecdateDays" style="width:110px" placeholder="持续天数"
                            size="small" :disabled="!wiTaskSpecdateFlag" maxlength="2"
                            onkeyup="value=value.replace(/[^\d]/g, '')" />
                    </el-form-item>
                </el-col>

                <el-col :span="2">
                    <el-form-item label-width="0px">
                        <el-input v-model="formAddData.wiTaskSpecdateTimes" placeholder="每天次数" size="small"
                            :disabled="!wiTaskSpecdateFlag" maxlength="2" style="width:100px"
                            onkeyup="value=value.replace(/[^\d]/g, '')" />
                    </el-form-item>
                </el-col>
            </el-row>
            <el-divider style="margin-top: 0;" v-if="state.deviceType !== '2'" />
            <el-row style="height: 45px;margin-top: -17px;">
                <el-col :span="5">
                    <el-form-item label="日志上传规则:" label-width="150px">
                        <el-radio-group v-model="formAddData.logUploadEnable" :disabled="!logUploadRules">
                            <el-radio label='1'>是</el-radio>
                            <el-radio label='0'>否</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>

                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="logUploadRules" />
                    </el-form-item>
                </el-col>

                <el-col :span="4">
                    <el-form-item label="开始日期:" label-width="100px">
                        <el-date-picker v-model="formAddData.logUploadDate" type="date" placeholder="开始日期"
                            value-format="YYYYMMDD" size="small" style="max-width: 130px;" :shortcuts="shortcuts"
                            :disabled="!logUploadRules" />
                    </el-form-item>
                </el-col>

                <el-col :span="4">
                    <el-form-item label="天数/次数:" label-width="120px">
                        <el-input v-model="formAddData.logUploadDays" placeholder="持续天数" :disabled="!logUploadRules"
                            maxlength="2" onkeyup="value=value.replace(/[^\d]/g, '')" size="small" />
                    </el-form-item>
                </el-col>

                <el-col :span="2">
                    <el-form-item label-width="0px">
                        <el-input v-model="formAddData.logUploadTimes" placeholder="每天次数" :disabled="!logUploadRules"
                            maxlength="2" onkeyup="value=value.replace(/[^\d]/g, '')" size="small" />
                    </el-form-item>
                </el-col>

                <el-col :span="5">
                    <el-form-item label="日志等级(MCU/AI):" label-width="150px">
                        <el-select v-model="formAddData.logUploadMcuLevel" class="filter-item" placeholder="MCU等级"
                            :disabled="!logUploadRules" size="small">
                            <el-option v-for="item in Dic.logUploadLevel" :key="item.value" :label="item.label"
                                :value="item.value" />
                        </el-select>
                    </el-form-item>
                </el-col>

                <el-col :span="2">
                    <el-form-item label-width="0px">
                        <el-select v-model="formAddData.logUploadAiLevel" class="filter-item" placeholder="AI等级"
                            :disabled="!logUploadRules" size="small">
                            <el-option v-for="item in Dic.logUploadLevel" :key="item.value" :label="item.label"
                                :value="item.value" />
                        </el-select>
                    </el-form-item>
                </el-col>
            </el-row>

            <el-row style="height: 45px;">
                <el-col :span="7">
                    <el-form-item label="输出串口日志:" label-width="150px">
                        <el-radio-group v-model="formAddData.isprintcomlog" :disabled="!isprintcomlog">
                            <el-radio label='1'>是</el-radio>
                            <el-radio label='0'>否</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="isprintcomlog" />
                    </el-form-item>
                </el-col>
                <el-col :span="7">
                    <el-form-item label="上传错误的日志:" label-width="150px">
                        <el-radio-group v-model="formAddData.uploadLastFailLogFlag" :disabled="!uploadLastFailLogFlag">
                            <el-radio label='1'>是</el-radio>
                            <el-radio label='0'>否</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="uploadLastFailLogFlag" />
                    </el-form-item>
                </el-col>

                <el-col :span="7">
                    <el-form-item label="手动触发传日志:" label-width="150px">
                        <el-radio-group v-model="formAddData.logTaskManwakeupFlag" :disabled="!logTaskManwakeupFlag">
                            <el-radio label='1'>是</el-radio>
                            <el-radio label='0'>否</el-radio>
                        </el-radio-group>
                    </el-form-item>
                </el-col>
                <el-col :span="1">
                    <el-form-item>
                        <el-switch class="switch_style" v-model="logTaskManwakeupFlag" />
                    </el-form-item>
                </el-col>
            </el-row>

            <el-divider style="margin-top: 0;margin-bottom: 5px;" />
            <el-row style="height: 45px;margin-top: -5px;">
                <el-col :span="6">
                    <el-form-item label="电池使用时长清零:" label-width="150px">
                        <el-switch class="switch_style" v-model="formAddData.isresetbat" active-value="1"
                            inactive-value="0" />
                    </el-form-item>
                </el-col>

                <el-col :span="5">
                    <el-form-item label="MCU运行次数清零:" label-width="150px">
                        <el-switch class="switch_style" v-model="formAddData.isrestmcu" active-value="1"
                            inactive-value="0" />
                    </el-form-item>
                </el-col>

                <el-col :span="5">
                    <el-form-item label="WDT读数清零:" label-width="150px">
                        <el-switch class="switch_style" v-model="formAddData.isresetwdt" active-value="1"
                            inactive-value="0" />
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
    </div>
</template>

<script lang="ts" setup>
import { TaskRemoteCfg } from "@/types";
import { onMounted, reactive, toRefs, ref } from "vue";
import Dic from "@/dictionary/aicbqcfg";
import { watch } from 'vue';

const props = defineProps({
    data: Object,
})

//使用父组件传递过来的值
const { data } = toRefs(props)

const state = reactive({
    formAddData: {} as TaskRemoteCfg,
    deviceType: '1',
});

const {
    formAddData,
    deviceType
} = toRefs(state);

const stationCode = ref(false);
const ip1Port1 = ref(false);
const ip2Port2 = ref(false);
const ip3Port3 = ref(false);
const ip4Port4 = ref(false);
const domainNamePort = ref(false);
const dnType = ref(false);
const digitNum = ref(false);
const uintType = ref(false);
const setupDir = ref(false);
const sampleInterval = ref(false);
const networkRegTimeout = ref(false);
const setupYear = ref(false);
const aiPullBack = ref(false);
const aiPass = ref(false);
const aiSinglePass = ref(false);
const pwmHz = ref(false);
const pwmDuty = ref(false);
const flashBrightMin = ref(false);
const upWholeImgWeekRule = ref(false);
const ip1ExpandOn = ref(false);
const upInterval = ref(false);
const ltSampleInterval = ref(false);
const workLt = ref(false);
const batAlarmSoc = ref(false);
const workHt = ref(false);
const batAlarmVt = ref(false);
const cpuVersion = ref(false);
const tongxunVersion = ref(false);
const tongxunWay = ref(false);
const tianxianType = ref(false);
//const wheelNum = ref(false);
const lastVal = ref(false);
const meterFontStyle = ref(false);
const pgRange = ref(false);
const pgPrecisionType = ref(false);
const pgCorrectvalue = ref(false);
const pgManualConfig = ref(false);
const pgIsDebug = ref(false);
const pgInitTargetRegion = ref(false);
const isprintcomlog = ref(false);
const isresetwdt = ref(false);
const wiTaskManwakeupFlag = ref(false);
const wiTaskMonthFlag = ref(false);
const wiTaskSpecdateFlag = ref(false);
const logUploadRules = ref(false);
const uploadLastFailLogFlag = ref(false);
const logTaskManwakeupFlag = ref(false);
/* 结束 ---- 记录打开了那一项的配置开关,简单写法,应该可优化 */

/* 开始 ---- 记录星期的勾选 */
const week1 = ref(false);
const week2 = ref(false);
const week3 = ref(false);
const week4 = ref(false);
const week5 = ref(false);
const week6 = ref(false);
const week7 = ref(false);
/* 结束 ---- 记录星期的勾选 */

const initData = () => {
    stationCode.value = false;
    ip1Port1.value = false;
    ip2Port2.value = false;
    ip3Port3.value = false;
    ip4Port4.value = false;
    domainNamePort.value = false;
    dnType.value = false;
    digitNum.value = false;
    uintType.value = false;
    setupDir.value = false;
    sampleInterval.value = false;
    networkRegTimeout.value = false;
    setupYear.value = false;
    aiPullBack.value = false;
    aiPass.value = false;
    aiSinglePass.value = false;
    pwmHz.value = false;
    pwmDuty.value = false;
    flashBrightMin.value = false;
    upWholeImgWeekRule.value = false;
    ip1ExpandOn.value = false;
    upInterval.value = false;
    ltSampleInterval.value = false;
    workLt.value = false;
    batAlarmSoc.value = false;
    workHt.value = false;
    batAlarmVt.value = false;
    cpuVersion.value = false;
    tongxunVersion.value = false;
    tianxianType.value = false;
    tongxunWay.value = false;
    //wheelNum.value = false;         //按协议约定,要和数字个数一起配置
    lastVal.value = false;

    week1.value = false;
    week2.value = false;
    week3.value = false;
    week4.value = false;
    week5.value = false;
    week6.value = false;
    week7.value = false;

    meterFontStyle.value = false;
    pgRange.value = false;
    pgPrecisionType.value = false;
    pgCorrectvalue.value = false;
    pgManualConfig.value = false;
    pgIsDebug.value = false;
    pgInitTargetRegion.value = false;

    isprintcomlog.value = false;
    isresetwdt.value = false;
    wiTaskManwakeupFlag.value = false;
    wiTaskMonthFlag.value = false;
    wiTaskSpecdateFlag.value = false;
    logUploadRules.value = false;
    uploadLastFailLogFlag.value = false;
    logTaskManwakeupFlag.value = false;
}
const isDebugSwitchChange = () => {
    state.formAddData.pgIsDebug = pgIsDebug.value ? '1' : '0';
}

const pgInitSwitchChange = () => {
    state.formAddData.pgInitTargetRegion = pgInitTargetRegion.value ? '1' : '0';
}

const comlogSwitchChange = () => {
    state.formAddData.isprintcomlog = isprintcomlog.value ? '1' : '0';
}

const isresetwdtSwitchChange = () => {
    state.formAddData.isresetwdt = isresetwdt.value ? '1' : '0';
}

const uploadLastFailLogFlagSwitchChange = () => {
    state.formAddData.uploadLastFailLogFlag = uploadLastFailLogFlag.value ? '1' : '0';
}

/* 日期控件开始 */
const size = ref<'' | 'large' | 'small'>('')
const shortcuts = [
    {
        text: '今天',
        value: new Date(),
    },
    {
        text: '昨天',
        value: () => {
            const date = new Date()
            date.setTime(date.getTime() - 3600 * 1000 * 24)
            return date
        },
    },
    {
        text: '前一周',
        value: () => {
            const date = new Date()
            date.setTime(date.getTime() - 3600 * 1000 * 24 * 7)
            return date
        },
    },
]
/* 日期控件结束 */

//监听配置对象
watch(() => props.data, (val: any) => {
    state.formAddData = val as TaskRemoteCfg;
    loadCfg();
}, { deep: true })

onMounted(() => {
    initData();
    //loadCfg();
});

//修改时加载配置
const loadCfg = () => {
    if (state.formAddData && state.formAddData.taskId) {
        if (state.formAddData != null && state.formAddData.upWholeImgWeekRule != null && state.formAddData.upWholeImgWeekRule.length == 7) {
            week1.value = state.formAddData.upWholeImgWeekRule[0] == "1";
            week2.value = state.formAddData.upWholeImgWeekRule[1] == "1";
            week3.value = state.formAddData.upWholeImgWeekRule[2] == "1";
            week4.value = state.formAddData.upWholeImgWeekRule[3] == "1";
            week5.value = state.formAddData.upWholeImgWeekRule[4] == "1";
            week6.value = state.formAddData.upWholeImgWeekRule[5] == "1";
            week7.value = state.formAddData.upWholeImgWeekRule[6] == "1";
            upWholeImgWeekRule.value = true;
        }

        stationCode.value = state.formAddData.stationCode != null;
        ip1Port1.value = state.formAddData.ip1Port1 != null;
        ip2Port2.value = state.formAddData.ip2Port2 != null;
        ip3Port3.value = state.formAddData.ip3Port3 != null;
        ip4Port4.value = state.formAddData.ip4Port4 != null;
        domainNamePort.value = state.formAddData.domainNamePort != null;
        dnType.value = state.formAddData.dnType != null;
        digitNum.value = state.formAddData.digitNum != null;
        uintType.value = state.formAddData.uintType != null;
        setupDir.value = state.formAddData.setupDir != null;
        sampleInterval.value = state.formAddData.sampleInterval != null;
        networkRegTimeout.value = state.formAddData.networkRegTimeout != null;
        setupYear.value = state.formAddData.setupYear != null;
        aiPullBack.value = state.formAddData.aiPullBack != null;
        aiPass.value = state.formAddData.aiPass != null;
        aiSinglePass.value = state.formAddData.aiSinglePass != null;
        pwmHz.value = state.formAddData.pwmHz != null;
        pwmDuty.value = state.formAddData.pwmDuty != null;
        flashBrightMin.value = state.formAddData.flashBrightMin != null;
        ip1ExpandOn.value = state.formAddData.ip1ExpandOn != null;
        upInterval.value = state.formAddData.upInterval != null;
        ltSampleInterval.value = state.formAddData.ltSampleInterval != null;
        workLt.value = state.formAddData.workLt != null;
        batAlarmSoc.value = state.formAddData.batAlarmSoc != null;
        workHt.value = state.formAddData.workHt != null;
        batAlarmVt.value = state.formAddData.batAlarmVt != null;
        cpuVersion.value = state.formAddData.cpuVersion != null;
        tongxunVersion.value = state.formAddData.tongxunVersion != null;
        tianxianType.value = state.formAddData.tianxianType != null;
        tongxunWay.value = state.formAddData.tongxunWay != null;
        lastVal.value = state.formAddData.lastVal != null;
        meterFontStyle.value = state.formAddData.meterFontStyle != null;

        //压力表添加 2022-09-13 guozhao
        pgRange.value = state.formAddData.pgRangeMin != null || state.formAddData.pgRangeMax != null;
        pgPrecisionType.value = state.formAddData.pgPrecisionType != null;
        pgCorrectvalue.value = state.formAddData.pgCorrectvalue != null;
        pgManualConfig.value = state.formAddData.pgManualConfig != null;
        pgIsDebug.value = state.formAddData.pgIsDebug != null;
        pgInitTargetRegion.value = state.formAddData.pgInitTargetRegion != null;

        isprintcomlog.value = state.formAddData.isprintcomlog != null;
        isresetwdt.value = state.formAddData.isresetwdt != null;

        wiTaskManwakeupFlag.value = state.formAddData.wiTaskManwakeupFlag != null;
        wiTaskMonthFlag.value = state.formAddData.wiTaskMonthFlag != null;
        wiTaskSpecdateFlag.value = state.formAddData.wiTaskSpecdateFlag != null;
        logUploadRules.value = state.formAddData.logUploadRules != null;
        uploadLastFailLogFlag.value = state.formAddData.uploadLastFailLogFlag != null;
        logTaskManwakeupFlag.value = state.formAddData.logTaskManwakeupFlag != null;
    }
}

//周规则发生改变
const WeekRuleChange = () => {
    if (upWholeImgWeekRule.value) {
        let weeks = "";
        weeks += week1.value ? "1" : "0";
        weeks += week2.value ? "1" : "0";
        weeks += week3.value ? "1" : "0";
        weeks += week4.value ? "1" : "0";
        weeks += week5.value ? "1" : "0";
        weeks += week6.value ? "1" : "0";
        weeks += week7.value ? "1" : "0";
        state.formAddData.upWholeImgWeekRule = weeks;
    }
}

//周规则启用开关发生改变
const weekRuleSwitchChange=()=>{
    state.formAddData.upWholeImgWeekRule=upWholeImgWeekRule.value?'0000000':'';
}
</script>