<template>
  <el-dialog
    class="adddeviceDialog"
    :title="title"
    :visible.sync="isShow"
    :close-on-click-modal="false"
    width="670px"
  >
    <el-form
      label-position="left"
      ref="formInfo"
      label-width="auto"
      :rules="rules"
      :model="formdata"
    >
      <el-form-item label="名称" prop="name">
        <el-input v-model="formdata.name" autocomplete="off"></el-input>
      </el-form-item>
      <div class="timeBoxArr">
        <el-form-item label="时间" prop="time">
          <el-time-picker
            is-range
            v-model="formdata.time"
            range-separator="至"
            start-placeholder="开始时间"
            end-placeholder="结束时间"
            value-format="HH:mm:ss"
          >
          </el-time-picker>
        </el-form-item>
        <el-form-item label="间隔（分）" prop="span">
          <!-- <el-input v-model="formdata.span" autocomplete="off" type="number"></el-input> -->
          <el-input-number v-model="formdata.span" :min="1"></el-input-number>
        </el-form-item>
        <button>新增</button>
        <button>删除</button>
      </div>

      <el-form-item label="备注" prop="remark">
        <el-input v-model="formdata.remark" autocomplete="off"></el-input>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="isShow = false">取 消</el-button>
      <el-button type="primary" @click="submitForm()">确 定</el-button>
    </div>
  </el-dialog>
</template>
<script>
//import { addScheduleRulel, updateScheduleRulel } from "@/utils/api/index";
export default {
  props: {
    title: String,
  },
  data() {
    return {
      isShow: false,
      formdata: {},
    };
  },
  methods: {
    //判断
    getdataform(val) {
      console.log(val);
      if (val == null) {
        return (this.formdata = {});
      }
      this.formdata = val;
      this.$set(this.formdata, "time", [val.startTime, val.endTime]);
    },
    // 保存确定操作
    submitForm() {
      this.$refs.formInfo.validate((valid) => {
        if (valid) {
          console.log(valid);
        } else {
          console.log("error submit!!");
          return false;
        }
      });
    },
    display() {
      this.isShow = true;
    },
    hide() {
      this.isShow = false;
    },
  },
  mounted() {},
};
</script>
<style lang="less">
.adddeviceDialog {
  .el-form {
    .timeBoxArr {
      display: flex;
      .el-date-editor.el-input,
      .el-date-editor.el-input__inner {
        width: 226px;
        margin-right: 16px;
      }
    }
  }
}
</style>
