<!--
 * @Title: 
 * @Description: 维修任务参数配置
 * @Author: swp
 * @Date: 2022-08-24 10:49:21
 * @LastEditors: 
 * @LastEditTime: 2022-08-24 10:49:21
-->
<template>
    <div>
        <el-row>
            <el-col :span="24">
                <basic-container>
                    <label style="color: gray;font-size: 0.8rem;">备注：预警总开关关闭后，所有预警配置将忽略</label>
                </basic-container>
            </el-col>
        </el-row>
        <el-row>
            <el-col :span="24">
                <basic-container>
                    <avue-form :option="warnSettingOption" v-model="warnSettingForm" @submit="submitWarnSetting" />
                </basic-container>
            </el-col>
        </el-row>
    </div>
</template>

<script>
import { getSettingDetail, submitSetting } from "@/api/baseinfo/warn/warnsetting.js";

export default {
    components: {

    },
    props: {

    },
    name: 'warnsetting',
    data() {
        return {
            warnSettingForm: {

            },
            warnSettingOption: {
                labelWidth: 180,
                emptyBtn: false,
                column: [
                    {
                        label: "预警总开关",
                        prop: "warnActive",
                        span: 24,
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                        type: 'radio',
                        dicData: [{
                            label: '关闭',
                            value: 0
                        }, {
                            label: '启动',
                            value: 1
                        }]
                    },
                    {
                        label: "离线预警开关",
                        prop: "warnOfflineActive",
                        span: 12,
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                        type: 'radio',
                        dicData: [{
                            label: '关闭',
                            value: 0
                        }, {
                            label: '启动',
                            value: 1
                        }]
                    },
                    {
                        label: "时钟异常预警开关",
                        prop: "warnClockActive",
                        display: false,
                        span: 8,
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                        type: 'radio',
                        dicData: [{
                            label: '关闭',
                            value: 0
                        }, {
                            label: '启动',
                            value: 1
                        }]
                    },
                    {
                        label: "雨量分钟报延时预警开关",
                        prop: "warnMinUpDelayActive",
                        span: 8,
                        display: false,
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                        type: 'radio',
                        dicData: [{
                            label: '关闭',
                            value: 0
                        }, {
                            label: '启动',
                            value: 1
                        }]
                    },
                    {
                        label: "小时报延时预警开关",
                        prop: "warnHourUpDelayActive",
                        span: 12,
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                        type: 'radio',
                        dicData: [{
                            label: '关闭',
                            value: 0
                        }, {
                            label: '启动',
                            value: 1
                        }]
                    },
                    {
                        label: "漏报预警开关",
                        prop: "warnMissOutActive",
                        span: 8,
                        display: false,
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                        type: 'radio',
                        dicData: [{
                            label: '关闭',
                            value: 0
                        }, {
                            label: '启动',
                            value: 1
                        }]
                    },
                    {
                        label: "雨量疑似异常值预警开关",
                        prop: "warnOutlierValueActive",
                        span: 8,
                        display: false,
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                        type: 'radio',
                        dicData: [{
                            label: '关闭',
                            value: 0
                        }, {
                            label: '启动',
                            value: 1
                        }]
                    },
                    {
                        label: "离线预警是否创建任务",
                        prop: "warnOfflineAutoTask",
                        span: 8,
                        display: false,
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                        type: 'radio',
                        dicData: [{
                            label: '关闭',
                            value: 0
                        }, {
                            label: '创建',
                            value: 1
                        }]
                    },
                    {
                        label: "时钟异常是否创建任务",
                        prop: "warnClockAutoTask",
                        span: 8,
                        display: false,
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                        type: 'radio',
                        dicData: [{
                            label: '关闭',
                            value: 0
                        }, {
                            label: '创建',
                            value: 1
                        }]
                    },
                    {
                        label: "分钟上报延时是否创建任务",
                        prop: "warnDelayAutoTask",
                        span: 8,
                        display: false,
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                        type: 'radio',
                        dicData: [{
                            label: '关闭',
                            value: 0
                        }, {
                            label: '创建',
                            value: 1
                        }]
                    },
                    {
                        label: "小时上报延时是否创建任务",
                        prop: "warnHourUpDelayAutoTask",
                        span: 8,
                        display: false,
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                        type: 'radio',
                        dicData: [{
                            label: '关闭',
                            value: 0
                        }, {
                            label: '创建',
                            value: 1
                        }]
                    },
                    {
                        label: "漏报预警是否创建任务",
                        prop: "warnMissOutAutoTask",
                        span: 8,
                        display: false,
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                        type: 'radio',
                        dicData: [{
                            label: '关闭',
                            value: 0
                        }, {
                            label: '创建',
                            value: 1
                        }]
                    },
                    {
                        label: "雨量疑似异常值是否创建任务",
                        prop: "warnOutlierValueAutoTask",
                        span: 16,
                        display: false,
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                        type: 'radio',
                        dicData: [{
                            label: '关闭',
                            value: 0
                        }, {
                            label: '创建',
                            value: 1
                        }]
                    },
                    {
                        label: "雨情测站离线时长",
                        prop: "warnRainOfflineDuration",
                        span: 8,
                        display: false,
                        tip: '单位为小时',
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                    },
                    {
                        label: "测站离线时长阀值",
                        prop: "warnRiverOfflineDuration",
                        span: 12,
                        tip: '单位为小时',
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                    },
                    {
                        label: "墒情测站离线时长",
                        prop: "warnGroundOfflineDuration",
                        span: 8,
                        display: false,
                        tip: '单位为小时',
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                    },
                    {
                        label: "5分钟雨情上报延时时长",
                        prop: "warnRainDelayMinDuration",
                        span: 8,
                        display: false,
                        tip: '单位为分钟',
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                    },
                    {
                        label: "小时雨情上报延时时长",
                        prop: "warnRainDelayHourDuration",
                        span: 8,
                        display: false,
                        tip: '单位为分钟',
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                    },
                    {
                        label: "小时报上报延时阀值",
                        prop: "warnRiverDelayHourDuration",
                        span: 12,
                        tip: '单位为分钟',
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                    },
                    {
                        label: "小时墒情上报延时时长",
                        prop: "warnGroundDelayHourDuration",
                        span: 8,
                        display: false,
                        tip: '单位为分钟',
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                    },
                    {
                        label: "漏报数量阀值",
                        prop: "warnMissNum",
                        span: 8,
                        display: false,
                        tip: '24小时内漏报阀值数量',
                        rules: [{
                            required: true,
                            message: "必填项",
                        }],
                    },
                ]
            },
            loading: true,
        };
    },
    computed: {
        // ...mapGetters(["userInfo", "permission"]),
        permissionList() {
            return {
                // addBtn: this.vaildData(this.permission.docCategory_add, false),
                // viewBtn: this.vaildData(this.permission.docCategory_view, false),
                // delBtn: this.vaildData(this.permission.docCategory_delete, false),
                // editBtn: this.vaildData(this.permission.docCategory_edit, false),
            };
        },
        ids() {
            let ids = [];
            return ids.join(",");
        },
    },
    mounted() {
    },
    created() {
        this.initData();
    },
    methods: {
        initData() {
            getSettingDetail().then((res) => {
                this.warnSettingForm = res.data.data;
                //console.log(JSON.stringify(this.warnSettingForm))
            });
        },
        submitWarnSetting(from, done) {
            //console.log(JSON.stringify(from))
            //console.log(JSON.stringify(this.warnSettingForm))
            this.loading = true;
            submitSetting(from).then((res) => {
                console.log(JSON.stringify(res))
                this.loading = false;
                this.$message({
                    type: "success",
                    message: "配置提交成功！",
                });
                done();
                getSettingDetail().then((res) => {
                    this.warnSettingForm = res.data.data;
                });
            }, (error) => {
                console.log(error)
                this.loading = false;
                done();
            });
        }
    },
};
</script>
