<template>
  <el-dialog v-dialogDrag class="planEdit__tool update-station-interval-time" :title="title" :visible.sync="dialogShow" width="420px" :before-close="doClose" :z-index="2000" :modal="false" :close-on-click-modal="false">
    <el-row>
      <el-form ref="form" :model="runPlanLevelVO" label-width="140px" size="mini" :rules="rules">
        <el-form-item :label="$t('planMonitor.updateStation.level1')" prop="level1">
          <el-input-number v-model="runPlanLevelVO.level1" :min="1" />
          <span>{{ $t('global.second') }}</span>
        </el-form-item>
        <el-form-item :label="$t('planMonitor.updateStation.level2')" prop="level2">
          <el-input-number v-model="runPlanLevelVO.level2" :min="1" />
          <span>{{ $t('global.second') }}</span>
        </el-form-item>
        <el-form-item :label="$t('planMonitor.updateStation.level3')" prop="level3">
          <el-input-number v-model="runPlanLevelVO.level3" :min="1" />
          <span>{{ $t('global.second') }}</span>
        </el-form-item>
        <el-form-item :label="$t('planMonitor.updateStation.level4')" prop="level4">
          <el-input-number v-model="runPlanLevelVO.level4" :min="1" />
          <span>{{ $t('global.second') }}</span>
        </el-form-item>
        <el-form-item :label="$t('planMonitor.updateStation.level5')" prop="level5">
          <el-input-number v-model="runPlanLevelVO.level5" :min="1" />
          <span>{{ $t('global.second') }}</span>
        </el-form-item>
      </el-form>
    </el-row>
    <el-row type="flex" justify="center" class="button-group">
      <el-button @click="handleCommit">{{ $t('global.confirm') }}</el-button>
      <el-button @click="doClose">{{ $t('global.cancel') }}</el-button>
    </el-row>
  </el-dialog>
</template>

<script>
export default {
    name: 'UpdateStationIntervalTime',
    components: {
    },
    data() {
        return {
            dialogShow: false,
            loading: false,
            editModel: {},
            runPlanLevelVO: {}
        };
    },
    computed: {
        title() {
            return this.$t('planMonitor.updateStation.updateData');
        },
        rules() {
            return {
                level1: [
                    { required: true, message: this.$t('planMonitor.updateStation.pleaseInputLevel1'), trigger: 'blur' }
                ],
                level2: [
                    { required: true, message: this.$t('planMonitor.updateStation.pleaseInputLevel2'), trigger: 'blur' }
                ],
                level3: [
                    { required: true, message: this.$t('planMonitor.updateStation.pleaseInputLevel3'), trigger: 'blur' }
                ],
                level4: [
                    { required: true, message: this.$t('planMonitor.updateStation.pleaseInputLevel4'), trigger: 'blur' }
                ],
                level5: [
                    { required: true, message: this.$t('planMonitor.updateStation.pleaseInputLevel5'), trigger: 'blur' }
                ]
            };
        }
    },
    mounted() {
    },
    methods: {
        doShow(params) {
            this.editModel = params || {};
            this.runPlanLevelVO = Object.assign({}, this.editModel.runPlanLevelVO || {});
            this.dialogShow = true;
        },
        doClose() {
            this.loading = false;
            this.dialogShow = false;
        },
        handleCommit() {
            this.$refs['form'].validate((valid) => {
                if (valid) {
                    const model = {
                        level1: this.runPlanLevelVO.level1,
                        level2: this.runPlanLevelVO.level2,
                        level3: this.runPlanLevelVO.level3,
                        level4: this.runPlanLevelVO.level4,
                        level5: this.runPlanLevelVO.level5,
                        stationRunningId: this.runPlanLevelVO.stationRunningId
                    };
                    this.$emit('handleConfirm', model);
                    this.doClose();
                }
            });
        }
    }
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
    @import "src/styles/mixin.scss";

    /deep/ {
        .el-input {
            width: 120px;
        }

        .el-input-number {
            width: 120px;
        }
    }
</style>
